forum.alglib.net
http://forum.alglib.net/

minlmoptimize function wrap
http://forum.alglib.net/viewtopic.php?f=2&t=3781
Page 1 of 1

Author:  arima [ Wed Dec 07, 2016 5:10 am ]
Post subject:  minlmoptimize function wrap

Hi there,

I have a problem related with using minlmoptimize method for curve fitting.
I tried to create a vector of fi[i] of each data point, as shown below, then pass them into the minlmoptimize function.

Code:
        public static void function_fvec(double[] vars, double[] fi, object obj)
        {                       
            double[] tempfuncs = new double[10];
           
            for (int i = 0; i < 10; i++)
            {
                tempfuncs[i] = Math.Abs(data_y[i] - simu(vars, data_x[i])); //compare input data and calculated results.
            }

            fi= tempfuncs;           
        }


However, it seems does not work. Can someone help me out?

Thank you!

Author:  Sergey.Bochkanov [ Wed Dec 07, 2016 10:04 am ]
Post subject:  Re: minlmoptimize function wrap

Hi!

You should rewrite elements of fi, not create new array. As you may see, fi[] is passed by value, so when you create tempfuncs[] there is no way to tell optimizer that it should work with newly allocated array.

Author:  arima [ Wed Dec 07, 2016 1:53 pm ]
Post subject:  Re: minlmoptimize function wrap

Hello Mr.Bochkanov,

Thank you for replying in person! Now the problem is fixed, your solver works wonderfully!

Maybe another quick question, is there a way to get the correlation matrix of the fitting varables?

Many thanks!

Author:  Sergey.Bochkanov [ Thu Dec 08, 2016 1:24 pm ]
Post subject:  Re: minlmoptimize function wrap

No, LM optimizer does not support covariance matrix estimation. Only linear LS solver provides such option.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/