Class LaplaceDistribution

  • All Implemented Interfaces:
    ProbabilityDistribution<Double>

    public class LaplaceDistribution
    extends Object
    implements ProbabilityDistribution<Double>
    The Laplace distribution is a continuous probability distribution with probability density function $$ \begin{align*} f(x)=\frac{1}{2b}e^{-\frac{|x-\mu|}{b}} \end{align*} $$ where $\mu$ is the location parameter and $b$ is the scale parameter. The cumulative distribution function and its inverse are defined as: $$ \begin{align*} F(x)&= \begin{cases} \frac{1}{2}e^{\frac{x-\mu}{b}} & \text{if } x < \mu\\ 1-\frac{1}{2}e^{-\frac{x-\mu}{b}} & \text{if } x\geq \mu \end{cases}\\ F^{-1}(p)&=\mu-b\text{ sgn}(p-0.5)\ln(1-2|p-0.5|) \end{align*} $$ Given a uniform random variable $U$ drawn from the interval $(-\frac{1}{2}, \frac{1}{2}]$, a Laplace-distributed random variable with parameters $\mu$ and $b$ is given by: $$ \begin{align*} X=\mu-b\text{ sgn}(U)\ln(1-2|U|) \end{align*} $$
    • Constructor Detail

      • LaplaceDistribution

        public LaplaceDistribution​(double mu,
                                   double b)
        Creates an instance.
        Parameters:
        mu - The location parameter
        b - The scale parameter, greater than zero
      • LaplaceDistribution

        public LaplaceDistribution​(double mu,
                                   double b,
                                   RandomEngine engine)
        Creates an instance.
        Parameters:
        mu - The location parameter
        b - The scale parameter, greater than zero
        engine - A uniform random number generator, not null
    • Method Detail

      • getCDF

        public double getCDF​(Double x)
        Returns the cumulative distribution function for a value
        Specified by:
        getCDF in interface ProbabilityDistribution<Double>
        Parameters:
        x - The value, not null
        Returns:
        The cdf
      • getInverseCDF

        public double getInverseCDF​(Double p)
        Given a probability, return the value that returns this cdf
        Specified by:
        getInverseCDF in interface ProbabilityDistribution<Double>
        Parameters:
        p - The probability, not null. $0 \geq p \geq 1$
        Returns:
        The inverse cdf
      • getPDF

        public double getPDF​(Double x)
        Return the probability density function for a value
        Specified by:
        getPDF in interface ProbabilityDistribution<Double>
        Parameters:
        x - The value, not null
        Returns:
        The pdf
      • getMu

        public double getMu()
        Gets the location parameter.
        Returns:
        The location parameter
      • getB

        public double getB()
        Gets the scale parameter.
        Returns:
        The scale parameter
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object