File Exchange

image thumbnail

errorshade

version 1.1 (532 KB) by

A nuanced method of plotting uncertainty.

12 Downloads

Updated

View License

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.

Comments and Ratings (6)

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.

Chad Greene

Chad Greene (view profile)

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.

Chad Greene

Chad Greene (view profile)

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:

errorshade(x,imfilter(y_measured,fspecial('average',[1 5]),'replicate'),sigma,[0.0824 0.6902 0.1020])

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

very cool! Would be really useful for teaching stats!

Updates

1.1

Image update.

1.1

Fixed a typo in calculation of Gaussian distribution, added moving average option.

MATLAB Release
MATLAB 8.0 (R2012b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

errorshade/html/