public class BivariateNormalVector extends java.lang.Object implements RandomVector
| Modifier and Type | Field and Description |
|---|---|
private double |
correlation |
private double |
correlation2 |
private double[] |
mean |
private double[] |
standardDeviation |
private RandomVariate[] |
standardNormalsGenerator |
| Constructor and Description |
|---|
BivariateNormalVector()
Instantiate a BivariateNormalVector; Instantiate the
standardNormalsGenerator array that generates standard normal (0, 1)
variates.
|
| Modifier and Type | Method and Description |
|---|---|
double[] |
generate()
Uses formula:
X_0 = σ0 * Z0 + μ0 X_1 = σ1 * (ρ * Z0 + √1 - ρ2 * Z1) + μ1 |
double |
getCorrelation() |
double[] |
getMean() |
double |
getMean(int index) |
java.lang.Object[] |
getParameters()
Returns an array containing the parameters of this RandomVector.
|
RandomNumber |
getRandomNumber()
Gets the instance of the supporting RandomNumber.
|
double[] |
getStandardDeviation() |
double |
getStandardDeviation(int index) |
RandomVariate[] |
getStandardNormalsGenerator() |
void |
setCorrelation(double correlation) |
void |
setMean(double[] mean) |
void |
setMean(int index,
double mean) |
void |
setParameters(java.lang.Object... parameters)
If array of length 3 is passed, the elements must be double[], double[],
double representing the means, variances, and correlation, respectively.
|
void |
setRandomNumber(RandomNumber randomNumber)
Sets the supporting RandomNumber.
|
void |
setStandardDeviation(double[] standardDeviation) |
void |
setStandardDeviation(int index,
double standardDeviation) |
void |
setStandardNormalsGenerator(RandomVariate[] standardNormalsGenerator)
It is assumed that the RandomVariates both generate standard normal
variates
|
java.lang.String |
toString() |
private RandomVariate[] standardNormalsGenerator
private double[] mean
private double[] standardDeviation
private double correlation
private double correlation2
public BivariateNormalVector()
public double[] generate()
generate in interface RandomVectorpublic double[] getMean()
public double getMean(int index)
index - index of mean - must be 0 or 1java.lang.ArrayIndexOutOfBoundsException - if index is not 0 or 1public void setMean(double[] mean)
mean - vector of meansjava.lang.IllegalArgumentException - is length of array is not 2public void setMean(int index,
double mean)
index - index of mean to setmean - value of new meanjava.lang.ArrayIndexOutOfBoundsException - if index is not 0 or 1public double[] getStandardDeviation()
public double getStandardDeviation(int index)
index - index of standardDeviation - must be 0 or 1java.lang.ArrayIndexOutOfBoundsException - if index is not 0 or 1public void setStandardDeviation(double[] standardDeviation)
standardDeviation - standard deviation vectorjava.lang.IllegalArgumentException - if length of argument array is not 2java.lang.IllegalArgumentException - if either value is < 0.0public void setStandardDeviation(int index,
double standardDeviation)
index - index of standard deviation to set; must be 0 or 1standardDeviation - new value of standardDeviation[index]java.lang.ArrayIndexOutOfBoundsException - if index is not 0 or 1java.lang.IllegalArgumentException - if either value is < 0.0public double getCorrelation()
public void setCorrelation(double correlation)
correlation - desired correlationjava.lang.IllegalArgumentException - is argument is not between -1.0 and 1.0
inclusivepublic java.lang.String toString()
toString in class java.lang.Objectpublic void setRandomNumber(RandomNumber randomNumber)
RandomVectorsetRandomNumber in interface RandomVectorrandomNumber - The RandomNumber object to be used to generate the underlying Un(0,1)
random numbers.public RandomNumber getRandomNumber()
RandomVectorgetRandomNumber in interface RandomVectorpublic void setParameters(java.lang.Object... parameters)
If an array of length 5 is passed, the elements must be all doubles, representing the two means, two standardNormals deviations, and correlation.
setParameters in interface RandomVectorparameters - means, variances, and correlationjava.lang.IllegalArgumentException - if the number of arguments is not 3 or 5public java.lang.Object[] getParameters()
RandomVectorgetParameters in interface RandomVectorpublic RandomVariate[] getStandardNormalsGenerator()
public void setStandardNormalsGenerator(RandomVariate[] standardNormalsGenerator)
standardNormalsGenerator - Array of RandomVariates to generate the
independent standard normal variatesjava.lang.IllegalArgumentException - if array is not length 2