如何创建所有可能组合的列表? c#(变量选择算法)

时间:2017-10-26 21:34:15

标签: c# statistics regression

这对我来说有点复杂,所以我会尽力解释。我试图从包含观察数据的大约160个十进制列表中执行多次回归。我需要至少2个公式列表和最多10个公式列表,我试图找出如何为所有可能的小数列表组合运行此计算。这是我到目前为止的一些代码,我试图将此代码转换为

var matrixArray = CreateMatrix.DenseOfColumnArrays(listMRInfo.ElementAt(0).ListValues.ToArray(), listMRInfo.ElementAt(1).ListValues.ToArray(), listMRInfo.ElementAt(2).ListValues.ToArray(), 
listMRInfo.ElementAt(3).ListValues.ToArray(), listMRInfo.ElementAt(4).ListValues.ToArray(), listMRInfo.ElementAt(5).ListValues.ToArray(), listMRInfo.ElementAt(6).ListValues.ToArray(), 
listMRInfo.ElementAt(7).ListValues.ToArray(), listMRInfo.ElementAt(8).ListValues.ToArray(), listMRInfo.ElementAt(9).ListValues.ToArray(), listMRInfo.ElementAt(10).ListValues.ToArray());
var items = MultipleRegression.NormalEquations(matrixArray, vectorArray);
var estimatedList = new List<double>();
var y = calcTemp.CalculateYIntercept(matrixArray, vectorArray.ToList(), items);

  for (int i = 0; i < listMRInfo.First().ListValues.Count; i++)
     {
       var estimate = (items.ElementAt(0) * listMRInfo.ElementAt(0).ListValues.ElementAt(i)) + (items.ElementAt(1) * listMRInfo.ElementAt(1).ListValues.ElementAt(i)) +
                                (items.ElementAt(2) * listMRInfo.ElementAt(2).ListValues.ElementAt(i)) + (items.ElementAt(3) * listMRInfo.ElementAt(3).ListValues.ElementAt(i)) +
                                (items.ElementAt(4) * listMRInfo.ElementAt(4).ListValues.ElementAt(i)) + (items.ElementAt(5) * listMRInfo.ElementAt(5).ListValues.ElementAt(i)) +
                                (items.ElementAt(6) * listMRInfo.ElementAt(6).ListValues.ElementAt(i)) + (items.ElementAt(7) * listMRInfo.ElementAt(7).ListValues.ElementAt(i)) +
                                (items.ElementAt(8) * listMRInfo.ElementAt(8).ListValues.ElementAt(i)) + (items.ElementAt(9) * listMRInfo.ElementAt(9).ListValues.ElementAt(i)) +
                                (items.ElementAt(10) * listMRInfo.ElementAt(10).ListValues.ElementAt(i)) + y;
                            estimatedList.Add(estimate);
     }

    var rss = calcTemp.CalculateResidualSumOfSquares(estimatedList, vectorArray.ToList());
    var tss = calcTemp.CalculateTotalSumOfSquares(vectorArray.ToList());
    var rSquared = 1 - (rss / tss);

我试图为每个可能的列表组合运行上面的代码。如果您需要我解释一下,请告诉我

0 个答案:

没有答案