Index : Reference :

Random

A pseudo random number generation class.

Example:
  
  // Gets a random number between 0 and 1 and
  // outputs it to the console:
  
  var random = new(Random);
  random->Init(8374946);
  
  println(random->Get01());
  
  
  // Throws a six-sided dice and
  // outputs it to the console:
  
  println("You threw a ", int(random->Get01() * 6 + 1));
  


Note: See also Noise

Definition

class Random
{
public:
  Random();

  void Init(int seed);

  float Get01();
  float Get11();
  float GetG01();
  float GetG11();
};

Members

Random()

Class Constructor

void Init(int seed)

Initializes the pseudo random number sequence. The seed parameter must be between 0 and 2E9. Seeds that are close to each other, like 140 and 145, initially lead to similar random sequences.

One can use the internal time() function as seed if one wants total randomness. However, it's often best to let the user specify the seed, so that the results are reproducable (e.g. for safe use in NETrender).

float Get01()

Returns a uniformly distributed random value between 0 and 1.

float Get11()

Returns a uniformly distributed random value between -1 and 1.

float GetG01()

Returns a random value between 0 and 1 with Gaussian distribution around 0.5. The standard deviation is 0.09.

float GetG11()

Returns a random value between -1 and 1 with Gaussian distribution around 0. The standard deviation is 0.18.


Copyright 2014 MAXON. See Plugin Cafe for the latest version. Last modified: 2014-10-03