mlmc.moments.Moments
- class mlmc.moments.Moments(size, domain, log=False, safe_eval=True)[source]
Base class for computing moment functions of a random variable.
Provides transformation, scaling, and evaluation utilities common to various types of generalized moment bases (monomial, Fourier, Legendre, etc.).
- __init__(size, domain, log=False, safe_eval=True)[source]
Initialize the moment function set.
- Parameters:
size – int Number of moment functions.
domain – tuple(float, float) Domain of the input variable (min, max).
log – bool If True, use logarithmic transformation of the domain.
safe_eval – bool If True, clip transformed values outside the reference domain and replace them with NaN.
Methods
__init__(size, domain[, log, safe_eval])Initialize the moment function set.
change_size(size)Return a new moment object with a different number of basis functions.
clip(value)Clip values to the reference domain, replacing outliers with NaN.
eval(i, value)Evaluate the i-th moment function.
eval_all(value[, size])Evaluate all moments up to the specified size.
eval_all_der(value[, size, degree])Evaluate derivatives of all moment functions.
eval_diff(value[, size])Evaluate first derivatives of all moment functions.
eval_diff2(value[, size])Evaluate second derivatives of all moment functions.
eval_single_moment(i, value)Evaluate a single moment function (less efficient for large i).
inv_linear(value)Inverse linear transformation back to the original domain.
linear(value)Apply linear transformation to reference domain.