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

lsfit question with 2 variables
http://forum.alglib.net/viewtopic.php?f=2&t=520
Page 1 of 1

Author:  annparis [ Thu Jan 19, 2012 4:55 pm ]
Post subject:  lsfit question with 2 variables

Hi all. I am trying to use the "lsfit_d_nlf" example for a more complex function.
http://www.alglib.net/translator/man/ma ... sfit_d_nlf

To fit without weights one must use:
Code:
XAlglib.lsfitcreatef(x, y, c, diffstep, state)

If the function is for example:
Code:
func = System.Math.Exp(-c(0) * x(0) * x(0)) + 4 * c(2) * Cos(c(1))

and declare
Code:
Dim c() As Double = New Double() {1, 0.5, 2}
everything runs smoothly.

But, if I have a function like:
Code:
func = System.Math.Exp(-c(0) * x(0) * x(0)) + 4 * c(2) * Cos(c(1)) + g()
' (Of course this gives an error)
where
Code:
Dim g() as Double = New Double() {0,2,4,6,8,10,12,14,16,18,20}
and with array size = array size of x and y because y=f(x,g,c) and changes values as x index increases, how can I do the fit?

In other words, I would like to do a fit having 3 columns of values x,y,g (two independent variables) and the adjustable parameter c.
The question is in VB.net but please in the reply use whatever lang! thanks!

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