RogueSharp
Show / Hide Table of Contents

Class GaussianRandom

A class implementing IRandom which uses the Box-Muller transformation to help generate Gaussian pseudo-random numbers

Inheritance
System.Object
GaussianRandom
Implements
IRandom
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: RogueSharp.Random
Assembly: RogueSharp.dll
Syntax
public class GaussianRandom : IRandom
Remarks

Gaussian pseudo-random generation can be useful if you want a bell shaped curve distribution of numbers. What this means is numbers half way between the min and max values are much more likely than numbers on the extreme edge. If you were to generate numbers between 1 and 10, it would be more likely a 5 would be generated than a 1 or a 10.

Constructors

| Improve this Doc View Source

GaussianRandom()

Constructs a new Gaussian pseudo-random number generator with a seed based on the number of milliseconds elapsed since the system started

Declaration
public GaussianRandom()
| Improve this Doc View Source

GaussianRandom(Int32)

Constructs a new Gaussian pseudo-random number generator with the specified seed

Declaration
public GaussianRandom(int seed)
Parameters
Type Name Description
System.Int32 seed

An integer used to calculate a starting value for the pseudo-random number sequence

Methods

| Improve this Doc View Source

Next(Int32)

Will approximately give the next Gaussian pseudo-random integer between 0 and that specified max value inclusively so that min and max are at 3.5 deviations from the mean (half-way of min and max).

Declaration
public int Next(int maxValue)
Parameters
Type Name Description
System.Int32 maxValue

Inclusive maximum result

Returns
Type Description
System.Int32

Returns a Gaussian pseudo-random integer between 0 and the specified maxValue inclusive

| Improve this Doc View Source

Next(Int32, Int32)

Will approximately give the next random Gaussian integer between the specified min and max values inclusively so that min and max are at 3.5 deviations from the mean (half-way of min and max).

Declaration
public int Next(int minValue, int maxValue)
Parameters
Type Name Description
System.Int32 minValue

Inclusive minimum result

System.Int32 maxValue

Inclusive maximum result

Returns
Type Description
System.Int32

Returns a pseudo-random integer between the specified minValue and maxValue inclusive

| Improve this Doc View Source

Restore(RandomState)

Restores the state of the pseudo-random number generator based on the specified state parameter

Declaration
public void Restore(RandomState state)
Parameters
Type Name Description
RandomState state

The state to restore to, usually obtained from calling the Save method

Examples

If you generated three random numbers and then called Save to store the state and followed that up by generating 10 more numbers before calling Restore with the previously saved RandomState the Restore method should return the generator back to the state when Save was first called. This means that if you went on to generate 10 more numbers they would be the same 10 numbers that were generated the first time after Save was called.

Exceptions
Type Condition
System.ArgumentNullException

Thrown on null RandomState

| Improve this Doc View Source

Save()

Saves the current state of the pseudo-random number generator

Declaration
public RandomState Save()
Returns
Type Description
RandomState

A RandomState class representing the current state of this pseudo-random number generator

Examples

If you generated three random numbers and then called Save to store the state and followed that up by generating 10 more numbers before calling Restore with the previously saved RandomState the Restore method should return the generator back to the state when Save was first called. This means that if you went on to generate 10 more numbers they would be the same 10 numbers that were generated the first time after Save was called.

Implements

IRandom
  • Improve this Doc
  • View Source
RogueSharp © 2014-2020 Faron Bracy
Back to top