2017 © Pedro Peláez
 

library random

A random number generator library

image

emonkak/random

A random number generator library

  • Saturday, December 3, 2016
  • by emonkak
  • Repository
  • 4 Watchers
  • 5 Stars
  • 5,023 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 18 % Grown

The README.md

Emonkak\Random

Build Status Coverage Status, (*1)

This library provides pseudo-random number generators and probability distributions., (*2)

Requirements

  • PHP 7.1 or higher

Licence

MIT Licence, (*3)

Example

use Emonkak\Random\Engine\MT19937Engine;
use Emonkak\Random\Distribution\NormalDistribution;

$seed = 100;  // Initial seed
$engine = new MT19937Engine($seed);  // 32bit Mersenne Twister engine
$distribution = new NormalDistribution(0, 1);  // Standard normal distribution

// Generate a random number with the normal distribution.
$distribution->generate($engine);

Engine

  • KnuthBEngine, (*4)

  • LinearCongruentialEngine, (*5)

  • MinstdRand0Engine, (*6)

  • MinstdRandEngine, (*7)

  • MT19937Engine, (*8)

    The random generator engine according to Mersenne Twister. It is full-compatible to the built-in mt_rand()., (*9)

    // Also, the initial seed algorithm is full-compatible to the built-in `mt_srand()`
    $engine = new MT19937Engine(/* $seed */);
    
    // Get a next random number from the current generator state.
    $number = $engine->next();  // as int
    $number = $engine->nextDouble();  // as float
    
    // Get the minimum and maximum number which generate a value by the engine.
    $minimum = $engine->min();
    $maximum = $engine->max();
    
    // Iterate the generator engine.
    foreach (new LimitIterator($engine, 0, 100) as $n) {
    }
    
  • MTRandWrapper, (*10)

    The wrapper for the built-in mt_rand()., (*11)

  • ShuffleOrderEngine, (*12)

  • XorShift128Engine, (*13)

    The random generator engine according to Xorshift 128 bit algorithm., (*14)

Distribution

  • BernoulliDistribution
  • BinomialDistribution
  • DiscreteDistribution
  • DistributionIterator
  • ExponentialDistribution
  • GammaDistribution
  • GeometricDistribution
  • LogNormalDistribution
  • NormalDistribution
  • PiecewiseConstantDistribution
  • PiecewiseLinerDistribution
  • UniformIntDistribution
  • UniformRealDistribution

The Versions

03/12 2016

dev-master

9999999-dev https://github.com/emonkak/php-random

A random number generator library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Shota Nozaki

random

12/05 2016

v2.0.2

2.0.2.0 https://github.com/emonkak/php-random

A random number generator library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Shota Nozaki

random

12/04 2016

v2.0.1

2.0.1.0 https://github.com/emonkak/php-random

A random number generator library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Shota Nozaki

random

11/04 2016

v2.0.0

2.0.0.0 https://github.com/emonkak/php-random

A random number generator library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Shota Nozaki

random

24/03 2016

v1.0.0

1.0.0.0 https://github.com/emonkak/php-random

A random number generator library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Shota Nozaki

random