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

Is it known problem with lrbuild?
http://forum.alglib.net/viewtopic.php?f=2&t=313
Page 1 of 1

Author:  Synteger [ Sat Mar 05, 2011 12:22 pm ]
Post subject:  Is it known problem with lrbuild?

This code gives good result - Coefficients are 2,3,4,5.
As you can see, here we use ONE argument as a regular nodes 0,1,2......
=======================================================
Private Function test() As Double()

Dim Rnd = New Random

Dim LRData(9, 3) As Double

For i = 0 To LRData.GetUpperBound(0)
LRData(i, 0) = i
LRData(i, 1) = Rnd.NextDouble
LRData(i, 2) = Rnd.NextDouble
LRData(i, 3) = 2 * LRData(i, 0) + 3 * LRData(i, 1) + 4 * LRData(i, 2) + 5
ListBox1.Items.Add(LRData(i, 0))
ListBox1.Items.Add(LRData(i, 1))
ListBox1.Items.Add(LRData(i, 2))
ListBox1.Items.Add(LRData(i, 3))
ListBox1.Items.Add("---")
Next


Dim Info = 0
Dim LM = New XAlglib.linearmodel()
Dim LR = New XAlglib.lrreport()
XAlglib.lrbuild(LRData, 10, 3, Info, LM, LR)

Dim Result() As Double

XAlglib.lrunpack(LM, Result, 3)
Return Result

End Function
=======================================================
This code gives bad result - Coefficients are 2.5, 2.5, 4, 5.
As you can see, here we use TWO argument as a regular nodes 0,1,2......
=======================================================
Private Function test() As Double()

Dim Rnd = New Random

Dim LRData(9, 3) As Double

For i = 0 To LRData.GetUpperBound(0)
LRData(i, 0) = i
LRData(i, 1) = i
LRData(i, 2) = Rnd.NextDouble
LRData(i, 3) = 2 * LRData(i, 0) + 3 * LRData(i, 1) + 4 * LRData(i, 2) + 5
ListBox1.Items.Add(LRData(i, 0))
ListBox1.Items.Add(LRData(i, 1))
ListBox1.Items.Add(LRData(i, 2))
ListBox1.Items.Add(LRData(i, 3))
ListBox1.Items.Add("---")
Next


Dim Info = 0
Dim LM = New XAlglib.linearmodel()
Dim LR = New XAlglib.lrreport()
XAlglib.lrbuild(LRData, 10, 3, Info, LM, LR)

Dim Result() As Double

XAlglib.lrunpack(LM, Result, 3)
Return Result

End Function
=======================================================

Author:  Sergey.Bochkanov [ Sun Mar 06, 2011 9:19 am ]
Post subject:  Re: Is it known problem with lrbuild?

It is not problem - it is normal behavior for lrbuild(). Your second problem has non-unique solution, because first and second columns are equal, and overall system is degenerate. So (2, 3, 4, 5) is solution, (2.5, 2.5, 4, 5) is solution too, and generally (2+x, 3-x, 4, 5) will be solution for any real x.

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