forum.alglib.net

ALGLIB forum
It is currently Sat Apr 27, 2024 12:04 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Is it known problem with lrbuild?
PostPosted: Sat Mar 05, 2011 12:22 pm 
Offline

Joined: Sun Jan 23, 2011 1:01 am
Posts: 4
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
=======================================================


Top
 Profile  
 
 Post subject: Re: Is it known problem with lrbuild?
PostPosted: Sun Mar 06, 2011 9:19 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 250 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group