Mercurial > hg > octave-avbm
changeset 14551:60ed9260399a
Improve/correct documentation for splinefit.m
* splinefit.m: Clarify and correct documentation.
* doc/interpreter/poly.txi: ditto.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 11 Apr 2012 19:34:53 -0400 |
parents | bc4c574ab3b6 |
children | 86854d032a37 |
files | doc/interpreter/poly.txi scripts/polynomial/splinefit.m |
diffstat | 2 files changed, 22 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/poly.txi +++ b/doc/interpreter/poly.txi @@ -184,9 +184,10 @@ @end float @end ifnotinfo -The piece-wise polynomial fit provided by @code{splinefit} provides -continuous derivatives up to the @var{order} of the fit. This can -be demonstrated by the code +The piece-wise polynomial fit, provided by @code{splinefit}, has +continuous derivatives up to the @var{order}-1. For example, a cubic fit +has continuous first and second derivatives. This is demonstrated by +the code @example @group @@ -260,14 +261,14 @@ @float Figure,fig:splinefit3 @center @image{splinefit3,4in} -@caption{Comparison of piecewise cubic fits to a noisy periodic function with, -and without, periodic boundary conditions.} +@caption{Comparison of piecewise polynomial fits to a noisy periodic +function with, and without, periodic boundary conditions.} @end float @end ifnotinfo More complex constraints may be added as well. For example, the code below -illustrates a periodic fit with values that have been clamped end point values -and a second periodic fit with hinged end point values. +illustrates a periodic fit with values that have been clamped at the end points, +and a second periodic fit which is hinged at the end points. @example @group @@ -276,7 +277,7 @@ y = sin (2 * x) + 0.1 * randn (size (x)); ## Breaks breaks = linspace (0, 2 * pi, 10); -## Clamped endpoints, y = y" = 0 +## Clamped endpoints, y = y' = 0 xc = [0, 0, 2*pi, 2*pi]; cc = [(eye (2)), (eye (2))]; con = struct ("xc", xc, "cc", cc); @@ -347,7 +348,8 @@ @float Figure,fig:splinefit6 @center @image{splinefit6,4in} -@caption{Comparison of two different levels of robust fitting (@var{beta} = 0.25 and 0.75) to noisy data combined with outlying data. A standard fit is also included.} +@caption{Comparison of two different levels of robust fitting (@var{beta} = 0.25 and 0.75) to noisy data combined with outlying data. A conventional fit, without +robust fitting (@var{beta} = 0) is also included.} @end float @end ifnotinfo
--- a/scripts/polynomial/splinefit.m +++ b/scripts/polynomial/splinefit.m @@ -27,9 +27,9 @@ ## may be evaluated using @code{ppval}. ## ## @deftypefnx {Function File} {@var{pp} =} splinefit (@var{x}, @var{y}, @var{p}) -## @var{p} is a positive integer defining the number of linearly spaced -## intervals along @var{x}. @var{p} is the number of intervalas and -## @var{p}+1 is the number of breaks. +## @var{p} is a positive integer defining the number of intervals along @var{x}, +## and @var{p}+1 is the number of breaks. The number of points in each interval +## differ by no more than 1. ## ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "periodic", @var{periodic}) ## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "robust", @var{robust}) @@ -53,21 +53,21 @@ ## outlying data. Values close to unity may cause instability or rank ## deficiency. ## -## @var{order} sets the order polynomials used to construct the spline. +## The splines are constructed of polynomials with degree @var{order}. ## The default is a cubic, @var{order}=3. A spline with P pieces has ## P+@var{order} degrees of freedom. With periodic boundary conditions ## the degrees of freedom are reduced to P. ## -## The optional property, @var{constraints}, is a structure specifying +## The optional property, @var{constaints}, is a structure specifying ## linear constraints on the fit. The structure has three fields, "xc", ## "yc", and "cc". ## ## @table @asis ## @item "xc" -## x-locations of the constraints (vector) with a size identical to @var{x}. +## Vector of the x-locations of the constraints. ## @item "yc" -## Constraining values with a size identical to @var{y}. The default -## is an array of zeros. +## Constaining values at the locations, @var{xc}. +## The default is an array of zeros. ## @item "cc" ## Coefficients (matrix). The default is an array of ones. The number of ## rows is limited to the order of the piece-wise polynomials, @var{order}. @@ -79,10 +79,10 @@ ## @example ## @group ## @tex -## $cc(1,j) \cdot y(x) + cc(2,j) \cdot y\prime(x) + ... = yc(:,\dots,:,j), \quad x = xc(j)$. +## $cc(1,j) \cdot y(xc(j)) + cc(2,j) \cdot y\prime(xc(j)) + ... = yc(:,\dots,:,j)$. ## @end tex ## @ifnottex -## cc(1,j) * y(x) + cc(2,j) * y'(x) + ... = yc(:,...,:,j), x = xc(j). +## cc(1,j) * y(xc(j)) + cc(2,j) * y'(xc(j)) + ... = yc(:,...,:,j). ## @end ifnottex ## @end group ## @end example @@ -130,7 +130,7 @@ %! y = sin (x) + 0.1 * randn (size (x)); %! % Breaks %! breaks = [0:5, 2*pi]; -%! % Constraints: y(0) = 0, y"(0) = 1 and y(3) + y"(3) = 0 +%! % Constraints: y(0) = 0, y'(0) = 1 and y(3) + y"(3) = 0 %! xc = [0 0 3]; %! yc = [0 1 0]; %! cc = [1 0 1; 0 1 0; 0 0 1];