A class to generate random numbers.
More...
#include <rand.h>
|
| Random (quint64 seed=0, QObject *parent=0) |
| Random. More...
|
|
| ~Random () |
| Destroy objects. More...
|
|
quint64 | seed () |
| Get the seed that was used. More...
|
|
void | seed (quint64 seed) |
| seed the generator (again) More...
|
|
double | random () |
| Generate a random double from the uniform distribution [0, 1]. More...
|
|
double | range (const double low=0.0, const double high=1.0) |
| Generate a random double from the uniform distribution [low, high]. More...
|
|
double | normal (const double mean, const double sigma) |
| Generate a random double from the normal distribution. More...
|
|
int | integer (const int low=0, const int high=1) |
| Generate a random int from the uniform distribution [low, high]. More...
|
|
bool | metropolis (double energyChange, double inversekT) |
| Randomly choose yes using a Boltzmann factor. More...
|
|
bool | metropolisWithCoupling (double energyChange, double inversekT, double coupling) |
| Randomly choose yes using a Boltzmann factor and coupling constant. More...
|
|
bool | chooseYes (double percent) |
| Randomly choose yes a percent of the time. More...
|
|
bool | chooseNo (double percent) |
| Randomly choose no a percent of the time. More...
|
|
|
boost::mt19937 * | twister |
| The underlying random number generator. More...
|
|
boost::variate_generator
< boost::mt19937
&, boost::uniform_01< double > > * | generator01 |
| The underlying generator coupled to the uniform distribution on [0,1]. More...
|
|
quint64 | m_seed |
| The seed used to start the generator. More...
|
|
A class to generate random numbers.
LangmuirCore::Random::Random |
( |
quint64 |
seed = 0 , |
|
|
QObject * |
parent = 0 |
|
) |
| |
Random.
- Parameters
-
seed | makes the generator deterministic
- seed == 0 uses the current clock time
|
parent | object this belongs to |
LangmuirCore::Random::~Random |
( |
| ) |
|
bool LangmuirCore::Random::chooseNo |
( |
double |
percent | ) |
|
Randomly choose no a percent of the time.
bool LangmuirCore::Random::chooseYes |
( |
double |
percent | ) |
|
Randomly choose yes a percent of the time.
int LangmuirCore::Random::integer |
( |
const int |
low = 0 , |
|
|
const int |
high = 1 |
|
) |
| |
Generate a random int from the uniform distribution [low, high].
bool LangmuirCore::Random::metropolis |
( |
double |
energyChange, |
|
|
double |
inversekT |
|
) |
| |
Randomly choose yes using a Boltzmann factor.
- Parameters
-
energyChange | change in energy when going from initial to final state |
inversekT | decay constant in exponential |
bool LangmuirCore::Random::metropolisWithCoupling |
( |
double |
energyChange, |
|
|
double |
inversekT, |
|
|
double |
coupling |
|
) |
| |
Randomly choose yes using a Boltzmann factor and coupling constant.
- Parameters
-
energyChange | change in energy when going from initial to final state |
inversekT | decay constant in exponential |
coupling | alters acceptance probability
- if energy < 0 : chooses yes coupling * Boltzmann factor percent of the time
- if energy > 0 : chooses yes 1 - coupling percent of the time
|
double LangmuirCore::Random::normal |
( |
const double |
mean, |
|
|
const double |
sigma |
|
) |
| |
Generate a random double from the normal distribution.
- Parameters
-
mean | average value of the normal distribution sampled |
sigma | standard deviation of the normal distribution sampled |
double LangmuirCore::Random::random |
( |
| ) |
|
Generate a random double from the uniform distribution [0, 1].
double LangmuirCore::Random::range |
( |
const double |
low = 0.0 , |
|
|
const double |
high = 1.0 |
|
) |
| |
Generate a random double from the uniform distribution [low, high].
quint64 LangmuirCore::Random::seed |
( |
| ) |
|
Get the seed that was used.
void LangmuirCore::Random::seed |
( |
quint64 |
seed | ) |
|
seed the generator (again)
If seed == 0 is used, then the generator does not use the current time. This is different than the constructor Random.
QDataStream& operator<< |
( |
QDataStream & |
stream, |
|
|
Random & |
random |
|
) |
| |
|
friend |
Output the random state to a QDataStream Possibly Broken.
- Warning
- This may not quite be working correctly
QTextStream& operator<< |
( |
QTextStream & |
stream, |
|
|
Random & |
random |
|
) |
| |
|
friend |
Output the random state to a QTextStream Possibly Broken.
- Warning
- This may not quite be working correctly
std::ostream& operator<< |
( |
std::ostream & |
stream, |
|
|
Random & |
random |
|
) |
| |
|
friend |
Output the random state to a std::ostream.
QDataStream& operator>> |
( |
QDataStream & |
stream, |
|
|
Random & |
random |
|
) |
| |
|
friend |
Load the random state from a QDataStream Possibly Broken.
- Warning
- This may not quite be working correctly
QTextStream& operator>> |
( |
QTextStream & |
stream, |
|
|
Random & |
random |
|
) |
| |
|
friend |
Load the random state from a QTextStream Possibly Broken.
- Warning
- This may not quite be working correctly
std::istream& operator>> |
( |
std::istream & |
stream, |
|
|
Random & |
random |
|
) |
| |
|
friend |
Load the random state from a std::istream.
boost::variate_generator<boost::mt19937&, boost::uniform_01<double> >* LangmuirCore::Random::generator01 |
|
private |
The underlying generator coupled to the uniform distribution on [0,1].
quint64 LangmuirCore::Random::m_seed |
|
private |
The seed used to start the generator.
boost::mt19937* LangmuirCore::Random::twister |
|
private |
The underlying random number generator.
The documentation for this class was generated from the following file:
- /home/adam/opt/langmuir/src/langmuirCore/include/rand.h