Changeset 9363 for branches/OaaS/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/StatisticCalculatorsTest.cs
- Timestamp:
- 04/16/13 13:13:41 (11 years ago)
- Location:
- branches/OaaS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Tests
- Property svn:ignore
-
old new 4 4 *.vs10x 5 5 _ReSharper.HeuristicLab 3.3 Tests 6 *.user 7 *.suo
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/StatisticCalculatorsTest.cs
r7915 r9363 139 139 } 140 140 } 141 142 [TestMethod] 143 public void CalculateHoeffdingsDTest() { 144 OnlineCalculatorError error; 145 // direct perfect dependency 146 var xs = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; 147 var ys = new double[] { 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 }; 148 var d = HoeffdingsDependenceCalculator.CalculateHoeffdings(xs, ys, out error); 149 Assert.AreEqual(error, OnlineCalculatorError.None); 150 Assert.AreEqual(d, 1.0, 1E-5); 151 152 // perfect negative dependency 153 ys = xs.Select(x => -x).ToArray(); 154 d = HoeffdingsDependenceCalculator.CalculateHoeffdings(xs, ys, out error); 155 Assert.AreEqual(error, OnlineCalculatorError.None); 156 Assert.AreEqual(d, 1.0, 1E-5); 157 158 // ties 159 xs = new double[] { 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 5.0 }; 160 ys = new double[] { 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 6.0 }; 161 d = HoeffdingsDependenceCalculator.CalculateHoeffdings(xs, ys, out error); 162 Assert.AreEqual(error, OnlineCalculatorError.None); 163 Assert.AreEqual(d, 0.6783, 1E-5); 164 165 // ties 166 xs = new double[] { 1.0, 1.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 6.0, 6.0 }; 167 ys = xs.Select(x => x * x).ToArray(); 168 d = HoeffdingsDependenceCalculator.CalculateHoeffdings(xs, ys, out error); 169 Assert.AreEqual(error, OnlineCalculatorError.None); 170 Assert.AreEqual(d, 0.75, 1E-5); 171 172 // degenerate 173 xs = new double[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; 174 ys = new double[] { 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 }; 175 d = HoeffdingsDependenceCalculator.CalculateHoeffdings(xs, ys, out error); 176 Assert.AreEqual(error, OnlineCalculatorError.None); 177 Assert.AreEqual(d, -0.3516, 1E-4); 178 179 180 var normal = new HeuristicLab.Random.NormalDistributedRandom(new HeuristicLab.Random.MersenneTwister(31415), 0, 1); 181 182 xs = Enumerable.Range(0, 1000).Select(i => normal.NextDouble()).ToArray(); 183 ys = Enumerable.Range(0, 1000).Select(i => normal.NextDouble()).ToArray(); 184 185 // independent 186 d = HoeffdingsDependenceCalculator.CalculateHoeffdings(xs, ys, out error); 187 Assert.AreEqual(error, OnlineCalculatorError.None); 188 Assert.AreEqual(d, -0.00023, 1E-5); 189 190 191 xs = Enumerable.Range(0, 1000).Select(i => normal.NextDouble()).ToArray(); 192 ys = xs.Select(x => x * x).ToArray(); 193 194 d = HoeffdingsDependenceCalculator.CalculateHoeffdings(xs, ys, out error); 195 Assert.AreEqual(error, OnlineCalculatorError.None); 196 Assert.AreEqual(d, 0.25071, 1E-5); 197 198 // symmetric? 199 d = HoeffdingsDependenceCalculator.CalculateHoeffdings(ys, xs, out error); 200 Assert.AreEqual(error, OnlineCalculatorError.None); 201 Assert.AreEqual(d, 0.25071, 1E-5); 202 203 } 141 204 } 142 205 }
Note: See TracChangeset
for help on using the changeset viewer.