File Exchange

version 1.1 (532 KB) by

A nuanced method of plotting uncertainty.

Updated

It's common to use a shaded region or error bars to depict uncertainty in plots. However, shaded regions and error bars tend to have definite extents, which rarely represents the reality of uncertainty. In truth, gaussian uncertainty tapers gradually, and should be depicted accordingly.

Too often we try to depict a binary world in which all values are either within the range of uncertainty, or outside the range of uncertainty. This function is meant to show that all errors are *not* contained within the arbitrary bounds of one standard deviation of the noise. To accomplish this, the errorshade function creates a semitransparent RGB image of a specified color, whose opacity scales directly with a gaussian distribution of uncertainty.

Oleg Komarov

### Oleg Komarov (view profile)

I think the image should be updated. The function works well now, but the snapshot is a bit off.

Oleg--Thanks for pressing this issue. I took a closer look and found I'd left out a ^2 in the calculation of the Gaussian distribution. The error has been fixed.

Oleg Komarov

### Oleg Komarov (view profile)

Uncertainty should go both ways independent of what is the direction of the step, but here it looks like if the increment is positive, we have only positive uncertainty, although a two-tailed normal assumption should give confidence intervals on both ends.

Oleg--Indeed, the spikes look weird, but it's an accurate depiction of the underlying assumption that each measurement is independent and uncertainty at each measurement is not a function of neighboring measurements.

If your application permits violating that assumption and you want a prettier plot, consider calling errorshade with a moving average. In the example provided the moving-average implementation might look like this:

Oleg Komarov

### Oleg Komarov (view profile)

Isn't the blurring a bit weird with those triangular spikes alternative up and down? I would expect a more uniform blurring.

Ben Dichter

### Ben Dichter (view profile)

very cool! Would be really useful for teaching stats!