Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Normally Distributed Random Numbers

Author
Message
Negative Zero
20
Years of Service
User Offline
Joined: 13th Apr 2004
Location:
Posted: 13th Apr 2004 23:17 Edited at: 14th Apr 2004 22:32
I looked around on the codebase and I couldn't find anything that would give me normally distrubuted random numbers (a bell curve) so I wrote these functions. Credit to Kevil for the log function.

To get the normal distribution I applied the Box-Muller transformation to the regular rnd function.

There are a few functions included to make this work, but the main two are:

randnormal takes two parameters. The first is the mean and the second is the standard deviation.

randrange takes three paremeters. The first two are the lower and upper limit of the range and the third value is either the standard deviation or a value of zero which will the give the default standard deviation of a forth of the range.



-veZero

Login to post a reply

Server time is: 2024-05-13 16:11:09
Your offset time is: 2024-05-13 16:11:09