Distributions#
- class quantflow.utils.distributions.Distribution1D#
Base class for 1D distributions to be used as Jump distributions in Compound Poisson processes
Methods:
Asymmetry of the distribution, 0 for symmetric
Create a distribution from variance and asymmetry
Sample from the distribution
Set the asymmetry of the distribution
Set the variance of the distribution
Attributes:
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- asymmetry() float #
Asymmetry of the distribution, 0 for symmetric
Implemented by distributions that have asymmetry
- classmethod from_variance_and_asymmetry(variance: float, asymmetry: float) Self #
Create a distribution from variance and asymmetry
- abstract sample(n: int) ndarray #
Sample from the distribution
- set_asymmetry(asymmetry: float) None #
Set the asymmetry of the distribution
Implemented by distributions that have asymmetry
- set_variance(variance: float) None #
Set the variance of the distribution
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class quantflow.utils.distributions.Exponential(*, decay: Annotated[float, Gt(gt=0)] = 1)#
A
Distribution1D
for the Exponential distributionThe exponential distribution is a continuous probability distribution with PDF given by
\[f(x) = \lambda e^{-\lambda x}\ \ \forall x \geq 0\]Methods:
The analytical CDF of the exponential distribution
Compute the characteristic function on support points n.
Expected value
The analytical PDF of the exponential distribution as defined above
Sample from the distribution
Compute the x axis.
Variance
Attributes:
The exponential decay rate \(\lambda\)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
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].
- 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 distributionThis 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 thedecay
parameter, and \(\kappa\) is the asymmetrickappa
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:
Asymmetry of the distribution
Characteristic function of the double exponential distribution
Create a double exponential distribution from the mean, variance and asymmetry
Create a distribution from variance and asymmetry
The mean of the double exponential distribution
The analytical PDF as defined above
Sample from the double exponential distribution
Set the asymmetry of the distribution
Set the variance of the distribution
Compute the x axis.
Variance
Attributes:
The exponential decay rate \(\lambda\)
Asymmetric parameter - when k=1, the distribution is symmetric
The location parameter m
The log of the
kappa
parameterConfiguration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- asymmetry() float #
Asymmetry of the distribution
- 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 m}}{\left(1 + \frac{i u \kappa}{\lambda}\right) \left(1 - \frac{i u}{\lambda \kappa}\right)}\]
- 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
- classmethod from_variance_and_asymmetry(variance: float, asymmetry: float) Self #
Create a distribution from variance and asymmetry
- 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
- set_asymmetry(asymmetry: float) None #
Set the asymmetry of the distribution
Implemented by distributions that have asymmetry
- set_variance(variance: float) None #
Set the variance of 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\)
- kappa: float#
Asymmetric parameter - when k=1, the distribution is symmetric
- loc: float#
The location parameter m
- 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)#
A
Distribution1D
for the Normal distributionThe normal distribution is a continuous probability distribution with PDF given by
\[f(x) = \frac{e^{-\frac{\left(x - \mu\right)^2}{2\sigma^2}}}{\sqrt{2\pi\sigma^2}}\]Methods:
Compute the characteristic function on support points n.
The normal distribution is symmetric, so the asymmetry is ignored
Expected value
Sample from the distribution
Set the variance of the distribution
Compute the x axis.
Variance
Attributes:
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
The mean \(\mu\) of the normal distribution
The standard deviation \(\sigma\) of the normal distribution
- characteristic(u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series #
Compute the characteristic function on support points n.
- classmethod from_variance_and_asymmetry(variance: float, asymmetry: float) Self #
The normal distribution is symmetric, so the asymmetry is ignored
- 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
- set_variance(variance: float) None #
Set the variance of 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].
- mu: float#
The mean \(\mu\) of the normal distribution
- sigma: float#
The standard deviation \(\sigma\) of the normal distribution