Distributions#

class quantflow.utils.distributions.Exponential(*, decay: Annotated[float, Gt(gt=0)] = 1)#

A Marginal1D for the Exponential distribution

The exponential distribution is a continuous probability distribution with PDF given by

\[f(x) = \lambda e^{-\lambda x}\ \ \forall x \geq 0\]

Methods:

cdf

The analytical CDF of the exponential distribution

characteristic

Compute the characteristic function on support points n.

mean

Expected value

pdf

The analytical PDF of the exponential distribution as defined above

sample

Sample from the distribution

support

Compute the x axis.

variance

Variance

Attributes:

decay

The exponential decay rate \(\lambda\)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

scale

The scale parameter, it is the inverse of the decay rate

cdf(x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float#

The analytical CDF of the exponential distribution

\[F(x) = 1 - e^{-\lambda x}\ \ \forall x \geq 0\]
characteristic(u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

Compute the characteristic function on support points n.

mean() float#

Expected value

This should be overloaded if a more efficient way of computing the mean

pdf(x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float#

The analytical PDF of the exponential distribution as defined above

sample(n: int) ndarray#

Sample from the distribution

support(points: int = 100, *, std_mult: float = 4) ndarray[tuple[int, ...], dtype[floating[Any]]]#

Compute the x axis.

variance() float#

Variance

This should be overloaded if a more efficient way of computing the

decay: float#

The exponential decay rate \(\lambda\)

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property scale: float#

The scale parameter, it is the inverse of the decay rate

class quantflow.utils.distributions.DoubleExponential(*, decay: Annotated[float, Gt(gt=0)] = 1, loc: float = 0, kappa: Annotated[float, Gt(gt=0)] = 1)#

A Marginal1D for the generalized double exponential distribution

This is also know as the Asymmetric Laplace distribution (ALD) which is a continuous probability distribution with PDF

\[\begin{split}\begin{align} f(x) &= \frac{\lambda}{\kappa + \frac{1}{\kappa}} e^{-\left(x - m\right) \lambda s(x) \kappa^{s(x)}}\\ s(x) &= {\tt sgn}\left({x - m}\right) \end{align}\end{split}\]

where m is the loc parameter, \(\lambda\) is the decay parameter, and \(\kappa\) is the asymmetric kappa parameter.

The Asymmetric Laplace distribution is similar to the Gaussian/normal distribution, but is sharper at the peak, it has fatter tails and allow for skewness. It represents the difference between two independent, exponential random variables.

Methods:

characteristic

Characteristic function of the double exponential distribution

from_moments

Create a double exponential distribution from the mean, variance and asymmetry

mean

The mean of the double exponential distribution

pdf

The analytical PDF as defined above

sample

Sample from the double exponential distribution

support

Compute the x axis.

variance

Variance

Attributes:

decay

The exponential decay rate \(\lambda\)

kappa

Asymmetric parameter - when k=1, the distribution is symmetric

loc

The location parameter m

log_kappa

The log of the kappa parameter

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

characteristic(u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

Characteristic function of the double exponential distribution

\[\phi(u) = \frac{e^{i u \mu}}{1 - \sigma^2 u^2}\]
classmethod from_moments(*, mean: float = 0, variance: float = 1, kappa: float = 1) Self#

Create a double exponential distribution from the mean, variance and asymmetry

Parameters:
  • mean – The mean of the distribution

  • variance – The variance of the distribution

  • kappa – The asymmetry parameter of the distribution, 1 for symmetric

mean() float#

The mean of the double exponential distribution

pdf(x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float#

The analytical PDF as defined above

sample(n: int) ndarray#

Sample from the double exponential distribution

support(points: int = 100, *, std_mult: float = 4) ndarray[tuple[int, ...], dtype[floating[Any]]]#

Compute the x axis.

variance() float#

Variance

This should be overloaded if a more efficient way of computing the

decay: float#

The exponential decay rate \(\lambda\)

kappa: float#

Asymmetric parameter - when k=1, the distribution is symmetric

loc: float#

The location parameter m

property log_kappa: float#

The log of the kappa parameter

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class quantflow.utils.distributions.Normal(*, mu: float = 0, sigma: Annotated[float, Gt(gt=0)] = 1)#

Methods:

characteristic

Compute the characteristic function on support points n.

mean

Expected value

sample

Sample from the distribution

support

Compute the x axis.

variance

Variance

Attributes:

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

characteristic(u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

Compute the characteristic function on support points n.

mean() float#

Expected value

This should be overloaded if a more efficient way of computing the mean

sample(n: int) ndarray#

Sample from the distribution

support(points: int = 100, *, std_mult: float = 4) ndarray[tuple[int, ...], dtype[floating[Any]]]#

Compute the x axis.

variance() float#

Variance

This should be overloaded if a more efficient way of computing the

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].