Free cookie consent management tool by TermsFeed Policy Generator

source: branches/MemPRAlgorithm/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/EffectSizeUnitTests.cs @ 15780

Last change on this file since 15780 was 14185, checked in by swagner, 8 years ago

#2526: Updated year of copyrights in license headers

File size: 2.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Analysis.Statistics;
24using Microsoft.VisualStudio.TestTools.UnitTesting;
25
26namespace HeuristicLab.Analysis.Tests {
27  [TestClass]
28  public class EffectSizeUnitTests {
29    private readonly double[] x = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 1.5, 0.3 };
30    private readonly double[] y = new double[] { 1.0, 3.0, 10.0, 4.0, 2.5, 6.0, 7.5, 8.0, 1.5, 0.5 };
31    private readonly double[] z = new double[] { 45.0, 0.3, 12.0, 45.0, 68.0, 79.0, 10.0, 87.0, 84.0, 1.0 };
32
33    [TestMethod]
34    [TestCategory("Analysis.Statistics")]
35    [TestProperty("Time", "short")]
36    public void CohensdTest1() {
37      //compared to R lsr package/cohenD(..)
38      var result = SampleSizeDetermination.CalculateCohensD(x, y);
39      Assert.AreEqual(0.2074003, Math.Round(result, 7));
40    }
41
42    [TestMethod]
43    [TestCategory("Analysis.Statistics")]
44    [TestProperty("Time", "short")]
45    public void CohensdTest2() {
46      //compared to R lsr package/cohenD(..)
47      var result = SampleSizeDetermination.CalculateCohensD(x, z);
48      Assert.AreEqual(1.57424, Math.Round(result, 5));
49    }
50
51    [TestMethod]
52    [TestCategory("Analysis.Statistics")]
53    [TestProperty("Time", "short")]
54    public void HedgesGTest1() {
55      //compared to R effsize package/cohen.d(..,hedges.correction=TRUE)
56      var result = SampleSizeDetermination.CalculateHedgesG(x, y);
57      Assert.AreEqual(0.1986369, Math.Round(result, 7));
58    }
59
60    [TestMethod]
61    [TestCategory("Analysis.Statistics")]
62    [TestProperty("Time", "short")]
63    public void HedgesGTest2() {
64      //compared to R effsize package/cohen.d(..,hedges.correction=TRUE)
65      var result = SampleSizeDetermination.CalculateHedgesG(x, z);
66      Assert.AreEqual(1.507722, Math.Round(result, 6));
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.