Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1993
*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 1993

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

Search the Archive

NonlinearFit (do I use the right program?)

  • To: MathGroup at yoda.physics.unc.edu
  • Subject: NonlinearFit (do I use the right program?)
  • From: Reiner Wilhelms <reiner at shs.ohio-state.edu>
  • Date: Mon, 15 Mar 93 19:53:35 EST

Problem: Is there package which implements a general multidimensional
non-linear least squares estimation? I believed NonlinearFit would do
this but I must misunderstand something.

I tried to apply the program NonlinearFit by Pekka Janhunen (item
number 0202-150 of the mathsource archive) to a particular problem
which has 5 parameters and 6-dimensional data.  It didn't like it. The
program was complaining that the values field was not of size 5 but 6.
An experiment is listed at the end.

What I want, in  general can be described as follows:
                              n    m
Let G(X,A) be a mapping from R -> R  with an unknown parameter vector A.

X is a n-dimensional vector X=(x1,...,xn), the variables
A is a k-dimensional vector A=(a1,...,ak), the unknown parameters 
G is an m-dimensional function (row-) vector 
G = ( g1(x1,...,xn,a1,...,ak), ...., gm(x1,...,xn,a1,...,ak) )

I would like to have an algorithm which minimizes:

     N                        
    sum	 G(X_i,A) G(X_i,A)'   -> Minimum
    i=1                       

where ()' means transposed, and X_i, i=1,...,N represents the N data
vectors for which the mapping is defined. I assume that all
derivatives with respect to the parameters A exist and are continuous.
If in particular n=m, one could define for example g_k(x_1,...,x_n,A)
as some difference : 
g_k(x_1,...,x_n,A) = f_k(x_1,...,x_n,A) - x_k. 

This is the case in the below example in which n = m = 6, k = 5, and N=6.

Because I thought NonlinearFit would be able to do this I tried to use
it here. I must be mistaken and I think I misunderstand what the
program actually does:

Input:
------
dist[x_,y_,a_,b_]:= Sqrt[(x-a)^2+(y-b)^2];
f[x_,y_,a_,b_,r_]:= r*(x-a)/dist[x,y,a,b] +a;
g[x_,y_,a_,b_,r_]:= r*(y-b)/dist[x,y,a,b] +b;

model={ f[x1,y1,a,b,r1]-x1, 
	g[x1,y1,a,b,r1]-y1, 
	f[x2,y2,a,b,r2]-x2,
        g[x2,y2,a,b,r2]-y2, 
	f[x3,y3,a,b,r3]-x3, 
	g[x3,y3,a,b,r3]-y3 };

params = {a,b,r1,r2,r3};

vars = {x1,y1,x2,y2,x3,y3};

data = { {0.8, 1.2, 2.0, 1.3, 2.9, 1.1},
	 {1.0, 1.0, 2.1, 0.8, 3.0, 0.6},
	 {1.1, 0.8, 2.2, 0.4, 3.0, 0.3}, 
	 {1.0, 0.0, 2.1, 0.0, 3.0, 0.1}
	 {1.1, -0.1, 2.0, -0.2, 2.9, -0.1},
	 {0.8, -0.5, 1.8, -0.4, 2.8, -.07}};

NonlinearFit[data,model,params,variables] 

Output:
-------
NonlinearFit::badvar:
   Variable list {x1, y1, x2, y2, x3, y3} is not a list of 5 symbols.
.....

I guess I am running the wrong program here... Or do I just call
it wrong?????

Reiner
















  • Prev by Date: Two trivial questions
  • Next by Date: WANTED: ANY USED BOOK ON MATHEMATICA
  • Previous by thread: Two trivial questions
  • Next by thread: WANTED: ANY USED BOOK ON MATHEMATICA