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 Instance Methods Concrete 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 valuedouble
getInverseCDF(Double p)
Given a probability, return the value that returns this cdfdouble
getMu()
Gets the location parameter.double
getPDF(Double x)
Return the probability density function for a valueint
hashCode()
double
nextRandom()
-
-
-
Constructor Detail
-
LaplaceDistribution
public LaplaceDistribution(double mu, double b)
Creates an instance.- Parameters:
mu
- The location parameterb
- The scale parameter, greater than zero
-
LaplaceDistribution
public LaplaceDistribution(double mu, double b, RandomEngine engine)
Creates an instance.- Parameters:
mu
- The location parameterb
- The scale parameter, greater than zeroengine
- 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 interfaceProbabilityDistribution<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 interfaceProbabilityDistribution<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 interfaceProbabilityDistribution<Double>
- Parameters:
x
- The value, not null- Returns:
- The pdf
-
nextRandom
public double nextRandom()
- Specified by:
nextRandom
in interfaceProbabilityDistribution<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
-
-