MathGroup Archive 2011

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

Search the Archive

Re: Can FindFit take two (or more) equations?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123546] Re: Can FindFit take two (or more) equations?
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Sun, 11 Dec 2011 03:44:51 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201112091056.FAA03863@smc.vnet.net>

Not sure if you can use FindFit for this, but NMinimize or FindMinimum 
might do the job. For example you could find a least squares solution by 
doing something like

y1[a_, b_] = Function[{x}, 1 - a^2/(x^2 + b^2)]
y2[a_, b_] = Function[{x}, a^2*b/(x*(x^2 + b^2))]

NMinimize[Total[(y1[a, b][#1] - #2)^2 + (y2[a, b][#1] - #3)^2 & @@@ 
data], {a, b}][[2]]

(* output: {a -> 14.5228, b -> 2.36932} *)

Heike

On 9 Dec 2011, at 11:56, Luiz Melo wrote:

> Dear mathgroup
> I have the following list of data:
>
> {{0.972, -45.7, 60.3}, {1.17, -39.7, 52.4}, {1.35, -34.1, 46.3},
> {1.55, -29.8, 40.0}, {1.73, -25.9, 34.6},
> {1.91, -22.5, 30.6}, {2.11, -19.6, 27.3}, {2.29, -17.4, 24.7}, {2.49,
> -15.8, 22.3}, {2.67, -14.5, 20.6},
> {2.86, -13.2, 19.2}, {3.05, -12.1,18.0}, {3.24, -11.1, 16.9}, {3.43,
> -10.4, 15.7}, {3.62, -9.66, 14.5},
> {3.80, -9.07, 13.3}, {4.00, -8.35, 12.3}, {4.18, -7.73, 11.4}, {4.38,
> -7.26, 10.6}, {4.56, -6.71, 9.82},
> {4.74, -6.12, 9.20}, {4.94, -5.61, 8.63}, {5.12, -5.09, 8.13}, {5.32,
> -4.59, 7.78}, {5.50, -4.16, 7.46},
> {5.68, -3.82, 7.12}, {5.88, -3.51, 6.87}, {6.06, -3.26, 6.65}, {6.26,
> -2.99, 6.48}, {6.44, -2.72, 6.31},
> {6.62, -2.51, 6.16}, {6.82, -2.29, 6.02}, {7.00, -2.09, 5.88}, {7.20,
> -1.97, 5.79}, {7.38, -1.78, 5.71},
> {7.57, -1.62, 5.60}, {7.76, -1.52, 5.58}, {7.95, -1.41, 5.56}, {8.14,
> -1.34, 5.50}, {8.33, -1.36, 5.39},
> {8.51, -1.38, 5.29}, {8.71, -1.40, 5.19}, {8.89, -1.41, 5.02}, {9.09,
> -1.32, 4.84}, {9.27, -1.32, 4.62},
> {9.45, -1.26, 4.41}, {9.65, -1.20, 4.21}, {9.83, -1.19, 3.94}, {10.0,
> -1.18, 3.69}}
>
> where the first column is, let's say, x, the second is y1 and the 
third, y2.
> I would like to simultaneously fit the curve given by the points y1 
> y1(x) with the equation y1(x) = 1 - a^2/(x^2+b^2), and the curve
> given by the points y2 = y2(x) with the equation y2(x) = 
a^2*b/(x*(x^2+b^2)).
> Can FindFit help us to find the parameters "a" and "b" of the above
> equations? How?
>
> Thank you.
> Luiz
>




  • Prev by Date: Re: While Loop
  • Next by Date: Re: NDSolve[]
  • Previous by thread: Re: Can FindFit take two (or more) equations?
  • Next by thread: Re: Can FindFit take two (or more) equations?