DMM.moments#

module for operations on moments

deconvolve_unknown_variance(moments)#

Deconvolution with unknown sigma, using Lindsay’s estimator. Fit moments with U+sigma Z. Estimate common sigma, and moments of U.

Args: moments: array of float, length 2k moments estimate of degree 1 to 2k

Returns: Tuple of deconvolved moments and estimated variance (sigma^2)

det_mom(moments)#

Compute determinant of moment matrix

Args: moments: array of moments of

Return: determinant of moment matrix

determinant(mat, rows=None, cols=None)#

Compute the determinant of a submatrix

Args: mat: matrix, list of lists input matrix

rows: list of int selection of rows

cols: list of int, same size as rows selection of columns

Returns: determinant of submatrix mat[rows, cols]

empirical_moment(samples, degree)#

Compute empirical moments of samples Args: samples: x=(x1…xn) degree: L

Returns matrix M of size L*n each row is the moments of (x1…xn) (start from the first degree to degree L)

get_hankel(moments)#

Construct Hankel matrix from (m_0,…,m_{2k})

Args: moments: array of floats of length 2k+1 moments of degrees from 0 to 2k

Return: Hankel matrix from those moments of size (k+1,k+1)

hermite_transform_matrix(degree, sigma=1)#

Hermite transformation Let x=(x,…,x^k)’, then Ax+b=(g_1(x,sigma),…,g_k(x,sigma)) g_k(x,sigma)=sigma^k*H_k(x/sigma), g_k(x,1)=H_k(x), the usual Hermite polynomial

Args: degree: int highest degree k

Return: tuple (A,b): A is a matrix of shape (k,k), b is a vector of shape (k,1)

projection(moments, interval=None, wmat=None)#

project to a valid moment sequence on interval [a,b]

Args: moments: a sequence of estimated moments, starting from degree 1 interval [a,b]: range of distributions, default [-1,1] wmat: weighting matrix, default identity matrix

Returns: a sequence of valid moments on [a,b], starting from degree 1 (default [a,b]=[-1,1]) minimize (moments-x)’ * wmat * (moments-x), subject to x is a valid moment sequence

quadmom(moments, dettol=0, inf=10000000000.0)#

compute quadrature from moments ref: Gene Golub, John Welsch, Calculation of Gaussian Quadrature Rules

Args: m: moments sequence dettol: tolerant of singularity of moments sequence (quantified by determinant of moment matrix) INF: infinity

Returns: U: quadrature

transform(mat, x_var)#

Compute a linear tranformation Ax+b

mat: Tuple (A,b) A: matrix of shape (k,k) b: matrix of shape (k,1)

x_var: variable x array of length k

Returns: array of length k, y=Ax+b