Class LaplaceDistribution

• java.lang.Object
• com.opengamma.strata.math.impl.statistics.distribution.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 Summary

Constructors
Constructor Description
LaplaceDistribution​(double mu, double b)
Creates an instance.
LaplaceDistribution​(double mu, double b, RandomEngine engine)
Creates an instance.
• Method Summary

All Methods
Modifier and Type Method Description
boolean equals​(Object obj)
double getB()
Gets the scale parameter.
double getCDF​(Double x)
Returns the cumulative distribution function for a value
double getInverseCDF​(Double p)
Given a probability, return the value that returns this cdf
double getMu()
Gets the location parameter.
double getPDF​(Double x)
Return the probability density function for a value
int hashCode()
double nextRandom()
• Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
• 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
• nextRandom

public double nextRandom()
Specified by:
nextRandom in interface ProbabilityDistribution<Double>
Returns:
The next random number from this distribution
• 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
• equals

public boolean equals​(Object obj)
Overrides:
equals in class Object