From: Coronia on
Hi all,

I want to know what's the major difference between spline toolbox and curvefitting toolbox, as their functions look so similiar.

What's their respective merits?

Thanks
From: Richard Willey on
Hi Coronia,

Here's how I differentiate between the two products

Reasons that you might want to use Curve Fitting Toolbox rather than Spline
Toolbox

1. Parametric modeling: Curve Fitting Toolbox supports linear and
nonlinear regression. Spline Toolbox does not. ("Parametric modeling" is a
fancy way of saying that you are able to specify a function that describes
the relationship between your dependent variable and your independent
variable(s). You have good reason to know that you should model this data
set using a line or a Fourier series or a logarithmic growth model, etc.
This parametric model is typically derived from your domain knowledge)

2. Nonparametric modeling: Curve Fitting Toolbox supports localized
regression (LOESS and LOWESS). Spline Toolbox does not. (Both products
support Smoothing Splines which are often preferred to localized regression.
However, if you really want to use LOESS/LOWESS then Curve Fitting Toolbox
is your only option)

3. "Fit Objects": Curve Fitting Toolbox provides objects to store the
result of a fitting operation. I think that these objects significantly
improve ease of use. I attached some demo code at the end of this message
that you can use to experiment with fit objects.

Reasons that you might want to use Spline Toolbox rather than Curve Fitting
Toolbox

1. Curve Fitting Toolbox is limited to fitting curves Y = f(X) and
surfaces Z = f(X,Y). You can use Spline Toolbox to work with higher numbers
of dimensions

2. Spline Toolbox allows you to generate Thin Plate Splines

3. Spline Toolbox allows you to construct Splines (Curve Fitting
Toolbox limits you to "fitting" splines to existing data

4. Spline Toolbox provides much more support for knot selection, knot
placement, and knot removal

Demo code

------------------------------------------

%% Show the peaks function



peaks



%% Generate some data



P = haltonset( 2 );

P = scramble( P, 'RR2' );

X = net( P, 200);



x = ((X(:,1)) * 6) - 3;

y = (X(:,2) * 6) - 3;



%% Use the peaks function to generate a z vector



z = peaks(x,y);



% add in a noise vector



z = z + .2 * randn(200,1);



%% Generate a fit using nonlinear regression and store this as a fit object
named "foo"



% The equation is the same as that used to generate "peaks"



foo = fit( [x, y], z, 'a*(1-x).^2.*exp(-(x.^2) - (y+1).^2) + b*(x/5 -
x.^3 - y.^5).*exp(-x.^2-y.^2) + c*exp(-(x+1).^2 - y.^2)');



%% Generate a plot of the fitted surface



plot(foo)



%% Show how to use the fit object for prediction



foo(-2, 4)



%% Show how to use the "differentiate" method



X = linspace(-3,3,13);

Y = linspace(-3,3,13);

[X,Y] = meshgrid(X,Y);



differentiate(foo, X, Y)

%% Show the full set of set of methods for a surface fit object



methods(foo)


"Coronia " <sneky(a)163.com> wrote in message
news:hsrsfj$9tv$1(a)fred.mathworks.com...
> Hi all,
>
> I want to know what's the major difference between spline toolbox and
> curvefitting toolbox, as their functions look so similiar.
>
> What's their respective merits?
>
> Thanks


From: Coronia on
"Richard Willey" <rwilley(a)mathworks.com> wrote in message <hss1ht$mv1$1(a)fred.mathworks.com>...
> Hi Coronia,
>
> Here's how I differentiate between the two products
>
> Reasons that you might want to use Curve Fitting Toolbox rather than Spline
> Toolbox
>
> 1. Parametric modeling: Curve Fitting Toolbox supports linear and
> nonlinear regression. Spline Toolbox does not. ("Parametric modeling" is a
> fancy way of saying that you are able to specify a function that describes
> the relationship between your dependent variable and your independent
> variable(s). You have good reason to know that you should model this data
> set using a line or a Fourier series or a logarithmic growth model, etc.
> This parametric model is typically derived from your domain knowledge)
>
> 2. Nonparametric modeling: Curve Fitting Toolbox supports localized
> regression (LOESS and LOWESS). Spline Toolbox does not. (Both products
> support Smoothing Splines which are often preferred to localized regression.
> However, if you really want to use LOESS/LOWESS then Curve Fitting Toolbox
> is your only option)
>
> 3. "Fit Objects": Curve Fitting Toolbox provides objects to store the
> result of a fitting operation. I think that these objects significantly
> improve ease of use. I attached some demo code at the end of this message
> that you can use to experiment with fit objects.
>
> Reasons that you might want to use Spline Toolbox rather than Curve Fitting
> Toolbox
>
> 1. Curve Fitting Toolbox is limited to fitting curves Y = f(X) and
> surfaces Z = f(X,Y). You can use Spline Toolbox to work with higher numbers
> of dimensions
>
> 2. Spline Toolbox allows you to generate Thin Plate Splines
>
> 3. Spline Toolbox allows you to construct Splines (Curve Fitting
> Toolbox limits you to "fitting" splines to existing data
>
> 4. Spline Toolbox provides much more support for knot selection, knot
> placement, and knot removal
>
> Demo code
>
> ------------------------------------------
>
> %% Show the peaks function
>
>
>
> peaks
>
>
>
> %% Generate some data
>
>
>
> P = haltonset( 2 );
>
> P = scramble( P, 'RR2' );
>
> X = net( P, 200);
>
>
>
> x = ((X(:,1)) * 6) - 3;
>
> y = (X(:,2) * 6) - 3;
>
>
>
> %% Use the peaks function to generate a z vector
>
>
>
> z = peaks(x,y);
>
>
>
> % add in a noise vector
>
>
>
> z = z + .2 * randn(200,1);
>
>
>
> %% Generate a fit using nonlinear regression and store this as a fit object
> named "foo"
>
>
>
> % The equation is the same as that used to generate "peaks"
>
>
>
> foo = fit( [x, y], z, 'a*(1-x).^2.*exp(-(x.^2) - (y+1).^2) + b*(x/5 -
> x.^3 - y.^5).*exp(-x.^2-y.^2) + c*exp(-(x+1).^2 - y.^2)');
>
>
>
> %% Generate a plot of the fitted surface
>
>
>
> plot(foo)
>
>
>
> %% Show how to use the fit object for prediction
>
>
>
> foo(-2, 4)
>
>
>
> %% Show how to use the "differentiate" method
>
>
>
> X = linspace(-3,3,13);
>
> Y = linspace(-3,3,13);
>
> [X,Y] = meshgrid(X,Y);
>
>
>
> differentiate(foo, X, Y)
>
> %% Show the full set of set of methods for a surface fit object
>
>
>
> methods(foo)
>
>
> "Coronia " <sneky(a)163.com> wrote in message
> news:hsrsfj$9tv$1(a)fred.mathworks.com...
> > Hi all,
> >
> > I want to know what's the major difference between spline toolbox and
> > curvefitting toolbox, as their functions look so similiar.
> >
> > What's their respective merits?
> >
> > Thanks
>
Richard,
Thank you soooo much for the information. I could never find these out so soon by myself.