Chaste
Release::3.4
|
#include <RandomNumberGenerator.hpp>
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) |
Public Member Functions inherited from SerializableSingleton< RandomNumberGenerator > | |
SerializableSingleton < RandomNumberGenerator > * | GetSerializationWrapper () const |
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::random::normal_distribution_v156<> > | 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 59 of file RandomNumberGenerator.hpp.
|
protected |
Protected constructor. Use Instance() to access the random number generator.
Definition at line 41 of file RandomNumberGenerator.cpp.
References mpInstance.
Referenced by Instance().
|
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 62 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 133 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 125 of file RandomNumberGenerator.cpp.
References mMersenneTwisterGenerator.
Referenced by GammaDistributedStochasticDurationCellCycleModel::SetG1Duration().
|
static |
Definition at line 53 of file RandomNumberGenerator.cpp.
References mpInstance, and RandomNumberGenerator().
Referenced by AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::AbstractCellBasedSimulation(), DiffusionForce< DIM >::AddForceContribution(), CryptSimulation1d::CalculateCellDivisionVector(), RandomDirectionVertexBasedDivisionRule< SPACE_DIM >::CalculateCellDivisionVector(), CryptSimulation2d::CalculateCellDivisionVector(), OffLatticeSimulation< ELEMENT_DIM, SPACE_DIM >::CalculateCellDivisionVector(), ExclusionCaBasedDivisionRule< SPACE_DIM >::CalculateDaughterNodeIndex(), RandomCellKiller< DIM >::CheckAndLabelSingleCellForApoptosis(), MutableVertexMesh< ELEMENT_DIM, SPACE_DIM >::CheckForRosettes(), CryptCellsGenerator< CELL_CYCLE_MODEL >::Generate(), CellsGenerator< CELL_CYCLE_MODEL, DIM >::GenerateBasicRandom(), StochasticOxygenBasedCellCycleModel::GenerateStochasticG2Duration(), StochasticWntCellCycleModel::GenerateStochasticG2Duration(), HoneycombMeshGenerator::GetCircularMesh(), CryptProjectionStatistics::GetCryptSection(), CryptStatistics::GetCryptSection(), VertexMesh< ELEMENT_DIM, SPACE_DIM >::GetShortAxisOfElement(), MutableVertexMesh< ELEMENT_DIM, SPACE_DIM >::IdentifySwapType(), CryptSimulationBoundaryCondition< DIM >::ImposeBoundaryCondition(), PlaneBoundaryCondition< ELEMENT_DIM, SPACE_DIM >::ImposeBoundaryCondition(), MutableVertexMesh< ELEMENT_DIM, SPACE_DIM >::PerformProtorosetteResolution(), MutableVertexMesh< ELEMENT_DIM, SPACE_DIM >::PerformRosetteRankDecrease(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodes(), SimpleWntCellCycleModel::serialize(), StochasticDurationGenerationBasedCellCycleModel::serialize(), StochasticOxygenBasedCellCycleModel::serialize(), StochasticWntCellCycleModel::serialize(), GammaDistributedStochasticDurationCellCycleModel::serialize(), StochasticDurationCellCycleModel::serialize(), ExponentiallyDistributedStochasticDurationGenerationBasedCellCycleModel::serialize(), RandomCellKiller< DIM >::serialize(), AbstractCellBasedSimulation< DIM >::serialize(), StochasticDurationGenerationBasedCellCycleModel::SetG1Duration(), GammaDistributedStochasticDurationCellCycleModel::SetG1Duration(), StochasticDurationCellCycleModel::SetG1Duration(), ExponentiallyDistributedStochasticDurationGenerationBasedCellCycleModel::SetG1Duration(), SimpleWntCellCycleModel::SetG1Duration(), AbstractCellBasedTestSuite::setUp(), Shuffle(), PottsBasedCellPopulation< DIM >::UpdateCellLocations(), CaBasedCellPopulation< DIM >::UpdateCellLocations(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), and CaBasedCellPopulation< DIM >::WriteVtkResultsToFile().
|
inlineprivate |
Load the RandomNumberGenerator and its member variables.
archive | the archive |
version | the current version of this class |
Definition at line 118 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 120 of file RandomNumberGenerator.cpp.
References StandardNormalRandomDeviate().
Referenced by StochasticOxygenBasedCellCycleModel::GenerateStochasticG2Duration(), StochasticWntCellCycleModel::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 71 of file RandomNumberGenerator.cpp.
References mMersenneTwisterGenerator, and NEVER_REACHED.
Referenced by MutableVertexMesh< ELEMENT_DIM, SPACE_DIM >::PerformProtorosetteResolution(), MutableVertexMesh< ELEMENT_DIM, SPACE_DIM >::PerformRosetteRankDecrease(), Shuffle(), PottsBasedCellPopulation< DIM >::UpdateCellLocations(), and CaBasedCellPopulation< DIM >::UpdateCellLocations().
double RandomNumberGenerator::ranf | ( | ) |
Definition at line 110 of file RandomNumberGenerator.cpp.
References mGenerateUnitReal.
Referenced by CryptSimulation1d::CalculateCellDivisionVector(), RandomDirectionVertexBasedDivisionRule< SPACE_DIM >::CalculateCellDivisionVector(), CryptSimulation2d::CalculateCellDivisionVector(), OffLatticeSimulation< ELEMENT_DIM, SPACE_DIM >::CalculateCellDivisionVector(), ExclusionCaBasedDivisionRule< SPACE_DIM >::CalculateDaughterNodeIndex(), RandomCellKiller< DIM >::CheckAndLabelSingleCellForApoptosis(), CryptCellsGenerator< CELL_CYCLE_MODEL >::Generate(), CellsGenerator< CELL_CYCLE_MODEL, DIM >::GenerateBasicRandom(), HoneycombMeshGenerator::GetCircularMesh(), CryptProjectionStatistics::GetCryptSection(), CryptStatistics::GetCryptSection(), VertexMesh< ELEMENT_DIM, SPACE_DIM >::GetShortAxisOfElement(), CryptSimulationBoundaryCondition< DIM >::ImposeBoundaryCondition(), PlaneBoundaryCondition< ELEMENT_DIM, SPACE_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 145 of file RandomNumberGenerator.cpp.
References mGenerateStandardNormal, mGenerateUnitReal, and mMersenneTwisterGenerator.
Referenced by AbstractCellBasedTestSuite::setUp().
|
inlineprivate |
Save the RandomNumberGenerator and its member variables.
archive | the archive |
version | the current version of this class |
Definition at line 90 of file RandomNumberGenerator.hpp.
References mGenerateStandardNormal, and mMersenneTwisterGenerator.
|
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 194 of file RandomNumberGenerator.hpp.
References Instance(), and randMod().
Referenced by TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodes(), PottsBasedCellPopulation< DIM >::UpdateCellLocations(), and CaBasedCellPopulation< DIM >::UpdateCellLocations().
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 156 of file RandomNumberGenerator.cpp.
References Instance(), and randMod().
double RandomNumberGenerator::StandardNormalRandomDeviate | ( | ) |
Definition at line 115 of file RandomNumberGenerator.cpp.
References mGenerateStandardNormal.
Referenced by DiffusionForce< DIM >::AddForceContribution(), and NormalRandomDeviate().
|
private |
An adaptor to a standard normal distribution.
Definition at line 72 of file RandomNumberGenerator.hpp.
Referenced by load(), Reseed(), save(), and StandardNormalRandomDeviate().
|
private |
An adaptor to a unit interval distribution.
Definition at line 68 of file RandomNumberGenerator.hpp.
|
private |
The main random number generator.
Definition at line 63 of file RandomNumberGenerator.hpp.
Referenced by ExponentialRandomDeviate(), GammaRandomDeviate(), load(), randMod(), Reseed(), and save().
|
staticprivate |
Pointer to the single instance.
Definition at line 77 of file RandomNumberGenerator.hpp.
Referenced by Destroy(), Instance(), and RandomNumberGenerator().