optframework.utils.func.jit_pbm_chyqmom module
- optframework.utils.func.jit_pbm_chyqmom.sign(q)
Return the sign of the input number.
- Parameters:
q (float): Input number.
- Returns:
int: 1 if q > 0, 0 if q == 0, and -1 if q < 0.
- optframework.utils.func.jit_pbm_chyqmom.hyqmom2(moments)
Invert moments to obtain a two-node quadrature rule.
- Parameters:
moments (array-like): The input moments.
- Returns:
tuple: (x, w) where x are the abscissas and w are the weights.
- optframework.utils.func.jit_pbm_chyqmom.hyqmom3(moments, max_skewness=30, checks=True)
Invert moments to obtain a three-node quadrature rule.
- Parameters:
moments (array-like): The input moments. max_skewness (float): Maximum allowed skewness (default: 30). checks (bool): Flag to perform validity checks (default: True).
- Returns:
tuple: (x, w) where x are the abscissas and w are the weights.
- optframework.utils.func.jit_pbm_chyqmom.chyqmom4(moments, indices, max_skewness=30)
Invert 2D moments to obtain a four-node quadrature rule via the CHyQMOM method.
- Parameters:
moments (array-like): Input moments. indices (array-like): Moment indices (2D) used for central moments. max_skewness (float): Maximum allowed skewness (default: 30).
- Returns:
tuple: (x, w) where x is a list with two arrays [x, y] of abscissas and w are the weights.
- optframework.utils.func.jit_pbm_chyqmom.chyqmom9(moments, indices, max_skewness=30, checks=True)
Invert 2D moments to obtain a nine-node quadrature rule via the CHyQMOM method.
- Parameters:
moments (array-like): Input moments. indices (array-like): Moment indices for the 2D moments. max_skewness (float): Maximum allowed skewness (default: 30). checks (bool): Flag to perform validity checks (default: True).
- Returns:
tuple: (x, w) where x is a list with two arrays [x, y] of abscissas and w are the weights.
- optframework.utils.func.jit_pbm_chyqmom.chyqmom27(moments, indices, max_skewness=30, checks=True)[source]
(Non-jitted) Invert moments to obtain a 27-node quadrature rule for 3D distributions via CHyQMOM.
- Parameters:
moments (array-like): Input moments (3D). indices (array-like): Indices corresponding to the moments. max_skewness (float): Maximum allowed skewness (default: 30). checks (bool): Flag for performing validity checks (default: True).
- Returns:
Updates internal arrays. (This function uses many intermediate variables.)
- optframework.utils.func.jit_pbm_chyqmom.quadrature_1d(weights, abscissas, moment_index)
Compute a unidimensional quadrature sum.
- Parameters:
weights (array-like): Quadrature weights. abscissas (array-like): Abscissas corresponding to weights. moment_index (int): Power to which abscissas are raised.
- Returns:
float: Approximated moment.
- optframework.utils.func.jit_pbm_chyqmom.quadrature_2d(weights, abscissas, moment_index)
Compute a two-dimensional quadrature sum.
- Parameters:
weights (array-like): Quadrature weights. abscissas (list of arrays): List containing two arrays of abscissas (for x and y). moment_index (list or array): Powers for the two dimensions.
- Returns:
float: Approximated moment.
- optframework.utils.func.jit_pbm_chyqmom.quadrature_3d(weights, abscissas, moment_index)
Compute a three-dimensional quadrature sum.
- Parameters:
weights (array-like): Quadrature weights. abscissas (ndarray): 2D array where each row corresponds to one coordinate. moment_index (list or array): Powers for each of the three dimensions.
- Returns:
float: Approximated moment.
- optframework.utils.func.jit_pbm_chyqmom.compute_central_moments_2d(moments, indices)
Compute central moments for a 2D distribution.
- Parameters:
moments (array-like): Array of raw moments. indices (array-like): 2D indices array such as [[0,0], [1,0], [0,1], …].
- Returns:
- tuple: (mom00, bx, by, central_moments) where mom00 is the zeroth moment,
bx and by are the centroids, and central_moments is an array of central moments.
- optframework.utils.func.jit_pbm_chyqmom.compute_central_moments_1d(moments)
Compute central moments for a 1D distribution.
- Parameters:
moments (array-like): Array of raw moments.
- Returns:
tuple: (bx, central_moments) where bx is the centroid and central_moments is an array of central moments.
- optframework.utils.func.jit_pbm_chyqmom.comb(n, k)
Compute the binomial coefficient “n choose k”.
- Parameters:
n (int): Total number. k (int): Number chosen.
- Returns:
int: The binomial coefficient.
- optframework.utils.func.jit_pbm_chyqmom.factorial(n)
Compute the factorial of n.
- Parameters:
n (int): Non-negative integer.
- Returns:
int: n!
- optframework.utils.func.jit_pbm_chyqmom.get_moment(moments, indices, p, q)
Retrieve the moment corresponding to orders (p, q) from the moments array.
- Parameters:
moments (array-like): Array of moments. indices (array-like): Array of indices (2D). p (int): Order in first variable. q (int): Order in second variable.
- Returns:
float: The moment value if found; otherwise 0.