Program: 143984
Project: 143984
Buggy source:
public void runGibbsSampler(){
  for (int sampleIndex=0; sampleIndex < numberOfBurnInSamples; sampleIndex++) {
    samplePriors(0);
    sampleConfusionMatrix(0);
    sampleClusterAssignments(0);
    sampleLabels(0);
  }
  for (int sampleIndex=1; sampleIndex < numberOfSamples; sampleIndex++) {
    for (int i=0; i < numberOfThinningSamples + 1; i++) {
      samplePriors(sampleIndex - 1);
      sampleConfusionMatrix(sampleIndex - 1);
      sampleClusterAssignments(sampleIndex - 1);
      sampleLabels(sampleIndex - 1);
    }
    storeSample(sampleIndex);
  }
  for (int sampleNumber=0; sampleNumber < numberOfSamples; sampleNumber++) {
    for (int p=0; p < numberOfDomains; p++) {
      priorMeans[p]+=priorSamples[sampleNumber][p];
      for (int j=0; j < numberOfFunctions; j++) {
        double errorRate=0;
        for (int i=0; i < numberOfDataSamples[p]; i++)         errorRate+=functionOutputsArray[j][p][i] != labelsSamples[sampleNumber][p][i] ? 1 : 0;
        errorRateMeans[p][j]+=errorRate / numberOfDataSamples[p];
      }
      for (int i=0; i < numberOfDataSamples[p]; i++)       labelMeans[p][i]+=labelsSamples[sampleNumber][p][i];
    }
  }
  for (int p=0; p < numberOfDomains; p++) {
    priorMeans[p]/=numberOfSamples;
    for (int j=0; j < numberOfFunctions; j++)     errorRateMeans[p][j]/=numberOfSamples;
    for (int i=0; i < numberOfDataSamples[p]; i++)     labelMeans[p][i]/=numberOfSamples;
    for (int sampleNumber=0; sampleNumber < numberOfSamples; sampleNumber++) {
      double temp=priorSamples[sampleNumber][p] - priorMeans[p];
      priorVariances[p]+=temp * temp;
      for (int j=0; j < numberOfFunctions; j++) {
        temp=(confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][0][1] * priorSamples[sampleNumber][p] + confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][1][0] * (1 - priorSamples[sampleNumber][p])) - errorRateMeans[p][j];
        errorRateVariances[p][j]+=temp * temp;
      }
      for (int i=0; i < numberOfDataSamples[p]; i++) {
        temp=labelsSamples[sampleNumber][p][i] - labelMeans[p][i];
        labelVariances[p][i]+=temp * temp;
      }
    }
    priorVariances[p]/=numberOfSamples;
    for (int j=0; j < numberOfFunctions; j++)     errorRateVariances[p][j]/=numberOfSamples;
    for (int i=0; i < numberOfDataSamples[p]; i++)     labelVariances[p][i]/=numberOfSamples;
  }
}

Fixed version (ground truth):
public void runGibbsSampler(){
  for (int sampleIndex=0; sampleIndex < numberOfBurnInSamples; sampleIndex++) {
    samplePriors(0);
    sampleConfusionMatrix(0);
    sampleClusterAssignments(0);
    sampleLabels(0);
  }
  for (int sampleIndex=1; sampleIndex < numberOfSamples; sampleIndex++) {
    for (int i=0; i < numberOfThinningSamples + 1; i++) {
      samplePriors(sampleIndex - 1);
      sampleConfusionMatrix(sampleIndex - 1);
      sampleClusterAssignments(sampleIndex - 1);
      sampleLabels(sampleIndex - 1);
    }
    storeSample(sampleIndex);
  }
  for (int sampleNumber=0; sampleNumber < numberOfSamples; sampleNumber++) {
    for (int p=0; p < numberOfDomains; p++) {
      priorMeans[p]+=labelPriorsSamples[sampleNumber][p];
      for (int j=0; j < numberOfFunctions; j++) {
        double errorRate=0;
        for (int i=0; i < numberOfDataSamples[p]; i++)         errorRate+=functionOutputsArray[j][p][i] != labelsSamples[sampleNumber][p][i] ? 1 : 0;
        errorRateMeans[p][j]+=errorRate / numberOfDataSamples[p];
      }
      for (int i=0; i < numberOfDataSamples[p]; i++)       labelMeans[p][i]+=labelsSamples[sampleNumber][p][i];
    }
  }
  for (int p=0; p < numberOfDomains; p++) {
    priorMeans[p]/=numberOfSamples;
    for (int j=0; j < numberOfFunctions; j++)     errorRateMeans[p][j]/=numberOfSamples;
    for (int i=0; i < numberOfDataSamples[p]; i++)     labelMeans[p][i]/=numberOfSamples;
    for (int sampleNumber=0; sampleNumber < numberOfSamples; sampleNumber++) {
      double temp=labelPriorsSamples[sampleNumber][p] - priorMeans[p];
      priorVariances[p]+=temp * temp;
      for (int j=0; j < numberOfFunctions; j++) {
        temp=(confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][0][1] * labelPriorsSamples[sampleNumber][p] + confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][1][0] * (1 - labelPriorsSamples[sampleNumber][p])) - errorRateMeans[p][j];
        errorRateVariances[p][j]+=temp * temp;
      }
      for (int i=0; i < numberOfDataSamples[p]; i++) {
        temp=labelsSamples[sampleNumber][p][i] - labelMeans[p][i];
        labelVariances[p][i]+=temp * temp;
      }
    }
    priorVariances[p]/=numberOfSamples;
    for (int j=0; j < numberOfFunctions; j++)     errorRateVariances[p][j]/=numberOfSamples;
    for (int i=0; i < numberOfDataSamples[p]; i++)     labelVariances[p][i]/=numberOfSamples;
  }
}