https://github.com/botprof/plotting-uncertainty-ellipses
This Jupyter notebook demonstrates how to properly plot uncertainty (confidence) ellipses for 2D normally distributed data.
https://github.com/botprof/plotting-uncertainty-ellipses
confidence-ellipse ipynb jupyter-notebook matplotlib normal-distribution plot plotting plotting-uncertainty-ellipses python sample-ellipse statistics uncertainty uncertainty-estimation
Last synced: 8 months ago
JSON representation
This Jupyter notebook demonstrates how to properly plot uncertainty (confidence) ellipses for 2D normally distributed data.
- Host: GitHub
- URL: https://github.com/botprof/plotting-uncertainty-ellipses
- Owner: botprof
- License: mit
- Created: 2020-10-13T22:03:53.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-29T19:08:25.000Z (about 2 years ago)
- Last Synced: 2025-02-01T10:41:35.788Z (8 months ago)
- Topics: confidence-ellipse, ipynb, jupyter-notebook, matplotlib, normal-distribution, plot, plotting, plotting-uncertainty-ellipses, python, sample-ellipse, statistics, uncertainty, uncertainty-estimation
- Language: Jupyter Notebook
- Homepage:
- Size: 2.22 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# How to Properly Plot Uncertainty Ellipses for 2D Normally Distributed Data
This notebook demonstrates how to properly plot ellipses that represent desired levels of uncertainty as given by the covariance matrix of normally distributed data in 2D. The reason for this note is that I have seen others naively extend 1D covariance bounds to 2D, which is not technically correct. The example is written in Python and uses [Matplotlib](https://matplotlib.org).
## Main Files
* [plotting-uncertainty-ellipses.ipynb](https://github.com/botprof/plotting-uncertainty-ellipses/blob/main/plotting-uncertainty-ellipses.ipynb) (Jupyter notebook)
## Sample Output
Here is an example 95 \% confidence ellipse for 1000 sample points.

## References
You can find a similar but partial treatment of this problem on the Matplotlib page called ["Plot a confidence ellipse of a two-dimensional dataset"](https://matplotlib.org/devdocs/gallery/statistics/confidence_ellipse.html). Vincent Spruyt also has a really nice and complete description on his page called ["How to draw a covariance error ellipse?"](https://www.visiondummy.com/2014/04/draw-error-ellipse-representing-covariance-matrix/). We also employ the book Johnson and Wichern (2007) [Applied Multivariate Statistical Anlaysis](https://ocul-qu.primo.exlibrisgroup.com/permalink/01OCUL_QU/11tsvcl/alma9925738833405158) (6th ed.), Chapter 4, Result 4.7 on page 163.
## Cite this Work
You may wish to cite this work in your publications.
> Joshua A. Marshall, How to Properly Plot Uncertainty Ellipses for 2D Normally Distributed Data, 2020, URL: [https://github.com/botprof/plotting-uncertainty-ellipses](https://github.com/botprof/plotting-uncertainty-ellipses).
You might also use the BibTeX entry below.
```latex
@misc{Marshall2020,
author = {Marshall, Joshua A.},
title = {How to Properly Plot Uncertainty Ellipses for 2D Normally Distributed Data},
year = {2020},
howpublished = {\url{https://github.com/botprof/plotting-uncertainty-ellipses}}
}
```## License
Source code examples in this notebook are subject to an [MIT License](LICENSE).