It would be useful to have a function that generates a random number between 0 and 1, similar to JavaScript's Math.random()
.
1 Like
If it is anything urgent, you could try a writing an Evaluator Linear Congruential Generator.
To get random numbers between 0 and 1, divide the pseudo-random output by ( modulus - 1 ).
https://en.wikipedia.org/wiki/Linear_congruential_generator
Edit:
I played with this a little to see if I could generate an Evaluator column of random numbers.
For the modulus I used 2^16 + 1 which is a known Fermat Prime, 2^(2^4) + 1.
The Wikipedia article referenced above has an entry for this with multiplier a = 75 and increment
c = 74 .
The general algorithm is
Here's what I got to work for a Random Number Evaluator Column.
The numbers are not between 0 and 1 yet in this code.
m=Pow(2,16) + 1;
a=75;
c=74;
if ( $glob:seed)
{
x=$glob:seed;
}
else
{
$glob:seed=1;
x=1;
}
x=(a*x + c)Mod m;
$glob:seed=x;
return x;
Maybe not, the range of numbers generated seems too narrow.