Class 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 substream
      boolean 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 lognormal
      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
      double getCorrelation()
      Gets the correlation
      double getMean1()
      Gets the first mean
      double getMean2()
      Gets the second mean
      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;
      RNStreamIfc getRandomNumberGenerator()  
      double[] getValues()
      Returns an array containing the bivariate pair x[0] = 1st marginal x[1] = 2nd marginal
      double[] getValues​(double[] x)
      Fills the supplied array with 2 values As a convenience also returns the array
      double getVariance1()
      Gets the first variance
      double getVariance2()
      Gets the 2nd variance
      static 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 substream
      void setAntitheticOption​(boolean flag)
      Tells the stream to start producing antithetic variates
      void setCorrelation​(double rho)
      Sets the correlation
      void setMean1​(double mean)
      Sets the first mean
      void setMean2​(double mean)
      Sets the second mean
      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;
      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
      void setRandomNumberGenerator​(RNStreamIfc rng)  
      void setVariance1​(double variance)
      Sets the first variance
      void setVariance2​(double variance)
      Sets the 2nd variance
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • 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 mean
        var1 - the first variance
        mean2 - the second mean
        var2 - the second variance
        rho - 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 array
        rng - 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 mean
        var1 - lognormal variance
        mean2 - lognormal 2nd mean
        var2 - lognormal 2nd variance
        rho - correlation of lognormals
        rng - 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 mean
        v1 - the first variance
        m2 - the second mean
        v2 - the second variance
        r - 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 interface ParametersIfc
        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 interface ParametersIfc
        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 normal
        v1 - variance 1 of bivariate normal
        m2 - mean 1 of bivariate normal
        v2 - variance 2 of bivariate normal
        r - 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 interface RNStreamControlIfc
        Parameters:
        flag - true means that it produces antithetic variates.
      • 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 interface RNStreamControlIfc
      • 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 class java.lang.Object
      • main

        public static void main​(java.lang.String[] args)