Package jsl.utilities.distributions
Class BivariateLogNormal
- java.lang.Object
-
- jsl.utilities.distributions.BivariateLogNormal
-
- All Implemented Interfaces:
ParametersIfc
,RNStreamControlIfc
public class BivariateLogNormal extends java.lang.Object implements RNStreamControlIfc, ParametersIfc
Allows for the generation of bivariate lognormal random variables. Note that this class takes in the actual parameters of the bivariate lognormal and computes the necessary parameters for the underlying bivariate normal
-
-
Constructor Summary
Constructors Constructor Description BivariateLogNormal()
Constructs a bivariate lognormal with mean's = 1.0, variance = 1.0.BivariateLogNormal(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;BivariateLogNormal(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;BivariateLogNormal(double mean1, double var1, double mean2, double var2, double rho)
BivariateLogNormal(double mean1, double var1, double mean2, double var2, double rho, RNStreamIfc rng)
These parameters are the parameters of the lognormal (not the bivariate normal)BivariateLogNormal(RNStreamIfc rng)
Constructs a bivariate lognormal with mean's = 1.0, variance = 1.0.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceToNextSubstream()
Positions the RNG at the beginning of its next substreamboolean
getAntitheticOption()
double[]
getBiVariateNormalParameters()
Returns the parameters of the underlying bivariate normal param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;static double[]
getBVLNParametersFromBVNParameters(double[] param)
Takes in the parameters of a bivariate normal and returns the corresponding parameters for the bivariate lognormal x[0] = mean 1 of bivariate lognormal x[1] = variance 1 of bivariate lognormal x[2] = mean 2 of bivariate lognormal x[3] = variance 2 of bivariate lognormal x[4] = correlation of bivariate lognormalstatic double[]
getBVLNParametersFromBVNParameters(double m1, double v1, double m2, double v2, double r)
Takes in the parameters of a bivariate normal and returns the corresponding parameters for the bivariate lognormal param[0] = mean 1 of bivariate lognormal param[1] = variance 1 of bivariate lognormal param[2] = mean 2 of bivariate lognormal param[3] = variance 2 of bivariate lognormal param[4] = correlation of bivariate lognormaldouble
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()
double[]
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 variancestatic void
main(java.lang.String[] args)
void
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 m1, double v1, double m2, double v2, double r)
Takes in the parameters of the bivariate lognormal and sets the parameters of the underlying bivariate normalvoid
setRandomNumberGenerator(RNStreamIfc rng)
void
setVariance1(double variance)
Sets the first variancevoid
setVariance2(double variance)
Sets the 2nd variancejava.lang.String
toString()
-
-
-
Field Detail
-
myBVN
protected BivariateNormal myBVN
-
myMu1
protected double myMu1
-
myVar1
protected double myVar1
-
myMu2
protected double myMu2
-
myVar2
protected double myVar2
-
myRho
protected double myRho
-
-
Constructor Detail
-
BivariateLogNormal
public BivariateLogNormal()
Constructs a bivariate lognormal with mean's = 1.0, variance = 1.0. correlation = 0.0
-
BivariateLogNormal
public BivariateLogNormal(RNStreamIfc rng)
Constructs a bivariate lognormal with mean's = 1.0, variance = 1.0. correlation = 0.0- Parameters:
rng
- a random number generator
-
BivariateLogNormal
public BivariateLogNormal(double mean1, double var1, double mean2, double var2, double rho)
- Parameters:
mean1
- the first meanvar1
- the first variancemean2
- the second meanvar2
- the second variancerho
- the corrlation
-
BivariateLogNormal
public BivariateLogNormal(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
- the parameter array
-
BivariateLogNormal
public BivariateLogNormal(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
- the parameter arrayrng
- a random number generator
-
BivariateLogNormal
public BivariateLogNormal(double mean1, double var1, double mean2, double var2, double rho, RNStreamIfc rng)
These parameters are the parameters of the lognormal (not the bivariate normal)- Parameters:
mean1
- lognormal meanvar1
- lognormal variancemean2
- lognormal 2nd meanvar2
- lognormal 2nd variancerho
- correlation of lognormalsrng
- a random number generator
-
-
Method Detail
-
setParameters
public void setParameters(double m1, double v1, double m2, double v2, double r)
Takes in the parameters of the bivariate lognormal and sets the parameters of the underlying bivariate normal- Parameters:
m1
- the first meanv1
- the first variancem2
- the second meanv2
- the second variancer
- the correlation
-
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
- the parameter array
-
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:
- the parameters
-
getBiVariateNormalParameters
public final double[] getBiVariateNormalParameters()
Returns the parameters of the underlying bivariate normal param[0] = mean 1; param[1] = variance 1; param[2] = mean 2; param[3] = variance 2; param[4] = correlation;- Returns:
- the computed parameters
-
getBVLNParametersFromBVNParameters
public static double[] getBVLNParametersFromBVNParameters(double m1, double v1, double m2, double v2, double r)
Takes in the parameters of a bivariate normal and returns the corresponding parameters for the bivariate lognormal param[0] = mean 1 of bivariate lognormal param[1] = variance 1 of bivariate lognormal param[2] = mean 2 of bivariate lognormal param[3] = variance 2 of bivariate lognormal param[4] = correlation of bivariate lognormal- Parameters:
m1
- mean 1 of bivariate normalv1
- variance 1 of bivariate normalm2
- mean 1 of bivariate normalv2
- variance 2 of bivariate normalr
- correlation of bivariate normal- Returns:
- the computed parameters
-
getBVLNParametersFromBVNParameters
public static double[] getBVLNParametersFromBVNParameters(double[] param)
Takes in the parameters of a bivariate normal and returns the corresponding parameters for the bivariate lognormal x[0] = mean 1 of bivariate lognormal x[1] = variance 1 of bivariate lognormal x[2] = mean 2 of bivariate lognormal x[3] = variance 2 of bivariate lognormal x[4] = correlation of bivariate lognormal- Parameters:
param
- array of parameters representing the bivariate normal- Returns:
- the computed parameters
-
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:
- the first mean
-
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:
- the first variance
-
setMean2
public final void setMean2(double mean)
Sets the second mean- Parameters:
mean
- the second mean
-
getMean2
public final double getMean2()
Gets the second mean- Returns:
- the second mean
-
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:
- the 2nd variance
-
setCorrelation
public final void setCorrelation(double rho)
Sets the correlation- Parameters:
rho
- the correlation
-
getCorrelation
public final double getCorrelation()
Gets the correlation- Returns:
- the correlation
-
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
-
getAntitheticOption
public boolean getAntitheticOption()
- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- true means on
-
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:
- bivariate values
-
getValues
public double[] getValues()
Returns an array containing the bivariate pair x[0] = 1st marginal x[1] = 2nd marginal- Returns:
- the values
-
getRandomNumberGenerator
public RNStreamIfc getRandomNumberGenerator()
-
setRandomNumberGenerator
public void setRandomNumberGenerator(RNStreamIfc rng)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
-
-