polyconf (optim_doc)

Next: LinearRegression, Previous: wpolyfit, Up: Residual optimization [Index]

### 2.12 Confidence and prediction intervals for polynomial fitting

#### Helptext:

    [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-;;');