API¶
- class QuadraticFormsMGHyp.QuadraticForm(a0, a, A, C, mu, gam, lam, chi, psi)¶
Quadratic form
L = a0 + a'X + X'A Xin a multivariate GH vector.X = mu + W gam + sqrt(W) C Z, withZstandard normal andW ~ GIG(lam, chi, psi).gamis the skewness vector γ.a,mu, andgamhave lengthd.AandCared × d, either shaped(d, d)or flattened in row-major order.The constructor diagonalizes the form. Repeat
evalon one instance when several threshold grids share that reduction. The object releases the C state when it is closed, when awithblock ends, or when it is collected.- Parameters:
a0 (float) – Constant term and the GIG parameters λ, χ, and ψ.
lam (float) – Constant term and the GIG parameters λ, χ, and ψ.
chi (float) – Constant term and the GIG parameters λ, χ, and ψ.
psi (float) – Constant term and the GIG parameters λ, χ, and ψ.
a (array_like) – Length-
dvectors.mu (array_like) – Length-
dvectors.gam (array_like) – Length-
dvectors.A (array_like) –
d × dmatrices.C (array_like) –
d × dmatrices.
- dimension¶
Length of
a.Noneafterfrom_spectral.- Type:
int or None
- ne¶
Number of retained spectral terms.
Noneuntilfrom_spectral.- Type:
int or None
- classmethod from_spectral(omega, d, e, c, k, kk, lam, chi, psi)¶
Build from the spectral reduction used by the integral.
- Parameters:
omega (array_like) – Eigenvalues and the two coefficient vectors, same length.
d (array_like) – Eigenvalues and the two coefficient vectors, same length.
e (array_like) – Eigenvalues and the two coefficient vectors, same length.
c (float) – The remaining scalar coefficients.
kkis added back when the conditional expectation is formed.k (float) – The remaining scalar coefficients.
kkis added back when the conditional expectation is formed.kk (float) – The remaining scalar coefficients.
kkis added back when the conditional expectation is formed.lam (float) – The remaining scalar coefficients.
kkis added back when the conditional expectation is formed.chi (float) – The remaining scalar coefficients.
kkis added back when the conditional expectation is formed.psi (float) – The remaining scalar coefficients.
kkis added back when the conditional expectation is formed.
- Return type:
- eval(x, threads=0)¶
Integrate once and return the distribution and both moments.
- Parameters:
x (array_like) – One-dimensional thresholds.
threads (int, optional) – Worker count on the scalar path.
threads <= 0uses one worker per logical CPU. NIG, ψ = 0, and the general-GH series evaluate the vector on the calling thread. More than 24 thresholds are reduced to a Chebyshev grid first.
- Returns:
cdf, ccdf, pm, es –
cdf[i] = P(L <= x[i]),ccdf[i] = P(L > x[i]),pm[i] = E[L 1_{L > x[i]}], andes[i] = E[L | L > x[i]]. The cdf and the partial moment are formed from the survival function and the expected shortfall of this same pass.- Return type:
ndarray
- close()¶
Release the C object. A later
evalraisesRuntimeError.