Free cookie consent management tool by TermsFeed Policy Generator

source: branches/RemoveBackwardsCompatibility/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/ConfidenceIntervalsTests.cs @ 15160

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

#2212 merged r12008, r12009, r12010 back into trunk

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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 ConfidenceIntervalsTests {
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[] { -0.4071000,  1.3207543,  0.8364860, -0.6574363,  0.6215807, 
31      1.1562429, -0.7299977, -0.1013315, -1.5221018, -0.9375169, -0.6257027,  1.1698417, -0.9868505,  0.6890087,
32      -0.1643505, -0.4920212, -0.6958091,  1.8849663,  0.8117723,  0.9806149};
33    private readonly double[] z = new double[] { 45, 55, 67, 45, 68, 79, 98, 87, 84, 82 };
34
35    [TestMethod]
36    [TestCategory("Analysis.Statistics")]
37    [TestProperty("Time", "short")]
38    public void ConfidenceIntervalsTest1() {
39      var result = z.ConfidenceIntervals(0.98);
40      Assert.AreEqual(54.8, Math.Round(result.Item1, 1));
41      Assert.AreEqual(87.2, Math.Round(result.Item2, 1));
42    }
43
44    [TestMethod]
45    [TestCategory("Analysis.Statistics")]
46    [TestProperty("Time", "short")]
47    public void ConfidenceIntervalsTest2() {
48      //comparison with R's t.test(..)
49      var result = x.ConfidenceIntervals(0.95);
50      Assert.AreEqual(1.880506, Math.Round(result.Item1, 6));
51      Assert.AreEqual(5.679494, Math.Round(result.Item2, 6));
52    }
53
54    [TestMethod]
55    [TestCategory("Analysis.Statistics")]
56    [TestProperty("Time", "short")]
57    public void ConfidenceIntervalsTest3() {
58      //comparison with R's t.test(..)
59      var result = y.ConfidenceIntervals(0.1);
60      Assert.AreEqual(0.0802945, Math.Round(result.Item1, 7));
61      Assert.AreEqual(0.1348105, Math.Round(result.Item2, 7));
62    }
63
64    [TestMethod]
65    [TestCategory("Analysis.Statistics")]
66    [TestProperty("Time", "short")]
67    public void ConfidenceIntervalsTest4() {
68      //comparison with R's t.test(..)
69      var result = y.ConfidenceIntervals(0.99);
70      Assert.AreEqual(-0.5047921, Math.Round(result.Item1, 7));
71      Assert.AreEqual(0.7198970, Math.Round(result.Item2, 7));
72    }
73  }
74}
Note: See TracBrowser for help on using the repository browser.