Important: The information in this document is obsolete and should not be used for new development.
RandomBits
You can use theRandomBitsfunction to return a sequence of pseudorandom numbers.
unsigned long RandomBits(long count, long focus);
count- The number of bits in the number to be generated by the random number generator.
focus- The degree of clustering about the mean value.
- function result
- A sequence of pseudorandom numbers.
DESCRIPTION
TheRandomBitsfunction returns random numbers in the range of 0 to 2count- 1. A focus of 0 generates numbers that are uniformly distributed.A positive value for the
focusparameter generates numbers that are clustered about the mean, analogous to averaging 2focusuniform random numbers. A negative focus generates numbers that tend to avoid the mean.If you define a value limit to be 1 <<
count, the result of theRandomBitsfunction ranges from 0 to limit - 1. Its mean is (limit - 1) / 2. The mean is independent of the focus. If the focus is positive, the standard deviation of the numbers generated by theRandomBitsfunction is approximately (0.28868 limit) / e1.41421 focus. As thefocusparameter gets bigger, two things happen:
If the focus is negative, the
- The values cluster about the mean.
- The values approximate a normal distribution (central limit theorem).
RandomBitsfunction result is computed as if it were positive; for results less than limit / 2, limit / 2 is added; for others, limit / 2 is subtracted. This causes the distribution to avoid the mean.To generate a clustering of points around a given value, generate x and y offsets with
FractMultiply(radius, RandomBits(31, focus) - fract1);The average distance will be 0.57735 radius/e1.41421 focus.A good way to select a value for the focus is to experiment until the desired result is achieved.
SEE ALSO
TheSetRandomSeedfunction sets the starting number seed for the random number generator algorithm. TheSetRandomSeedfunction is described in the next section. TheGetRandomSeedfunction returns the current starting number seed for the random number generator algorithm. TheGetRandomSeedfunction is described on page 8-60.