B3spline: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
imported>Jeremy
No edit summary
Line 1: Line 1:
===Purpose===
===Purpose===
Univariate spline fit and prediction.
Univariate spline fit and prediction.
===Synopsis===
===Synopsis===
:modl = b3spline(x,y,t,''options'');
:modl = b3spline(x,y,t,''options'');
:pred = b3spline(x,modl,''options'');
:pred = b3spline(x,modl,''options'');
:valid = b3spline(x,y,modl,''options'');
:valid = b3spline(x,y,modl,''options'');
===Description===
===Description===
Curve fitting using second order splines where
Curve fitting using second order splines where
yi = f(xi) for i=1,...,M.  
yi = f(xi) for i=1,...,M.  
See (options.algorithm) for more information.
See (options.algorithm) for more information.
====INPUTS====
====INPUTS====
* '''x''' = Mx1 vector of independent variable values.
* '''x''' = Mx1 vector of independent variable values.
* '''y''' = Mx1 vector of corresponding dependent variable values.
* '''y''' = Mx1 vector of corresponding dependent variable values.
* '''t''' = defines the number of knots or knot positions. This can be either:
* '''t''' = defines the number of knots or knot positions. This can be either:
** A scalar integer defining the number of uniformly distributed INTERIOR knots. There will be t+2 knots positioned at: modl.t = linspace(min(x),max(x),t+2)';
** A scalar integer defining the number of uniformly distributed INTERIOR knots. There will be t+2 knots positioned at: modl.t = linspace(min(x),max(x),t+2)';
** A Kx1 vector defining manually placed knot positions, where modl.t = sort(t);
** A Kx1 vector defining manually placed knot positions, where modl.t = sort(t);
Note that knot positions need not be uniform, and that t(1) can be <min(x) and t(K) can be >max(x).
Note that knot positions need not be uniform, and that t(1) can be <min(x) and t(K) can be >max(x).
However, knot positions must be such that there are at least 3 unique data points between each knot:  tk,tk+1 for k=1,...,K.
However, knot positions must be such that there are at least 3 unique data points between each knot:  tk,tk+1 for k=1,...,K.


====OUTPUTS====
====OUTPUTS====
* '''modl''' = standard model structure containing the spline model (See MODELSTRUCT).
* '''modl''' = standard model structure containing the spline model (See MODELSTRUCT).
* '''pred''' = structure array with predictions.
* '''pred''' = structure array with predictions.
* '''valid''' = structure array with predictions.
* '''valid''' = structure array with predictions.
===Options===
===Options===
* '''''options''''' =  a structure array with the following fields:
* '''''options''''' =  a structure array with the following fields:
* '''display''': [ {'on'} | 'off' ] level of display to command window.
* '''display''': [ {'on'} | 'off' ] level of display to command window.
* '''plots''': [ {'final'} | 'none' ] governs level of plotting. If 'final' and calibrating a model, the plot shows plot(xi,yi) and plot(xi,f(xi),'-') with knots.
* '''plots''': [ {'final'} | 'none' ] governs level of plotting. If 'final' and calibrating a model, the plot shows plot(xi,yi) and plot(xi,f(xi),'-') with knots.
* '''algorithm''': [ {'b3spline'} | 'b3_0' | 'b3_01' ] fitting algorithm
* '''algorithm''': [ {'b3spline'} | 'b3_0' | 'b3_01' ] fitting algorithm
''' 'b3spline'''': fits quadradic polynomials f{k,k+1} to the data between knots tk, k=1,...,K, subject to:
 
  f{k,k+1}(tk+1)  = f{k+1,k+2}(tk+1) and
** ''' 'b3spline'''': fits quadradic polynomials f{k,k+1} to the data between knots tk, k=1,...,K, subject to:
  f'{k,k+1}(tk+1) = f'{k+1,k+2}(tk+1) for k=1,...,K-1.
 
''''b3_0'''': is the same as 'b3spline' but also constrains the ends to 0: f{1,2}(t1) = 0 and f{K-1,K}(tK) = 0.
::  f{k,k+1}(tk+1)  = f{k+1,k+2}(tk+1) and
''''b3_01':''' is 'b3_0' but also constrains the derivatives at the ends to 0: f'{1,2}(t1) = 0 and f'{K-1,K}(tK) = 0.
 
::  f'{k,k+1}(tk+1) = f'{k+1,k+2}(tk+1) for k=1,...,K-1.
 
** ''''b3_0'''': is the same as 'b3spline' but also constrains the ends to 0: f{1,2}(t1) = 0 and f{K-1,K}(tK) = 0.
 
**''''b3_01':''' is 'b3_0' but also constrains the derivatives at the ends to 0: f'{1,2}(t1) = 0 and f'{K-1,K}(tK) = 0.
 
* '''order''': positive integer for polynomial order {default = 1}.
* '''order''': positive integer for polynomial order {default = 1}.
The default options can be retreived using: options = baseline('options');.
The default options can be retreived using: options = baseline('options');.
===See Also===
===See Also===

Revision as of 07:43, 3 September 2008

Purpose

Univariate spline fit and prediction.

Synopsis

modl = b3spline(x,y,t,options);
pred = b3spline(x,modl,options);
valid = b3spline(x,y,modl,options);

Description

Curve fitting using second order splines where

yi = f(xi) for i=1,...,M.

See (options.algorithm) for more information.

INPUTS

  • x = Mx1 vector of independent variable values.
  • y = Mx1 vector of corresponding dependent variable values.
  • t = defines the number of knots or knot positions. This can be either:
    • A scalar integer defining the number of uniformly distributed INTERIOR knots. There will be t+2 knots positioned at: modl.t = linspace(min(x),max(x),t+2)';
    • A Kx1 vector defining manually placed knot positions, where modl.t = sort(t);

Note that knot positions need not be uniform, and that t(1) can be <min(x) and t(K) can be >max(x).

However, knot positions must be such that there are at least 3 unique data points between each knot: tk,tk+1 for k=1,...,K.

OUTPUTS

  • modl = standard model structure containing the spline model (See MODELSTRUCT).
  • pred = structure array with predictions.
  • valid = structure array with predictions.

Options

  • options = a structure array with the following fields:
  • display: [ {'on'} | 'off' ] level of display to command window.
  • plots: [ {'final'} | 'none' ] governs level of plotting. If 'final' and calibrating a model, the plot shows plot(xi,yi) and plot(xi,f(xi),'-') with knots.
  • algorithm: [ {'b3spline'} | 'b3_0' | 'b3_01' ] fitting algorithm
    • 'b3spline': fits quadradic polynomials f{k,k+1} to the data between knots tk, k=1,...,K, subject to:
f{k,k+1}(tk+1) = f{k+1,k+2}(tk+1) and
f'{k,k+1}(tk+1) = f'{k+1,k+2}(tk+1) for k=1,...,K-1.
    • 'b3_0': is the same as 'b3spline' but also constrains the ends to 0: f{1,2}(t1) = 0 and f{K-1,K}(tK) = 0.
    • 'b3_01': is 'b3_0' but also constrains the derivatives at the ends to 0: f'{1,2}(t1) = 0 and f'{K-1,K}(tK) = 0.
  • order: positive integer for polynomial order {default = 1}.

The default options can be retreived using: options = baseline('options');.

See Also