You've already forked lazarus-ccr
LazStats: Add tests.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7925 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
72
applications/lazstats/tests/tdist_test/Project1.lpi
Normal file
72
applications/lazstats/tests/tdist_test/Project1.lpi
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="Project1"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<PackageName Value="TAChartLazarusPkg"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<PackageName Value="LMath"/>
|
||||
</Item>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="Project1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="Project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\..\source\units"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
49
applications/lazstats/tests/tdist_test/Project1.pas
Normal file
49
applications/lazstats/tests/tdist_test/Project1.pas
Normal file
@@ -0,0 +1,49 @@
|
||||
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.
|
||||
|
Reference in New Issue
Block a user