Sergen Cansiz
May 5, 2023

--

Hi Renzo,

The issue is due to your variables have negative correlation. So the angle for the ellipse should be negative.

angle=-np.rad2deg(np.arccos(v[0, 0])), edgecolor='#fab1a0')

Here is the version that checks whether the relation is negative or not:

angle=np.rad2deg(np.arccos(v[0, 0])) if covariance[0, 1] >= 0 else -np.rad2deg(np.arccos(v[0, 0]))

You can also use this implementation:

https://github.com/srcansiz/pystml/blob/master/src/pystml/preprocess/Mahalonobis.py

--

--

Sergen Cansiz
Sergen Cansiz

Written by Sergen Cansiz

Data Scientist, Statistician, Python and R Developer

Responses (1)