Error bounds are useful for determining if your data is reasonably modeled by the fit. You can obtain the error bounds by passing an optional second output parameter from
polyfit as an input parameter to
This example uses the
census demo data and normalizes the data by centering it at zero mean and scaling it to unit standard deviation. The example then uses
polyval to produce error bounds for a second-order polynomial model. Year values are normalized. This code uses an interval of ±2, corresponding to a 95% confidence interval.
|Exponential Fit||The Basic Fitting Interface|