optframework.utils.func.jit_pbm_qmom module
- optframework.utils.func.jit_pbm_qmom.calc_qmom_nodes_weights(moments, n, adaptive, use_central)
Compute nodes (ξ_i) and weights (w_i) using QMOM with the adaptive Wheeler algorithm.
- Parameters:
moments (list or numpy.ndarray): Array of moments [M0, M1, …, M2n-1]. n (int): Number of quadrature nodes. adaptive (bool): If True, use adaptive criteria to refine the solution. use_central (bool): If True, use central moments.
- Returns:
tuple: (x, w, n), where x are the nodes (ξ_i), w are the weights (w_i), and n is the number of nodes.
- optframework.utils.func.jit_pbm_qmom.calc_qmom_recurrence(moments, n, adaptive, cutoff)
Calculate recurrence coefficients for QMOM using the Wheeler algorithm.
- Parameters:
moments (list or numpy.ndarray): Array of moments [M0, M1, …, M2n-1]. n (int): Number of quadrature nodes. adaptive (bool): If True, use adaptive criteria to refine the solution. cutoff (float): Minimum diagonal element to consider for stability.
- Returns:
tuple: (a, b, n), where a and b are the recurrence coefficients, and n is the number of nodes.
- optframework.utils.func.jit_pbm_qmom.recurrence_jacobi_nodes_weights(moments, a, b)
Construct Jacobi matrix and solve for eigenvalues and eigenvectors to get nodes and weights.
- Parameters:
moments (list or numpy.ndarray): Array of moments [M0, M1, …, M2n-1]. a (list or numpy.ndarray): Recurrence coefficient a. b (list or numpy.ndarray): Recurrence coefficient b.
- Returns:
tuple: (x, w), where x are the nodes (ξ_i) and w are the weights (w_i).
- optframework.utils.func.jit_pbm_qmom.calc_gqmom_nodes_weights(moments, n, n_add, method, nu, adaptive, cutoff)
Compute nodes (ξ_i) and weights (w_i) using Generalized QMOM (GQMOM).
- Parameters:
moments (list or numpy.ndarray): Array of moments [M0, M1, …, M2n-1]. n (int): Number of quadrature nodes. n_add (int): Number of additional quadrature nodes. method (str): Method for GQMOM (“gaussian”, “gamma”, “lognormal”, “beta”). nu (float): Exponent for the correction. adaptive (bool): If True, use adaptive criteria to refine the solution. cutoff (float): Minimum diagonal element to consider for stability.
- Returns:
tuple: (x, w, n), where x are the nodes (ξ_i), w are the weights (w_i), and n is the number of nodes.
- optframework.utils.func.jit_pbm_qmom.calc_gqmom_recurrence_real(a_reg, b_reg, n_add, nu)
Correct recurrence coefficients a and b for (Gaussian) Generalized QMOM.
- Parameters:
a_reg (list or numpy.ndarray): List of regular recurrence coefficient a. b_reg (list or numpy.ndarray): List of regular recurrence coefficient b. n_add (int): Number of additional quadrature nodes. nu (float): Exponent for the correction.
- Returns:
tuple: Updated a and b lists.
- optframework.utils.func.jit_pbm_qmom.calc_gqmom_recurrence_beta(a_reg, b_reg, n_add)
Correct recurrence coefficients a and b for (Beta) Generalized QMOM.
- Parameters:
a_reg (list or numpy.ndarray): List of regular recurrence coefficient a. b_reg (list or numpy.ndarray): List of regular recurrence coefficient b. n_add (int): Number of additional quadrature nodes.
- Returns:
tuple: Updated a and b lists.
- optframework.utils.func.jit_pbm_qmom.calc_gqmom_recurrence_realplus(moments, a_reg, b_reg, n_add, ndf_type)
Correct recurrence coefficients for (Gamma/Lognormal) Generalized QMOM using R+ moments.
- Parameters:
moments (list or numpy.ndarray): List of input moments [M0, M1, M2, …]. a_reg (list or numpy.ndarray): Recurrence coefficient a to be updated. b_reg (list or numpy.ndarray): Recurrence coefficient b to be updated. n_add (int): Number of additional quadrature nodes. ndf_type (str): Type of node distribution (“gamma” or “lognormal”).
- Returns:
tuple: Updated a, b.
- optframework.utils.func.jit_pbm_qmom.calc_zetas(a, b, n_reg, n_max_nodes)
Set regular zetas array from constraint: a_i=zeta_2i+zeta_(2i+1),b_i=zeta_(2i-1)*zeta_2i Currently, zetas[0] is not being used, which means there is redundancy in the array length. If this needs to be modified, all indices in the calculation process must be adjusted accordingly.
The paper mentions that i should go up to n. However, in the program, the indices of a and b start from zero. Calculating zetas[2n] requires a[n] to be known, but at this point, we only have regular, a[n-1]. Therefore, i is limited to n-1 here. This results in the generation of zetas[2n-2] and zetas[2n-1]. The corresponding Laguerre polynomials are actually zetas_L[2i-1] for i=n and zetas_L[2i] for i=n-1! This necessitates corresponding adjustments in the subsequent calculations for the extended nodes.
- Returns:
numpy.ndarray: zetas arrays.
- optframework.utils.func.jit_pbm_qmom.vander_rybicki(x, q)
Solve the Vandermonde linear system using the Rybicki algorithm.
- Parameters:
x (numpy.ndarray): Node vector (1D array). q (numpy.ndarray): Right-hand side vector (1D array).
- Returns:
numpy.ndarray: Solution vector.
- optframework.utils.func.jit_pbm_qmom.conditional_mom_sys_solve(M_matrix, u, R_diag)
Solve the conditional moment system using the Rybicki algorithm.
- Parameters:
M_matrix (numpy.ndarray): Moment matrix. u (numpy.ndarray): Node vector. R_diag (numpy.ndarray): Diagonal of the weight matrix.
- Returns:
numpy.ndarray: Solution matrix.
- optframework.utils.func.jit_pbm_qmom.calc_cqmom_2d(moments, n, indices, use_central=True)
Compute nodes and weights for 2D Conditional QMOM (CQMOM).
- Parameters:
moments (list or numpy.ndarray): Array of moments. n (int): Number of quadrature nodes. indices (list or numpy.ndarray): Moment indices. use_central (bool): If True, use central moments.
- Returns:
tuple: (abscissas, weights, n), where abscissas are the nodes, weights are the weights, and n is the number of nodes.
- optframework.utils.func.jit_pbm_qmom.quadrature_2d(x1, w1, x2, w2, moment_index)
Perform 2D quadrature to compute the moment.
- Parameters:
x1 (numpy.ndarray): Nodes for the first dimension. w1 (numpy.ndarray): Weights for the first dimension. x2 (numpy.ndarray): Nodes for the second dimension. w2 (numpy.ndarray): Weights for the second dimension. moment_index (list or numpy.ndarray): Moment index.
- Returns:
float: Computed moment.