You've already forked lazarus-ccr
LazStats: Complete refactoring of FreqUnit.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7691 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -9,9 +9,16 @@ interface
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
const
|
||||
TWO_PI = 2.0 * PI;
|
||||
SQRT_PI = 1.7724538509055160;
|
||||
SQRT2 = sqrt(2.0);
|
||||
|
||||
function erf(x: Double): Double;
|
||||
function erfc(x: Double) : Double;
|
||||
|
||||
function NormalDist(x: Double): Double;
|
||||
function NormalDistDensity(x, AMean, AStdDev: Double): Double;
|
||||
|
||||
function Beta(a, b: Double): Extended;
|
||||
function BetaI(a,b,x: Double): Extended;
|
||||
@ -27,6 +34,9 @@ function Chi2Density(x: Double; N: Integer): Double;
|
||||
|
||||
function CalcC4(n: Integer): Double;
|
||||
|
||||
procedure MantisseAndExponent(x: Double; out Mantisse: Double; out Exponent: Integer);
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -40,7 +50,6 @@ uses
|
||||
function erf(x: Double): Double;
|
||||
const
|
||||
xup = 6.25;
|
||||
SQRT_PI = 1.7724538509055160;
|
||||
c: array[1..18] of Double = (
|
||||
1.9449071068178803e0, 4.20186582324414e-2, -1.86866103976769e-2,
|
||||
5.1281061839107e-3, -1.0683107461726e-3, 1.744737872522e-4,
|
||||
@ -117,8 +126,6 @@ end;
|
||||
// Cumulative normal distribution
|
||||
// x = -INF ... INF --> 0 ... 1
|
||||
function NormalDist(x: Double): Double;
|
||||
const
|
||||
SQRT2 = sqrt(2.0);
|
||||
begin
|
||||
if x > 0 then
|
||||
Result := (erf(x / SQRT2) + 1) * 0.5
|
||||
@ -129,6 +136,11 @@ begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function NormalDistDensity(x, AMean, AStdDev: Double): Double;
|
||||
begin
|
||||
Result := 1.0 / (sqrt(TWO_PI) * AStdDev) * exp(-0.5 * sqr((x - AMean) / AStdDev));
|
||||
end;
|
||||
|
||||
|
||||
function Beta(a, b: Double): Extended;
|
||||
begin
|
||||
@ -307,5 +319,21 @@ begin
|
||||
}
|
||||
end;
|
||||
|
||||
|
||||
procedure MantisseAndExponent(x: Double; out Mantisse: Double; out Exponent: Integer);
|
||||
var
|
||||
s, sm, se: String;
|
||||
p: Integer;
|
||||
res: Integer;
|
||||
begin
|
||||
str(x, s);
|
||||
p := pos('E', s);
|
||||
sm := copy(s, 1, p-1);
|
||||
se := copy(s, p+1, MaxInt);
|
||||
val(sm, Mantisse, res);
|
||||
val(se, Exponent, res);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user