Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/14 12:47:54 (10 years ago)
Author:
sbreuer
Message:
  • selected average and co. implemented
  • SelectionChanged NullPointer fixed
File:
1 edited

Legend:

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

    r10663 r10809  
    7373    }
    7474
    75     public T GetMin<T>(int columnIndex) where T : IComparable<T> {
    76       return preprocessingData.GetValues<T>(columnIndex).Min();
     75    public T GetMin<T>(int columnIndex, bool considerSelection) where T : IComparable<T> {
     76      return preprocessingData.GetValues<T>(columnIndex, considerSelection).Min();
    7777    }
    7878
    79     public T GetMax<T>(int columnIndex) where T : IComparable<T> {
    80       return preprocessingData.GetValues<T>(columnIndex).Max();
     79    public T GetMax<T>(int columnIndex, bool considerSelection) where T : IComparable<T> {
     80      return preprocessingData.GetValues<T>(columnIndex, considerSelection).Max();
    8181    }
    8282
    83     public double GetMedian(int columnIndex) {
     83    public double GetMedian(int columnIndex, bool considerSelection) {
    8484      double median = double.NaN;
    8585      if (preprocessingData.IsType<double>(columnIndex)) {
    86         median = GetValuesWithoutNaN<double>(columnIndex).Median();
     86        median = GetValuesWithoutNaN<double>(columnIndex, considerSelection).Median();
    8787      }
    8888      return median;
    8989    }
    9090
    91     public double GetAverage(int columnIndex) {
     91    public double GetAverage(int columnIndex, bool considerSelection) {
    9292      double avg = double.NaN;
    9393      if (preprocessingData.IsType<double>(columnIndex)) {
    94         avg = GetValuesWithoutNaN<double>(columnIndex).Average();
     94        avg = GetValuesWithoutNaN<double>(columnIndex, considerSelection).Average();
    9595      }
    9696      return avg;
    9797    }
    9898
    99     public DateTime GetMedianDateTime(int columnIndex) {
     99    public DateTime GetMedianDateTime(int columnIndex, bool considerSelection) {
    100100      DateTime median = new DateTime();
    101101      if (preprocessingData.IsType<DateTime>(columnIndex)) {
    102         median = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex).Median());
     102        median = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex, considerSelection).Median());
    103103      }
    104104      return median;
    105105    }
    106106
    107     public DateTime GetAverageDateTime(int columnIndex) {
     107    public DateTime GetAverageDateTime(int columnIndex, bool considerSelection) {
    108108      DateTime avg = new DateTime();
    109109      if (preprocessingData.IsType<DateTime>(columnIndex)) {
    110         avg = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex).Average());
     110        avg = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex, considerSelection).Average());
    111111      }
    112112      return avg;
    113113    }
    114114
    115     public T GetMostCommonValue<T>(int columnIndex) {
    116       var t = preprocessingData.GetValues<T>(columnIndex);
     115    public T GetMostCommonValue<T>(int columnIndex, bool considerSelection) {
     116      var t = preprocessingData.GetValues<T>(columnIndex, considerSelection);
    117117      var t2 = t.GroupBy(x => x);
    118118      var t3 = t2.Select(g => g.Key);
    119119
    120       return preprocessingData.GetValues<T>(columnIndex)
     120      return preprocessingData.GetValues<T>(columnIndex, considerSelection)
    121121                              .GroupBy(x => x)
    122122                              .OrderByDescending(g => g.Count())
     
    129129      double stdDev = double.NaN;
    130130      if (preprocessingData.IsType<double>(columnIndex)) {
    131         stdDev = GetValuesWithoutNaN<double>(columnIndex).StandardDeviation();
     131        stdDev = GetValuesWithoutNaN<double>(columnIndex, false).StandardDeviation();
    132132      } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
    133         stdDev = GetDateTimeAsSeconds(columnIndex).StandardDeviation();
     133        stdDev = GetDateTimeAsSeconds(columnIndex, false).StandardDeviation();
    134134      }
    135135      return stdDev;
     
    139139      double variance = double.NaN;
    140140      if (preprocessingData.IsType<double>(columnIndex)) {
    141         variance = preprocessingData.GetValues<double>(columnIndex).Variance();
     141        variance = preprocessingData.GetValues<double>(columnIndex, false).Variance();
    142142      } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
    143         variance = GetDateTimeAsSeconds(columnIndex).Variance();
     143        variance = GetDateTimeAsSeconds(columnIndex, false).Variance();
    144144      }
    145145      return variance;
     
    147147
    148148    public int GetDifferentValuesCount<T>(int columnIndex) {
    149       return preprocessingData.GetValues<T>(columnIndex).GroupBy(x => x).Count();
     149      return preprocessingData.GetValues<T>(columnIndex, false).GroupBy(x => x).Count();
    150150    }
    151151
     
    179179    }
    180180
    181     private IEnumerable<double> GetDateTimeAsSeconds(int columnIndex) {
    182       return GetValuesWithoutNaN<DateTime>(columnIndex).Select(x => (double)x.Ticks / TimeSpan.TicksPerSecond);
     181    private IEnumerable<double> GetDateTimeAsSeconds(int columnIndex, bool considerSelection) {
     182      return GetValuesWithoutNaN<DateTime>(columnIndex, considerSelection).Select(x => (double)x.Ticks / TimeSpan.TicksPerSecond);
    183183    }
    184184
    185     private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex) {
    186       return searchLogic.GetValuesWithoutNaN<T>(columnIndex);
     185    private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection) {
     186      return searchLogic.GetValuesWithoutNaN<T>(columnIndex, considerSelection);
    187187    }
    188188
Note: See TracChangeset for help on using the changeset viewer.