- Timestamp:
- 05/11/11 15:56:17 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/DataAnalysis SolutionEnsembles (added) merged: 5815-5816
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.DataAnalysis (added) merged: 5816
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Tests/StatisticCalculatorsTest.cs
r5944 r6184 78 78 double variance = calculator.Variance; 79 79 80 Assert.AreEqual(mean_alglib , mean, 1E-6 * scale);81 Assert.AreEqual(variance_alglib , variance, 1E-6 * scale);80 Assert.AreEqual(mean_alglib.ToString(), mean.ToString()); 81 Assert.AreEqual(variance_alglib.ToString(), variance.ToString()); 82 82 } 83 83 } … … 109 109 double r2 = r2Calculator.RSquared; 110 110 111 Assert.AreEqual(r2_alglib , r2, 1E-6 * Math.Max(c1Scale, c2Scale));111 Assert.AreEqual(r2_alglib.ToString(), r2.ToString()); 112 112 } 113 113 } 114 114 } 115 115 } 116 [TestMethod] 117 public void CalculatePearsonsRSquaredOfConstantTest() { 118 System.Random random = new System.Random(31415); 119 int n = 12; 120 int cols = testData.GetLength(1); 121 for (int c1 = 0; c1 < cols; c1++) { 122 double c1Scale = random.NextDouble() * 1E7; 123 double c2Scale = 1.0; 124 IEnumerable<double> x = from rows in Enumerable.Range(0, n) 125 select testData[rows, c1] * c1Scale; 126 IEnumerable<double> y = (new List<double>() { 150494407424305.44 }) 127 .Concat(Enumerable.Repeat(150494407424305.47, n - 1)); 128 double[] xs = x.ToArray(); 129 double[] ys = y.ToArray(); 130 double r2_alglib = alglib.pearsoncorrelation(xs, ys, n); 131 r2_alglib *= r2_alglib; 132 133 var r2Calculator = new OnlinePearsonsRSquaredCalculator(); 134 for (int i = 0; i < n; i++) { 135 r2Calculator.Add(xs[i], ys[i]); 136 } 137 double r2 = r2Calculator.RSquared; 138 139 Assert.AreEqual(r2_alglib.ToString(), r2.ToString()); 140 } 141 } 116 142 } 117 143 }
Note: See TracChangeset
for help on using the changeset viewer.