https://github.com/marcofaziorandom/gaussian-random
An implementation of the Marsaglia polar method for generating random number with a Gaussian distribution.
https://github.com/marcofaziorandom/gaussian-random
Last synced: 8 months ago
JSON representation
An implementation of the Marsaglia polar method for generating random number with a Gaussian distribution.
- Host: GitHub
- URL: https://github.com/marcofaziorandom/gaussian-random
- Owner: MarcoFazioRandom
- License: mit
- Created: 2020-01-31T17:55:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-31T18:57:51.000Z (over 6 years ago)
- Last Synced: 2025-02-13T00:17:08.636Z (over 1 year ago)
- Language: C#
- Size: 411 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gaussian-Random
**An implementation of the Marsaglia polar method for generating random number with a Gaussian distribution.**
The class MyRandom can be used just like the System.Random class and calling the method NextGaussian() will return a double between (-1, 1) with the mean at 0.
### Standard deviation:
From [Wikipedia](https://en.wikipedia.org/wiki/Normal_distribution):
> the standard deviation (SD, also represented by the lower case Greek letter sigma σ for the population standard deviation or the Latin letter s for the sample standard deviation) is a measure of the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean (also called the expected value) of the set, while a high standard deviation indicates that the values are spread out over a wider range.
So with a SD of 1 The method NextGaussian(1) will a distribution that follows a Standard Normal Distribution curve (a standard bell form), if the SD if less than 1 the curve will be more narrow, if it's more than 1 the curve will be more flat.
### Examples (with 1024 values):
#### SD = 0.5:

#### SD = 1:

#### SD = 1.5:

### Performance:
Test made using Unity: