ellipse_bounds¶
-
safe_learning.utilities.
ellipse_bounds
(P, level, n=100)¶ Compute the bounds of a 2D ellipse.
The levelset of the ellipsoid is given by level = x’ P x. Given the coordinates of the first dimension, this function computes the corresponding lower and upper values of the second dimension and removes any values of x0 that are outside of the ellipse.
Parameters: - P : np.array
The matrix of the ellipsoid
- level : float
The value of the levelset
- n : int
Number of data points
Returns: - x : np.array
1D array of x positions of the ellipse
- yu : np.array
The upper bound of the ellipse
- yl : np.array
The lower bound of the ellipse
Notes
This can be used as
`plt.fill_between(*ellipse_bounds(P, level))`