Package jsl.utilities.distributions
Class BivariateNormal
- java.lang.Object
-
- jsl.utilities.distributions.BivariateNormal
-
- All Implemented Interfaces:
ParametersIfc
,RNStreamControlIfc
public class BivariateNormal extends java.lang.Object implements RNStreamControlIfc, ParametersIfc
Allows for the generation of bivariate normal random variables
-
-
Constructor Summary
Constructors Constructor Description BivariateNormal()
Constructs a standard bivariate normal with no correlationBivariateNormal(double[] param)
Interprets the array of parameters as the parameters param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;BivariateNormal(double[] param, RNStreamIfc rng)
Interprets the array of parameters as the parameters param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;BivariateNormal(double mean1, double var1, double mean2, double var2, double rho)
BivariateNormal(double mean1, double var1, double mean2, double var2, double rho, RNStreamIfc rng)
Constructs a bivariate normal with the provided parametersBivariateNormal(RNStreamIfc rng)
Constructs a standard bivariate normal with no correlation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceToNextSubstream()
Positions the RNG at the beginning of its next substreamboolean
getAntitheticOption()
double
getCorrelation()
Gets the correlationdouble
getMean1()
Gets the first meandouble
getMean2()
Gets the second meandouble[]
getParameters()
Returns the parameters as an array param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;RNStreamIfc
getRandomNumberGenerator()
Returns the distributions underlying random number generatordouble[]
getValues()
Returns an array containing the bivariate pair x[0] = 1st marginal x[1] = 2nd marginaldouble[]
getValues(double[] x)
Fills the supplied array with 2 values As a convenience also returns the arraydouble
getVariance1()
Gets the first variancedouble
getVariance2()
Gets the 2nd variancevoid
resetStartStream()
The resetStartStream method will position the RNG at the beginning of its stream.void
resetStartSubstream()
Resets the position of the RNG at the start of the current substreamvoid
setAntitheticOption(boolean flag)
Tells the stream to start producing antithetic variatesvoid
setCorrelation(double rho)
Sets the correlationvoid
setMean1(double mean)
Sets the first meanvoid
setMean2(double mean)
Sets the second meanvoid
setParameters(double[] param)
Interprets the array of parameters as the parameters param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;void
setParameters(double mean1, double var1, double mean2, double var2, double rho)
Sets all the parametersvoid
setRandomNumberGenerator(RNStreamIfc rng)
Sets the underlying random number generator for the distribution Throws a NullPointerException if rng is nullvoid
setVariance1(double variance)
Sets the first variancevoid
setVariance2(double variance)
Sets the 2nd variancejava.lang.String
toString()
-
-
-
Field Detail
-
myRNG
protected RNStreamIfc myRNG
-
myMu1
protected double myMu1
-
myVar1
protected double myVar1
-
myMu2
protected double myMu2
-
myVar2
protected double myVar2
-
myRho
protected double myRho
-
-
Constructor Detail
-
BivariateNormal
public BivariateNormal()
Constructs a standard bivariate normal with no correlation
-
BivariateNormal
public BivariateNormal(RNStreamIfc rng)
Constructs a standard bivariate normal with no correlation
-
BivariateNormal
public BivariateNormal(double mean1, double var1, double mean2, double var2, double rho)
- Parameters:
mean1
-var1
-mean2
-var2
-rho
-
-
BivariateNormal
public BivariateNormal(double[] param)
Interprets the array of parameters as the parameters param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;- Parameters:
param
-
-
BivariateNormal
public BivariateNormal(double[] param, RNStreamIfc rng)
Interprets the array of parameters as the parameters param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;- Parameters:
param
-rng
-
-
BivariateNormal
public BivariateNormal(double mean1, double var1, double mean2, double var2, double rho, RNStreamIfc rng)
Constructs a bivariate normal with the provided parameters- Parameters:
mean1
-var1
-mean2
-var2
-rho
-rng
-
-
-
Method Detail
-
setAntitheticOption
public void setAntitheticOption(boolean flag)
Description copied from interface:RNStreamControlIfc
Tells the stream to start producing antithetic variates- Specified by:
setAntitheticOption
in interfaceRNStreamControlIfc
- Parameters:
flag
- true means that it produces antithetic variates.
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RNStreamControlIfc
Resets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstream
in interfaceRNStreamControlIfc
-
resetStartStream
public void resetStartStream()
Description copied from interface:RNStreamControlIfc
The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.- Specified by:
resetStartStream
in interfaceRNStreamControlIfc
-
advanceToNextSubstream
public void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfc
Positions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstream
in interfaceRNStreamControlIfc
-
setParameters
public final void setParameters(double mean1, double var1, double mean2, double var2, double rho)
Sets all the parameters- Parameters:
mean1
-var1
-mean2
-var2
-rho
-
-
setParameters
public final void setParameters(double[] param)
Interprets the array of parameters as the parameters param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;- Specified by:
setParameters
in interfaceParametersIfc
- Parameters:
param
-
-
getParameters
public final double[] getParameters()
Returns the parameters as an array param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;- Specified by:
getParameters
in interfaceParametersIfc
- Returns:
-
setMean1
public final void setMean1(double mean)
Sets the first mean- Parameters:
mean
- of the distribution
-
getMean1
public final double getMean1()
Gets the first mean- Returns:
-
setVariance1
public final void setVariance1(double variance)
Sets the first variance- Parameters:
variance
- of the distribution, must be > 0
-
getVariance1
public final double getVariance1()
Gets the first variance- Returns:
-
setMean2
public final void setMean2(double mean)
Sets the second mean- Parameters:
mean
-
-
getMean2
public final double getMean2()
Gets the second mean- Returns:
-
setVariance2
public final void setVariance2(double variance)
Sets the 2nd variance- Parameters:
variance
- of the distribution, must be > 0
-
getVariance2
public final double getVariance2()
Gets the 2nd variance- Returns:
-
setCorrelation
public final void setCorrelation(double rho)
Sets the correlation- Parameters:
rho
-
-
getCorrelation
public final double getCorrelation()
Gets the correlation- Returns:
-
getRandomNumberGenerator
public RNStreamIfc getRandomNumberGenerator()
Returns the distributions underlying random number generator- Returns:
-
setRandomNumberGenerator
public void setRandomNumberGenerator(RNStreamIfc rng)
Sets the underlying random number generator for the distribution Throws a NullPointerException if rng is null- Parameters:
rng
- the reference to the random number generator
-
getValues
public double[] getValues(double[] x)
Fills the supplied array with 2 values As a convenience also returns the array- Parameters:
x
- Must be of size 2 or larger- Returns:
-
getValues
public double[] getValues()
Returns an array containing the bivariate pair x[0] = 1st marginal x[1] = 2nd marginal- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getAntitheticOption
public boolean getAntitheticOption()
- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- true means on
-
-