nus-yam/ex-repair huggingface dataset:
Program: 21389
Project: 21389
Buggy source:
public BayesianNetwork train(DataOnMemory<DataInstance> data,StaticVariables allVars,List<Variable> SF,boolean includeClassVariablePM){
  DAG dag=new DAG(allVars);
  if (data.getDataInstance(0).getValue(TIME_ID) != 0 && includeClassVariablePM)   dag.getParentSet(classVariable).addParent(classVariable_PM);
  dag.getParentSets().stream().filter(parent -> SF.contains(parent.getMainVar())).filter(w -> w.getMainVar().getVarID() != classVariable.getVarID()).forEach(w -> w.addParent(classVariable));
  StreamingVariationalBayesVMP vmp=new StreamingVariationalBayesVMP();
  vmp.setDAG(dag);
  vmp.setDataStream(data);
  vmp.setWindowsSize(100);
  vmp.runLearning();
  return vmp.getLearntBayesianNetwork();
}

Fixed version (ground truth):
public BayesianNetwork train(DataOnMemory<DataInstance> data,StaticVariables allVars,List<Variable> SF){
  DAG dag=new DAG(allVars);
  if (data.getDataInstance(0).getValue(TIME_ID) != 0)   dag.getParentSet(classVariable).addParent(classVariable_PM);
  dag.getParentSets().stream().filter(parent -> SF.contains(parent.getMainVar())).filter(w -> w.getMainVar().getVarID() != classVariable.getVarID()).forEach(w -> w.addParent(classVariable));
  StreamingVariationalBayesVMP vmp=new StreamingVariationalBayesVMP();
  vmp.setDAG(dag);
  vmp.setDataStream(data);
  vmp.setWindowsSize(100);
  vmp.runLearning();
  return vmp.getLearntBayesianNetwork();
}
Program: 21392
Project: 21392
Buggy source:
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  BayesianNetwork bNet=null;
  for (int i=0; i < NbrClients; i++) {
    Multinomial uniform=new Multinomial(classVariable_PM);
    uniform.setProbabilityOfState(DEFAULTER_VALUE_INDEX,0.5);
    uniform.setProbabilityOfState(NON_DEFAULTER_VALUE_INDEX,0.5);
    posteriors.put(i,uniform);
  }
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 11; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonth(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID) + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}

Fixed version (ground truth):
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID) + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}
Program: 21393
Project: 21393
Buggy source:
public BayesianNetwork train(DataOnMemory<DataInstance> data,StaticVariables allVars,List<Variable> SF,boolean includeClassVariablePM){
  DAG dag=new DAG(allVars);
  if (data.getDataInstance(0).getValue(TIME_ID) != 0 && includeClassVariablePM)   dag.getParentSet(classVariable).addParent(classVariable_PM);
  dag.getParentSets().stream().filter(parent -> SF.contains(parent.getMainVar())).filter(w -> w.getMainVar().getVarID() != classVariable.getVarID()).forEach(w -> w.addParent(classVariable));
  StreamingVariationalBayesVMP vmp=new StreamingVariationalBayesVMP();
  vmp.setDAG(dag);
  vmp.setDataStream(data);
  vmp.setWindowsSize(100);
  vmp.runLearning();
  return vmp.getLearntBayesianNetwork();
}

Fixed version (ground truth):
public BayesianNetwork train(DataOnMemory<DataInstance> data,StaticVariables allVars,List<Variable> SF){
  DAG dag=new DAG(allVars);
  if (data.getDataInstance(0).getValue(TIME_ID) != 0)   dag.getParentSet(classVariable).addParent(classVariable_PM);
  dag.getParentSets().stream().filter(parent -> SF.contains(parent.getMainVar())).filter(w -> w.getMainVar().getVarID() != classVariable.getVarID()).forEach(w -> w.addParent(classVariable));
  StreamingVariationalBayesVMP vmp=new StreamingVariationalBayesVMP();
  vmp.setDAG(dag);
  vmp.setDataStream(data);
  vmp.setWindowsSize(100);
  vmp.runLearning();
  return vmp.getLearntBayesianNetwork();
}
Program: 21395
Project: 21395
Buggy source:
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID) + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}

Fixed version (ground truth):
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    int idMonthMinus12=(int)monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(idMonthMinus12 + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}
Program: 21396
Project: 21396
Buggy source:
public static void main(String[] args) throws IOException {
  DataStream<DataInstance> data=DataStreamLoader.loadFromFile("String_Node_Str");
  for (int i=1; i < args.length; i++) {
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setUsePRCArea(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNonDeterministic(true);
  }
  wrapperBN wbnet=new wrapperBN();
  wbnet.learnCajamarModel(data);
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  DataStream<DataInstance> data=DataStreamLoader.loadFromFile("String_Node_Str");
  for (int i=1; i < args.length; i++) {
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setUsePRCArea(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNonDeterministic(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNB(true);
  }
  wrapperBN wbnet=new wrapperBN();
  wbnet.learnCajamarModel(data);
}
Program: 21400
Project: 21400
Buggy source:
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    int idMonthMinus12=(int)monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(idMonthMinus12 + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}

Fixed version (ground truth):
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=0;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  while (iterator.hasNext()) {
    int idMonthMinus12=(int)monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID);
    BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.poll());
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(idMonthMinus12 + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}
Program: 21401
Project: 21401
Buggy source:
public static void main(String[] args) throws IOException {
  DataStream<DataInstance> data=DataStreamLoader.loadFromFile("String_Node_Str");
  for (int i=1; i < args.length; i++) {
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setUsePRCArea(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNonDeterministic(true);
  }
  wrapperBN wbnet=new wrapperBN();
  wbnet.learnCajamarModel(data);
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  DataStream<DataInstance> data=DataStreamLoader.loadFromFile("String_Node_Str");
  for (int i=1; i < args.length; i++) {
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setUsePRCArea(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNonDeterministic(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNB(true);
  }
  wrapperBN wbnet=new wrapperBN();
  wbnet.learnCajamarModel(data);
}
Program: 21405
Project: 21405
Buggy source:
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    int idMonthMinus12=(int)monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(idMonthMinus12 + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}

Fixed version (ground truth):
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=0;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  while (iterator.hasNext()) {
    int idMonthMinus12=(int)monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID);
    BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.poll());
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(idMonthMinus12 + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}
Program: 21406
Project: 21406
Buggy source:
public static void main(String[] args) throws IOException {
  DataStream<DataInstance> data=DataStreamLoader.loadFromFile("String_Node_Str");
  for (int i=1; i < args.length; i++) {
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setUsePRCArea(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNonDeterministic(true);
  }
  wrapperBN wbnet=new wrapperBN();
  wbnet.learnCajamarModel(data);
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  DataStream<DataInstance> data=DataStreamLoader.loadFromFile("String_Node_Str");
  for (int i=1; i < args.length; i++) {
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setUsePRCArea(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNonDeterministic(true);
    if (args[i].equalsIgnoreCase("String_Node_Str"))     setNB(true);
  }
  wrapperBN wbnet=new wrapperBN();
  wbnet.learnCajamarModel(data);
}
Program: 21410
Project: 21410
Buggy source:
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    int idMonthMinus12=(int)monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(idMonthMinus12 + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}

Fixed version (ground truth):
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=0;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  while (iterator.hasNext()) {
    int idMonthMinus12=(int)monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID);
    BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.poll());
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(idMonthMinus12 + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}
Program: 21413
Project: 21413
Buggy source:
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  BayesianNetwork bNet=null;
  for (int i=0; i < NbrClients; i++) {
    Multinomial uniform=new Multinomial(classVariable_PM);
    uniform.setProbabilityOfState(DEFAULTER_VALUE_INDEX,0.5);
    uniform.setProbabilityOfState(NON_DEFAULTER_VALUE_INDEX,0.5);
    posteriors.put(i,uniform);
  }
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 11; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonth(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID) + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}

Fixed version (ground truth):
void learnCajamarModel(DataStream<DataInstance> data){
  StaticVariables Vars=new StaticVariables(data.getAttributes());
  classVariable=Vars.getVariableById(Vars.getNumberOfVars() - 1);
  classVariable_PM=Vars.getVariableById(Vars.getNumberOfVars() - 2);
  TIME_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  SEQUENCE_ID=data.getAttributes().getAttributeByName("String_Node_Str");
  int count=NbrClients;
  double averageAUC=0;
  Iterable<DataOnMemory<DataInstance>> iteratable=data.iterableOverBatches(NbrClients);
  Iterator<DataOnMemory<DataInstance>> iterator=iteratable.iterator();
  Queue<DataOnMemory<DataInstance>> monthsMinus12to0=new LinkedList<>();
  for (int i=0; i < 2; i++) {
    monthsMinus12to0.add(iterator.next());
  }
  BayesianNetwork bn=wrapperBNOneMonthNB(monthsMinus12to0.peek());
  while (iterator.hasNext()) {
    DataOnMemory<DataInstance> currentMonth=iterator.next();
    monthsMinus12to0.add(currentMonth);
    double auc=propagateAndTest(monthsMinus12to0,bn);
    System.out.println(monthsMinus12to0.peek().getDataInstance(0).getValue(TIME_ID) + "String_Node_Str" + auc);
    averageAUC+=auc;
    count+=NbrClients;
    monthsMinus12to0.remove();
  }
  System.out.println("String_Node_Str" + averageAUC / (count / NbrClients));
}
Program: 21414
Project: 21414
Buggy source:
public BayesianNetwork train(DataOnMemory<DataInstance> data,StaticVariables allVars,List<Variable> SF,boolean includeClassVariablePM){
  DAG dag=new DAG(allVars);
  if (data.getDataInstance(0).getValue(TIME_ID) != 0 && includeClassVariablePM)   dag.getParentSet(classVariable).addParent(classVariable_PM);
  dag.getParentSets().stream().filter(parent -> SF.contains(parent.getMainVar())).filter(w -> w.getMainVar().getVarID() != classVariable.getVarID()).forEach(w -> w.addParent(classVariable));
  StreamingVariationalBayesVMP vmp=new StreamingVariationalBayesVMP();
  vmp.setDAG(dag);
  vmp.setDataStream(data);
  vmp.setWindowsSize(100);
  vmp.runLearning();
  return vmp.getLearntBayesianNetwork();
}

Fixed version (ground truth):
public BayesianNetwork train(DataOnMemory<DataInstance> data,StaticVariables allVars,List<Variable> SF){
  DAG dag=new DAG(allVars);
  if (data.getDataInstance(0).getValue(TIME_ID) != 0)   dag.getParentSet(classVariable).addParent(classVariable_PM);
  dag.getParentSets().stream().filter(parent -> SF.contains(parent.getMainVar())).filter(w -> w.getMainVar().getVarID() != classVariable.getVarID()).forEach(w -> w.addParent(classVariable));
  StreamingVariationalBayesVMP vmp=new StreamingVariationalBayesVMP();
  vmp.setDAG(dag);
  vmp.setDataStream(data);
  vmp.setWindowsSize(100);
  vmp.runLearning();
  return vmp.getLearntBayesianNetwork();
}
Program: 21419
Project: 21419
Buggy source:
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList<>();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}

Fixed version (ground truth):
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}
Program: 21420
Project: 21420
Buggy source:
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}

Fixed version (ground truth):
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    if (momentValue == 0)     continue;
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}
Program: 21421
Project: 21421
Buggy source:
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if (elbo > 0.1 && !this.isObserved()) {
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}

Fixed version (ground truth):
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if ((elbo > 0.5 && !this.isObserved()) || Double.isNaN(elbo)) {
    this.PDist.getExpectedLogNormalizer(momentParents);
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}
Program: 21422
Project: 21422
Buggy source:
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList<>();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}

Fixed version (ground truth):
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}
Program: 21423
Project: 21423
Buggy source:
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}

Fixed version (ground truth):
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    if (momentValue == 0)     continue;
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}
Program: 21424
Project: 21424
Buggy source:
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if (elbo > 0.1 && !this.isObserved()) {
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}

Fixed version (ground truth):
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if ((elbo > 0.5 && !this.isObserved()) || Double.isNaN(elbo)) {
    this.PDist.getExpectedLogNormalizer(momentParents);
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}
Program: 21425
Project: 21425
Buggy source:
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList<>();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}

Fixed version (ground truth):
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}
Program: 21426
Project: 21426
Buggy source:
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}

Fixed version (ground truth):
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    if (momentValue == 0)     continue;
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}
Program: 21427
Project: 21427
Buggy source:
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if (elbo > 0.1 && !this.isObserved()) {
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}

Fixed version (ground truth):
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if ((elbo > 0.5 && !this.isObserved()) || Double.isNaN(elbo)) {
    this.PDist.getExpectedLogNormalizer(momentParents);
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}
Program: 21428
Project: 21428
Buggy source:
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList<>();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}

Fixed version (ground truth):
@Override public ConditionalDistribution toConditionalDistribution(Map<Variable,Vector> expectedParameters){
  List<Distribution> distributionList=new ArrayList();
  for (  EF_Distribution dist : this.distributions) {
    EF_ConditionalLearningDistribution learningDistribution=(EF_ConditionalLearningDistribution)dist;
    ConditionalDistribution conditionalDistribution=learningDistribution.toConditionalDistribution(expectedParameters);
    if (conditionalDistribution instanceof BaseDistribution_MultinomialParents) {
      BaseDistribution_MultinomialParents base=(BaseDistribution_MultinomialParents)conditionalDistribution;
      distributionList.add(base.getBaseDistribution(0));
    }
 else {
      distributionList.add(conditionalDistribution);
    }
  }
  return new BaseDistribution_MultinomialParents(this.multinomialParents,distributionList);
}
Program: 21429
Project: 21429
Buggy source:
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}

Fixed version (ground truth):
@Override public double getExpectedLogNormalizer(Map<Variable,MomentParameters> momentParents){
  int nConf=MultinomialIndex.getNumberOfPossibleAssignments(this.multinomialParents);
  double expectedLogNormalizer=0;
  for (int i=0; i < nConf; i++) {
    double[] assignment=MultinomialIndex.getVariableArrayAssignmentFromIndex(this.multinomialParents,i);
    double momentValue=1;
    for (int j=0; j < assignment.length; j++) {
      momentValue*=momentParents.get(this.multinomialParents.get(j)).get((int)assignment[j]);
    }
    if (momentValue == 0)     continue;
    double partialLogNormalizer=0;
    if (this.isBaseConditionalDistribution) {
      partialLogNormalizer=this.getBaseEFConditionalDistribution(i).getExpectedLogNormalizer(momentParents);
    }
 else {
      partialLogNormalizer=this.getBaseEFUnivariateDistribution(i).computeLogNormalizer();
    }
    expectedLogNormalizer+=momentValue * partialLogNormalizer;
  }
  return expectedLogNormalizer;
}
Program: 21430
Project: 21430
Buggy source:
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if (elbo > 0.1 && !this.isObserved()) {
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}

Fixed version (ground truth):
public double computeELBO(){
  Map<Variable,MomentParameters> momentParents=this.getMomentParents();
  double elbo=0;
  NaturalParameters expectedNatural=this.PDist.getExpectedNaturalFromParents(momentParents);
  if (!isObserved()) {
    expectedNatural.substract(this.QDist.getNaturalParameters());
    elbo+=expectedNatural.dotProduct(this.QDist.getMomentParameters());
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.QDist.computeLogNormalizer();
  }
 else {
    elbo+=expectedNatural.dotProduct(this.sufficientStatistics);
    elbo-=this.PDist.getExpectedLogNormalizer(momentParents);
    elbo+=this.PDist.computeLogBaseMeasure(this.assignment);
  }
  if (elbo > 0 && !this.isObserved() && Math.abs(expectedNatural.sum()) < 0.01) {
    elbo=0;
  }
  if ((elbo > 0.5 && !this.isObserved()) || Double.isNaN(elbo)) {
    this.PDist.getExpectedLogNormalizer(momentParents);
    throw new IllegalStateException("String_Node_Str" + this.getMainVariable().getName() + "String_Node_Str"+ elbo+ "String_Node_Str"+ expectedNatural.sum());
  }
  return elbo;
}