Program: 56806
Project: 56806
Buggy source:
/** 
 * Normalize all columns in the tablet, based on values of all dimensions. For a numerical dimension, this would mean, that global minima and maxima are retrieved instead of local ones (as is done with normalize()) Operates with the raw data as basis by default, however when a logarithmized representation is in the dimension this is used. Make sure that all dimensions are logarithmized.
 */
@Override protected void normalize(){
  if (numericalProperties != null && numericalProperties.getImputeDescription() != null)   performImputation(numericalProperties.getImputeDescription());
  datasetStatistics=computeTableStats();
  if (numericalProperties != null && NumericalProperties.ZSCORE_ROWS.equals(numericalProperties.getzScoreNormalization())) {
    DoubleStatistics.Builder postStats=DoubleStatistics.builder();
    for (int rowCount=0; rowCount < getNrRows(); rowCount++) {
      DoubleStatistics stats=computeRowStats(rowCount);
      for (      AColumn<?,?> column : columns) {
        @SuppressWarnings("String_Node_Str") NumericalColumn<?,Float> nColumn=(NumericalColumn<?,Float>)column;
        double zScore=((nColumn.getRaw(rowCount)) - stats.getMean()) / stats.getSd();
        nColumn.setRaw(rowCount,(float)zScore);
        postStats.add(zScore);
      }
    }
    datasetStatistics=postStats.build();
  }
 else   if (numericalProperties != null && NumericalProperties.ZSCORE_COLUMNS.equals(numericalProperties.getzScoreNormalization())) {
    DoubleStatistics.Builder postStats=DoubleStatistics.builder();
    for (    AColumn<?,?> column : columns) {
      @SuppressWarnings("String_Node_Str") NumericalColumn<?,Float> nColumn=(NumericalColumn<?,Float>)column;
      DoubleStatistics stats=computeColumnStats(nColumn);
      for (int rowCount=0; rowCount < getNrRows(); rowCount++) {
        double zScore=((nColumn.getRaw(rowCount)) - stats.getMean()) / stats.getSd();
        nColumn.setRaw(rowCount,(float)zScore);
        postStats.add(zScore);
      }
    }
    datasetStatistics=postStats.build();
  }
  if (numericalProperties != null && numericalProperties.getClipToStdDevFactor() != null) {
    float nrDevs=numericalProperties.getClipToStdDevFactor();
    setMax(datasetStatistics.getMean() + nrDevs * datasetStatistics.getSd());
    setMin(datasetStatistics.getMean() - nrDevs * datasetStatistics.getSd());
    if (dataCenter == null) {
      if (min < 0 && max > 0)       dataCenter=0d;
    }
  }
  for (  AColumn<?,?> column : columns) {
    NumericalColumn<?,?> nColumn=(NumericalColumn<?,?>)column;
    nColumn.setExternalMin(getMin());
    nColumn.setExternalMax(getMax());
    nColumn.normalize();
    nColumn.log2();
    nColumn.log10();
  }
  ColorMapper mapper=getColorMapper();
  ColorMarkerPoint point=mapper.getMarkerPoints().get(0);
  double raw=datasetStatistics.getMean() - 3 * datasetStatistics.getSd();
  float normalized=(float)getNormalizedForRaw(defaultDataTransformation,raw);
  if (normalized < 0)   normalized=0;
  point.setRightSpread(normalized);
  point=mapper.getMarkerPoints().get(mapper.getMarkerPoints().size() - 1);
  raw=datasetStatistics.getMean() + 3 * datasetStatistics.getSd();
  normalized=(float)getNormalizedForRaw(defaultDataTransformation,raw);
  float distance=1 - normalized;
  if (distance < 0)   distance=0;
  point.setLeftSpread(distance);
  mapper.update();
}

Fixed version (ground truth):
/** 
 * Normalize all columns in the tablet, based on values of all dimensions. For a numerical dimension, this would mean, that global minima and maxima are retrieved instead of local ones (as is done with normalize()) Operates with the raw data as basis by default, however when a logarithmized representation is in the dimension this is used. Make sure that all dimensions are logarithmized.
 */
@Override protected void normalize(){
  if (numericalProperties != null && numericalProperties.getImputeDescription() != null)   performImputation(numericalProperties.getImputeDescription());
  if (numericalProperties != null && NumericalProperties.ZSCORE_ROWS.equals(numericalProperties.getzScoreNormalization())) {
    DoubleStatistics.Builder postStats=DoubleStatistics.builder();
    for (int rowCount=0; rowCount < getNrRows(); rowCount++) {
      DoubleStatistics stats=computeRowStats(rowCount);
      for (      AColumn<?,?> column : columns) {
        @SuppressWarnings("String_Node_Str") NumericalColumn<?,Float> nColumn=(NumericalColumn<?,Float>)column;
        double zScore=((nColumn.getRaw(rowCount)) - stats.getMean()) / stats.getSd();
        nColumn.setRaw(rowCount,(float)zScore);
        postStats.add(zScore);
      }
    }
    datasetStatistics=postStats.build();
  }
 else   if (numericalProperties != null && NumericalProperties.ZSCORE_COLUMNS.equals(numericalProperties.getzScoreNormalization())) {
    DoubleStatistics.Builder postStats=DoubleStatistics.builder();
    for (    AColumn<?,?> column : columns) {
      @SuppressWarnings("String_Node_Str") NumericalColumn<?,Float> nColumn=(NumericalColumn<?,Float>)column;
      DoubleStatistics stats=computeColumnStats(nColumn);
      for (int rowCount=0; rowCount < getNrRows(); rowCount++) {
        double zScore=((nColumn.getRaw(rowCount)) - stats.getMean()) / stats.getSd();
        nColumn.setRaw(rowCount,(float)zScore);
        postStats.add(zScore);
      }
    }
    datasetStatistics=postStats.build();
  }
 else {
    datasetStatistics=computeTableStats();
  }
  if (numericalProperties != null && numericalProperties.getClipToStdDevFactor() != null) {
    float nrDevs=numericalProperties.getClipToStdDevFactor();
    setMax(datasetStatistics.getMean() + nrDevs * datasetStatistics.getSd());
    setMin(datasetStatistics.getMean() - nrDevs * datasetStatistics.getSd());
    if (dataCenter == null) {
      if (min < 0 && max > 0)       dataCenter=0d;
    }
  }
  for (  AColumn<?,?> column : columns) {
    NumericalColumn<?,?> nColumn=(NumericalColumn<?,?>)column;
    nColumn.setExternalMin(getMin());
    nColumn.setExternalMax(getMax());
    nColumn.normalize();
    nColumn.log2();
    nColumn.log10();
  }
  ColorMapper mapper=getColorMapper();
  ColorMarkerPoint point=mapper.getMarkerPoints().get(0);
  double raw=datasetStatistics.getMean() - 3 * datasetStatistics.getSd();
  float normalized=(float)getNormalizedForRaw(defaultDataTransformation,raw);
  if (normalized < 0)   normalized=0;
  point.setRightSpread(normalized);
  point=mapper.getMarkerPoints().get(mapper.getMarkerPoints().size() - 1);
  raw=datasetStatistics.getMean() + 3 * datasetStatistics.getSd();
  normalized=(float)getNormalizedForRaw(defaultDataTransformation,raw);
  float distance=1 - normalized;
  if (distance < 0)   distance=0;
  point.setLeftSpread(distance);
  mapper.update();
}