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.
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.
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:
errorshade(x,imfilter(y_measured,fspecial('average',[1 5]),'replicate'),sigma,[0.0824 0.6902 0.1020])
Isn't the blurring a bit weird with those triangular spikes alternative up and down? I would expect a more uniform blurring.
very cool! Would be really useful for teaching stats!
Fixed a typo in calculation of Gaussian distribution, added moving average option.
Inspired by: confplot, JackKnife, errorfill, confplot_t, raacampbell/shadedErrorBar, boundedline.m, stdshade, plot_ci, Plot with shadings for e.g. standard error, Shaded Error Bar YY, mseb(x,y,errBar,lineProps,transparent), superbar
Create scripts with code, output, and formatted text in a single executable document.