Skip to content

A uniform distributed random number generator.

License

Notifications You must be signed in to change notification settings

resemble-studies/random

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ensemble Random

A uniform distributed random number generator.

  • Supports seeds.
  • Supports range.
  • Simple to use.

Usage

We include the Random class.

#include <ensemble/random.hpp>
using Ensemble::Random;

We create an instance of Random.

auto random = Random();

We initialise by calling the Randomize which fills the seed with values based on the system clock.

random.Randomize();

We might as well obtain the seed generated by the Randomize method.

auto initialSeed = random.GetSeed();

We can use the GetRand() method (with a maximum value) to get an integer value.

for (int i = 0; i < 10; ++i)
{
    printf("%d\n", random.GetRand(1000));
}

...

760
435
954
372
237
149
114
676
113
888

We can use the GetRandF() method (with a maximum value) to get a float value.

for (int i = 0; i < 10; ++i)
{
    printf("%f\n", random.GetRandF(1000));
}

...

41.0
518.0
370.0
636.0
104.0
530.0
531.0
239.0
312.0
695.0

We could also instantiate a new Random class with our initial seed.

random = Random(initialSeed);

The output will be the same if we repeated the processes from the above loops since we are using the same seed.

About

A uniform distributed random number generator.

Topics

Resources

License

Stars

Watchers

Forks