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

Home » Public Forums » archive » faster minimization needed - maybe mpfit?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: faster minimization needed - maybe mpfit? [message #79722 is a reply to message #79653] Tue, 27 March 2012 06:38 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Tuesday, March 27, 2012 8:28:02 AM UTC-4, chris wrote:
> Hi Craig,
> sorry I made several typos. I would also be satisfied with a least
> squares solution as you can see if you compare function test2 with the
> previous posts. The function I want to minimize is test2. It doesnt
> matter for me at this stage whether total(abs(resid)) or
> total(resid^2) is minimized.
>
> function test2,p,xval=x,errval=err
> resid=convol(x-rebin(p[*],size(x,/dim)),[-1.,0.,1.])
> return,total(resid^2)
> end
>
> ENVI> help,im
> IM INT = Array[512, 7237]
> ENVI> sz=size(im,/dim)
> ENVI> im2=im+fix(1000.*rebin((((add=randomn(seed,sz[0])))-mean(add ))/
> stddev(add),sz))
> ENVI> help,im2
> IM2 INT = Array[512, 7237]
> ENVI> p0=((p0=total(im2,2)/float(sz[1])))-smooth(p0,3,/edge_trunc)
> ENVI> help,p0
> P0 FLOAT = Array[512]
> ENVI> st={x:im2,errval:sqrt(p0)}
> &res=mpfit('test2',p0,functargs=st,maxiter=100,status=st atus,errmsg=errmsg)
> &print,status,string(10b),errmsg
> 0
> ERROR: number of parameters must not exceed data

Check out the documentation for MPFIT. It expects your user function to return a 1D array of residuals, not the sum of squares.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Cellular automata
Next Topic: IDL and PV wave language free

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

Current Time: Thu Oct 09 22:41:47 PDT 2025

Total time taken to generate the page: 0.00189 seconds