Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5082 > unrolled thread
| Started by | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| First post | 2011-09-19 11:12 +0000 |
| Last post | 2011-09-19 11:12 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Making a function from the output of the Fit Daniel Lichtblau <danl@wolfram.com> - 2011-09-19 11:12 +0000
| From | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| Date | 2011-09-19 11:12 +0000 |
| Subject | Re: Making a function from the output of the Fit |
| Message-ID | <j5783f$jaq$1@smc.vnet.net> |
----- Original Message -----
> From: "Just A Stranger" <forpeopleidontknow@gmail.com>
> To: mathgroup@smc.vnet.net
> Sent: Saturday, September 17, 2011 5:25:53 AM
> Subject: Making a function from the output of the Fit function.
> Hello,
>
> So I am trying to use the Fit ffunction to make another function.
>
> So I want to do something like this:
>
> f[x_] := Fit[ data, {1,x}, x]
>
> But I want f[x] to be the function for the line, a+bx. But as written
> above
> it does not have this result of course (I know it's because whatever
> gets
> passed is used as an argument for the fit function, so passing a
> number
> doesn't work, and passing a variable simply isn't what I want to do)
> So how
> can I use the fit function to get
> f[x_] := a+bx (where a and b are the appropriate constants. )
>
> My jerry rigged solution is to just execute Fit[ data, {1,x}, x] then
> copy
> and past the output to define a function. But this tacky solution just
> won't
> do :)
>
> Thank you for your help mathgroup.
Might be easier to use FindFit.
In[49]:= data =
Table[{j, 3*j - 2}, {j, 20}] + RandomReal[{-.1, .1}, {20, 2}];
Now one can do
In[58]:= a + b*x /. FindFit[data, a + b*x, {a, b}, x]
Out[58]= -1.939582811115561 + 2.994503289542548 x
or
In[61]:= f[x_] = a + b*x /. FindFit[data, a + b*x, {a, b}, x]
Out[61]= -1.939582811115561 + 2.994503289542548 x
Many years ago I used the term "jerry rigged" in some in-house email. I was informed that it is not proper phraseology. It seems that "jury rig" and "jerry build" are quite different in meaning.
Several years after that incident, I noticed "jerry rigged" in a James Ellroy novel (White Jazz, I think it was). It seems that the term has entered the language as a crossover of sorts.
http://www.wordcourt.com/archives.php?show04-03-10
http://en.wikipedia.org/wiki/Jury_rig
http://www.answerbag.com/q_view/9245
Daniel Lichtblau
Wolfram Research
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web