Re: NonlinearModelFit and assumptions on fit parameters

• To: mathgroup at smc.vnet.net
• Subject: [mg128213] Re: NonlinearModelFit and assumptions on fit parameters
• From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
• Date: Tue, 25 Sep 2012 04:38:56 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net

```Hi

I have a set of data (x, y) that I can succesfully fit a nonlinear function to using NonlinearModelFit:

data = {{1, 1}, {2, 2}, {3, 3.2}};
fitFuncExactNoLosses[a_, b_, x_] := a*x^2 + b + x;
nlm = NonlinearModelFit[data, fitFuncExactNoLosses[a, b, x],
{
{a, 1},
{b, 1}},
x]

However, the paramter "b" comes out negative and it *must* be positive. Is there a way to utilize assumptions such that b is constrained to be grater than zero?

Best,
Niels.

Hi, Niels,
Try this:

ff = FindFit[data, {a*x^2 + b + x, b > 0.05}, {{a, 1}, {b, 1}}, x]

Show[{ListPlot[data, PlotStyle -> Red],
Plot[(a*x^2 + b + x) /. ff, {x, 0, 3}]}]

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu

```

• Prev by Date: Re: Re: creating a graphic in a text cell
• Next by Date: DynamicModule with an infinite variable
• Previous by thread: Re: NonlinearModelFit and assumptions on fit parameters
• Next by thread: Stylesheet for input side by side with output