|
| static float | CalcPointValue (float fX, float fSlope, float fIntercept=0.0) |
| | Returns the value of a linear function.
|
| |
| static float | GetRand () |
| | Random number generator.
|
| |
| static float | CalculateBasalArea (float fDbh) |
| | Calculates basal area.
|
| |
| static float | Round (float fNumber, int iNumDigits) |
| | Rounds a number to a specified number of digits.
|
| |
| static int | RandomRound (float fNumber) |
| | Uses a random number to decide whether to round a number up or down to the next integer.
|
| |
| static float | CalculateWeibullFunction (float fDispersal, float fTheta, float fDistance) |
| | Calculates the exponential of the Weibull probability distribution function at a particular point.
|
| |
| static float | CalculateLognormalFunction (float fX0, float fXb, float fDistance) |
| | Calculates the exponential of the Lognormal probability distribution function at a particular point.
|
| |
| static int | PoissonRandomDraw (float fLambda) |
| | Returns a random Poisson-distributed number.
|
| |
| static float | LognormalRandomDraw (float fMean, float fStdDev) |
| | Returns a random lognormally-distributed number.
|
| |
| static float | NormalRandomDraw (float fStdDev) |
| | Returns a random normally-distributed number with mean zero and standard deviation sigma.
|
| |
| static int | NegBinomialRandomDraw (float fMean, float fClumping) |
| | Returns a random negative binomially-distributed number.
|
| |
| static float | AddBarkToDBH (float fDIB, float fA, float fB, float fC) |
| | Adds bark to a tree diameter.
|
| |
| static float | InverseGaussianRandomDraw (float fMu, float fLambda) |
| | Returns a random number over the inverse Gaussian distribution.
|
| |
| static float | GammaRandomDraw (float fMean, float fScale) |
| | Returns a random number drawn from the gamma distribution.
|
| |
| static void | SetRandomSeed (long iSeed) |
| | Sets the random seed.
|
| |
SORTIE math library.
This library provides some model-specific math functions.
The random number generator is very important. To make sure that no one can mess with the seed, I put the seed and the seed setting function in the private portion. Then clSimManager is a friend class and is the only one that can change the seed.
This used to be a library of C-style functions. But it turns out that the random number generator doesn't work right unless the seed is a class member.
I have made some wrappers for GSL, for back-compatibility from before GSL was used. But I have also opened up the random number generator so that other classes can use the GSL functions directly if they wish.
Copyright 2005 Charles D. Canham.
- Author
- Lora E. Murphy
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
| static float clModelMath::InverseGaussianRandomDraw |
( |
float |
fMu, |
|
|
float |
fLambda |
|
) |
| |
|
static |
Returns a random number over the inverse Gaussian distribution.
I got this code from http://www.cbr.washington.edu/papers/zabel/index.html, which is the dissertation "Spatial and Temporal Models of Migrating Juvenile Salmon
with Applications", by Richard W. Zabel, University of Washington.
The inverse Gaussian PDF is:
f(x; μ, λ) = [λ /(2πx3)]^(1/2) * exp[(-λ(x-μ)2 )/ (2 μ2x)]
- Parameters
-
| fMu,: | mu. |
| fLambda,: | lambda. |
| static float clModelMath::LognormalRandomDraw |
( |
float |
fMean, |
|
|
float |
fStdDev |
|
) |
| |
|
static |
Returns a random lognormally-distributed number.
The lognormal distribution has the form
p(x) dx = 1/(x * sqrt(2 pi sigma2)) exp(-(ln(x) - zeta)2/2 sigma2) dx
for x > 0. Lognormal random numbers are the exponentials of gaussian random numbers.
This just wraps the appropriate GSL function.
- Parameters
-
| fMean | Mean of the distribution, or zeta in the above formula. |
| fStdDev | Standard deviation of the distribution, or sigma in the above formula. |
- Returns
- Random lognormally-distributed number.
| static float clModelMath::NormalRandomDraw |
( |
float |
fStdDev | ) |
|
|
static |
Returns a random normally-distributed number with mean zero and standard deviation sigma.
The probability distribution for normal random variates is, p(x) dx = {1 / sqrt{2 π σ2}} exp (-x2 / 2σ2) dx for x in the range -infty to +infty. Use the transformation z = mu + x on the numbers returned to obtain a normal distribution with mean mu.
This function just wraps the appropriate GSL function.
- Parameters
-
| fStdDev | Standard deviation. |
- Returns
- Random normally-distributed number.