You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7925 8e941d3f-bd1b-0410-a28a-d453659cc2b4
50 lines
877 B
ObjectPascal
50 lines
877 B
ObjectPascal
program Project1;
|
|
|
|
uses
|
|
spe,
|
|
MathUnit;
|
|
|
|
const
|
|
xmin = 0.0;
|
|
xmax = 3.0;
|
|
dx = 0.5;
|
|
DF = 10;
|
|
|
|
procedure Test(s: Integer);
|
|
var
|
|
i: Integer;
|
|
x, y_lazStats, y_numlib: Double;
|
|
ok: string;
|
|
begin
|
|
WriteLn('Student''s t distribution with ', DF, ' degrees of freedom (', s, '-sided)');
|
|
WriteLn;
|
|
WriteLn('x':15, 'y(lazstats)':15, 'y(numlib)':15, 'OK':15);
|
|
x := xmin;
|
|
while (x <= xmax) do begin
|
|
if x < 0 then
|
|
y_numlib := 1.0 - spe.tDist(-x, DF, s)
|
|
else
|
|
y_numlib := spe.tDist(x, DF, s);
|
|
|
|
if x < 0 then
|
|
y_lazstats := 1.0 - mathunit.tDist(-x, DF, s=1)
|
|
else
|
|
y_lazstats := mathunit.tDist(x, DF, s=1);
|
|
|
|
if abs(y_lazstats - y_numlib) < 1E-6 then
|
|
ok := 'OK'
|
|
else
|
|
ok := 'ERROR';
|
|
|
|
WriteLn(x:15:5, y_lazstats:15:5, y_numlib:15:5, ok:15);
|
|
x := x + dx;
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
Test(1);
|
|
Test(2);
|
|
ReadLn;
|
|
end.
|
|
|