Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/EffectSizeUnitTests.cs @ 11703

Last change on this file since 11703 was 11703, checked in by ascheibe, 10 years ago

#2031 moved statistic algs and unit tests to trunk

File size: 2.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2014 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 Statistics.UnitTests {
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    public void CohensdTest1() {
35      //compared to R lsr package/cohenD(..)
36      var result = SampleSizeDetermination.CalculateCohensD(x, y);
37      Assert.AreEqual(0.2074003, Math.Round(result, 7));
38    }
39
40    [TestMethod]
41    public void CohensdTest2() {
42      //compared to R lsr package/cohenD(..)
43      var result = SampleSizeDetermination.CalculateCohensD(x, z);
44      Assert.AreEqual(1.57424, Math.Round(result, 5));
45    }
46
47    [TestMethod]
48    public void HedgesGTest1() {
49      //compared to R effsize package/cohen.d(..,hedges.correction=TRUE)
50      var result = SampleSizeDetermination.CalculateHedgesG(x, y);
51      Assert.AreEqual(0.1986369, Math.Round(result, 7));
52    }
53
54    [TestMethod]
55    public void HedgesGTest2() {
56      //compared to R effsize package/cohen.d(..,hedges.correction=TRUE)
57      var result = SampleSizeDetermination.CalculateHedgesG(x, z);
58      Assert.AreEqual(1.507722, Math.Round(result, 6));
59    }
60  }
61}
Note: See TracBrowser for help on using the repository browser.