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 =======================================================
|