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:
wp_xxyyzz
2020-12-05 19:03:07 +00:00
parent 7800484f54
commit 21484fc4bd
29 changed files with 1767 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?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>
<Units>
<Unit>
<Filename Value="project1.lpr"/>
<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>

View File

@@ -0,0 +1,50 @@
program project1;
uses
Math,
MathUnit;
function Factorial(x: integer): longint; //integer;
var
decx: longint; // integer;
product: longint; //integer;
begin
decx := x;
product := 1;
while (decx > 0) do
begin
product := decx * product;
decx := decx - 1;
end;
result := product;
end;
function PoissonPDF_old(x: integer; a: double): Double;
begin
if (x < 0) then
Result := 0.0
else
Result := exp(-a) * power(a, x) / factorial(x);
end;
procedure Test(a: Double; delta: Integer);
var
i, n: Integer;
begin
WriteLn('a = ', a:0:5);
WriteLn;
WriteLn(' n Poisson PoissonPDF_old ');
WriteLn('---------- ------------------- -------------------');
for i := 0 to 20 do begin
n := i * delta;
WriteLn(n:10, PoissonPDF(n, a):20:5, PoissonPDF_old(n, a):20:5);
end;
WriteLn;
end;
begin
Test(9, 1);
ReadLn;
end.