comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » mpfit: multivariate fit
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
mpfit: multivariate fit [message #53931] Mon, 07 May 2007 21:19 Go to previous message
Dave[3] is currently offline  Dave[3]
Messages: 12
Registered: November 2006
Junior Member
Hi all,

I'm trying to use MPFIT to numerically estimate a coordinate
transformation matrix that relates two sensors. One set is
uncalibrated, and the other has a known calibration. So, I have a set
of observed vectors (xyz_obs) and a set of known vectors (xyz_known)
and I'm trying to estimate (in a least squares sense) the
transformation matrix T that relates them. Judiciously choosing the
data in the fictional example below, I expect the transformation
matrix to be 2 * identity(3,3).

When I execute the code below, I get:

IDL> .r foo
% Compiled module: TRANS.
% Compiled module: $MAIN$.
Iter 1 CHI-SQUARE = 1278958.0 DOF = 291
P(0) = 1.00000
P(1) = 0.00000
P(2) = 0.00000
P(3) = 0.00000
P(4) = 1.00000
P(5) = 0.00000
P(6) = 0.00000
P(7) = 0.00000
P(8) = 1.00000
% MPFIT: Error detected while calling MPFIT_FDJAC2:
% MPFIT: Out of range subscript encountered: FJAC.
% MPFIT: Error condition detected. Returning to MAIN level.

Any ideas on what I'm doing wrong here?

Thanks!
Dave

%%%
% Contents of foo.pro
%%%

function trans, K, X=x, Y=y, err=err, forward=fw
model = K ## x
if keyword_set(fw) then return, model else return, (y-model)/err
end

; MAIN

; Attempt to estimate the transformation matrix given a set
; of observed Cartesian vectors and a set of known cartesian
; vectors.

n = 100 ; number of 'observations'

v = [1.0d, 0.15, 0.5] ; template vector
xyz_obs = dblarr(n, 3) ; observations
for i=0, n-1 do $
xyz_obs[i,*] = reform( v+0.01*randomn(seed,3), 1, 3)

xyz_known = dblarr(n, 3) ; known values (trivial scaling)
for i=0, n-1 do $
xyz_known[i,*] = reform( v*2.0, 1, 3)

; Estimate the transformation matrix, T
T0 = identity(3, /DOUBLE) ; initial guess transformation matrix
f = {x: xyz_obs, y: xyz_known, err: 0.01}
T = mpfit('trans', T0, functargs=f, COVAR=S2)

end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Idlgrsymbol size?
Next Topic: Re: write a root group to HDF5 file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:36:02 PDT 2025

Total time taken to generate the page: 0.00614 seconds