forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 2:15 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  [ 5 posts ] 
Author Message
 Post subject: Wrapper for XAlglib.lrbuild in alglibnet2 - How To?
PostPosted: Sun Jan 23, 2011 1:22 am 
Offline

Joined: Sun Jan 23, 2011 1:01 am
Posts: 4
I'm trying to use linear regression from alglib for VB .Net project in VS2010.

Dim LRData(Mins.Count - 1, Maxs.Count - 1) As Double

……………………………………

Dim Info = 0
Dim LM = New XAlglib.linearmodel()
Dim LR = New XAlglib.lrreport()
XAlglib.lrbuild(LRData, Maxs.Count, Mins.Count, Info, LM, LR)


But =>
System.IndexOutOfRangeException was unhandled
Message=Index was outside the bounds of the array.
Source=alglibnet2
StackTrace:
at alglib.linreg.lrbuilds(Double[,] xy, Double[] s, Int32 npoints, Int32 nvars, Int32& info, linearmodel lm, lrreport ar)
at alglib.linreg.lrbuild(Double[,] xy, Int32 npoints, Int32 nvars, Int32& info, linearmodel lm, lrreport ar)
at alglib.lrbuild(Double[,] xy, Int32 npoints, Int32 nvars, Int32& info, linearmodel& lm, lrreport& ar)


May be the problem is that LM and LR constructors didn't initialize array W in XAlglib.linearmodel and arrays C and CVDEFECTS in XAlglib.lrreport?
How to setup instances of linearmodel & lrreport before running the lrbuild?
Thank you in advance )


Top
 Profile  
 
 Post subject: Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To?
PostPosted: Sun Jan 23, 2011 11:54 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
I think that you've passed incorrect sizes of input arguments. It should be XAlglib.lrbuild(LRData, Mins.Count, Maxs.Count, Info, LM, LR).


Top
 Profile  
 
 Post subject: Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To?
PostPosted: Sun Jan 23, 2011 10:26 pm 
Offline

Joined: Sun Jan 23, 2011 1:01 am
Posts: 4
Thank you!
It turns out that correct version is

Dim LRData(Maxs.Count - 1, Mins.Count) As Double

……………………………………

Dim Info = 0
Dim LM = New XAlglib.linearmodel()
Dim LR = New XAlglib.lrreport()
XAlglib.lrbuild(LRData, Maxs.Count, Mins.Count, Info, LM, LR)

Now it works and as a result for NVars=6 in LM I've got an array of 11 Double like
[0]11.0
[1]5.0
[2]6.0
[3]4.0
[4]108.59
[5]-43.01
[6]84.94
[7]-6.26
[8]-80.95
[9]-40.54
[10]98769.4431
The last value is similar to A[N] in Y = A(0)*X[0] + ... + A(N-1)*X[N-1] + A(N).
The values from 108.59 to -40.54 can be A[0] to A[5].
But the meaning of 11,5,6,4 ?
Where I can read about "linear model in the ALGLIB format and its subroutines to work with the model"?


Top
 Profile  
 
 Post subject: Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To?
PostPosted: Mon Jan 24, 2011 7:24 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
You should use LRUnpack() function to access model coefficients. Other coefficients you've mentioned are used for internal purposes only.


Top
 Profile  
 
 Post subject: Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To?
PostPosted: Tue Jan 25, 2011 9:18 pm 
Offline

Joined: Sun Jan 23, 2011 1:01 am
Posts: 4
Thank you, it works)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 29 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