Skip to content

Commit b16ffbb

Browse files
cmd-ntrflarsmans
authored andcommitted
DOC: fix 2 covariance examples rst math markup.
Some formulas in plot_mahalanobis_distances and plot_robust_vs_empirical_covariance were not correctly rendered by sphinx as some characters were not properly escaped. This is fixed by setting the docstrings as raw string using r""" There was also missing braces for the number of features and samples subscript.
1 parent f571834 commit b16ffbb

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

examples/covariance/plot_mahalanobis_distances.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
================================================================
33
Robust covariance estimation and Mahalanobis distances relevance
44
================================================================
@@ -25,8 +25,9 @@
2525
The Minimum Covariance Determinant estimator is a robust,
2626
high-breakdown point (i.e. it can be used to estimate the covariance
2727
matrix of highly contaminated datasets, up to
28-
:math:`\frac{n_samples-n_features-1}{2}` outliers) estimator of
29-
covariance. The idea is to find :math:`\frac{n_samples+n_features+1}{2}`
28+
:math:`\frac{n_\text{samples}-n_\text{features}-1}{2}` outliers)
29+
estimator of covariance. The idea is to find
30+
:math:`\frac{n_\text{samples}+n_\text{features}+1}{2}`
3031
observations whose empirical covariance has the smallest determinant,
3132
yielding a "pure" subset of observations from which to compute
3233
standards estimates of location and covariance.

examples/covariance/plot_robust_vs_empirical_covariance.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
=======================================
33
Robust vs Empirical covariance estimate
44
=======================================
@@ -12,8 +12,10 @@
1212
----------------------------------------
1313
The Minimum Covariance Determinant estimator is a robust, high-breakdown point
1414
(i.e. it can be used to estimate the covariance matrix of highly contaminated
15-
datasets, up to :math:`\\frac{n_samples - n_features-1}{2}` outliers) estimator of
16-
covariance. The idea is to find :math:`\\frac{n_samples+n_features+1}{2}`
15+
datasets, up to
16+
:math:`\frac{n_\text{samples} - n_\text{features}-1}{2}` outliers) estimator of
17+
covariance. The idea is to find
18+
:math:`\frac{n_\text{samples} + n_\text{features}+1}{2}`
1719
observations whose empirical covariance has the smallest determinant, yielding
1820
a "pure" subset of observations from which to compute standards estimates of
1921
location and covariance. After a correction step aiming at compensating the
@@ -31,7 +33,8 @@
3133
3234
- The mean and the empirical covariance of the full dataset, which break
3335
down as soon as there are outliers in the data set
34-
- The robust MCD, that has a low error provided n_samples > 5 * n_features
36+
- The robust MCD, that has a low error provided
37+
:math:`n_\text{samples} > 5n_\text{features}`
3538
- The mean and the empirical covariance of the observations that are known
3639
to be good ones. This can be considered as a "perfect" MCD estimation,
3740
so one can trust our implementation by comparing to this case.

0 commit comments

Comments
 (0)