Hotelling’s T-squared statistic and confidence ellipses for multivariate data
pyEllipse computes Hotelling’s T-squared statistic, its control limits, and the confidence ellipses and ellipsoids drawn from them, for outlier detection and score plots of PCA, PLS and other multivariate models. Its Hotelling functions are the Python counterpart of the HotellingEllipse R package and give the same results (see Validation).
hotelling_coordinates(scores, pcx=1, pcy=2, conf_limit=0.99, method="beta") returns the points of the matching ellipse, for plotting. The PCA example goes through a complete analysis.
Validation
The test suite runs on every change, on Python 3.9 to 3.14. For hotelling_parameters and hotelling_coordinates, it checks the formulas of the Theory page directly (T-squared against the squared Mahalanobis distance, the ellipse points against the limit, the semi-axes and rotation against the ellipse points), checks that about 5% of simulated observations exceed the 95% Beta limit, and compares both functions with the HotellingEllipse 1.3.0 R package on a reference data set, to within a relative \(10^{-10}\). The examples in the reference pages are run as tests too; for confidence_ellipse, this example is so far the only test.
How to cite
@software{goueguel_pyellipse, author = {Goueguel, Christian L.}, title = {{pyEllipse: Statistical confidence ellipses and Hotelling's T-squared ellipses}}, version = {0.2.1}, url = {https://github.com/ChristianGoueguel/pyEllipse}, license = {MIT}}
Please cite the version you used, as shown in the footer of this page.