# HG changeset patch # User John W. Eaton # Date 1231758801 -3600 # Node ID deb777a926ee7a6d2caf2dd76630206fe367fde1 # Parent 377d908f7e408b253f7d8eacd954f0dfdb5aa486 style fixes diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2008-02-19 Ben Abbott + + * polynomial/polyfit.m: Use QR decomposition. Handle + normalization option. + * polynomial/polyval.m: Normalize dependent variable. Optionally + generate 50% prediction intervals. + 2008-10-13 Francesco Potorti * plot/__errplot__.m: Wrong if switch compared strings using ==. diff --git a/scripts/polynomial/polyfit.m b/scripts/polynomial/polyfit.m --- a/scripts/polynomial/polyfit.m +++ b/scripts/polynomial/polyfit.m @@ -24,20 +24,19 @@ ## ## The polynomial coefficients are returned in a row vector. ## -## The second output is a structured variable, @var{s}, -## containing the following fields: +## The second output is a structure containing the following fields: ## ## @table @samp ## @item R -## Triangular factor R from the QR decomposition. +## Triangular factor R from the QR decomposition. ## @item X -## The Vandermonde matrix used to compute the polynomial coefficients. +## The Vandermonde matrix used to compute the polynomial coefficients. ## @item df -## The degrees of freedom. +## The degrees of freedom. ## @item normr -## The norm of the residuals. +## The norm of the residuals. ## @item yf -## The values of the polynomial for each value of @var{x}. +## The values of the polynomial for each value of @var{x}. ## @end table ## ## The second output may be used by @code{polyval} to calculate the diff --git a/scripts/polynomial/polyval.m b/scripts/polynomial/polyval.m --- a/scripts/polynomial/polyval.m +++ b/scripts/polynomial/polyval.m @@ -24,8 +24,8 @@ ## is present evaluate the polynomial for (@var{x}-@var{mu}(1))/@var{mu}(2). ## If @var{x} is a vector or matrix, the polynomial is evaluated for each of ## the elements of @var{x}. -## @deftypefnx {Function File} {[@var{y}, @var{dy}] =} polyval (@var{p}, @var{x}, @var{S}) -## @deftypefnx {Function File} {[@var{y}, @var{dy}] =} polyval (@var{p}, @var{x}, @var{S}, @var{mu}) +## @deftypefnx {Function File} {[@var{y}, @var{dy}] =} polyval (@var{p}, @var{x}, @var{s}) +## @deftypefnx {Function File} {[@var{y}, @var{dy}] =} polyval (@var{p}, @var{x}, @var{s}, @var{mu}) ## In addition to evaluating the polynomial, the second output ## represents the prediction interval, @var{y} +/- @var{dy}, which ## contains at least 50% of the future predictions. To calculate the @@ -75,10 +75,6 @@ y = reshape (y, size (x)); if (nargout == 2) - ## The line below is *not* the result of a conceptual grasp of statistics. - ## Instead, after reading the links below and comparing to the output of Matlab's polyval.m, - ## http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html?/access/helpdesk/help/toolbox/stats/finv.html - ## http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/index.html?/access/helpdesk/help/toolbox/curvefit/bq_5ka6-1_1.html ## Note: the F-Distribution is generally considered to be single-sided. ## http://www.itl.nist.gov/div898/handbook/eda/section3/eda3673.htm ## t = finv (1-alpha, s.df, s.df);