[Date Index]
[Thread Index]
[Author Index]
Re: NonlinearRegression
*To*: mathgroup at smc.vnet.net
*Subject*: [mg25152] Re: NonlinearRegression
*From*: "Bill Bertram" <wkb at ansto.gov.au>
*Date*: Sun, 10 Sep 2000 21:25:44 -0400 (EDT)
*Organization*: Australian Nuclear Science and Technology Organisation
*References*: <8p9kit$1rm@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
David Pires <l45337 at alfa.ist.utl.pt> wrote in message
news:8p9kit$1rm at smc.vnet.net...
> I want to fit my data with a function such as:
> f(x)=Sqrt(a-b*x), where a and b are the parameters I want to adjust and x
> is the variable. The problem is that there is only a given range of x for
> that f(x) has real values. When I use the NonlinearRegression (or
> NonlinearFit) command, Mathematica gives error messages and aborts the
> fitting process.
>
> I'd like to know if someone knows how to set the range of x when using
> that command.
Hi,
Here is a method I have used in the past.
Instead of fitting to f(x) = Sqrt[a-b*x], define the fitting function as
f[a_,b_,x_] := If[a-b*x > 0, Evaluate[Sqrt[a-b*x]], 0]
as in the following example,
<< Statistics`NonlinearFit`
data = Table[{x, Sqrt[1 - 0.2x]}, {x, 0, 4, 0.3}]
func[a_, b_, x_] := If[a - b x > 0, Evaluate[Sqrt[a - b x]], 0];
NonlinearRegress[data, func[a, b, x], {x}, {a, b}]
This seems to work fine.
Cheers,
Bill
Prev by Date:
**Re: Displaying Mixed Numbers**
Next by Date:
**Re: Displaying Mixed Numbers**
Previous by thread:
**Re: NonlinearRegression**
Next by thread:
**Mathematica 3.0/4.0**
| |