[11699] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using HeuristicLab.Analysis.Statistics;
|
---|
| 24 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 25 |
|
---|
[11705] | 26 | namespace HeuristicLab.Analysis.Tests {
|
---|
[11699] | 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 | public void ConfidenceIntervalsTest1() {
|
---|
| 37 | var result = z.ConfidenceIntervals(0.98);
|
---|
| 38 | Assert.AreEqual(54.8, Math.Round(result.Item1, 1));
|
---|
| 39 | Assert.AreEqual(87.2, Math.Round(result.Item2, 1));
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | [TestMethod]
|
---|
| 43 | public void ConfidenceIntervalsTest2() {
|
---|
| 44 | //comparison with R's t.test(..)
|
---|
| 45 | var result = x.ConfidenceIntervals(0.95);
|
---|
| 46 | Assert.AreEqual(1.880506, Math.Round(result.Item1, 6));
|
---|
| 47 | Assert.AreEqual(5.679494, Math.Round(result.Item2, 6));
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | [TestMethod]
|
---|
| 51 | public void ConfidenceIntervalsTest3() {
|
---|
| 52 | //comparison with R's t.test(..)
|
---|
| 53 | var result = y.ConfidenceIntervals(0.1);
|
---|
| 54 | Assert.AreEqual(0.0802945, Math.Round(result.Item1, 7));
|
---|
| 55 | Assert.AreEqual(0.1348105, Math.Round(result.Item2, 7));
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | [TestMethod]
|
---|
| 59 | public void ConfidenceIntervalsTest4() {
|
---|
| 60 | //comparison with R's t.test(..)
|
---|
| 61 | var result = y.ConfidenceIntervals(0.99);
|
---|
| 62 | Assert.AreEqual(-0.5047921, Math.Round(result.Item1, 7));
|
---|
| 63 | Assert.AreEqual(0.7198970, Math.Round(result.Item2, 7));
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 | }
|
---|