Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11699


Ignore:
Timestamp:
12/19/14 12:46:06 (9 years ago)
Author:
ascheibe
Message:

#2031

  • fixed confidence intervals calculation
  • added more unit tests
  • some cosmetic changes
Location:
branches/StatisticalTesting
Files:
1 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/EnumerableStatisticsExtension.cs

    r11375 r11699  
    3535      double x = values.Average();
    3636      int n = values.Count();
    37       double t = alglib.studenttdistribution(n - 1, 1 - (alpha / 2));
     37      double t = alglib.invstudenttdistribution(n - 1, (1.0 - alpha) / 2.0);
    3838
    39       lower = x - t * (s / Math.Sqrt(n));
    40       upper = x + t * (s / Math.Sqrt(n));
     39      lower = x + t * (s / Math.Sqrt(n));
     40      upper = x - t * (s / Math.Sqrt(n));
    4141
    4242      return new Tuple<double, double>(lower, upper);
    4343    }
    44 
    45     // Bessel corrected variance
    46     public static double EstimatedVariance(this IEnumerable<double> values) {
    47       double n = values.Count();
    48       return values.Variance() * n / (n - 1);
    49     }
    50 
    51     // Bessel corrected standard deviation
    52     public static double EstimatedStandardDeviation(this IEnumerable<double> values) {
    53       double n = values.Count();
    54       return values.StandardDeviation() * n / (n - 1);
    55     }
    5644  }
    5745}
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/KruskalWallisTest.cs

    r11692 r11699  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Analysis.Statistics {
     
    5152      int cnt = 0;
    5253      for (int i = 0; i < r.Length; i++) {
    53         if (lastG == g[i]) {
     54        if (lastG.IsAlmost(g[i])) {
    5455          curSum += r[i];
    5556          cnt++;
     
    116117
    117118      for (int i = 1; i < x.Length; i++) {
    118         if (last != x[i]) {
     119        if (!last.IsAlmost(x[i])) {
    119120          number.Add(x[i]);
    120121          last = x[i];
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/LinearLeastSquaresFitting.cs

    r11375 r11699  
    5353
    5454    public double CalculateError(double[] dataPoints, double p0, double p1) {
    55       double r = 0.0;
     55      double r;
    5656      double avgy = dataPoints.Average();
    5757      double sstot = 0.0;
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/LogFitting.cs

    r11375 r11699  
    2626  public class LogFitting : IFitting {
    2727    private void LogFunc(double[] c, double[] x, ref double func, object obj) {
    28       func = c[0] * System.Math.Exp(c[1] / x[0]);
     28      func = c[0] * Math.Exp(c[1] / x[0]);
    2929    }
    3030
     
    7474
    7575      for (int i = 0; i < stdX.Count(); i++) {
    76         newRow.Values.Add(c0 * System.Math.Exp(c1 / stdX[i]));
     76        newRow.Values.Add(c0 * Math.Exp(c1 / stdX[i]));
    7777      }
    7878
     
    8686
    8787      for (int i = 0; i < x.Count(); i++) {
    88         newRow.Values.Add(c0 * System.Math.Exp(c1 / x[i]));
     88        newRow.Values.Add(c0 * Math.Exp(c1 / x[i]));
    8989      }
    9090
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeDetermination.cs

    r11692 r11699  
    3838      var confInterval = samples.ConfidenceIntervals(0.95);
    3939      double e = (confInterval.Item2 - confInterval.Item1) / 2;
    40       double s = samples.EstimatedStandardDeviation();
     40      double s = samples.StandardDeviation();
    4141      double z = alglib.invnormaldistribution((conf + 1) / 2);
    4242      double n = samples.Count();
     
    5656      var confInterval = samples.ConfidenceIntervals(0.95);
    5757      double e = (confInterval.Item2 - confInterval.Item1) / 2;
    58       double s = samples.EstimatedStandardDeviation();
     58      double s = samples.StandardDeviation();
    5959      double z = alglib.invnormaldistribution((conf + 1) / 2);
    6060
  • branches/StatisticalTesting/Statistics.UnitTests/Statistics.UnitTests.csproj

    r11625 r11699  
    6565  </Choose>
    6666  <ItemGroup>
     67    <Compile Include="BonferroniHolmUnitTests.cs" />
    6768    <Compile Include="KruskalWallisUnitTests.cs" />
    6869    <Compile Include="Properties\AssemblyInfo.cs" />
    69     <Compile Include="BonferroniHolmUnitTest.cs" />
     70    <Compile Include="ConfidenceIntervalsTests.cs" />
    7071  </ItemGroup>
    7172  <ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.