> Not quite sure what the following means
>
> >I mentioned the issue before with random numbers, but >here we go again:
> >never use modulo, use divison instead for scaling to the >right range of
> >numbers. mod tends to not deliver good sequence of >random numbers!
> >
That means that it is best to use something like this to get random numbers in a
range:
declare
fun {MkScale Min0 Max0 Min1 Max1}
F = (Max1-Min1)/(Max0-Min0)
in
fun {$ X} (X - Min0)*F + Min1 end
end
I2F = IntToFloat
fun {MkRand MyMin MyMax}
Min Max Scale
in
{OS.randLimits Min Max}
Scale = {MkScale {I2F Min} {I2F Max} {I2F MyMin} {I2F MyMax}}
fun {$} {FloatToInt {Scale {OS.rand}}} end
end
Cheers,
Jorge
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users