nus-yam/ex-repair huggingface dataset:
Program: 21222
Project: 21222
Buggy source:
public static void test3(){
  Variables variables=new Variables();
  EF_SparseMultinomial dist=new EF_SparseMultinomial(variables.newMultionomialVariable("String_Node_Str",10));
  EF_Multinomial distM=new EF_Multinomial(variables.newMultionomialVariable("String_Node_Str",10));
  int size=10;
  SufficientStatistics sufficientStatistics=dist.getSufficientStatistics(1);
  sufficientStatistics.multiplyBy(size);
  sufficientStatistics.sum(dist.createInitSufficientStatistics());
  dist.setMomentParameters(sufficientStatistics);
  distM.setMomentParameters(sufficientStatistics);
  dist.updateNaturalFromMomentParameters();
  distM.updateNaturalFromMomentParameters();
  dist.fixNumericalInstability();
  distM.fixNumericalInstability();
  dist.updateMomentFromNaturalParameters();
  distM.updateMomentFromNaturalParameters();
  assertEquals(dist.getNaturalParameters().sum(),distM.getNaturalParameters().sum());
  assertEquals(dist.getMomentParameters().sum(),distM.getMomentParameters().sum());
  assertEquals(dist.computeLogBaseMeasure(1.0),distM.computeLogBaseMeasure(1.0));
  assertEquals(dist.computeLogNormalizer(),distM.computeLogNormalizer());
  for (int i=0; i < 10; i++) {
    assertEquals(dist.computeLogProbabilityOf(i),distM.computeLogProbabilityOf(i));
  }
}

Fixed version (ground truth):
public static void test3(){
  Variables variables=new Variables();
  EF_SparseMultinomial dist=new EF_SparseMultinomial(variables.newMultinomialVariable("String_Node_Str",10));
  EF_Multinomial distM=new EF_Multinomial(variables.newMultinomialVariable("String_Node_Str",10));
  int size=10;
  SufficientStatistics sufficientStatistics=dist.getSufficientStatistics(1);
  sufficientStatistics.multiplyBy(size);
  sufficientStatistics.sum(dist.createInitSufficientStatistics());
  dist.setMomentParameters(sufficientStatistics);
  distM.setMomentParameters(sufficientStatistics);
  dist.updateNaturalFromMomentParameters();
  distM.updateNaturalFromMomentParameters();
  dist.fixNumericalInstability();
  distM.fixNumericalInstability();
  dist.updateMomentFromNaturalParameters();
  distM.updateMomentFromNaturalParameters();
  assertEquals(dist.getNaturalParameters().sum(),distM.getNaturalParameters().sum());
  assertEquals(dist.getMomentParameters().sum(),distM.getMomentParameters().sum());
  assertEquals(dist.computeLogBaseMeasure(1.0),distM.computeLogBaseMeasure(1.0));
  assertEquals(dist.computeLogNormalizer(),distM.computeLogNormalizer());
  for (int i=0; i < 10; i++) {
    assertEquals(dist.computeLogProbabilityOf(i),distM.computeLogProbabilityOf(i));
  }
}
Program: 21223
Project: 21223
Buggy source:
public static void test1(){
  Variables variables=new Variables();
  EF_SparseMultinomial dist=new EF_SparseMultinomial(variables.newMultionomialVariable("String_Node_Str",10));
  System.out.println(dist.getSufficientStatistics(1).output());
  System.out.println(dist.getNaturalParameters().output());
  System.out.println(dist.getMomentParameters().output());
  System.out.println();
  dist.setMomentParameters(dist.getSufficientStatistics(1));
  System.out.println(dist.getMomentParameters().output());
  System.out.println();
  dist.updateNaturalFromMomentParameters();
  System.out.println(dist.getNaturalParameters().output());
  System.out.println();
  dist.updateMomentFromNaturalParameters();
  System.out.println(dist.getMomentParameters().output());
}

Fixed version (ground truth):
public static void test1(){
  Variables variables=new Variables();
  EF_SparseMultinomial dist=new EF_SparseMultinomial(variables.newMultinomialVariable("String_Node_Str",10));
  System.out.println(dist.getSufficientStatistics(1).output());
  System.out.println(dist.getNaturalParameters().output());
  System.out.println(dist.getMomentParameters().output());
  System.out.println();
  dist.setMomentParameters(dist.getSufficientStatistics(1));
  System.out.println(dist.getMomentParameters().output());
  System.out.println();
  dist.updateNaturalFromMomentParameters();
  System.out.println(dist.getNaturalParameters().output());
  System.out.println();
  dist.updateMomentFromNaturalParameters();
  System.out.println(dist.getMomentParameters().output());
}
Program: 21224
Project: 21224
Buggy source:
public static void test(){
  Variables variables=new Variables();
  ParameterVariables parameterVariables=new ParameterVariables(1);
  Variable multiA=variables.newMultionomialVariable("String_Node_Str",10);
  Variable dirichlet=parameterVariables.newDirichletParameter("String_Node_Str",10);
  EF_SparseMultinomial_SparseDirichlet dist=new EF_SparseMultinomial_SparseDirichlet(multiA,dirichlet);
  EF_SparseDirichlet distDirichlet=new EF_SparseDirichlet(dirichlet);
  EF_LearningBayesianNetwork ef_learningBayesianNetwork=new EF_LearningBayesianNetwork(Arrays.asList(dist,distDirichlet));
}

Fixed version (ground truth):
public static void test(){
  Variables variables=new Variables();
  ParameterVariables parameterVariables=new ParameterVariables(1);
  Variable multiA=variables.newMultinomialVariable("String_Node_Str",10);
  Variable dirichlet=parameterVariables.newDirichletParameter("String_Node_Str",10);
  EF_SparseMultinomial_SparseDirichlet dist=new EF_SparseMultinomial_SparseDirichlet(multiA,dirichlet);
  EF_SparseDirichlet distDirichlet=new EF_SparseDirichlet(dirichlet);
  EF_LearningBayesianNetwork ef_learningBayesianNetwork=new EF_LearningBayesianNetwork(Arrays.asList(dist,distDirichlet));
}
Program: 21225
Project: 21225
Buggy source:
public static void testMultinomials1() throws IOException, ClassNotFoundException {
  Variables variables=new Variables();
  Variable varA=variables.newMultionomialVariable("String_Node_Str",2);
  DAG dag=new DAG(variables);
  BayesianNetwork bn=new BayesianNetwork(dag);
  bn.randomInitialization(new Random(0));
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setSeed(2);
  DataStream<DataInstance> data=sampler.sampleToDataStream(1000);
  SVB svb=new SVB();
  svb.setWindowsSize(1000);
  svb.setSeed(5);
  VMP vmp=svb.getPlateuStructure().getVMP();
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  svb.setDAG(bn.getDAG());
  svb.setDataStream(data);
  svb.runLearning();
  BayesianNetwork learnBN=svb.getLearntBayesianNetwork();
  System.out.println(bn.toString());
  System.out.println(learnBN.toString());
  assertTrue(bn.equalBNs(learnBN,0.05));
}

Fixed version (ground truth):
public static void testMultinomials1() throws IOException, ClassNotFoundException {
  Variables variables=new Variables();
  Variable varA=variables.newMultinomialVariable("String_Node_Str",2);
  DAG dag=new DAG(variables);
  BayesianNetwork bn=new BayesianNetwork(dag);
  bn.randomInitialization(new Random(0));
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setSeed(2);
  DataStream<DataInstance> data=sampler.sampleToDataStream(1000);
  SVB svb=new SVB();
  svb.setWindowsSize(1000);
  svb.setSeed(5);
  VMP vmp=svb.getPlateuStructure().getVMP();
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  svb.setDAG(bn.getDAG());
  svb.setDataStream(data);
  svb.runLearning();
  BayesianNetwork learnBN=svb.getLearntBayesianNetwork();
  System.out.println(bn.toString());
  System.out.println(learnBN.toString());
  assertTrue(bn.equalBNs(learnBN,0.05));
}
Program: 21226
Project: 21226
Buggy source:
public static void test2(){
  Variables variables=new Variables();
  Variable word=variables.newSparseMultionomialVariable("String_Node_Str",100);
  Variable topicIndicator=variables.newMultionomialVariable("String_Node_Str",2);
  DAG dagLDA=new DAG(variables);
  dagLDA.getParentSet(word).addParent(topicIndicator);
  List<EF_ConditionalDistribution> dists=dagLDA.getParentSets().stream().map(pSet -> pSet.getMainVar().getDistributionType().<EF_ConditionalDistribution>newEFConditionalDistribution(pSet.getParents())).collect(Collectors.toList());
  EF_LearningBayesianNetwork ef_learningmodel=new EF_LearningBayesianNetwork(dists);
}

Fixed version (ground truth):
public static void test2(){
  Variables variables=new Variables();
  Variable word=variables.newSparseMultionomialVariable("String_Node_Str",100);
  Variable topicIndicator=variables.newMultinomialVariable("String_Node_Str",2);
  DAG dagLDA=new DAG(variables);
  dagLDA.getParentSet(word).addParent(topicIndicator);
  List<EF_ConditionalDistribution> dists=dagLDA.getParentSets().stream().map(pSet -> pSet.getMainVar().getDistributionType().<EF_ConditionalDistribution>newEFConditionalDistribution(pSet.getParents())).collect(Collectors.toList());
  EF_LearningBayesianNetwork ef_learningmodel=new EF_LearningBayesianNetwork(dists);
}
Program: 21227
Project: 21227
Buggy source:
public static void testMultinomials1() throws IOException, ClassNotFoundException {
  Variables variables=new Variables();
  Variable varA=variables.newMultionomialVariable("String_Node_Str",2);
  DAG dag=new DAG(variables);
  BayesianNetwork bn=new BayesianNetwork(dag);
  bn.randomInitialization(new Random(0));
  System.out.println(bn.toString());
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setSeed(2);
  DataStream<DataInstance> data=sampler.sampleToDataStream(100);
  baseTest(data,bn,100,10,0.05);
}

Fixed version (ground truth):
public static void testMultinomials1() throws IOException, ClassNotFoundException {
  Variables variables=new Variables();
  Variable varA=variables.newMultinomialVariable("String_Node_Str",2);
  DAG dag=new DAG(variables);
  BayesianNetwork bn=new BayesianNetwork(dag);
  bn.randomInitialization(new Random(0));
  System.out.println(bn.toString());
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setSeed(2);
  DataStream<DataInstance> data=sampler.sampleToDataStream(100);
  baseTest(data,bn,100,10,0.05);
}
Program: 21232
Project: 21232
Buggy source:
public static BayesianNetwork createNetwork() throws Exception {
  Variables variables=new Variables();
  Variable varA=variables.newGaussianVariable("String_Node_Str");
  Variable varB=variables.newMultionomialVariable("String_Node_Str",2);
  DAG dag=new DAG(variables);
  dag.getParentSet(varA).addParent(varB);
  BayesianNetwork bayesianNetwork=new BayesianNetwork(dag);
  ((Multinomial)bayesianNetwork.getConditionalDistribution(varB)).setProbabilities(new double[]{0.4,0.6});
  Normal normal0=((Normal_MultinomialParents)bayesianNetwork.getConditionalDistribution(varA)).getNormal(0);
  Normal normal1=((Normal_MultinomialParents)bayesianNetwork.getConditionalDistribution(varA)).getNormal(1);
  normal0.setMean(-2.5);
  normal0.setVariance(0.75);
  normal1.setMean(2.5);
  normal1.setVariance(0.5);
  if (mixture)   return bayesianNetwork;
 else   return BayesianNetworkLoader.loadFromFile("String_Node_Str");
}

Fixed version (ground truth):
public static BayesianNetwork createNetwork() throws Exception {
  Variables variables=new Variables();
  Variable varA=variables.newGaussianVariable("String_Node_Str");
  Variable varB=variables.newMultinomialVariable("String_Node_Str",2);
  DAG dag=new DAG(variables);
  dag.getParentSet(varA).addParent(varB);
  BayesianNetwork bayesianNetwork=new BayesianNetwork(dag);
  ((Multinomial)bayesianNetwork.getConditionalDistribution(varB)).setProbabilities(new double[]{0.4,0.6});
  Normal normal0=((Normal_MultinomialParents)bayesianNetwork.getConditionalDistribution(varA)).getNormal(0);
  Normal normal1=((Normal_MultinomialParents)bayesianNetwork.getConditionalDistribution(varA)).getNormal(1);
  normal0.setMean(-2.5);
  normal0.setVariance(0.75);
  normal1.setMean(2.5);
  normal1.setVariance(0.5);
  if (mixture)   return bayesianNetwork;
 else   return BayesianNetworkLoader.loadFromFile("String_Node_Str");
}
Program: 21235
Project: 21235
Buggy source:
public double updateModel(DataOnMemory<DynamicDataInstance> dataBatch){
  if (learningAlgorithm == null) {
    learningAlgorithm.setDynamicDAG(this.getDynamicDAG());
    learningAlgorithm.setWindowsSize(windowSize);
    learningAlgorithm.initLearning();
  }
  return learningAlgorithm.updateModel(dataBatch);
}

Fixed version (ground truth):
public double updateModel(DataOnMemory<DynamicDataInstance> dataBatch){
  if (!initialized)   initLearning();
  return learningAlgorithm.updateModel(dataBatch);
}
Program: 21236
Project: 21236
Buggy source:
public double updateModel(DataOnMemory<DataInstance> datBatch){
  if (!initialized) {
    learningAlgorithm.setWindowsSize(windowSize);
    learningAlgorithm.setDAG(this.getDAG());
    learningAlgorithm.initLearning();
    initialized=true;
  }
  return learningAlgorithm.updateModel(datBatch);
}

Fixed version (ground truth):
public double updateModel(DataOnMemory<DataInstance> datBatch){
  if (!initialized)   initLearning();
  return learningAlgorithm.updateModel(datBatch);
}
Program: 21237
Project: 21237
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public SufficientStatistics createInitSufficientStatistics(){
  ArrayVector vector=new ArrayVector(this.sizeOfSufficientStatistics());
  double mean=0;
  double precision=0.000001;
  vector.set(0,mean * precision);
  vector.set(1,-0.5 * precision);
  return vector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public SufficientStatistics createInitSufficientStatistics(){
  SufficientStatistics vector=this.createZeroSufficientStatistics();
  double mean=0;
  double meansquare=0.1;
  vector.set(0,mean);
  vector.set(1,meansquare);
  return vector;
}
Program: 21241
Project: 21241
Buggy source:
@Override public void updateMomentFromNaturalParameters(){
  double delta=this.getNaturalParameters().get(0);
  this.momentParameters.set(0,Math.exp(delta) / (Math.exp(delta) - 1) - 1 / delta);
}

Fixed version (ground truth):
@Override public void updateMomentFromNaturalParameters(){
  double delta=this.getNaturalParameters().get(0);
  if (Math.exp(delta) > Double.MAX_VALUE) {
    this.momentParameters.set(0,1.0 - 1 / delta);
  }
 else {
    this.momentParameters.set(0,Math.exp(delta) / (Math.exp(delta) - 1) - 1 / delta);
  }
}
Program: 21242
Project: 21242
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public double predictedLogLikelihood(DataOnMemory<DataInstance> batch){
  this.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(false));
  double elbo=this.getPlateuStructure().getNonReplictedNodes().mapToDouble(node -> this.getPlateuStructure().getVMP().computeELBO(node)).sum();
  elbo+=this.updateModelOnBatchParallel(batch).getElbo();
  this.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(true));
  return elbo;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public double predictedLogLikelihood(DataOnMemory<DataInstance> batch){
  this.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(false));
  double elbo=0;
  elbo+=this.updateModelOnBatchParallel(batch).getElbo();
  this.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(true));
  return elbo;
}
Program: 21243
Project: 21243
Buggy source:
public StochasticVI(){
  this.svb=new SVB();
}

Fixed version (ground truth):
public StochasticVI(){
  this.svb=new SVB();
  this.svb.setNonSequentialModel(true);
}
Program: 21244
Project: 21244
Buggy source:
@Override public double updateModel(DataOnMemory<DataInstance> batch){
  NaturalParameters newParam=svb.updateModelOnBatchParallel(batch).getVector();
  newParam.multiplyBy(this.dataSetSize / (double)this.batchSize);
  newParam.sum(prior);
  double stepSize=Math.pow(1 + iteration,-learningFactor);
  newParam.multiplyBy(stepSize);
  currentParam.multiplyBy((1 - stepSize));
  currentParam.sum(newParam);
  this.svb.updateNaturalParameterPosteriors(currentParam);
  return Double.NaN;
}

Fixed version (ground truth):
@Override public double updateModel(DataOnMemory<DataInstance> batch){
  NaturalParameters newParam=svb.updateModelOnBatchParallel(batch).getVector();
  newParam.multiplyBy(this.dataSetSize / (double)this.batchSize);
  newParam.sum(prior);
  double stepSize=Math.pow(1 + iteration,-learningFactor);
  newParam.multiplyBy(stepSize);
  currentParam.multiplyBy((1 - stepSize));
  currentParam.sum(newParam);
  this.svb.updateNaturalParameterPosteriors(currentParam);
  iteration++;
  return Double.NaN;
}
Program: 21245
Project: 21245
Buggy source:
public static void printOutput() throws Exception {
  BayesianNetwork bnML=ml.getLearntBayesianNetwork();
  BayesianNetwork bnSVB=svb.getLearntBayesianNetwork();
  BayesianNetwork bnDriftSVB=driftSVB.getLearntBayesianNetwork();
  double meanML=((Normal)bnML.getConditionalDistribution(oneNormalVarBN.getVariables().getVariableByName("String_Node_Str"))).getMean();
  double meanSVB=((Normal)bnSVB.getConditionalDistribution(oneNormalVarBN.getVariables().getVariableByName("String_Node_Str"))).getMean();
  double meanDriftSVB=((Normal)bnDriftSVB.getConditionalDistribution(oneNormalVarBN.getVariables().getVariableByName("String_Node_Str"))).getMean();
  writerMean.println(meanML + "String_Node_Str" + meanSVB+ "String_Node_Str"+ meanDriftSVB);
  writerLambda.println(driftSVB.getLambdaValue());
}

Fixed version (ground truth):
public static void printOutput() throws Exception {
  BayesianNetwork bnML=ml.getLearntBayesianNetwork();
  BayesianNetwork bnSVB=svb.getLearntBayesianNetwork();
  BayesianNetwork bnDriftSVB=driftSVB.getLearntBayesianNetwork();
  BayesianNetwork bnStochasticVI=stochasticVI.getLearntBayesianNetwork();
  BayesianNetwork bnPopulationVI=populationVI.getLearntBayesianNetwork();
  double meanML=((Normal)bnML.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"))).getMean();
  double meanSVB=((Normal)bnSVB.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"))).getMean();
  double meanDriftSVB=((Normal)bnDriftSVB.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"))).getMean();
  double meanStochasticVI=((Normal)bnStochasticVI.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"))).getMean();
  double meanPopulationVI=((Normal)bnPopulationVI.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"))).getMean();
  double realMean=((Normal)network.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"))).getMean();
  writerMean.println(realMean + "String_Node_Str" + meanML+ "String_Node_Str"+ meanSVB+ "String_Node_Str"+ meanDriftSVB+ "String_Node_Str"+ meanStochasticVI+ "String_Node_Str"+ meanPopulationVI);
  writerLambda.println(driftSVB.getLambdaValue());
}
Program: 21246
Project: 21246
Buggy source:
public static void scenarioNoConceptDrift(int batchSize) throws Exception {
  for (int i=0; i < numIter; i++) {
    BayesianNetworkSampler sampler=new BayesianNetworkSampler(oneNormalVarBN);
    sampler.setSeed(i);
    DataOnMemory<DataInstance> batch=sampler.sampleToDataStream(batchSize).toDataOnMemory();
    if (i > 0)     printPredLL(batch);
    driftSVB.updateModelWithConceptDrift(batch);
    svb.updateModel(batch);
    populationVI.updateModel(batch);
    stochasticVI.updateModel(batch);
    BayesianNetwork bnSVB=svb.getLearntBayesianNetwork();
    BayesianNetwork bnStochasticVI=stochasticVI.getLearntBayesianNetwork();
    ml.updateModel(batch);
    printOutput();
  }
}

Fixed version (ground truth):
public static void scenarioNoConceptDrift(int batchSize) throws Exception {
  for (int i=0; i < numIter; i++) {
    BayesianNetworkSampler sampler=new BayesianNetworkSampler(network);
    sampler.setSeed(i);
    DataOnMemory<DataInstance> batch=sampler.sampleToDataStream(batchSize).toDataOnMemory();
    if (i > 0)     printPredLL(batch);
    driftSVB.updateModelWithConceptDrift(batch);
    svb.updateModel(batch);
    populationVI.updateModel(batch);
    stochasticVI.updateModel(batch);
    BayesianNetwork bnSVB=svb.getLearntBayesianNetwork();
    BayesianNetwork bnStochasticVI=stochasticVI.getLearntBayesianNetwork();
    ml.updateModel(batch);
    printOutput();
  }
}
Program: 21247
Project: 21247
Buggy source:
public static void initVILearners(int batchSize,int memoryPopulationVI,double learningRate){
  populationVI=new PopulationVI();
  populationVI.setWindowSize(memoryPopulationVI);
  populationVI.setSeed(0);
  populationVI.setLearningFactor(learningRate);
  VMP vmp=svb.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  populationVI.setDAG(oneNormalVarBN.getDAG());
  populationVI.initLearning();
  stochasticVI=new StochasticVI();
  stochasticVI.setDataSetSize(numIter * batchSize);
  stochasticVI.setBatchSize(batchSize);
  stochasticVI.setSeed(0);
  stochasticVI.setLearningFactor(learningRate);
  vmp=svb.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  stochasticVI.setDAG(oneNormalVarBN.getDAG());
  stochasticVI.initLearning();
  maximumLikelihoodInit();
}

Fixed version (ground truth):
public static void initVILearners(int batchSize,int memoryPopulationVI,double learningRate){
  populationVI=new PopulationVI();
  populationVI.setWindowSize(memoryPopulationVI);
  populationVI.setSeed(0);
  populationVI.setLearningFactor(learningRate);
  VMP vmp=svb.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  populationVI.setDAG(network.getDAG());
  populationVI.initLearning();
  stochasticVI=new StochasticVI();
  stochasticVI.setDataSetSize(numIter * batchSize);
  stochasticVI.setBatchSize(batchSize);
  stochasticVI.setSeed(0);
  stochasticVI.setLearningFactor(learningRate);
  vmp=svb.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  stochasticVI.setDAG(network.getDAG());
  stochasticVI.initLearning();
  maximumLikelihoodInit();
}
Program: 21248
Project: 21248
Buggy source:
private static void maximumLikelihoodInit(){
  ml=new ParallelMaximumLikelihood();
  ml.setParallelMode(true);
  ml.setDAG(oneNormalVarBN.getDAG());
  ml.initLearning();
}

Fixed version (ground truth):
private static void maximumLikelihoodInit(){
  ml=new ParallelMaximumLikelihood();
  ml.setParallelMode(true);
  ml.setDAG(network.getDAG());
  ml.initLearning();
}
Program: 21249
Project: 21249
Buggy source:
public static void scenarioMixedConceptDrift(int batchSize) throws Exception {
  for (int i=0; i < numIter; i++) {
    if (i > 0 && i < 20) {
      Normal normal=oneNormalVarBN.getConditionalDistribution(oneNormalVarBN.getVariables().getVariableByName("String_Node_Str"));
      normal.setMean(normal.getMean() + 5);
      normal.setVariance(normal.getVariance() + 0.5);
    }
    if (i > 30 && i < 40 && i % 3 == 0) {
      oneNormalVarBN.randomInitialization(new Random(i));
    }
    if (i > 40 && i < 70 && i % 4 == 0) {
      oneNormalVarBN.randomInitialization(new Random(i));
    }
    if (i > 90 && i < 100) {
      Normal normal=oneNormalVarBN.getConditionalDistribution(oneNormalVarBN.getVariables().getVariableByName("String_Node_Str"));
      normal.setMean(normal.getMean() - 5);
      normal.setVariance(normal.getVariance() - 1);
    }
    BayesianNetworkSampler sampler=new BayesianNetworkSampler(oneNormalVarBN);
    sampler.setSeed(i);
    DataOnMemory<DataInstance> batch=sampler.sampleToDataStream(batchSize).toDataOnMemory();
    if (i > 0)     printPredLL(batch);
    driftSVB.updateModelWithConceptDrift(batch);
    svb.updateModel(batch);
    populationVI.updateModel(batch);
    stochasticVI.updateModel(batch);
    ml.updateModel(batch);
    printOutput();
  }
}

Fixed version (ground truth):
public static void scenarioMixedConceptDrift(int batchSize) throws Exception {
  double predLL=0;
  for (int i=0; i < numIter; i++) {
    iter++;
    if (i > 20 && i < 30) {
      Normal normal=network.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"));
      normal.setMean(normal.getMean() + new Random(i).nextDouble());
      normal.setVariance(normal.getVariance() + new Random(i).nextDouble());
    }
    if (i > 30 && i < 40 && i % 3 == 0) {
      network.randomInitialization(new Random(i));
      Normal normal=network.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"));
      normal.setMean(normal.getMean() * new Random(i).nextDouble());
      normal.setVariance(normal.getVariance() * new Random(i).nextDouble());
    }
    if (i > 40 && i < 70 && i % 4 == 0) {
      network.randomInitialization(new Random(i));
    }
    if (i > 90 && i < 100) {
      Normal normal=network.getConditionalDistribution(network.getVariables().getVariableByName("String_Node_Str"));
      normal.setMean(normal.getMean() + 5);
      normal.setVariance(normal.getVariance() + 0.1);
    }
    BayesianNetworkSampler sampler=new BayesianNetworkSampler(network);
    sampler.setSeed(i);
    DataOnMemory<DataInstance> batch=sampler.sampleToDataStream(batchSize).toDataOnMemory();
    if (i > 0) {
      printPredLL(batch);
    }
    driftSVB.updateModelWithConceptDrift(batch);
    svb.updateModel(batch);
    populationVI.updateModel(batch);
    stochasticVI.updateModel(batch);
    ml.updateModel(batch);
    printOutput();
  }
}
Program: 21251
Project: 21251
Buggy source:
public static void initSVBLearners(int batchSize,double deltaValue){
  driftSVB=new DriftSVB();
  driftSVB.setWindowsSize(batchSize);
  driftSVB.setSeed(0);
  driftSVB.setDelta(deltaValue);
  VMP vmp=driftSVB.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  driftSVB.setDAG(oneNormalVarBN.getDAG());
  driftSVB.initLearning();
  svb=new SVB();
  svb.setWindowsSize(batchSize);
  svb.setSeed(0);
  vmp=svb.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  svb.setDAG(oneNormalVarBN.getDAG());
  svb.initLearning();
}

Fixed version (ground truth):
public static void initSVBLearners(int batchSize,double deltaValue){
  driftSVB=new DriftSVB();
  driftSVB.setWindowsSize(batchSize);
  driftSVB.setSeed(0);
  driftSVB.setDelta(deltaValue);
  VMP vmp=driftSVB.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  driftSVB.setDAG(network.getDAG());
  driftSVB.initLearning();
  svb=new SVB();
  svb.setWindowsSize(batchSize);
  svb.setSeed(0);
  vmp=svb.getPlateuStructure().getVMP();
  vmp.setOutput(false);
  vmp.setTestELBO(true);
  vmp.setMaxIter(1000);
  vmp.setThreshold(0.0001);
  svb.setDAG(network.getDAG());
  svb.initLearning();
}
Program: 21252
Project: 21252
Buggy source:
public static void printPredLL(DataOnMemory<DataInstance> batch) throws Exception {
  writerPredLL.println(svb.predictedLogLikelihood(batch) + "String_Node_Str" + driftSVB.predictedLogLikelihood(batch)+ "String_Node_Str"+ "String_Node_Str"+ stochasticVI.predictedLogLikelihood(batch)+ "String_Node_Str"+ populationVI.predictedLogLikelihood(batch));
}

Fixed version (ground truth):
public static void printPredLL(DataOnMemory<DataInstance> batch) throws Exception {
  predLLAcum[0]+=svb.predictedLogLikelihood(batch);
  predLLAcum[1]+=driftSVB.predictedLogLikelihood(batch);
  predLLAcum[2]+=stochasticVI.predictedLogLikelihood(batch);
  predLLAcum[3]+=populationVI.predictedLogLikelihood(batch);
  writerPredLL.println(predLLAcum[0] / iter + "String_Node_Str" + predLLAcum[1] / iter + "String_Node_Str" + predLLAcum[2] / iter + "String_Node_Str" + predLLAcum[3] / iter);
}
Program: 21253
Project: 21253
Buggy source:
/** 
 * Returns the number of states of this attribute, in case it has a finite state space. Otherwise it returns -1.
 * @return the number of states of this attribute.
 */
public int getNumberOfStates(){
  if (this.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.FINITE_SET)   return ((FiniteStateSpace)this.getStateSpaceType()).getNumberOfStates();
 else   return -1;
}

Fixed version (ground truth):
/** 
 * Returns the number of states of this attribute, in case it has a finite state space. Otherwise it returns -1.
 * @return the number of states of this attribute.
 */
public int getNumberOfStates(){
  if (this.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.FINITE_SET)   return ((FiniteStateSpace)this.getStateSpaceType()).getNumberOfStates();
 else   if (this.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.LARGE_FINITE_SET)   return ((LargeFiniteStateSpace)this.getStateSpaceType()).getNumberOfStates();
 else   return -1;
}
Program: 21254
Project: 21254
Buggy source:
public static String dataInstanceToARFFString(Attribute att,DataInstance assignment,String separator){
  StringBuilder builder=new StringBuilder();
  if (Utils.isMissingValue(assignment.getValue(att))) {
    builder.append("String_Node_Str");
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.FINITE_SET) {
    FiniteStateSpace stateSpace=att.getStateSpaceType();
    String nameState=stateSpace.getStatesName((int)assignment.getValue(att));
    builder.append(nameState + separator);
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.REAL) {
    if (att.isSpecialAttribute() || att.isTimeId()) {
      builder.append(decimalFormat.format(assignment.getValue(att)) + separator);
    }
 else {
      builder.append(assignment.getValue(att) + separator);
    }
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + att.getStateSpaceType().getStateSpaceTypeEnum());
  }
  return builder.toString();
}

Fixed version (ground truth):
public static String dataInstanceToARFFString(Attribute att,DataInstance assignment,String separator){
  StringBuilder builder=new StringBuilder();
  if (Utils.isMissingValue(assignment.getValue(att))) {
    builder.append("String_Node_Str");
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.FINITE_SET) {
    FiniteStateSpace stateSpace=att.getStateSpaceType();
    String nameState=stateSpace.getStatesName((int)assignment.getValue(att));
    builder.append(nameState + separator);
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.REAL) {
    if (att.isSpecialAttribute() || att.isTimeId()) {
      builder.append(decimalFormat.format(assignment.getValue(att)) + separator);
    }
 else {
      builder.append(assignment.getValue(att) + separator);
    }
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.LARGE_FINITE_SET) {
    int val=((int)assignment.getValue(att));
    builder.append(val + separator);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + att.getStateSpaceType().getStateSpaceTypeEnum());
  }
  return builder.toString();
}
Program: 21255
Project: 21255
Buggy source:
public static String attributeToARFFString(Attribute att){
  if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.REAL) {
    return "String_Node_Str" + att.getName() + "String_Node_Str";
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.FINITE_SET) {
    StringBuilder stringBuilder=new StringBuilder("String_Node_Str" + att.getName() + "String_Node_Str");
    FiniteStateSpace stateSpace=att.getStateSpaceType();
    stateSpace.getStatesNames().stream().limit(stateSpace.getNumberOfStates() - 1).forEach(e -> stringBuilder.append(e + "String_Node_Str"));
    stringBuilder.append(stateSpace.getStatesName(stateSpace.getNumberOfStates() - 1) + "String_Node_Str");
    return stringBuilder.toString();
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
public static String attributeToARFFString(Attribute att){
  if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.REAL) {
    return "String_Node_Str" + att.getName() + "String_Node_Str";
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.FINITE_SET) {
    StringBuilder stringBuilder=new StringBuilder("String_Node_Str" + att.getName() + "String_Node_Str");
    FiniteStateSpace stateSpace=att.getStateSpaceType();
    stateSpace.getStatesNames().stream().limit(stateSpace.getNumberOfStates() - 1).forEach(e -> stringBuilder.append(e + "String_Node_Str"));
    stringBuilder.append(stateSpace.getStatesName(stateSpace.getNumberOfStates() - 1) + "String_Node_Str");
    return stringBuilder.toString();
  }
 else   if (att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.LARGE_FINITE_SET) {
    return "String_Node_Str" + att.getName() + "String_Node_Str"+ att.getNumberOfStates();
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}
Program: 21256
Project: 21256
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean tryAdvance(Consumer<? super DataOnMemory<T>> action){
  if (!advance)   return false;
  final HoldingConsumer<T> holder=new HoldingConsumer<>();
  final DataOnMemoryListContainer<T> container=new DataOnMemoryListContainer(dataStream.getAttributes());
  if (tailInstance == null) {
    if (spliterator.tryAdvance(holder)) {
      tailInstance=holder.value;
      container.add(tailInstance);
    }
 else {
      return false;
    }
  }
 else {
    container.add(tailInstance);
  }
  while ((advance=spliterator.tryAdvance(holder)) && getSequenceID(holder.value) == getSequenceID(tailInstance)) {
    tailInstance=holder.value;
    container.add(tailInstance);
  }
  ;
  tailInstance=holder.value;
  if (est != Long.MAX_VALUE)   est-=container.getNumberOfDataInstances();
  if (container.getNumberOfDataInstances() > 0) {
    action.accept(container);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean tryAdvance(Consumer<? super DataOnMemory<T>> action){
  if (!advance)   return false;
  final HoldingConsumer<T> holder=new HoldingConsumer<>();
  final DataOnMemoryListContainer<T> container=new DataOnMemoryListContainer(dataStream.getAttributes());
  if (tailInstance == null) {
    if (spliterator.tryAdvance(holder)) {
      tailInstance=holder.value;
      container.add(tailInstance);
    }
 else {
      return false;
    }
  }
 else {
    container.add(tailInstance);
  }
  int count=0;
  while (count < this.batchSize && advance) {
    while ((advance=spliterator.tryAdvance(holder)) && getSequenceID(holder.value) == getSequenceID(tailInstance)) {
      tailInstance=holder.value;
      container.add(tailInstance);
    }
    ;
    tailInstance=holder.value;
    count++;
    if (count < this.batchSize && advance)     container.add(tailInstance);
  }
  if (est != Long.MAX_VALUE)   est-=container.getNumberOfDataInstances();
  if (container.getNumberOfDataInstances() > 0) {
    action.accept(container);
    return true;
  }
 else {
    return false;
  }
}
Program: 21257
Project: 21257
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public NaturalParameters getNaturalParameters(){
  this.naturalParameters=this.createEmtpyCompoundVector();
  RealVector beta=new ArrayRealVector(betas);
  double theta_0=beta0 / variance;
  double[] theta_0array={theta_0};
  double variance2Inv=1.0 / (2 * variance);
  RealVector theta_0Theta=beta.mapMultiply(-beta0 / variance);
  ((CompoundVector)this.naturalParameters).setXYbaseVector(new ArrayRealVector(theta_0array,theta_0Theta.getData()));
  double theta_Minus1=-variance2Inv;
  RealVector theta_beta=beta.mapMultiply(variance2Inv);
  RealMatrix theta_betaBeta=beta.outerProduct(beta).scalarMultiply(-variance2Inv * 2);
  RealMatrix natural_XY=new Array2DRowRealMatrix(nOfParents + 1,nOfParents + 1);
  double[] theta_Minus1array={theta_Minus1};
  RealVector covXY=new ArrayRealVector(theta_Minus1array,theta_beta.getData());
  natural_XY.setColumnVector(0,covXY);
  natural_XY.setRowVector(0,covXY);
  natural_XY.setSubMatrix(theta_betaBeta.getData(),1,1);
  ((CompoundVector)this.naturalParameters).setcovbaseVector(natural_XY);
  return this.naturalParameters;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public NaturalParameters getNaturalParameters(){
  CompoundVector naturalParametersCompound=this.createEmtpyCompoundVector();
  double theta_0=beta0 / variance;
  naturalParametersCompound.setThetaBeta0_NatParam(theta_0);
  double variance2Inv=1.0 / (2 * variance);
  double[] theta0_beta=Arrays.stream(betas).map(w -> -w * beta0 / variance).toArray();
  naturalParametersCompound.setThetaBeta0Beta_NatParam(theta0_beta);
  double theta_Minus1=-variance2Inv;
  naturalParametersCompound.setThetaCov_NatParam(theta_Minus1,betas,variance2Inv);
  this.naturalParameters=naturalParametersCompound;
  return this.naturalParameters;
}
Program: 21258
Project: 21258
Buggy source:
/** 
 * Generate a DataStream with the given number of samples and attributes (discrete and continuous).
 * @param seed, the seed of the random number generator.
 * @param nSamples, the number of samples of the data stream.
 * @param nDiscreteAtts, the number of discrete attributes.
 * @param nContinuousAttributes, the number of continuous attributes.
 * @return A valid {@code DataStream} object.
 */
public static DataStream<DataInstance> generate(int seed,int nSamples,int nDiscreteAtts,int nContinuousAttributes){
  BayesianNetworkGenerator.setSeed(seed);
  BayesianNetworkGenerator.setNumberOfGaussianVars(nContinuousAttributes);
  BayesianNetworkGenerator.setNumberOfMultinomialVars(nDiscreteAtts,2);
  int nTotal=nDiscreteAtts + nContinuousAttributes;
  BayesianNetworkGenerator.setNumberOfLinks((int)(0.2 * nTotal * (nTotal - 1) / 2));
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(BayesianNetworkGenerator.generateBayesianNetwork());
  sampler.setSeed(seed);
  return sampler.sampleToDataStream(nSamples);
}

Fixed version (ground truth):
/** 
 * Generate a DataStream with the given number of samples and attributes (discrete and continuous).
 * @param seed, the seed of the random number generator.
 * @param nSamples, the number of samples of the data stream.
 * @param nDiscreteAtts, the number of discrete attributes.
 * @param nContinuousAttributes, the number of continuous attributes.
 * @return A valid {@code DataStream} object.
 */
public static DataStream<DataInstance> generate(int seed,int nSamples,int nDiscreteAtts,int nContinuousAttributes){
  BayesianNetworkGenerator.setSeed(seed);
  BayesianNetworkGenerator.setNumberOfGaussianVars(nContinuousAttributes);
  BayesianNetworkGenerator.setNumberOfMultinomialVars(nDiscreteAtts,2);
  int nTotal=nDiscreteAtts + nContinuousAttributes;
  int nLinksMin=nTotal - 1;
  int nLinksMax=nTotal * (nTotal - 1) / 2;
  BayesianNetworkGenerator.setNumberOfLinks((int)(0.8 * nLinksMin + 0.2 * nLinksMax));
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(BayesianNetworkGenerator.generateBayesianNetwork());
  sampler.setSeed(seed);
  return sampler.sampleToDataStream(nSamples);
}
Program: 21259
Project: 21259
Buggy source:
/** 
 * Generate a DataStream with the given number of samples and attributes (discrete and continuous).
 * @param seed, the seed of the random number generator.
 * @param nSamples, the number of samples of the data stream.
 * @param nDiscreteAtts, the number of discrete attributes.
 * @param nContinuousAttributes, the number of continuous attributes.
 * @return A valid {@code DataStream} object.
 */
public static DataStream<DataInstance> generate(int seed,int nSamples,int nDiscreteAtts,int nContinuousAttributes){
  BayesianNetworkGenerator.setSeed(seed);
  BayesianNetworkGenerator.setNumberOfGaussianVars(nContinuousAttributes);
  BayesianNetworkGenerator.setNumberOfMultinomialVars(nDiscreteAtts,2);
  int nTotal=nDiscreteAtts + nContinuousAttributes;
  BayesianNetworkGenerator.setNumberOfLinks((int)(0.2 * nTotal * (nTotal - 1) / 2));
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(BayesianNetworkGenerator.generateBayesianNetwork());
  sampler.setSeed(seed);
  return sampler.sampleToDataStream(nSamples);
}

Fixed version (ground truth):
/** 
 * Generate a DataStream with the given number of samples and attributes (discrete and continuous).
 * @param seed, the seed of the random number generator.
 * @param nSamples, the number of samples of the data stream.
 * @param nDiscreteAtts, the number of discrete attributes.
 * @param nContinuousAttributes, the number of continuous attributes.
 * @return A valid {@code DataStream} object.
 */
public static DataStream<DataInstance> generate(int seed,int nSamples,int nDiscreteAtts,int nContinuousAttributes){
  BayesianNetworkGenerator.setSeed(seed);
  BayesianNetworkGenerator.setNumberOfGaussianVars(nContinuousAttributes);
  BayesianNetworkGenerator.setNumberOfMultinomialVars(nDiscreteAtts,2);
  int nTotal=nDiscreteAtts + nContinuousAttributes;
  int nLinksMin=nTotal - 1;
  int nLinksMax=nTotal * (nTotal - 1) / 2;
  BayesianNetworkGenerator.setNumberOfLinks((int)(0.8 * nLinksMin + 0.2 * nLinksMax));
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(BayesianNetworkGenerator.generateBayesianNetwork());
  sampler.setSeed(seed);
  return sampler.sampleToDataStream(nSamples);
}
Program: 21260
Project: 21260
Buggy source:
/** 
 * Generate a DataStream with the given number of samples and attributes (discrete and continuous).
 * @param seed, the seed of the random number generator.
 * @param nSamples, the number of samples of the data stream.
 * @param nDiscreteAtts, the number of discrete attributes.
 * @param nContinuousAttributes, the number of continuous attributes.
 * @return A valid {@code DataStream} object.
 */
public static DataStream<DynamicDataInstance> generate(int seed,int nSamples,int nDiscreteAtts,int nContinuousAttributes){
  DynamicBayesianNetworkGenerator.setSeed(seed);
  DynamicBayesianNetworkGenerator.setNumberOfContinuousVars(nContinuousAttributes);
  DynamicBayesianNetworkGenerator.setNumberOfDiscreteVars(nDiscreteAtts);
  DynamicBayesianNetworkGenerator.setNumberOfStates(2);
  int nTotal=nDiscreteAtts + nContinuousAttributes;
  DynamicBayesianNetworkGenerator.setNumberOfLinks((int)(0.2 * nTotal * (nTotal - 1) / 2));
  DynamicBayesianNetwork dbn=DynamicBayesianNetworkGenerator.generateDynamicBayesianNetwork();
  DynamicBayesianNetworkSampler sampler=new DynamicBayesianNetworkSampler(dbn);
  sampler.setSeed(seed);
  return sampler.sampleToDataBase(nSamples / 50,50);
}

Fixed version (ground truth):
/** 
 * Generate a DataStream with the given number of samples and attributes (discrete and continuous).
 * @param seed, the seed of the random number generator.
 * @param nSamples, the number of samples of the data stream.
 * @param nDiscreteAtts, the number of discrete attributes.
 * @param nContinuousAttributes, the number of continuous attributes.
 * @return A valid {@code DataStream} object.
 */
public static DataStream<DynamicDataInstance> generate(int seed,int nSamples,int nDiscreteAtts,int nContinuousAttributes){
  DynamicBayesianNetworkGenerator.setSeed(seed);
  DynamicBayesianNetworkGenerator.setNumberOfContinuousVars(nContinuousAttributes);
  DynamicBayesianNetworkGenerator.setNumberOfDiscreteVars(nDiscreteAtts);
  DynamicBayesianNetworkGenerator.setNumberOfStates(2);
  int nTotal=nDiscreteAtts + nContinuousAttributes;
  int nLinksMin=nTotal - 1;
  int nLinksMax=nTotal * (nTotal - 1) / 2;
  DynamicBayesianNetworkGenerator.setNumberOfLinks((int)(0.8 * nLinksMin + 0.2 * nLinksMax));
  DynamicBayesianNetwork dbn=DynamicBayesianNetworkGenerator.generateDynamicBayesianNetwork();
  DynamicBayesianNetworkSampler sampler=new DynamicBayesianNetworkSampler(dbn);
  sampler.setSeed(seed);
  return sampler.sampleToDataBase(nSamples / 50,50);
}
Program: 21263
Project: 21263
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean testConvergence(){
  boolean convergence=false;
  double newelbo=this.computeLogProbabilityOfEvidence();
  double percentage=100 * Math.abs(newelbo - local_elbo) / Math.abs(local_elbo);
  if (percentage < threshold) {
    convergence=true;
  }
  if (testELBO && (!convergence && (newelbo / nodes.size() < (local_elbo / nodes.size() - 0.01)) && local_iter > -1) || Double.isNaN(local_elbo)) {
    throw new IllegalStateException("String_Node_Str" + local_iter + "String_Node_Str"+ percentage+ "String_Node_Str"+ local_elbo+ "String_Node_Str"+ newelbo);
  }
  local_elbo=newelbo;
  return convergence;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean testConvergence(){
  boolean convergence=false;
  double newelbo=this.computeLogProbabilityOfEvidence();
  double percentage=100 * Math.abs(newelbo - local_elbo) / Math.abs(local_elbo);
  if (percentage < threshold || local_iter > this.getMaxIter()) {
    convergence=true;
  }
  if (testELBO && (!convergence && (newelbo / nodes.size() < (local_elbo / nodes.size() - 0.01)) && local_iter > -1) || Double.isNaN(local_elbo)) {
    throw new IllegalStateException("String_Node_Str" + local_iter + "String_Node_Str"+ percentage+ "String_Node_Str"+ local_elbo+ "String_Node_Str"+ newelbo);
  }
  local_elbo=newelbo;
  return convergence;
}
Program: 21264
Project: 21264
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean testConvergence(){
  boolean convergence=false;
  double newelbo=this.computeLogProbabilityOfEvidence();
  double percentage=100 * Math.abs(newelbo - local_elbo) / Math.abs(local_elbo);
  if (percentage < threshold) {
    convergence=true;
  }
  if (testELBO && (!convergence && (newelbo / nodes.size() < (local_elbo / nodes.size() - 0.01)) && local_iter > -1) || Double.isNaN(local_elbo)) {
    throw new IllegalStateException("String_Node_Str" + local_iter + "String_Node_Str"+ percentage+ "String_Node_Str"+ local_elbo+ "String_Node_Str"+ newelbo);
  }
  local_elbo=newelbo;
  return convergence;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean testConvergence(){
  boolean convergence=false;
  double newelbo=this.computeLogProbabilityOfEvidence();
  double percentage=100 * Math.abs(newelbo - local_elbo) / Math.abs(local_elbo);
  if (percentage < threshold || local_iter > this.getMaxIter()) {
    convergence=true;
  }
  if (testELBO && (!convergence && (newelbo / nodes.size() < (local_elbo / nodes.size() - 0.01)) && local_iter > -1) || Double.isNaN(local_elbo)) {
    throw new IllegalStateException("String_Node_Str" + local_iter + "String_Node_Str"+ percentage+ "String_Node_Str"+ local_elbo+ "String_Node_Str"+ newelbo);
  }
  local_elbo=newelbo;
  return convergence;
}
Program: 21265
Project: 21265
Buggy source:
/** 
 * Sets a new set of attributes. Links current variables with this new set by matching variable names with attributes names.
 * @param attributes an object of class {@link Attributes}
 */
public void setAttributes(Attributes attributes){
  for (  Variable variable : allVariables) {
    VariableImplementation variableImplementation=(VariableImplementation)variable;
    variableImplementation.setAttribute(attributes.getAttributeByName(variable.getName()));
  }
}

Fixed version (ground truth):
/** 
 * Sets a new set of attributes. Links current variables with this new set by matching variable names with attributes names.
 * @param attributes an object of class {@link Attributes}
 */
public void setAttributes(Attributes attributes){
  for (  Attribute att : attributes) {
    Variable variable=this.getVariableByName(att.getName());
    VariableImplementation variableImplementation=(VariableImplementation)variable;
    variableImplementation.setAttribute(att);
  }
}