11#include <util/param/ParamComposite.h>
12#include <util/space/Vector.h>
16#include <util/random/mersenne/mtrand.h>
17#define UTIL_ENGINE MTRand_int32
51 typedef unsigned long SeedType;
105 double uniform(
double range1,
double range2);
123 void getPoint(
double minR[],
double maxR[],
double r[]);
161 long drawFrom(
double probability[],
long size);
166 template <
class Archive>
167 void serialize(Archive& ar,
const unsigned int version);
206 return static_cast<double>(engine_()) * (1.0/ 4294967296.0);
215 double frac =
static_cast<double>(engine_()) * (1.0/ 4294967296.0);
216 return range1 + (range2 - range1)*frac;
225 double x =
uniform(range1, range2);
240 double cumProb = probability[0];
241 while ( cumProb < roulette && n < size ) {
243 cumProb += probability[n];
252 r[0] =
uniform(minR[0], maxR[0]);
253 r[1] =
uniform(minR[1], maxR[1]);
254 r[2] =
uniform(minR[2], maxR[2]);
283 template <
class Archive>
Saving archive for binary istream.
Saving / output archive for binary ostream.
An object that can read multiple parameters from file.
void setSeed(SeedType seed)
Sets of random seed, and initializes random number generator.
virtual void readParameters(std::istream &in)
Read seed from file, initialize RNG.
void getPoint(double minR[], double maxR[], double r[])
Generate a random point in a box.
long uniformInt(long range1, long range2)
Return random long int x uniformly distributed in range1 <= x < range2.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from file.
virtual ~Random()
Destructor.
void unitVector(Vector &v)
Generate unit vector with uniform probability over the unit sphere.
bool metropolis(double ratio)
Metropolis algorithm for whether to accept a MC move.
double uniform()
Return a random floating point number x, uniformly distributed in the range 0 <= x < 1.
double gaussian(void)
Return a Gaussian random number with zero average and unit variance.
long seed()
Returns value of random seed (private member variable seed_).
long drawFrom(double probability[], long size)
Choose one of several outcomes with a specified set of probabilities.
void serialize(Archive &ar, const unsigned int version)
Serialize to/from an archive.
virtual void save(Serializable::OArchive &ar)
Save internal state to file.
A Vector is a Cartesian vector.
Utility classes for scientific computation.