Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5053 > unrolled thread

Re: Making a function from the output of the Fit function.

Started byDrMajorBob <btreat1@austin.rr.com>
First post2011-09-18 08:24 +0000
Last post2011-09-18 08:24 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Making a function from the output of the Fit function. DrMajorBob <btreat1@austin.rr.com> - 2011-09-18 08:24 +0000

#5053 — Re: Making a function from the output of the Fit function.

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-09-18 08:24 +0000
SubjectRe: Making a function from the output of the Fit function.
Message-ID<j549r8$6ff$1@smc.vnet.net>
data = Sort@
    Table[{x + RandomReal[.05], .5 + 2 x + RandomReal[.05]}, {x, 0,
      1, .1}];

Clear[f, x]
f[x_] = Fit[data, {1, x}, x]

0.448981 + 2.03847 x

Show[Plot[f@x, {x, 0, 1}], ListPlot@data]

or

Clear[f, x]
f[x_] := Evaluate@Fit[data, {1, x}, x]

f@x

0.480993 + 2.02164 x

Show[Plot[f@x, {x, 0, 1}], ListPlot@data]

Bobby

On Sat, 17 Sep 2011 05:25:53 -0500, Just A Stranger  
<forpeopleidontknow@gmail.com> wrote:

> 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.


-- 
DrMajorBob@yahoo.com

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web