Re: Re: Function Fitting To 3D Data

• To: mathgroup at smc.vnet.net
• Subject: [mg53693] Re: [mg53663] Re: Function Fitting To 3D Data
• From: DrBob <drbob at bigfoot.com>
• Date: Sun, 23 Jan 2005 02:02:23 -0500 (EST)
• References: <csl1jv\$6ue\$1@smc.vnet.net> <200501220851.DAA20083@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Cool!

I'd suggest Mean rather than First, in case the same x and y appear with different z. Also, the definition of "alldata" needn't require knowing the limits of x and y (unless we intend to extrapolate beyond the data, as you did in your examples):

Clear[x, y]
ff[x_, y_] = Fit[data, {1, x, y}, {x, y}];
f = Interpolation@
Flatten[Table[If[MemberQ[data[[All, {1, 2}]], {x, y}],
Mean@Cases[data, {x, y, _}],
{x, y, ff[x, y]}],
Evaluate@Through[{x &, Min, Max}@data[[All, 1]]],
Evaluate@Through[{y &, Min, Max}@data[[All, 2]]]], 1];
f[3, 2]

14.2

Bobby

On Sat, 22 Jan 2005 03:51:43 -0500 (EST), Astanoff <astanoff at yahoo.fr> wrote:

> Assuming a linear fitting, this is the way I would do it :
>
> In[1]:=
> data={{3,2,13.9},{3,5,13.4},{3,10,12.3},{12,1,15.6},
> {24,2,16.0},{60,5,14.1},{120,10,13.0},{240,20,11.7}};
>
> ff[x_,y_]=Fit[data,{1,x,y},{x,y}];
> alldata=
> Flatten[Table[If[MemberQ[data[[All,{1,2}]],{x,y}],
> First@Cases[data,{x,y,_}],{x,y,ff[x,y]}],
> {x,1,240},
> {y,1,20}],1];
> f=Interpolation[alldata]
>
> Out[4]=
> InterpolatingFunction[{{1.,240.},{1.,20.}},<>]
>
> In[5]:=f[1,1]
> Out[5]=15.0536
>
> In[6]:=f[3,2]
> Out[6]=13.9
>
> In[7]:=f[3,4]
> Out[7]=14.0519
> In[8]:=f[3,5]
> Out[8]=13.4
>
> In[9]:=f[240,20]
> Out[9]=11.7
>
>
> hth
>
> Valeri
>
>
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Numbers and their reversals
• Next by Date: Re: Plotting lists of functions
• Previous by thread: Re: Function Fitting To 3D Data
• Next by thread: compile / optimize