ConfidenceEllipseCLR#

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

Confidence ellipse for prevalence estimates in CLR-transformed space.

Applies the Centered Log-Ratio (CLR) transformation:

\[\begin{split}T(\pi) = [\log(\pi_1/g(\pi)), ..., \log(\pi_n/g(\pi))],\\ g(\pi) = (\prod_i \pi_i)^{1/n}\end{split}\]

A confidence ellipse is then built in the transformed space:

\[\begin{split}CT_\alpha(\pi) = \begin{cases} 1 & \text{if } (T(\pi) - \mu_{CLR})^T \Sigma^{-1} (T(\pi) - \mu_{CLR}) \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 vector in CLR space.

precision_matrixndarray of shape (n, n)

Inverse covariance matrix in CLR space.

chi2_valfloat

Chi-squared threshold.

References

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

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

Examples

>>> X = np.random.dirichlet(np.ones(3), size=200)
>>> clr = ConfidenceEllipseCLR(X, confidence_level=0.9)
>>> clr.get_point_estimate().round(3)
array([ 0.,  0., -0.])
>>> clr.contains(np.array([0.4, 0.4, 0.2]))
True
contains(point, eps=1e-06)[source]#

Check whether a prevalence vector lies within the region.

get_point_estimate()[source]#

Return the point estimate of prevalence (e.g., mean of bootstrap samples).

get_region()[source]#

Return the parameters defining the confidence region.