Fit a sd-sigma covariance error ellipse to the data. :param x: ndarray, 1D input of X coordinates :param y: ndarray, 1D input of Y coordinates :param sd: int, size of the error ellipse in 'standard deviation' :return: ellipse center, semi-axes length, angle to the X-
(x, y, sd)
| 203 | @staticmethod |
| 204 | @jit(nopython=True) |
| 205 | def _fit_error(x, y, sd): |
| 206 | """Fit a sd-sigma covariance error ellipse to the data. |
| 207 | |
| 208 | :param x: ndarray, 1D input of X coordinates |
| 209 | :param y: ndarray, 1D input of Y coordinates |
| 210 | :param sd: int, size of the error ellipse in 'standard deviation' |
| 211 | :return: ellipse center, semi-axes length, angle to the X-axis |
| 212 | """ |
| 213 | cov = np.cov(x, y) |
| 214 | E, V = np.linalg.eigh(cov) # Returns the eigenvalues in ascending order |
| 215 | # r2 = chi2.ppf(2 * norm.cdf(sd) - 1, 2) |
| 216 | # height, width = np.sqrt(E * r2) |
| 217 | height, width = 2 * sd * np.sqrt(E) |
| 218 | a, b = V[:, 1] |
| 219 | rotation = math.atan2(b, a) % np.pi |
| 220 | return [np.mean(x), np.mean(y), width, height, rotation] |
| 221 | |
| 222 | @staticmethod |
| 223 | @jit(nopython=True) |