ConfidenceEllipseSimplex#

class mlquantify.confidence.ConfidenceEllipseSimplex(prev_estims, confidence_level=0.95)[source]#

Confidence ellipse for prevalence estimates in the simplex.

Defines a multivariate confidence region based on a chi-squared threshold:

\[\begin{split}CE_{\alpha}(\pi) = \begin{cases} 1 & \text{if} (\pi - \mu)^T \Sigma^{-1} (\pi - \mu) \le \chi^2_{n-1}(1-\alpha) \\ 0 & \text{otherwise} \end{cases}\end{split}\]
Parameters:
prev_estimsarray-like of shape (m, n)

Bootstrap prevalence estimates.

confidence_levelfloat, default=0.95

Confidence level.

Attributes:
mean_ndarray of shape (n,)

Mean prevalence estimate.

precision_matrixndarray of shape (n, n)

Inverse covariance matrix of estimates.

chi2_valfloat

Chi-squared cutoff threshold defining the ellipse.

References

[1] Moreo, A., & Salvati, N. (2025).

An Efficient Method for Deriving Confidence Intervals in Aggregative Quantification. Section 3.3, Equation (2).

Examples

>>> X = np.random.dirichlet(np.ones(3), size=200)
>>> ce = ConfidenceEllipseSimplex(X, confidence_level=0.95)
>>> ce.get_point_estimate().round(3)
array([0.33, 0.34, 0.33])
>>> ce.contains(np.array([0.4, 0.3, 0.3]))
True
contains(point)[source]#

Check whether a prevalence vector lies inside the ellipse.

Parameters:
pointarray-like of shape (n_classes,)

Prevalence vector to test.

Returns:
insidebool

True if the Mahalanobis distance from point to the ellipse centre is within the chi-squared threshold.

get_point_estimate()[source]#

Return the mean prevalence estimate.

Returns:
mean_ndarray of shape (n_classes,)

Mean of the bootstrap prevalence samples.

get_region()[source]#

Return the ellipse parameters.

Returns:
mean_ndarray of shape (n_classes,)

Mean prevalence vector (ellipse centre).

precision_matrixndarray of shape (n_classes, n_classes) or None

Inverse covariance matrix. None if the covariance is singular.

chi2_valfloat

Chi-squared threshold that defines the ellipse boundary.