Simple question:
i am after a function that, given a mean and standard deviation, returns a random value such that if you call the function often enough, the values it returns represent a normal distribution.
thanks :D
Printable View
Simple question:
i am after a function that, given a mean and standard deviation, returns a random value such that if you call the function often enough, the values it returns represent a normal distribution.
thanks :D
You want the normal distribution?
The density function is
(1/sqr(2*Pi)) * exp(-(t^2)/2)
with
t = (x- mu)/sigma
mu = mean
sigma = std. dev.
The distribution fn. is the integral of that between (-infinity) and whatever value of x you're interested in.
Thanks for that....the formula you gave, while correct, is a bit hard to put in code (like...integral to infinity). I guess i could approximate, but still tricky.
Maybe it would be best to approximate to binomial distr, with large enough n for good fit, but low enough to not take too long to compute....
ideas?
The integrand gets extremely small as you approach large negative (or positive) x-values. Just approximate with some reasonably large in magnitude minimum value - you'll be limited by floating point number precision and roundoff errors anyway.
The solution to the question can be seen in the attached file. One can use both MS-EXCEL or the analytical expression (Box-Muller method).
Good luck for all.
Wow! that's great :D
thanks, the second part is exactly what i was looking for...
but, for the Box-Muller thing, which i'll end up using, the random values that you give it (r1 and r2), do they have to be between 0 and 1, or must be integers, or what?
but anyway, thanks for the sheet...it's made really nicely. U have that already, or make it for this?
I use computer simulation methods often for the decision making processes: lay-out alternatives, organizational methods, equipment investments, overhauls of big machinery, etc., so I am used to these stats which give me lots of fun.Quote:
Originally Posted by sql_lall