#include <LogNormal.h>
Public Member Functions | |
LogNormal (double mean=znSqrtEC, double variance=znEC *(znEC-1)) | |
Creates a new instance of the Log Normal random number generator, initializes the range of the numbers and internal variables. | |
LogNormal (double mean, double variance, RNG &r) | |
Creates a new log normal random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the range of the numbers and internal variables. | |
double | mean () const |
Returns the current mean value logMean of the random numbers distribution. | |
double | variance () const |
Returns the current variance logVariance of the random numbers distribution. | |
void | mean (double newMean) |
Sets the current mean value logMean of the distribution to the new value "newMean" and prepares internal variables for the future random number generation. | |
void | variance (double newVar) |
Sets the current variance logVariance of the distribution to the new value "newVar" and prepares internal variables for the future random number generation. | |
double | operator() () |
Returns a log normally distributed random number for a distribution with mean value logMean and variance logVariance. | |
double | p (const double &) const |
Returns the probability for the occurrence of "x" for a log normal distribution with given mean value logMean and variance logVariance. | |
double | operator() (double mean, double variance) |
Returns a log normally distributed random number for a distribution with mean value "mean" and variance "variance". | |
Protected Attributes | |
double | logMean |
The mean value ![]() | |
double | logVariance |
This class is derived from class Normal and the random values returned by it are of type "double", simulating the Log Normal distribution given by the equation:
where and the log normal distribution results from the normal (gaussian) distribution
by
.
is the mean value or peak of the distribution curve, stored in logMean and
is the distribution's standard deviation, with the variance
stored in logVariance.
A special form of calculation is used to save time. For details please refer to "Simulation, Modelling & Analysis" by Law & Kelton, pp. 260.
Below you can see the Log Normal distribution for the standard values and
:
LogNormal::LogNormal | ( | double | mean = znSqrtEC , |
|
double | variance = znEC * ( znEC - 1 ) | |||
) |
Creates a new instance of the Log Normal random number generator, initializes the range of the numbers and internal variables.
Creates a new instance of the Log Normal random number generator, initializes the range of the numbers and internal variables.
The mean value logMean and the variance logVariance of the distribution are initialized.
Internal variables are also initialized to speed up the generation of future random numbers.
For this instance, the default pseudo random number generator as member of class RandomVar is used.
mean | the mean value of the log normal distribution, the default is ![]() | |
variance | the variance of the log normal distribution, the default is ![]() |
LogNormal::LogNormal | ( | double | mean, | |
double | variance, | |||
RNG & | r | |||
) |
Creates a new log normal random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the range of the numbers and internal variables.
Creates a new log normal random generator instance by using the pseudo random number generator "r" for the determination of random values and initializes the range of the numbers and internal variables.
Each instance of a log normal random number generator is based on a generator, that is defined in class RNG and returns uniformally pseudo random numbers of the interval (0,1). By default, this is a global generator named RNG::globalRng and included as member in class RandomVar.
Here another pseudo random number generator r is used instead.
Additionally to defining the used pseudo random number generator, the mean value and the variance of the distribution and internal variables are initialized.
mean | the mean value logMean of the log normal distribution | |
variance | the variance logVariance of the log normal distribution | |
r | the pseudo random number generator that is used |
double LogNormal::mean | ( | ) | const [inline] |
double LogNormal::variance | ( | ) | const [inline] |
Returns the current variance logVariance of the random numbers distribution.
Reimplemented from Normal.
void LogNormal::mean | ( | double | newMean | ) |
Sets the current mean value logMean of the distribution to the new value "newMean" and prepares internal variables for the future random number generation.
Sets the current mean value logMean of the distribution to the new value "newMean" and prepares internal variables for the future random number generation.
newMean | the new mean value for the distribution |
Reimplemented from Normal.
void LogNormal::variance | ( | double | newVariance | ) |
Sets the current variance logVariance of the distribution to the new value "newVar" and prepares internal variables for the future random number generation.
Sets the current variance logVariance of the distribution to the new value "newVar" and prepares internal variables for the future random number generation.
The variance is set to the new value "newVar".
newVariance | the new variance of the distribution |
Reimplemented from Normal.
double LogNormal::operator() | ( | ) | [virtual] |
Returns a log normally distributed random number for a distribution with mean value logMean and variance logVariance.
Returns a log normally distributed random number for a distribution with mean value logMean and variance logVariance.
To create a random number a special method (see class description) based on the Box-Müller method is used.
Reimplemented from Normal.
double LogNormal::p | ( | const double & | x | ) | const [virtual] |
Returns the probability for the occurrence of "x" for a log normal distribution with given mean value logMean and variance logVariance.
Returns the probability for the occurrence of "x" for a log normal distribution with given mean value logMean and variance logVariance.
x | the value ![]() |
Reimplemented from Normal.
double LogNormal::operator() | ( | double | mean, | |
double | variance | |||
) |
Returns a log normally distributed random number for a distribution with mean value "mean" and variance "variance".
Returns a log normally distributed random number for a distribution with mean value "mean" and variance "variance".
This method performs the inverse transformation of the original uniformally distributed random numbers of the interval (0,1) created by the used pseudo random number generator to the type of the log normal distribution.
To create such a transformed random number, a special method (see class description) based on the Box-Müller method is used.
Reimplemented from Normal.
double LogNormal::logVariance [protected] |
The variance of the distribution, where
is the distribution's standard deviation.