Index: trunk/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs
===================================================================
--- trunk/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs	(revision 1784)
+++ trunk/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs	(revision 1786)
@@ -52,5 +52,5 @@
     public int Columns {
       get { return columns; }
-      set { 
+      set {
         columns = value;
         if (variableNames == null || variableNames.Length != columns) {
@@ -72,5 +72,5 @@
 
     public void SetValue(int i, int j, double v) {
-      if(v != samples[columns * i + j]) {
+      if (v != samples[columns * i + j]) {
         samples[columns * i + j] = v;
         CreateDictionaries();
@@ -84,5 +84,5 @@
         scalingFactor = new double[columns];
         scalingOffset = new double[columns];
-        for(int i = 0; i < scalingFactor.Length; i++) {
+        for (int i = 0; i < scalingFactor.Length; i++) {
           scalingFactor[i] = 1.0;
           scalingOffset[i] = 0.0;
@@ -110,5 +110,5 @@
       cachedMeans = new Dictionary<int, Dictionary<int, double>>[columns];
       cachedRanges = new Dictionary<int, Dictionary<int, double>>[columns];
-      for(int i = 0; i < columns; i++) {
+      for (int i = 0; i < columns; i++) {
         cachedMeans[i] = new Dictionary<int, Dictionary<int, double>>();
         cachedRanges[i] = new Dictionary<int, Dictionary<int, double>>();
@@ -176,23 +176,23 @@
 
       variableNames = ParseVariableNamesString(node.Attributes["VariableNames"].Value);
-      if(node.Attributes["ScalingFactors"] != null)
+      if (node.Attributes["ScalingFactors"] != null)
         scalingFactor = ParseDoubleString(node.Attributes["ScalingFactors"].Value);
       else {
         scalingFactor = new double[columns]; // compatibility with old serialization format
-        for(int i = 0; i < scalingFactor.Length; i++) scalingFactor[i] = 1.0;
-      }
-      if(node.Attributes["ScalingOffsets"] != null)
+        for (int i = 0; i < scalingFactor.Length; i++) scalingFactor[i] = 1.0;
+      }
+      if (node.Attributes["ScalingOffsets"] != null)
         scalingOffset = ParseDoubleString(node.Attributes["ScalingOffsets"].Value);
       else {
         scalingOffset = new double[columns]; // compatibility with old serialization format
-        for(int i = 0; i < scalingOffset.Length; i++) scalingOffset[i] = 0.0;
+        for (int i = 0; i < scalingOffset.Length; i++) scalingOffset[i] = 0.0;
       }
 
       string[] tokens = node.InnerText.Split(';');
-      if(tokens.Length != rows * columns) throw new FormatException();
+      if (tokens.Length != rows * columns) throw new FormatException();
       samples = new double[rows * columns];
-      for(int row = 0; row < rows; row++) {
-        for(int column = 0; column < columns; column++) {
-          if(double.TryParse(tokens[row * columns + column], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out samples[row * columns + column]) == false) {
+      for (int row = 0; row < rows; row++) {
+        for (int column = 0; column < columns; column++) {
+          if (double.TryParse(tokens[row * columns + column], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out samples[row * columns + column]) == false) {
             throw new FormatException("Can't parse " + tokens[row * columns + column] + " as double value.");
           }
@@ -208,11 +208,11 @@
     private string ToString(NumberFormatInfo format) {
       StringBuilder builder = new StringBuilder();
-      for(int row = 0; row < rows; row++) {
-        for(int column = 0; column < columns; column++) {
+      for (int row = 0; row < rows; row++) {
+        for (int column = 0; column < columns; column++) {
           builder.Append(";");
           builder.Append(samples[row * columns + column].ToString("r", format));
         }
       }
-      if(builder.Length > 0) builder.Remove(0, 1);
+      if (builder.Length > 0) builder.Remove(0, 1);
       return builder.ToString();
     }
@@ -220,9 +220,9 @@
     private string GetVariableNamesString() {
       string s = "";
-      for(int i = 0; i < variableNames.Length; i++) {
+      for (int i = 0; i < variableNames.Length; i++) {
         s += variableNames[i] + "; ";
       }
 
-      if(variableNames.Length > 0) {
+      if (variableNames.Length > 0) {
         s = s.TrimEnd(';', ' ');
       }
@@ -231,9 +231,9 @@
     private string GetString(double[] xs) {
       string s = "";
-      for(int i = 0; i < xs.Length; i++) {
+      for (int i = 0; i < xs.Length; i++) {
         s += xs[i].ToString("r", CultureInfo.InvariantCulture) + "; ";
       }
 
-      if(xs.Length > 0) {
+      if (xs.Length > 0) {
         s = s.TrimEnd(';', ' ');
       }
@@ -244,5 +244,5 @@
       p = p.Trim();
       string[] tokens = p.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
-      for(int i = 0; i < tokens.Length; i++) tokens[i] = tokens[i].Trim();
+      for (int i = 0; i < tokens.Length; i++) tokens[i] = tokens[i].Trim();
       return tokens;
     }
@@ -251,5 +251,5 @@
       string[] ss = s.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
       double[] xs = new double[ss.Length];
-      for(int i = 0; i < xs.Length; i++) {
+      for (int i = 0; i < xs.Length; i++) {
         xs[i] = double.Parse(ss[i], CultureInfo.InvariantCulture);
       }
@@ -262,11 +262,11 @@
 
     public double GetMean(int column, int from, int to) {
-      if(!cachedMeans[column].ContainsKey(from) || !cachedMeans[column][from].ContainsKey(to)) {
+      if (!cachedMeans[column].ContainsKey(from) || !cachedMeans[column][from].ContainsKey(to)) {
         double[] values = new double[to - from];
-        for(int sample = from; sample < to; sample++) {
+        for (int sample = from; sample < to; sample++) {
           values[sample - from] = GetValue(sample, column);
         }
         double mean = Statistics.Mean(values);
-        if(!cachedMeans[column].ContainsKey(from)) cachedMeans[column][from] = new Dictionary<int, double>();
+        if (!cachedMeans[column].ContainsKey(from)) cachedMeans[column][from] = new Dictionary<int, double>();
         cachedMeans[column][from][to] = mean;
         return mean;
@@ -281,11 +281,11 @@
 
     public double GetRange(int column, int from, int to) {
-      if(!cachedRanges[column].ContainsKey(from) || !cachedRanges[column][from].ContainsKey(to)) {
+      if (!cachedRanges[column].ContainsKey(from) || !cachedRanges[column][from].ContainsKey(to)) {
         double[] values = new double[to - from];
-        for(int sample = from; sample < to; sample++) {
+        for (int sample = from; sample < to; sample++) {
           values[sample - from] = GetValue(sample, column);
         }
         double range = Statistics.Range(values);
-        if(!cachedRanges[column].ContainsKey(from)) cachedRanges[column][from] = new Dictionary<int, double>();
+        if (!cachedRanges[column].ContainsKey(from)) cachedRanges[column][from] = new Dictionary<int, double>();
         cachedRanges[column][from][to] = range;
         return range;
@@ -297,7 +297,7 @@
     public double GetMaximum(int column) {
       double max = Double.NegativeInfinity;
-      for(int i = 0; i < Rows; i++) {
+      for (int i = 0; i < Rows; i++) {
         double val = GetValue(i, column);
-        if(val > max) max = val;
+        if (!double.IsNaN(val) && val > max) max = val;
       }
       return max;
@@ -306,7 +306,7 @@
     public double GetMinimum(int column) {
       double min = Double.PositiveInfinity;
-      for(int i = 0; i < Rows; i++) {
+      for (int i = 0; i < Rows; i++) {
         double val = GetValue(i, column);
-        if(val < min) min = val;
+        if (!double.IsNaN(val) && val < min) min = val;
       }
       return min;
@@ -314,9 +314,9 @@
 
     internal void ScaleVariable(int column) {
-      if(scalingFactor[column] == 1.0 && scalingOffset[column] == 0.0) {
+      if (scalingFactor[column] == 1.0 && scalingOffset[column] == 0.0) {
         double min = GetMinimum(column);
         double max = GetMaximum(column);
         double range = max - min;
-        if(range == 0) ScaleVariable(column, 1.0, -min);
+        if (range == 0) ScaleVariable(column, 1.0, -min);
         else ScaleVariable(column, 1.0 / range, -min);
       }
@@ -328,5 +328,5 @@
       scalingFactor[column] = factor;
       scalingOffset[column] = offset;
-      for(int i = 0; i < Rows; i++) {
+      for (int i = 0; i < Rows; i++) {
         double origValue = samples[i * columns + column];
         samples[i * columns + column] = (origValue + offset) * factor;
@@ -337,6 +337,6 @@
 
     internal void UnscaleVariable(int column) {
-      if(scalingFactor[column] != 1.0 || scalingOffset[column]!=0.0) {
-        for(int i = 0; i < rows; i++) {
+      if (scalingFactor[column] != 1.0 || scalingOffset[column] != 0.0) {
+        for (int i = 0; i < rows; i++) {
           double scaledValue = samples[i * columns + column];
           samples[i * columns + column] = scaledValue / scalingFactor[column] - scalingOffset[column];
Index: trunk/sources/HeuristicLab.DataAnalysis/3.2/Statistics.cs
===================================================================
--- trunk/sources/HeuristicLab.DataAnalysis/3.2/Statistics.cs	(revision 1784)
+++ trunk/sources/HeuristicLab.DataAnalysis/3.2/Statistics.cs	(revision 1786)
@@ -41,7 +41,7 @@
       T minimum = enumerator.Current;
 
-      while(enumerator.MoveNext()) {
+      while (enumerator.MoveNext()) {
         T current = enumerator.Current;
-        if(current.CompareTo(minimum) < 0) {
+        if (current.CompareTo(minimum) < 0) {
           minimum = current;
         }
@@ -65,7 +65,7 @@
       T maximum = enumerator.Current;
 
-      while(enumerator.MoveNext()) {
+      while (enumerator.MoveNext()) {
         T current = enumerator.Current;
-        if(current.CompareTo(maximum) > 0) {
+        if (current.CompareTo(maximum) > 0) {
           maximum = current;
         }
@@ -99,5 +99,5 @@
     /// <returns></returns>
     public static double Range(double[] values, int start, int end) {
-      if(start < 0 || start > values.Length || end < 0 || end > values.Length || start > end) {
+      if (start < 0 || start > values.Length || end < 0 || end > values.Length || start > end) {
         throw new InvalidOperationException();
       }
@@ -105,10 +105,12 @@
       double minimum = values[start];
       double maximum = minimum;
-      for(int i = start; i < end; i++) {
-        if(values[i] > maximum) {
-          maximum = values[i];
-        }
-        if(values[i] < minimum) {
-          minimum = values[i];
+      for (int i = start; i < end; i++) {
+        if (!double.IsNaN(values[i])) {
+          if (values[i] > maximum) {
+            maximum = values[i];
+          }
+          if (values[i] < minimum) {
+            minimum = values[i];
+          }
         }
       }
@@ -124,6 +126,6 @@
       int n = values.Length;
       double sum = 0.0;
-      for(int i = 0; i < n; i++) {
-        if(double.IsNaN(values[i])) {
+      for (int i = 0; i < n; i++) {
+        if (double.IsNaN(values[i])) {
           throw new NotFiniteNumberException();
         } else {
@@ -156,9 +158,9 @@
     /// <returns></returns>
     public static double Mean(double[] values, int start, int end) {
-      if(values.Length == 0) throw new InvalidOperationException();
+      if (values.Length == 0) throw new InvalidOperationException();
       double sum = 0.0;
       int n = 0;
-      for(int i = start; i < end; i++) {
-        if(!double.IsNaN(values[i])) {
+      for (int i = start; i < end; i++) {
+        if (!double.IsNaN(values[i])) {
           sum += values[i];
           n++;
@@ -175,7 +177,7 @@
     /// <returns></returns>
     public static double Median(double[] values) {
-      if(values.Length == 0) throw new InvalidOperationException();
+      if (values.Length == 0) throw new InvalidOperationException();
       int n = values.Length;
-      if(n == 0)
+      if (n == 0)
         return 0;
 
@@ -186,5 +188,5 @@
 
       // return the middle element (if n is uneven) or the average of the two middle elements if n is even.
-      if(n % 2 == 1) {
+      if (n % 2 == 1) {
         return sortedValues[n / 2];
       } else {
