Random number generator with mean and spread distribution controls
Does anyone know how I could turn the evenly distributed random object values to values with user defined spread and mean controls?
That is, the spread would go from even chance of any number between min and max, to a normal distribution where there is more chance that the number will be in the middle and a high spread would mean almost no numbers at min and max. The mean control wold essentially be an offset.
Any help most appreciated - I will of course share any useful stuff I end up making.
Thanks
Tim
the most common way in practice is probably to start with a random function and then apply range scaling and distortion to its output.
for example you could do random 10000
/ 10000.
and then multiply it with itself: * 0.
in order to get random float numbers between 0 and 1 with a quadratic distortion or use sqrt on it to get a "linear" distribution.
expr (sqrt(-2.0*ln(1-((random(0\,32767))*(1./32768.)))))*(cos(((random(0\,32767))*(1./32768.))*6.283185307)) will output noise with a gaussian distribution, if you only want one half of this shape, add abs to it and you are done.
(note the minor difference between the arguments to the random object and the random function in expr.)
some common algorithms will have to be built around drunk though.
Thanks Roman, that is really helpful. I will give this a go.
If you want a bit of a GUI for this kind of idea table/itable objects can be fun.
example:
Thanks SLO, I will give that a go.