Class DEmpiricalCDF

    • Constructor Detail

      • DEmpiricalCDF

        public DEmpiricalCDF​(double[] values,
                             double[] cdf)
        Parameters:
        values - an array of values that will be drawn from
        cdf - a cdf corresponding to the values
      • DEmpiricalCDF

        public DEmpiricalCDF​(double[] values,
                             double[] cdf,
                             java.lang.String name)
        (v[0], cdf[0], ...) represent the value and the cumulative probability of that value.
        Parameters:
        values - an array of values that will be drawn from
        cdf - a cdf corresponding to the values
        name - an optional name/label
    • Method Detail

      • makePairs

        public static double[] makePairs​(double[] cdf)
        Assigns the probability associated with each cdf value to the integers starting at 0.
        Parameters:
        cdf - the probability array. must have valid probability elements and last element equal to 1. Every element must be greater than or equal to the previous element. That is, monotonically increasing.
        Returns:
        the pairs
      • makePairs

        public static double[] makePairs​(int start,
                                         double[] cdf)
        Assigns the probability associated with each cdf value to the integers starting at start.
        Parameters:
        start - place to start assignment
        cdf - the probability array. must have valid probability elements and last element equal to 1. Every element must be greater than or equal to the previous element. That is, monotonically increasing.
        Returns:
        the pairs
      • splitPairs

        public static double[][] splitPairs​(double[] pairs)
        This method takes in an Array of probability points (value, cumulative probability), Eg. X[] = {v1, cp1, v2, cp2, ...}, as the input parameter and makes a 2D array of the value/prob pairs
        Parameters:
        pairs - An array holding the value, cumulative probability pairs.
      • makePairs

        public static double[] makePairs​(double[] values,
                                         double[] cdf)
        Makes a pair array that can be used for the parameters of the DEmpiricalCDF distribution
        Parameters:
        values - an array of values that will be drawn from
        cdf - a cdf corresponding to the values
        Returns:
        a properly configured array of pairs for the DEmpiricalCDF distribution
      • cdf

        public final double cdf​(double x)
        Description copied from interface: CDFIfc
        Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
        Specified by:
        cdf in interface CDFIfc
        Parameters:
        x - a double representing the upper limit
        Returns:
        a double representing the probability
      • getMean

        public final double getMean()
        Description copied from interface: MeanIfc
        Returns the mean or expected value of a distribution
        Specified by:
        getMean in interface MeanIfc
        Returns:
        double the mean or expected value for the distribution
      • getVariance

        public final double getVariance()
        Description copied from interface: VarianceIfc
        Returns the variance of the distribution if defined
        Specified by:
        getVariance in interface VarianceIfc
        Returns:
        double the variance of the random variable
      • pmf

        public final double pmf​(double x)
        The probability mass function for this discrete distribution. Returns the same as pdf.
        Specified by:
        pmf in interface PMFIfc
        Parameters:
        x - The point to get the probability for
        Returns:
        The probability associated with x
      • toString

        public java.lang.String toString()
        Returns the pmf as a string.
        Overrides:
        toString in class Distribution
        Returns:
        A String of probability, value pairs.
      • invCDF

        public double invCDF​(double p)
        Provides the inverse cumulative distribution function for the distribution
        Specified by:
        invCDF in interface InverseCDFIfc
        Parameters:
        p - The probability to be evaluated for the inverse, p must be [0,1] or an IllegalArgumentException is thrown
        Returns:
        The inverse cdf evaluated at p
      • setParameters

        public final void setParameters​(double[] parameters)
        Sets the parameters for the distribution. Array of probability points (value, cumulative probability), Eg. X[] = [v1, cp1, v2, cp2, 7,0.5], as the input parameters.
        Specified by:
        setParameters in interface ParametersIfc
        Parameters:
        parameters - an array of doubles representing the parameters for the distribution
      • getParameters

        public double[] getParameters()
        Gets the parameters for the distribution
        Specified by:
        getParameters in interface ParametersIfc
        Returns:
        Returns an array of the parameters for the distribution
      • main

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