Program: 144072
Project: 144072
Buggy source:
public ErrorEstimationDomainsFastHDPMixedGraphicalModel(List<boolean[][]> functionOutputs,int numberOfIterations,int thinning,double alpha){
  this.alpha=alpha;
  this.numberOfIterations=numberOfIterations;
  burnInIterations=numberOfIterations * 9 / 10;
  this.thinning=thinning;
  numberOfFunctions=functionOutputs.get(0)[0].length;
  numberOfDomains=functionOutputs.size();
  numberOfDataSamples=new int[numberOfDomains];
  functionOutputsArray=new int[numberOfFunctions][numberOfDomains][];
  for (int p=0; p < numberOfDomains; p++) {
    numberOfDataSamples[p]=functionOutputs.get(p).length;
    for (int j=0; j < numberOfFunctions; j++) {
      functionOutputsArray[j][p]=new int[numberOfDataSamples[p]];
      for (int i=0; i < numberOfDataSamples[p]; i++)       functionOutputsArray[j][p][i]=functionOutputs.get(p)[i][j] ? 1 : 0;
    }
  }
  hdp=new FastHDPPrior(numberOfDomains,numberOfFunctions,alpha,gamma);
  numberOfSamples=(numberOfIterations - burnInIterations) / thinning;
  priorSamples=new double[numberOfSamples][numberOfDomains];
  errorRateSamples=new double[numberOfSamples][numberOfDomains * numberOfFunctions];
  zSamples=new int[numberOfSamples][numberOfDomains][numberOfFunctions];
  labelsSamples=new int[numberOfSamples][numberOfDomains][];
  disagreements=new double[numberOfFunctions][numberOfDomains];
  sum_1=new double[numberOfDomains * numberOfFunctions];
  sum_2=new double[numberOfDomains * numberOfFunctions];
  priorMeans=new double[numberOfDomains];
  priorVariances=new double[numberOfDomains];
  labelMeans=new double[numberOfDomains][];
  labelVariances=new double[numberOfDomains][];
  errorRateMeans=new double[numberOfDomains][numberOfFunctions];
  errorRateVariances=new double[numberOfDomains][numberOfFunctions];
  for (int p=0; p < numberOfDomains; p++) {
    labelMeans[p]=new double[numberOfDataSamples[p]];
    labelVariances[p]=new double[numberOfDataSamples[p]];
    priorSamples[0][p]=0.5;
    labelsSamples[0][p]=new int[numberOfDataSamples[p]];
    for (int i=0; i < numberOfDataSamples[p]; i++)     labelsSamples[0][p][i]=randomDataGenerator.nextBinomial(1,0.5);
    for (int j=0; j < numberOfFunctions; j++) {
      zSamples[0][p][j]=0;
      hdp.add_items_table_assignment(p,j,0,0);
      errorRateSamples[0][p * numberOfFunctions + j]=0.25;
      disagreements[j][p]=0;
      for (int i=0; i < numberOfDataSamples[p]; i++)       if (functionOutputsArray[j][p][i] != labelsSamples[0][p][i])       disagreements[j][p]++;
    }
  }
  for (int k=0; k < numberOfDomains * numberOfFunctions; k++) {
    sum_1[k]=0;
    sum_2[k]=0;
    for (int j=0; j < numberOfFunctions; j++) {
      for (int p=0; p < numberOfDomains; p++) {
        if (zSamples[0][p][j] == k) {
          sum_1[k]+=numberOfDataSamples[p];
          sum_2[k]+=disagreements[j][p];
        }
      }
    }
  }
}

Fixed version (ground truth):
public ErrorEstimationDomainsFastHDPMixedGraphicalModel(List<boolean[][]> functionOutputs,int numberOfIterations,int thinning,double alpha,double gamma){
  this.alpha=alpha;
  this.gamma=gamma;
  this.numberOfIterations=numberOfIterations;
  burnInIterations=numberOfIterations * 9 / 10;
  this.thinning=thinning;
  numberOfFunctions=functionOutputs.get(0)[0].length;
  numberOfDomains=functionOutputs.size();
  numberOfDataSamples=new int[numberOfDomains];
  functionOutputsArray=new int[numberOfFunctions][numberOfDomains][];
  for (int p=0; p < numberOfDomains; p++) {
    numberOfDataSamples[p]=functionOutputs.get(p).length;
    for (int j=0; j < numberOfFunctions; j++) {
      functionOutputsArray[j][p]=new int[numberOfDataSamples[p]];
      for (int i=0; i < numberOfDataSamples[p]; i++)       functionOutputsArray[j][p][i]=functionOutputs.get(p)[i][j] ? 1 : 0;
    }
  }
  hdp=new FastHDPPrior(numberOfDomains,numberOfFunctions,alpha,gamma);
  numberOfSamples=(numberOfIterations - burnInIterations) / thinning;
  priorSamples=new double[numberOfSamples][numberOfDomains];
  errorRateSamples=new double[numberOfSamples][numberOfDomains * numberOfFunctions];
  zSamples=new int[numberOfSamples][numberOfDomains][numberOfFunctions];
  labelsSamples=new int[numberOfSamples][numberOfDomains][];
  disagreements=new double[numberOfFunctions][numberOfDomains];
  sum_1=new double[numberOfDomains * numberOfFunctions];
  sum_2=new double[numberOfDomains * numberOfFunctions];
  priorMeans=new double[numberOfDomains];
  priorVariances=new double[numberOfDomains];
  labelMeans=new double[numberOfDomains][];
  labelVariances=new double[numberOfDomains][];
  errorRateMeans=new double[numberOfDomains][numberOfFunctions];
  errorRateVariances=new double[numberOfDomains][numberOfFunctions];
  for (int p=0; p < numberOfDomains; p++) {
    labelMeans[p]=new double[numberOfDataSamples[p]];
    labelVariances[p]=new double[numberOfDataSamples[p]];
    priorSamples[0][p]=0.5;
    labelsSamples[0][p]=new int[numberOfDataSamples[p]];
    for (int i=0; i < numberOfDataSamples[p]; i++)     labelsSamples[0][p][i]=randomDataGenerator.nextBinomial(1,0.5);
    for (int j=0; j < numberOfFunctions; j++) {
      zSamples[0][p][j]=0;
      hdp.add_items_table_assignment(p,j,0,0);
      errorRateSamples[0][p * numberOfFunctions + j]=0.25;
      disagreements[j][p]=0;
      for (int i=0; i < numberOfDataSamples[p]; i++)       if (functionOutputsArray[j][p][i] != labelsSamples[0][p][i])       disagreements[j][p]++;
    }
  }
  for (int k=0; k < numberOfDomains * numberOfFunctions; k++) {
    sum_1[k]=0;
    sum_2[k]=0;
    for (int j=0; j < numberOfFunctions; j++) {
      for (int p=0; p < numberOfDomains; p++) {
        if (zSamples[0][p][j] == k) {
          sum_1[k]+=numberOfDataSamples[p];
          sum_2[k]+=disagreements[j][p];
        }
      }
    }
  }
}