c# 3.0 - How to make double[,] x_List in C#3.0? -
i ned implement multi-linear regression in c#(3.0) using linest function of excel. trying achieve
=linest(acl_returns!i2:i10,acl_returns!j2:k10,false,true)
so have data below
double[] x1 = new double[] { 0.0330, -0.6463, 0.1226, -0.3304, 0.4764, -0.4159, 0.4209, -0.4070, -0.2090 }; double[] x2 = new double[] { -0.2718, -0.2240, -0.1275, -0.0810, 0.0349, -0.5067, 0.0094, -0.4404, -0.1212 }; double[] y = new double[] { 0.4807, -3.7070, -4.5582, -11.2126, -0.7733, 3.7269, 2.7672, 8.3333, 4.7023 };
i have write function signature be
compute(double[,] x_list, double[] y_list) { linest(x_list,y_list, true, true); < - excel function call. }
my question how using double[] x1 , double[] x2 make double[,] x_list ?
i using c#3.0 , framework 3.5.
thanks in advance
actually should be
double[,] xvalues = new double[x1.length, x2.length]; int max = (new int[]{ x1.length,x2.length}).max(); (int = 0; < max; i++) { xvalues[0, i] = x1.length > ? x1[i] : 0; xvalues[1, i] = x2.length > ? x2[i] : 0; }
samir right, should call max()
once outside iterator rather each iteration, i've amended this.
Comments
Post a Comment