#include <RandomNumberGenerator.hpp>
Inherits SerializableSingleton< RandomNumberGenerator >.

Public Member Functions | |
| double | StandardNormalRandomDeviate () |
| double | NormalRandomDeviate (double mean, double stdDev) |
| double | ranf () |
| double | GammaRandomDeviate (double shape, double scale) |
| double | ExponentialRandomDeviate (double scale) |
| unsigned | randMod (unsigned base) |
| template<class T > | |
| void | Shuffle (std::vector< boost::shared_ptr< T > > &rValues) |
| void | Shuffle (unsigned num, std::vector< unsigned > &rValues) |
| void | Reseed (unsigned seed) |
Static Public Member Functions | |
| static RandomNumberGenerator * | Instance () |
| static void | Destroy () |
Protected Member Functions | |
| RandomNumberGenerator () | |
Private Member Functions | |
| template<class Archive > | |
| void | save (Archive &archive, const unsigned int version) const |
| template<class Archive > | |
| void | load (Archive &archive, const unsigned int version) |
Private Attributes | |
| boost::mt19937 | mMersenneTwisterGenerator |
| boost::variate_generator < boost::mt19937 &, boost::uniform_real<> > | mGenerateUnitReal |
| boost::variate_generator < boost::mt19937 &, boost::normal_distribution<> > | mGenerateStandardNormal |
Static Private Attributes | |
| static RandomNumberGenerator * | mpInstance = NULL |
Friends | |
| class | boost::serialization::access |
A special singleton class allowing one to generate different types of random number in a globally consistent way.
Definition at line 51 of file RandomNumberGenerator.hpp.
| RandomNumberGenerator::RandomNumberGenerator | ( | ) | [protected] |
Protected constructor. Use Instance() to access the random number generator.
Definition at line 41 of file RandomNumberGenerator.cpp.
References mpInstance.
Referenced by Instance().
| void RandomNumberGenerator::Destroy | ( | ) | [static] |
Destroy the current instance of the random number generator. The next call to Instance will create a new instance and re-seed. This method *must* be called before program exit, to avoid a memory leak.
Definition at line 58 of file RandomNumberGenerator.cpp.
References mpInstance.
Referenced by AbstractCellBasedTestSuite::tearDown().
| scale | The scale parameter of the exponential distribution from which the random number is drawn, often named lambda |
Definition at line 129 of file RandomNumberGenerator.cpp.
References mMersenneTwisterGenerator.
Referenced by ExponentiallyDistributedStochasticDurationGenerationBasedCellCycleModel::SetG1Duration().
| shape | the shape parameter of the gamma distribution from which the random number is drawn | |
| scale | the scale parameter of the gamma distribution from which the random number is drawn |
Definition at line 121 of file RandomNumberGenerator.cpp.
References mMersenneTwisterGenerator.
Referenced by GammaDistributedStochasticDurationCellCycleModel::SetG1Duration().
| RandomNumberGenerator * RandomNumberGenerator::Instance | ( | ) | [static] |
Definition at line 49 of file RandomNumberGenerator.cpp.
References mpInstance, and RandomNumberGenerator().
Referenced by AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::AbstractCellBasedSimulation(), CaBasedCellPopulation< DIM >::AddCell(), DiffusionForce< DIM >::AddForceContribution(), CryptSimulation2d::CalculateCellDivisionVector(), CryptSimulation1d::CalculateCellDivisionVector(), OffLatticeSimulation< ELEMENT_DIM, SPACE_DIM >::CalculateCellDivisionVector(), RandomDirectionVertexBasedDivisionRule< SPACE_DIM >::CalculateCellDivisionVector(), RandomCellKiller< DIM >::CheckAndLabelSingleCellForApoptosis(), CryptCellsGenerator< CELL_CYCLE_MODEL >::Generate(), CellsGenerator< CELL_CYCLE_MODEL, DIM >::GenerateBasicRandom(), StochasticWntCellCycleModel::GenerateStochasticG2Duration(), StochasticOxygenBasedCellCycleModel::GenerateStochasticG2Duration(), HoneycombMeshGenerator::GetCircularMesh(), CryptStatistics::GetCryptSection(), CryptProjectionStatistics::GetCryptSection(), VertexMesh< ELEMENT_DIM, SPACE_DIM >::GetShortAxisOfElement(), CryptSimulationBoundaryCondition< DIM >::ImposeBoundaryCondition(), PlaneBoundaryCondition< DIM >::ImposeBoundaryCondition(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodes(), StochasticWntCellCycleModel::serialize(), SimpleWntCellCycleModel::serialize(), AbstractCellBasedSimulation< DIM >::serialize(), RandomCellKiller< DIM >::serialize(), StochasticOxygenBasedCellCycleModel::serialize(), StochasticDurationGenerationBasedCellCycleModel::serialize(), StochasticDurationCellCycleModel::serialize(), GammaDistributedStochasticDurationCellCycleModel::serialize(), ExponentiallyDistributedStochasticDurationGenerationBasedCellCycleModel::serialize(), SimpleWntCellCycleModel::SetG1Duration(), StochasticDurationGenerationBasedCellCycleModel::SetG1Duration(), StochasticDurationCellCycleModel::SetG1Duration(), GammaDistributedStochasticDurationCellCycleModel::SetG1Duration(), ExponentiallyDistributedStochasticDurationGenerationBasedCellCycleModel::SetG1Duration(), AbstractCellBasedTestSuite::setUp(), Shuffle(), PottsBasedCellPopulation< DIM >::UpdateCellLocations(), CaBasedCellPopulation< DIM >::UpdateCellLocations(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), and CaBasedCellPopulation< DIM >::WriteVtkResultsToFile().
| void RandomNumberGenerator::load | ( | Archive & | archive, | |
| const unsigned int | version | |||
| ) | [inline, private] |
Load the RandomNumberGenerator and its member variables.
| archive | the archive | |
| version | the current version of this class |
Reimplemented from SerializableSingleton< RandomNumberGenerator >.
Definition at line 101 of file RandomNumberGenerator.hpp.
References mGenerateStandardNormal, and mMersenneTwisterGenerator.
| mean | the mean of the normal distribution from which the random number is drawn | |
| stdDev | the standard deviation of the normal distribution from which the random number is drawn |
Definition at line 116 of file RandomNumberGenerator.cpp.
References StandardNormalRandomDeviate().
Referenced by StochasticWntCellCycleModel::GenerateStochasticG2Duration(), StochasticOxygenBasedCellCycleModel::GenerateStochasticG2Duration(), and SimpleWntCellCycleModel::SetG1Duration().
| base | the order of the field of positive integers from which the random number is drawn. This should be no greater than INT_MAX |
Definition at line 67 of file RandomNumberGenerator.cpp.
References mMersenneTwisterGenerator, and NEVER_REACHED.
Referenced by Shuffle(), and PottsBasedCellPopulation< DIM >::UpdateCellLocations().
| double RandomNumberGenerator::ranf | ( | ) |
Definition at line 106 of file RandomNumberGenerator.cpp.
References mGenerateUnitReal.
Referenced by CaBasedCellPopulation< DIM >::AddCell(), CryptSimulation2d::CalculateCellDivisionVector(), CryptSimulation1d::CalculateCellDivisionVector(), OffLatticeSimulation< ELEMENT_DIM, SPACE_DIM >::CalculateCellDivisionVector(), RandomDirectionVertexBasedDivisionRule< SPACE_DIM >::CalculateCellDivisionVector(), RandomCellKiller< DIM >::CheckAndLabelSingleCellForApoptosis(), CryptCellsGenerator< CELL_CYCLE_MODEL >::Generate(), CellsGenerator< CELL_CYCLE_MODEL, DIM >::GenerateBasicRandom(), HoneycombMeshGenerator::GetCircularMesh(), CryptStatistics::GetCryptSection(), CryptProjectionStatistics::GetCryptSection(), VertexMesh< ELEMENT_DIM, SPACE_DIM >::GetShortAxisOfElement(), CryptSimulationBoundaryCondition< DIM >::ImposeBoundaryCondition(), PlaneBoundaryCondition< DIM >::ImposeBoundaryCondition(), StochasticDurationGenerationBasedCellCycleModel::SetG1Duration(), StochasticDurationCellCycleModel::SetG1Duration(), PottsBasedCellPopulation< DIM >::UpdateCellLocations(), CaBasedCellPopulation< DIM >::UpdateCellLocations(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), and CaBasedCellPopulation< DIM >::WriteVtkResultsToFile().
| void RandomNumberGenerator::Reseed | ( | unsigned | seed | ) |
Reseed the random number generator.
| seed | the new seed |
Definition at line 141 of file RandomNumberGenerator.cpp.
References mMersenneTwisterGenerator.
Referenced by AbstractCellBasedTestSuite::setUp().
| void RandomNumberGenerator::save | ( | Archive & | archive, | |
| const unsigned int | version | |||
| ) | const [inline, private] |
Save the RandomNumberGenerator and its member variables.
| archive | the archive | |
| version | the current version of this class |
Reimplemented from SerializableSingleton< RandomNumberGenerator >.
Definition at line 77 of file RandomNumberGenerator.hpp.
References mGenerateStandardNormal, and mMersenneTwisterGenerator.
Produce a permutation of the integers 0,1,..,num-1, using the Knuth-algorithm (also called the Fisher-Yates algorithm), a linear time unbiased method. The shuffled values are returned in rValues, which doesn't need to be correctly-sized when passed in.
| num | the number of integers to shuffle | |
| rValues | the output permutation of shuffled values (any initial values ignored) |
Definition at line 146 of file RandomNumberGenerator.cpp.
References Instance(), and randMod().
| void RandomNumberGenerator::Shuffle | ( | std::vector< boost::shared_ptr< T > > & | rValues | ) | [inline] |
Produce a permutation of the integers and non-empty std::vector, using the Knuth-algorithm (also called the Fisher-Yates algorithm), a linear time unbiased method. The values are shuffled in place.
| rValues | the initial values and the output permutation of shuffled values. Must be non-empty |
Definition at line 177 of file RandomNumberGenerator.hpp.
References Instance(), and randMod().
Referenced by TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodes(), and PottsBasedCellPopulation< DIM >::UpdateCellLocations().
| double RandomNumberGenerator::StandardNormalRandomDeviate | ( | ) |
Definition at line 111 of file RandomNumberGenerator.cpp.
References mGenerateStandardNormal.
Referenced by DiffusionForce< DIM >::AddForceContribution(), and NormalRandomDeviate().
boost::variate_generator<boost::mt19937& , boost::normal_distribution<> > RandomNumberGenerator::mGenerateStandardNormal [private] |
An adaptor to a standard normal distribution.
Definition at line 61 of file RandomNumberGenerator.hpp.
Referenced by load(), save(), and StandardNormalRandomDeviate().
boost::variate_generator<boost::mt19937& , boost::uniform_real<> > RandomNumberGenerator::mGenerateUnitReal [private] |
An adaptor to a unit interval distribution.
Definition at line 58 of file RandomNumberGenerator.hpp.
Referenced by ranf().
boost::mt19937 RandomNumberGenerator::mMersenneTwisterGenerator [private] |
The main random number generator.
Definition at line 55 of file RandomNumberGenerator.hpp.
Referenced by ExponentialRandomDeviate(), GammaRandomDeviate(), load(), randMod(), Reseed(), and save().
RandomNumberGenerator * RandomNumberGenerator::mpInstance = NULL [static, private] |
Pointer to the single instance.
Definition at line 64 of file RandomNumberGenerator.hpp.
Referenced by Destroy(), Instance(), and RandomNumberGenerator().
1.6.2