An open API service indexing awesome lists of open source software.

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.

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.

![Sample ellipse](sample-ellipse.svg)

## 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).