Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/11/13 13:24:04 (11 years ago)
Author:
rstoll
Message:

Exchanged own median, standard deviation implementation with the one in the common lib
Added GetVariance (using common as well)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticInfo.cs

    r10191 r10216  
    11using System;
    22using System.Linq;
     3using HeuristicLab.Common;
    34
    45namespace HeuristicLab.DataPreprocessing {
     
    5758      double median = double.NaN;
    5859      if (preprocessingData.IsType<double>(variableName)) {
    59         median = preprocessingData.GetValues<double>(variableName).OrderBy(x => x).ElementAt(preprocessingData.Rows / 2);
     60        median = preprocessingData.GetValues<double>(variableName).Median();
    6061      }
    6162      return median;
     
    8283      double stdDev = double.NaN;
    8384      if (preprocessingData.IsType<double>(variableName)) {
    84         double avg = GetAverage(variableName);
    85         stdDev = Math.Sqrt(preprocessingData.GetValues<double>(variableName).Sum(x => (x - avg) * (x - avg)) / (preprocessingData.Rows - 1));
     85        stdDev = preprocessingData.GetValues<double>(variableName).StandardDeviation();
     86      }
     87      return stdDev;
     88    }
     89
     90    public double GetVariance(string variableName) {
     91      double stdDev = double.NaN;
     92      if (preprocessingData.IsType<double>(variableName)) {
     93        stdDev = preprocessingData.GetValues<double>(variableName).Variance();
    8694      }
    8795      return stdDev;
Note: See TracChangeset for help on using the changeset viewer.