Ejemplo n.º 1
0
  /** It computes the average and standard deviation of the input attributes */
  private void computeStatistics() {
    stdev = new double[this.getnVars()];
    average = new double[this.getnVars()];
    for (int i = 0; i < this.getnInputs(); i++) {
      average[i] = 0;
      for (int j = 0; j < X[i].length; j++) {
        average[i] += X[i][j];
      }
      average[i] /= X[i].length;
    }

    average[average.length - 1] = 0;
    for (int j = 0; j < outputReal.length; j++) {
      average[average.length - 1] += outputReal[j];
    }
    average[average.length - 1] /= outputReal.length;

    for (int i = 0; i < this.getnInputs(); i++) {
      double sum = 0;
      for (int j = 0; j < X[i].length; j++) {
        sum += (X[i][j] - average[i]) * (X[i][j] - average[i]);
      }
      sum /= X[i].length;
      stdev[i] = Math.sqrt(sum);
    }
    double sum = 0;
    for (int j = 0; j < outputReal.length; j++) {
      sum +=
          (outputReal[j] - average[average.length - 1])
              * (outputReal[j] - average[average.length - 1]);
    }
    sum /= outputReal.length;
    stdev[stdev.length - 1] = Math.sqrt(sum);
  }
Ejemplo n.º 2
0
  /** It computes the average and standard deviation of the input attributes */
  private void computeStatistics() {
    stdev = new double[this.getNvariables()];
    average = new double[this.getNvariables()];

    for (int i = 0; i < this.getnInputs(); i++) {
      average[i] = 0;
      for (int j = 0; j < this.getNdatos(); j++) {
        if (!this.isMissing(j, i)) {
          average[i] += X[j][i];
        }
      }
      average[i] /= this.getNdatos();
    }
    average[average.length - 1] = 0;
    for (int j = 0; j < outputReal.length; j++) {
      average[average.length - 1] += outputReal[j];
    }
    average[average.length - 1] /= outputReal.length;

    for (int i = 0; i < this.getnInputs(); i++) {
      double sum = 0;
      for (int j = 0; j < this.getNdatos(); j++) {
        if (!this.isMissing(j, i)) {
          sum += (X[j][i] - average[i]) * (X[j][i] - average[i]);
        }
      }
      sum /= this.getNdatos();
      stdev[i] = Math.sqrt(sum);
    }

    double sum = 0;
    for (int j = 0; j < outputReal.length; j++) {
      sum +=
          (outputReal[j] - average[average.length - 1])
              * (outputReal[j] - average[average.length - 1]);
    }
    sum /= outputReal.length;
    stdev[stdev.length - 1] = Math.sqrt(sum);
  }