+ RandomRange

git-svn-id: trunk@13262 -
This commit is contained in:
florian 2009-06-11 20:43:24 +00:00
parent 746200eb49
commit 855a65a061

View File

@ -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;