mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 04:59:26 +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 }
|
||||
function randg(mean,stddev : float) : float;
|
||||
function RandomRange(const aFrom, aTo: Integer): Integer;
|
||||
|
||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||
{ calculates the standard deviation }
|
||||
@ -1218,6 +1219,13 @@ function randg(mean,stddev : float) : float;
|
||||
randg:=Sqrt(-2*ln(S2)/S2)*u1*stddev+Mean;
|
||||
end;
|
||||
|
||||
|
||||
function RandomRange(const aFrom, aTo: Integer): Integer;
|
||||
begin
|
||||
Result:=Random(Abs(aFrom-aTo))+Min(aTo,AFrom);
|
||||
end;
|
||||
|
||||
|
||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||
function stddev(const data : array of Single) : float;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user