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 voidadvanceToNextSubstream()Positions the RNG at the beginning of its next substreambooleangetAntitheticOption()doublegetCorrelation()Gets the correlationdoublegetMean1()Gets the first meandoublegetMean2()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;RNStreamIfcgetRandomNumberGenerator()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 arraydoublegetVariance1()Gets the first variancedoublegetVariance2()Gets the 2nd variancevoidresetStartStream()The resetStartStream method will position the RNG at the beginning of its stream.voidresetStartSubstream()Resets the position of the RNG at the start of the current substreamvoidsetAntitheticOption(boolean flag)Tells the stream to start producing antithetic variatesvoidsetCorrelation(double rho)Sets the correlationvoidsetMean1(double mean)Sets the first meanvoidsetMean2(double mean)Sets the second meanvoidsetParameters(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;voidsetParameters(double mean1, double var1, double mean2, double var2, double rho)Sets all the parametersvoidsetRandomNumberGenerator(RNStreamIfc rng)Sets the underlying random number generator for the distribution Throws a NullPointerException if rng is nullvoidsetVariance1(double variance)Sets the first variancevoidsetVariance2(double variance)Sets the 2nd variancejava.lang.StringtoString()
-
-
-
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:RNStreamControlIfcTells the stream to start producing antithetic variates- Specified by:
setAntitheticOptionin interfaceRNStreamControlIfc- Parameters:
flag- true means that it produces antithetic variates.
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RNStreamControlIfcResets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstreamin interfaceRNStreamControlIfc
-
resetStartStream
public void resetStartStream()
Description copied from interface:RNStreamControlIfcThe 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:
resetStartStreamin interfaceRNStreamControlIfc
-
advanceToNextSubstream
public void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfcPositions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstreamin 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:
setParametersin 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:
getParametersin 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:
toStringin classjava.lang.Object
-
getAntitheticOption
public boolean getAntitheticOption()
- Specified by:
getAntitheticOptionin interfaceRNStreamControlIfc- Returns:
- true means on
-
-