You are not logged in.
Alright so I tried to research the exact_gauss() script by looking up guass things all over the internet, but I still don't have a solid concept on how it works... I was hoping someone could explain it to me using an example, that'd be very useful. Currently, I want to make a guass random curve that varies from 0 to 360 and is mostly attracted to 180, but at the same time I want to be able to change how much the attraction to 180. (Sometimes i want the random to be very close to 180 (very tight bell curve), and other times I want it to be very far from it(closer to a regular, linear distribution) how can I do this?)
I'm sorry for posting this, but I really just have no clue how it works and I REALLY want to understand it (I have tried doing research!). Thanks for any help.
Offline
I'm not an expert, and I didn't write the script, but it seems pretty straight-forward from my brief testing.
** Usage:
** exact_gauss(mean, deviation)
**
** Arguments:
** mean mean value of the distribution
** deviation standard deviation of distribution
**
** Returns:
** a pseudo-random number with an exact Gaussian distribution
Argument mean
is the value random numbers will be clustered around. In your example, mean
should be 180.
Argument deviation
determines how closely clustered the numbers should be. The lower the number, the less they'll deviate from 180. By varying deviation, you can control the distribution. At a deviation of 1.0, the vast majority of numbers will be within 1.0 of the mean (sorry, I haven't worked out the exact percentage). As the deviation approaches infinity, the distribution becomes more linear. Because of the way this works, it's not possible to limit the numbers returned to a certain specific range. As the deviation increases, more and more numbers will fall outside your desired limits. You can throw-out numbers outside the range and try again, but this may become impractical as the distribution becomes more linear.
exact_gauss(180, 10) : < 1% out of range
exact_gauss(180, 40) : < 1% out of range
exact_gauss(180, 100) : 7% out of range
exact_gauss(180, 1000) : 85% out of range
Not-so-great Alternatives
You might also consider using the regular random functions modulated by a gain function. It won't provide gaussian distribution (truthfully, it's not even close), but it is a bit more predictable and controllable.
** Usage:
** gain(g,t)
**
** Arguments:
** g gain, real
** t value, real
a = 2 * m * gain(0.5, random(1));
Here, m
is the mean value of the distribution, 180 in your example. Argument g
is set to 0.5
which is a perfectly linear distribution. Values above 0.5
will cluster around the mean, values below 0.5
will cluster at the edges (0 and 360).
g = 0.25
g = 0.50
g = 0.75
g = 0.95
Or you might consider using the pseudo-gauss function interpolated linearly with regular random numbers.
a = m + m * lerp(0.5, gauss(), random(2)-1);
Here 0.5
is the interpolation factor. As it approaches 1.0
, the distribution becomes more linear. As it approaches 0.0
, the distribution becomes more Gaussian. Getting the distribution to be more narrowly confined to the mean could be achieved by passing the output of gauss through a power function. Ugly solution altogether.
t = 0.0
t = 0.5
Abusing forum power since 1986.
Offline
you could use the error function to get the integral of the gaussian curve. And then feed this the random value you gained
Offline
Maybe YOU could. I didn't understand what you just said.
You are talking about this? http://www.gmlscripts.com/script/erf
Could you provide some examples?
Abusing forum power since 1986.
Offline