mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 20:29:17 +02:00
+ RandomRange
git-svn-id: trunk@13262 -
This commit is contained in:
parent
746200eb49
commit
855a65a061
@ -416,6 +416,7 @@ function maxvalue(const data : PInteger; Const N : Integer) : Integer;
|
|||||||
|
|
||||||
{ returns random values with gaussian distribution }
|
{ returns random values with gaussian distribution }
|
||||||
function randg(mean,stddev : float) : float;
|
function randg(mean,stddev : float) : float;
|
||||||
|
function RandomRange(const aFrom, aTo: Integer): Integer;
|
||||||
|
|
||||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||||
{ calculates the standard deviation }
|
{ calculates the standard deviation }
|
||||||
@ -1218,6 +1219,13 @@ function randg(mean,stddev : float) : float;
|
|||||||
randg:=Sqrt(-2*ln(S2)/S2)*u1*stddev+Mean;
|
randg:=Sqrt(-2*ln(S2)/S2)*u1*stddev+Mean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function RandomRange(const aFrom, aTo: Integer): Integer;
|
||||||
|
begin
|
||||||
|
Result:=Random(Abs(aFrom-aTo))+Min(aTo,AFrom);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||||
function stddev(const data : array of Single) : float;
|
function stddev(const data : array of Single) : float;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user