public class GammaARVariate extends RandomVariateBase
Instances of this class generate correlated Gamma random variates based on an approach in Gaver and Lewis (1986). The correlation rho must be ≥ 0 and the shape parameter k must be an integer. The generated sequence have a gamma distribution with the given parameters (k, lambda), where k is the shape and lambda is the scale. The lag-1 autocorrelation is rho.
The recursion is Xn+1=ρ Xn + εn where εn is generated from a mixture of constant(0), Exponential(λ) and Gamma(k, λ), k = 2,...,k. If k = 1, then the marginals are Exponential(λ).
Modifier and Type | Field and Description |
---|---|
private double |
currentValue |
private int |
k |
private double |
lambda |
private static java.util.logging.Logger |
LOGGER |
private RandomVariate |
mixtureVariate |
private double |
rho |
rng
Constructor and Description |
---|
GammaARVariate() |
Modifier and Type | Method and Description |
---|---|
static int |
binomialCoefficient(int n,
int k) |
double |
generate()
Generate a random variate having this class's distribution.
|
double |
getCurrentValue() |
int |
getK() |
double |
getLambda() |
RandomVariate |
getMixtureVariate() |
java.lang.Object[] |
getParameters()
Returns the array of parameters as an Object[].
|
double |
getRho() |
void |
setCurrentValue(double currentValue) |
void |
setK(int k) |
void |
setLambda(double lambda) |
void |
setParameters(java.lang.Object... params)
Parameters:
params[0] is λ (double)
params[1] is ρ (double)
(optional) params[2] is k (defaults to 2)
|
void |
setRho(double rho) |
private void |
setupMixture()
Creates the MixedVariate.
|
java.lang.String |
toString() |
getRandomNumber, setRandomNumber
private static final java.util.logging.Logger LOGGER
private double rho
private double lambda
private int k
private RandomVariate mixtureVariate
private double currentValue
public double generate()
RandomVariate
public void setParameters(java.lang.Object... params)
params
- Given parametersjava.lang.IllegalArgumentException
- if params.length ≠ 2 or 3java.lang.IllegalArgumentException
- if an element of params is not Numberprivate void setupMixture()
Creates the MixedVariate. The mixing probabilities are given by C(k,i)ρk-1(1-ρ)i for i = 0,...,k.
The probability distributions are Gamma(i, λ) for i = 0,...,k, noting that Gamma(0,λ) is Constant(0) and Gamma(1,λ) is Exponential(λ).
public java.lang.Object[] getParameters()
RandomVariate
public double getRho()
public void setRho(double rho)
rho
- the rho to setjava.lang.IllegalArgumentException
- if ρ ∉ [0,1]public double getLambda()
public void setLambda(double lambda)
lambda
- the lambda to setjava.lang.IllegalArgumentException
- if λ ≤ 0.0public java.lang.String toString()
toString
in class java.lang.Object
public double getCurrentValue()
public void setCurrentValue(double currentValue)
currentValue
- the currentValue to setpublic int getK()
public void setK(int k)
k
- the k to setjava.lang.IllegalArgumentException
- if k < 1public static int binomialCoefficient(int n, int k)
n
- Given "n"k
- Given "choose k"java.lang.IllegalArgumentException
- if n < 0 or k < 0public RandomVariate getMixtureVariate()