Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
Random number generation class, uses various types of random generators depending on the implementation. More...
#include <Uniform.h>
Static Public Member Functions | |
static void | init (unsigned long seed) |
Initialize the random generator's seed. More... | |
static void | free () |
Memory de-allocation. More... | |
static double | Uniform () |
Generates a random number from [0.0, 1.0[ uniformly distributed. More... | |
static unsigned int | Uniform (unsigned int max) |
Returns a uniformly distributed random number from [0.0, max[. More... | |
static bool | RandBool () |
Returns a random boolean. More... | |
static unsigned long | RandULong () |
Return a random unsigned long, from uniform distribution. More... | |
static double | gammln (double xx) |
From the Numerical Recieps. More... | |
static double | Poisson (double mean) |
From the Numerical Recieps. More... | |
static double | Gaussian (double sigma) |
static void | BivariateGaussian (double sigma1, double sigma2, double rho, double *out1, double *out2) |
static double | LogNormal (double zeta, double sigma) |
static double | Gamma (double a, double b) |
static double | Bernoulli (double p) |
static double | Exponential (double mu) |
static double | Binomial (double p, unsigned int n) |
static double | Beta (const double a, const double b) |
static unsigned int | Binomial2 (double p, unsigned int n) |
static void | Multinomial (size_t K, unsigned int N, const double p[], unsigned int n[]) |
static void | MultinomialOnNormalizedValarray (size_t K, unsigned int N, const std::valarray< double > &p, unsigned int n[]) |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0. More... | |
static void | MultinomialOnNormalizedValarray_expandedOut (size_t K, unsigned int N, const std::valarray< double > &p, unsigned int n[]) |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0, the output is an array of size N. More... | |
static void | MultinomialOnNormalizedValarray_scrambleOut (size_t K, unsigned int N, const std::valarray< double > &p, unsigned int n[]) |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0, the output is an array of size N. More... | |
static void | MultinomialOnNormalizedValarrayZipper_scrambleOut (size_t K, unsigned int N, const std::valarray< double > &p, unsigned int n[]) |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0, the output is an array of size N. More... | |
static void | ScrambleArrayUInt (const int length, unsigned int *array) |
Randomize the elements within an array. More... | |
static void | Sample (const int from, const int to, const unsigned int num, int *result, bool replace) |
Creates a sample of integers within range [from, to), with or without replacement. More... | |
static void | SampleSeq (int from, int to, int by, unsigned int num, int *result, bool replace=false) |
static void | SampleSeqWithReciprocal (int from, int to, int by, unsigned int num1, int *result1, unsigned int num2, int *result2) |
Static Public Attributes | |
static long | Seed1 = 0 |
static long | Seed2 = 98280582 |
Private Member Functions | |
RAND () | |
Random number generation class, uses various types of random generators depending on the implementation.
|
private |
|
inlinestatic |
References Uniform().
Referenced by TTNeutralGenes::init_sequence(), and ParamsParser::rbernoul().
|
inlinestatic |
References Gamma().
Referenced by Binomial().
|
inlinestatic |
References Beta(), and Uniform().
Referenced by Binomial2(), Multinomial(), MultinomialOnNormalizedValarray(), MultinomialOnNormalizedValarray_expandedOut(), MultinomialOnNormalizedValarray_scrambleOut(), TTNeutralGenes::mutate_2all(), TTNeutralGenes::mutate_KAM(), and TTNeutralGenes::mutate_SSM().
References Binomial().
|
inlinestatic |
References Uniform().
Referenced by TProtoQuanti::getMutationEffectBivariateGaussian().
|
inlinestatic |
References Uniform().
Referenced by ParamsParser::rexp(), and TProtoDeletMutations_bitstring::set_effects_exp().
|
inlinestatic |
Memory de-allocation.
Referenced by SimRunner::run().
|
inlinestatic |
References Gamma(), Gaussian(), and Uniform().
Referenced by Beta(), Gamma(), ParamsParser::rgamma(), and TProtoDeletMutations_bitstring::set_effects_gamma().
|
inlinestatic |
From the Numerical Recieps.
Referenced by Poisson().
|
inlinestatic |
From the GSL.
References Uniform().
Referenced by Gamma(), LCE_Selection_base::getFitnessMultivariateGaussian_VE(), LCE_Selection_base::getFitnessUnivariateGaussian_VE(), LCE_Breed_base::getGaussianFecundity(), TProtoQuanti::getMutationEffectUnivariateGaussian(), TTDispersal::init_sequence(), TTQuanti::init_sequence(), LCE_Patch_Extinction::rand_gaussian(), ParamsParser::rnorm(), TProtoQuanti::set_trait_value_VE(), and TProtoQuanti::setDominanceParameters().
|
inlinestatic |
Initialize the random generator's seed.
References _myenv, Seed1, MPIenv::workerCount(), and MPIenv::workerRank().
Referenced by SimRunner::init_random_seed(), and main().
|
inlinestatic |
References Uniform().
Referenced by LCE_Breed_base::getLogNormalFecundity(), LCE_Patch_Extinction::rand_lognormal(), ParamsParser::rlognorm(), and TProtoDeletMutations_bitstring::set_effects_lognorm().
|
inlinestatic |
References Binomial().
|
inlinestatic |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0.
References Binomial().
|
inlinestatic |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0, the output is an array of size N.
References Binomial().
|
inlinestatic |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0, the output is an array of size N.
References Binomial(), and ScrambleArrayUInt().
Referenced by LCE_Breed_Selection::do_breed_selection_WrightFisher_1sex(), and LCE_Breed_Selection::do_breed_selection_WrightFisher_2sex().
|
inlinestatic |
Multinomial draw assuming the probabilities sum to 1.0 and are all > 0, the output is an array of size N.
References ScrambleArrayUInt(), and Uniform().
|
inlinestatic |
From the Numerical Recieps.
References gammln(), and Uniform().
Referenced by LCE_Breed_base::getPoissonFecundity(), TTDispersal::mutate(), TProtoQuanti::mutate_diallelic_HC(), TT_BDMI::mutate_diplo(), TT_BDMI::mutate_haplo(), TProtoQuanti::mutate_HC(), TProtoQuanti::mutate_noHC(), TTDeletMutations_bitstring::mutate_noredraw(), TTDeletMutations_bitstring::mutate_noredraw_noBackMutation(), TTDeletMutations_bitstring::mutate_redraw(), LCE_Patch_Extinction::rand_poisson(), GeneticMap::recombine(), ParamsParser::rpoiss(), and LCE_Breed_Disperse::stochasticLogisticGrowth().
|
inlinestatic |
Returns a random boolean.
References Uniform().
Referenced by LCE_Patch_Extinction::do_remove(), TProtoQuanti::getMutationEffectBivariateDiallelic(), TProtoQuanti::getMutationEffectUnivariateDiallelic(), LCE_Breed_base::getOffsprgSexFixed(), LCE_Breed_base::getOffsprgSexRandom(), TTDispersal::inherit(), TProtoDeletMutations_bitstring::inherit_free(), TProtoQuanti::inherit_free(), TProtoNeutralGenes::inherit_free(), LCE_Disperse_EvolDisp::Migrate_SteppingStone1D(), TTDispersal::mutate(), TTNeutralGenes::mutate_2all(), TProtoQuanti::mutate_diallelic_HC(), TT_BDMI::mutate_diplo(), TProtoQuanti::mutate_HC(), TTNeutralGenes::mutate_KAM(), TProtoQuanti::mutate_noHC(), TTDeletMutations_bitstring::mutate_noredraw(), TTDeletMutations_bitstring::mutate_noredraw_noBackMutation(), TTDeletMutations_bitstring::mutate_redraw(), TTNeutralGenes::mutate_SSM(), GeneticMap::recombine(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().
|
inlinestatic |
Return a random unsigned long, from uniform distribution.
References Uniform().
|
inlinestatic |
Creates a sample of integers within range [from, to), with or without replacement.
Can be used to scramble an array (without replacement). The random sequence of integers is placed in the 'results' array.
from | starting number of the series |
to | last number of the series |
num | number of elements to draw within [from, to) |
result | container to hold the resulting randomized sequence of integers |
References Uniform().
Referenced by MPFileHandler::createAndPrintSample(), and FileServices::subSamplePatch().
|
inlinestatic |
References Uniform().
|
inlinestatic |
References Uniform().
Referenced by LCE_NtrlInit::init_allele_freq(), and LCE_QuantiInit::init_allele_freq().
Randomize the elements within an array.
length | the length of the array |
array | the array to scramble |
References Uniform().
Referenced by MultinomialOnNormalizedValarray_scrambleOut(), and MultinomialOnNormalizedValarrayZipper_scrambleOut().
|
inlinestatic |
Generates a random number from [0.0, 1.0[ uniformly distributed.
If SPRNG or GSL libraries are not used, implement a random generator from: L'Ecuyer, 1988, "Efficient and Portable Combined Random Number Generators", Communication of the ACM, 31(6):742-774.
Referenced by Bernoulli(), Binomial(), BivariateGaussian(), LCE_Breed_base::checkPolygyny(), LCE_Cross::create_individual_ancestors(), LCE_Patch_Extinction::do_remove(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Aging::execute(), LCE_Patch_Extinction::execute(), Exponential(), BinaryDataLoader::extractPop(), Metapop::fillPopulationFromSource(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Breed_base::fullPolyginy_manyMales(), Gamma(), Gaussian(), LCE_Breed_Disperse::get_parent(), LCE_Disperse_base::getMigrationPatchBackward(), LCE_Disperse_base::getMigrationPatchForward(), TProtoQuanti::getMutationEffectBivariateDiallelic(), TT_BDMI::init_sequence(), TTDeletMutations_bitstring::init_sequence(), TTDispersal::init_sequence(), TTNeutralGenes::init_sequence(), TTQuanti::init_sequence(), LogNormal(), LCE_Breed_Selection::makeOffspringWithSelection(), LCE_Breed_Disperse::mate_selfing(), LCE_Disperse_EvolDisp::Migrate_Island(), LCE_Disperse_EvolDisp::Migrate_Island_Propagule(), LCE_Disperse_EvolDisp::Migrate_Lattice(), LCE_Disperse_ConstDisp::MigratePatchByNumber(), MultinomialOnNormalizedValarrayZipper_scrambleOut(), TTDispersal::mutate(), TTWolbachia::mutate(), TTNeutralGenes::mutate_2all(), TProtoQuanti::mutate_diallelic_HC(), TT_BDMI::mutate_diplo(), TT_BDMI::mutate_haplo(), TProtoQuanti::mutate_HC(), TTNeutralGenes::mutate_KAM(), TProtoQuanti::mutate_noHC(), TTDeletMutations_bitstring::mutate_noredraw(), TTDeletMutations_bitstring::mutate_noredraw_noBackMutation(), TTDeletMutations_bitstring::mutate_redraw(), TTNeutralGenes::mutate_SSM(), LCE_Breed_base::partialMonoginy(), LCE_Breed_base::partialPolyginy(), LCE_Breed_base::partialPolyginy_manyMales(), LCE_Breed_base::partialSelfing(), Poisson(), LCE_Patch_Extinction::rand_exp(), LCE_Patch_Extinction::rand_uniform(), RandBool(), LCE_Breed_base::random_hermaphrodite(), LCE_Breed_base::RandomMating(), RandULong(), GeneticMap::recombine(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::regulateAgeClassWithBackup(), LCE_Regulation::regulatePatch(), ParamsParser::runif(), Sample(), LCE_Cross::sampleAmongPop(), SampleSeq(), SampleSeqWithReciprocal(), LCE_Cross::sampleWithinPop(), ScrambleArrayUInt(), LCE_Disperse_base::setPropaguleTargets(), TTProtoWithMap::setRecombinationMapRandom(), setSpatialMatrix(), LCE_Breed_Disperse::stochasticFecundityGrowth(), Uniform(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_base::WrightFisherPopulation(), and LCE_Breed_Quanti::WrightFisherPopulation().
|
static |
Referenced by Uniform().