Hoa central
Public Member Functions | Protected Member Functions | List of all members
Hoa\Math\Sampler\Random Class Reference
Inheritance diagram for Hoa\Math\Sampler\Random:

Public Member Functions

 construct ()
 
- Public Member Functions inherited from Hoa\Math\Sampler\Sampler
 __construct (Array $parameters=[])
 
 construct ()
 
 getParameters ()
 
 getInteger ($lower=null, $upper=null, Array &$exclude=null)
 
 getFloat ($lower=null, $upper=null)
 
 getExcludeSet ()
 

Protected Member Functions

 _getInteger ($lower, $upper)
 
 _getFloat ($lower, $upper)
 
- Protected Member Functions inherited from Hoa\Math\Sampler\Sampler
 _getInteger ($lower, $upper)
 
 _getFloat ($lower, $upper)
 

Additional Inherited Members

- Protected Attributes inherited from Hoa\Math\Sampler\Sampler
 $_parameters = null
 

Detailed Description

Class .

Random sampler.

Definition at line 47 of file Random.php.

Member Function Documentation

Hoa\Math\Sampler\Random::_getFloat (   $lower,
  $upper 
)
protected

Generate a continuous uniform distribution.

Parameters
float$lowerLower bound value.
float$upperUpper bound value.
Returns
float

Definition at line 98 of file Random.php.

99  {
100  return $lower + lcg_value() * abs($upper - $lower);
101  }
Hoa\Math\Sampler\Random::_getInteger (   $lower,
  $upper 
)
protected

Generate a discrete uniform distribution.

Parameters
int$lowerLower bound value.
int$upperUpper bound value.
Returns
int

Definition at line 86 of file Random.php.

87  {
88  return mt_rand($lower, $upper);
89  }
Hoa\Math\Sampler\Random::construct ( )

Construct.

Returns
void

Definition at line 54 of file Random.php.

55  {
56  if (null === $this->_parameters->getParameter('integer.min')) {
57  $this->_parameters->setParameter(
58  'integer.min',
59  max(
60  -mt_getrandmax(),
61  $this->_parameters->getParameter('integer.min')
62  )
63  );
64  }
65 
66  if (null === $this->_parameters->getParameter('integer.max')) {
67  $this->_parameters->setParameter(
68  'integer.max',
69  min(
70  mt_getrandmax(),
71  $this->_parameters->getParameter('integer.max')
72  )
73  );
74  }
75 
76  return;
77  }

The documentation for this class was generated from the following file: