forum.alglib.net http://forum.alglib.net/ |
|
Wrapper for XAlglib.lrbuild in alglibnet2 - How To? http://forum.alglib.net/viewtopic.php?f=2&t=277 |
Page 1 of 1 |
Author: | Synteger [ Sun Jan 23, 2011 1:22 am ] |
Post subject: | Wrapper for XAlglib.lrbuild in alglibnet2 - How To? |
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 ) |
Author: | Sergey.Bochkanov [ Sun Jan 23, 2011 11:54 am ] |
Post subject: | Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To? |
I think that you've passed incorrect sizes of input arguments. It should be XAlglib.lrbuild(LRData, Mins.Count, Maxs.Count, Info, LM, LR). |
Author: | Synteger [ Sun Jan 23, 2011 10:26 pm ] |
Post subject: | Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To? |
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"? |
Author: | Sergey.Bochkanov [ Mon Jan 24, 2011 7:24 am ] |
Post subject: | Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To? |
You should use LRUnpack() function to access model coefficients. Other coefficients you've mentioned are used for internal purposes only. |
Author: | Synteger [ Tue Jan 25, 2011 9:18 pm ] |
Post subject: | Re: Wrapper for XAlglib.lrbuild in alglibnet2 - How To? |
Thank you, it works) |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |