Home > freetb4matlab > optim > polyconf.m



% [y,dy] = polyconf(p,x,s)


function [y,dy] = polyconf(p,x,varargin)


% [y,dy] = polyconf(p,x,s)
%   Produce prediction intervals for the fitted y. The vector p 
%   and structure s are returned from polyfit or wpolyfit. The 
%   x values are where you want to compute the prediction interval.
% polyconf(...,['ci'|'pi'])
%   Produce a confidence interval (range of likely values for the
%   mean at x) or a prediction interval (range of likely values 
%   seen when measuring at x).  The prediction interval tells
%   you the width of the distribution at x.  This should be the same
%   regardless of the number of measurements you have for the value
%   at x.  The confidence interval tells you how well you know the
%   mean at x.  It should get smaller as you increase the number of
%   measurements.  Error bars in the physical sciences usually show 
%   a 1-alpha confidence value of erfc(1/sqrt(2)), representing
%   one standandard deviation of uncertainty in the mean.
% polyconf(...,1-alpha)
%   Control the width of the interval. If asking for the prediction
%   interval 'pi', the default is .05 for the 95% prediction interval.
%   If asking for the confidence interval 'ci', the default is
%   erfc(1/sqrt(2)) for a one standard deviation confidence interval.
% Example:
%  [p,s] = polyfit(x,y,1);
%  xf = linspace(x(1),x(end),150);
%  [yf,dyf] = polyconf(p,xf,s,'ci');
%  plot(xf,yf,'g-;fit;',xf,yf+dyf,'g.;;',xf,yf-dyf,'g.;;',x,y,'xr;data;');
%  plot(x,y-polyval(p,x),';residuals;',xf,dyf,'g-;;',xf,-dyf,'g-;;');


This function calls: This function is called by:
Generated on Sat 16-May-2009 00:04:49 by m2html © 2003