libnxter  0.1
Functions
RandomNorm.nxc File Reference

Normally distributed (Gaussian distribution) random number function. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int RandomNorm (int scale)
 Returns a random number sample from Guassian distribution scaled by the given factor (using lookup table). More...
 
long RandomNorm2 (int scale)
 Returns a random number sample from Guassian distribution scaled by the given factor (using sum of uniformly distributed random numbers). More...
 
long RandomNorm3 (int scale, int precision)
 Returns a random number sample from Guassian distribution scaled by the given factor (using sum of uniformly distributed random numbers). More...
 

Detailed Description

Normally distributed (Gaussian distribution) random number function.

Definition in file RandomNorm.nxc.

Function Documentation

int RandomNorm ( int  scale)

Returns a random number sample from Guassian distribution scaled by the given factor (using lookup table).

The returned sample (before scaling) has mean 0 and variance 1 (standard normal distribution). Okay. it's fake random number from a pre-computed table that will repeat every 256 samples, but it is very fast and should suffice for many simulation purpose on nxt.

Definition at line 64 of file RandomNorm.nxc.

long RandomNorm2 ( int  scale)

Returns a random number sample from Guassian distribution scaled by the given factor (using sum of uniformly distributed random numbers).

The returned sample (before scaling) has mean 0 and variance 1. A set of uniformly distributed random numbers are added to get a normally distributed sample. According to central limit theory, the resulting samples are normally distributed, given enough random samples are used in the sum. This function uses 12 samples which is considered good enough for most purposes.

Definition at line 83 of file RandomNorm.nxc.

long RandomNorm3 ( int  scale,
int  precision 
)

Returns a random number sample from Guassian distribution scaled by the given factor (using sum of uniformly distributed random numbers).

This function is same as RandomNorm2() except the precision allows adding more samples (multiple of 12) to get higher accuracy.

Definition at line 100 of file RandomNorm.nxc.