Program: 143972
Project: 143972
Buggy source:
public BayesianCombinationOfClassifiers(List<boolean[][]> functionOutputs,int numberOfBurnInSamples,int numberOfThinningSamples,int numberOfSamples,double alpha){
  this.numberOfBurnInSamples=numberOfBurnInSamples;
  this.numberOfThinningSamples=numberOfThinningSamples;
  this.numberOfSamples=numberOfSamples;
  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;
    }
  }
  dpPriors=new DirichletProcess[numberOfDomains];
  labelsSamples=new int[numberOfSamples][numberOfDomains][];
  labelPriorsSamples=new double[numberOfSamples][numberOfDomains];
  labelPriorsCounts=new double[numberOfDomains][2];
  confusionMatrixSamples=new double[numberOfSamples][numberOfDomains][numberOfFunctions][2][2];
  confusionMatrixCounts=new double[numberOfDomains][numberOfFunctions][2][2];
  clusterAssignmentSamples=new int[numberOfSamples][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 sampleIndex=0; sampleIndex < numberOfSamples; sampleIndex++)   for (int p=0; p < numberOfDomains; p++)   labelsSamples[sampleIndex][p]=new int[numberOfDataSamples[p]];
  for (int p=0; p < numberOfDomains; p++) {
    labelMeans[p]=new double[numberOfDataSamples[p]];
    labelVariances[p]=new double[numberOfDataSamples[p]];
    dpPriors[p]=new DirichletProcess(alpha,numberOfFunctions);
    labelPriorsSamples[0][p]=0.5;
    for (int j=0; j < numberOfFunctions; j++) {
      clusterAssignmentSamples[0][p][j]=0;
      dpPriors[p].addMemberToCluster(clusterAssignmentSamples[0][p][j]);
    }
    for (int i=0; i < numberOfDataSamples[p]; i++) {
      int sum=0;
      for (int j=0; j < numberOfFunctions; j++)       sum+=functionOutputsArray[j][p][i];
      labelsSamples[0][p][i]=sum >= (numberOfFunctions / 2) ? 1 : 0;
      updateCountsAfterSamplingLabel(0,p,i);
    }
  }
  samplePriors(0);
  for (int p=0; p < numberOfDomains; p++) {
    for (int j=0; j < numberOfFunctions; j++) {
      confusionMatrixSamples[0][p][0][0][0]=randomDataGenerator.nextBeta(confusionMatrixPrior[0][0] + confusionMatrixCounts[p][0][0][0],confusionMatrixPrior[0][1] + confusionMatrixCounts[p][0][0][1]);
      confusionMatrixSamples[0][p][0][1][0]=randomDataGenerator.nextBeta(confusionMatrixPrior[1][0] + confusionMatrixCounts[p][0][1][0],confusionMatrixPrior[1][1] + confusionMatrixCounts[p][0][1][1]);
      confusionMatrixSamples[0][p][0][0][1]=1 - confusionMatrixSamples[0][p][0][0][0];
      confusionMatrixSamples[0][p][0][1][1]=1 - confusionMatrixSamples[0][p][0][1][0];
    }
  }
}

Fixed version (ground truth):
public BayesianCombinationOfClassifiers(List<boolean[][]> functionOutputs,int numberOfBurnInSamples,int numberOfThinningSamples,int numberOfSamples,double alpha){
  this.numberOfBurnInSamples=numberOfBurnInSamples;
  this.numberOfThinningSamples=numberOfThinningSamples;
  this.numberOfSamples=numberOfSamples;
  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;
    }
  }
  dpPriors=new DirichletProcess[numberOfDomains];
  labelsSamples=new int[numberOfSamples][numberOfDomains][];
  labelPriorsSamples=new double[numberOfSamples][numberOfDomains];
  labelPriorsCounts=new double[numberOfDomains][2];
  confusionMatrixSamples=new double[numberOfSamples][numberOfDomains][numberOfFunctions][2][2];
  confusionMatrixCounts=new double[numberOfDomains][numberOfFunctions][2][2];
  clusterAssignmentSamples=new int[numberOfSamples][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 sampleIndex=0; sampleIndex < numberOfSamples; sampleIndex++)   for (int p=0; p < numberOfDomains; p++)   labelsSamples[sampleIndex][p]=new int[numberOfDataSamples[p]];
  for (int p=0; p < numberOfDomains; p++) {
    labelMeans[p]=new double[numberOfDataSamples[p]];
    labelVariances[p]=new double[numberOfDataSamples[p]];
    dpPriors[p]=new DirichletProcess(alpha,numberOfFunctions);
    labelPriorsSamples[0][p]=0.5;
    for (int j=0; j < numberOfFunctions; j++) {
      clusterAssignmentSamples[0][p][j]=0;
      dpPriors[p].addMemberToCluster(clusterAssignmentSamples[0][p][j]);
    }
    for (int i=0; i < numberOfDataSamples[p]; i++) {
      int sum=0;
      for (int j=0; j < numberOfFunctions; j++)       sum+=functionOutputsArray[j][p][i];
      labelsSamples[0][p][i]=sum >= (numberOfFunctions / 2) ? 1 : 0;
      updateCountsAfterSamplingLabel(0,p,i);
    }
  }
  samplePriors(0);
  sampleConfusionMatrix(0);
}