Marginal1D#
- class quantflow.utils.marginal.Marginal1D#
Marginal distribution
Methods:
Call option transform
Compute the cumulative distribution function
Jacobian of the cdf with respect to the parameters of the process.
Compute the characteristic function on support points n.
Compute the characteristic function with n discretization points and a max frequency
The space domain range for the random variable
The frequency domain range for the characteristic function
Expected value
Calculate mean as first derivative of characteristic function at 0
Option alpha
Compute the x axis.
Option time value
Option time value transform
Computes the probability density (or mass) function of the process.
Compute the probability density function from the characteristic function.
Jacobian of the pdf with respect to the parameters of the process.
Standard deviation at a time horizon
Calculate standard deviation as square root of variance
Compute the x axis.
Variance
Calculate variance as second derivative of characteristic function at 0
Attributes:
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- call_option_transform(u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series #
Call option transform
- cdf(x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Compute the cumulative distribution function
- Parameters:
n – Location in the stochastic process domain space. If a numpy array, the output should have the same shape as the input.
- cdf_jacobian(x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray #
Jacobian of the cdf with respect to the parameters of the process. It is useful for optimization purposes if necessary.
Optional to implement, otherwise raises
NotImplementedError
if called.
- abstract characteristic(u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series #
Compute the characteristic function on support points n.
- characteristic_df(n: int | None = None, *, max_frequency: float | None = None, simpson_rule: bool = False) DataFrame #
Compute the characteristic function with n discretization points and a max frequency
- domain_range() Bounds #
The space domain range for the random variable
This should be overloaded if required
- frequency_range(max_frequency: float | None = None) float #
The frequency domain range for the characteristic function
This should be overloaded if required
- mean() ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Expected value
This should be overloaded if a more efficient way of computing the mean
- mean_from_characteristic(*, d: float = 0.001) ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Calculate mean as first derivative of characteristic function at 0
- option_alpha() float #
Option alpha
- option_support(points: int = 101, max_moneyness: float = 1.0) ndarray[tuple[int, ...], dtype[floating[Any]]] #
Compute the x axis.
- option_time_value(n: int = 128, *, max_frequency: float | None = None, max_moneyness: float = 1, alpha: float = 1.1, simpson_rule: bool = False, use_fft: bool = False) TransformResult #
Option time value
- option_time_value_transform(u: int | float | complex | ndarray | Series, alpha: float = 1.1) int | float | complex | ndarray | Series #
Option time value transform
This transform does not require any additional correction since the integrant is already bounded for positive and negative moneyess
- pdf(x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Computes the probability density (or mass) function of the process.
It has a base implementation that computes the pdf from the
cdf
method, but a subclass should overload this method if a more optimized way of computing it is available.- Parameters:
n – Location in the stochastic process domain space. If a numpy array, the output should have the same shape as the input.
- pdf_from_characteristic(n: int | None = None, *, max_frequency: float | None = None, simpson_rule: bool = False, use_fft: bool = False, frequency_n: int | None = None) TransformResult #
Compute the probability density function from the characteristic function.
- Parameters:
n – Number of discretization points to use in the transform. If None, use 128.
max_frequency – The maximum frequency to use in the transform. If not provided, the value from the
frequency_range()
method is used. Only needed for special cases/testing.simpson_rule – Use Simpson’s rule for integration. Default is False.
use_fft – Use FFT for the transform. Default is False.
- pdf_jacobian(x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Jacobian of the pdf with respect to the parameters of the process. It has a base implementation that computes it from the
cdf_jacobian
method, but a subclass should overload this method if a more optimized way of computing it is available.
- std() ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Standard deviation at a time horizon
- std_from_characteristic() ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Calculate standard deviation as square root of variance
- abstract support(points: int = 100, *, std_mult: float = 3) ndarray[tuple[int, ...], dtype[floating[Any]]] #
Compute the x axis.
- variance() ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Variance
This should be overloaded if a more efficient way of computing the
- variance_from_characteristic(*, d: float = 0.001) ndarray[tuple[int, ...], dtype[floating[Any]]] | float #
Calculate variance as second derivative of characteristic function at 0
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].