Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: fitting a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58339] Re: [mg58323] fitting a function
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 28 Jun 2005 21:56:38 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

data={{10000,.3},{15000,.5},{20000,.6},{25000,.65}};

Needs["NumericalMath`PolynomialFit`"];

p=PolynomialFit[data,3];

p[x]//Expand

6.666666666666563*^-14*x^3 - 4.999999999999937*^-9*x^2 + 
0.00013333333333333212*x - 0.5999999999999929

Plot[p[x],{x,5000,30000},Epilog->
      {Red, AbsolutePointSize[4],Point/@data}];


Bob Hanlon

> 
> From: "Bosch, Darrell" <bosch at vt.edu>
To: mathgroup at smc.vnet.net
> Date: 2005/06/28 Tue AM 05:13:23 EDT
> Subject: [mg58339] [mg58323] fitting a function
> 
> 
> Dear Group,  I have two questions:  First, I want to fit a function
> relating utility to income based on some elicited data.  For example,
> the following pairs might represent the income and utility values for an
> individual:  {10,000, .3}, {15,000, .5}, {20,000, .6}, {25,000, .65}  I
> want to fit the data to a function and plot the resulting function.
> What is the best way to do this?  PolynomialFit seems like a logical
> choice, but it's not clear to me from the documentation how to specify
> the command for a series of pairs of points. 
> 
> 
> 
> Second, how do I plot the resulting value of a polynomial fit in the
> example below?  My 'ParametricPlot' command doesn't do the job.  Thanks
> in advance for your help.  Darrell Bosch
> 
> 
> 
> << "NumericalMath`PolynomialFit`"
> 
> In[28]:=
> 
> p = PolynomialFit[{1, 4, 9,
> 
>     16, 25, 36, 49}, 3]
> 
> ParametricPlot[p, {p, 0, 6}, PlotRange -> All, Compiled -> True]
> 
> 
> 
> 
> 
> 

Bob Hanlon
Chantilly, VA


  • Prev by Date: Re: A ToExpression question
  • Next by Date: Re: Optimal number of sheets
  • Previous by thread: Re: fitting a function
  • Next by thread: Optimal number of sheets