Program: 21233
Project: 21233
Buggy source:
public static void main(String[] args){
  Variables variables=new Variables();
  Variable word=variables.newSparseMultionomialVariable("String_Node_Str",2);
  Variable topicIndicator=variables.newMultionomialVariable("String_Node_Str",1);
  DAG dagLDA=new DAG(variables);
  dagLDA.setName("String_Node_Str");
  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);
  EF_Dirichlet dirichletOld=(EF_Dirichlet)ef_learningmodel.getDistributionList().get(2);
  EF_Dirichlet dirichletUnif=Serialization.deepCopy(dirichletOld);
  EF_Dirichlet dirichletNew=Serialization.deepCopy(dirichletOld);
  Variable expVar=variables.newTruncatedExponential("String_Node_Str");
  EF_TruncatedExponential ef_truncatedExponential=expVar.getDistributionType().newEFUnivariateDistribution();
  double alpha=1.0;
  for (int i=0; i < 10; i++) {
    double nUnif=0.1;
    dirichletUnif.getNaturalParameters().set(0,nUnif);
    dirichletUnif.getNaturalParameters().set(1,1000);
    dirichletUnif.updateMomentFromNaturalParameters();
    double distOld=0.01;
    double NOld=1e6;
    dirichletOld.getNaturalParameters().set(0,NOld * distOld);
    dirichletOld.getNaturalParameters().set(1,NOld * (1 - distOld));
    dirichletOld.updateMomentFromNaturalParameters();
    double distNew=0.05;
    double Nnew=9.7e3;
    dirichletNew.getNaturalParameters().set(0,Nnew * distNew + alpha * NOld * distOld + (1 - alpha) * nUnif);
    dirichletNew.getNaturalParameters().set(1,Nnew * (1 - distNew) + alpha * NOld * (1 - distOld) + (1 - alpha) * nUnif);
    dirichletNew.updateMomentFromNaturalParameters();
    double klOld=dirichletNew.kl(dirichletOld.getNaturalParameters(),dirichletOld.computeLogNormalizer());
    double klUnif=dirichletNew.kl(dirichletUnif.getNaturalParameters(),dirichletUnif.computeLogNormalizer());
    System.out.println(klOld);
    System.out.println(klUnif);
    System.out.println(klUnif - klOld);
    ef_truncatedExponential.getNaturalParameters().set(0,klUnif - klOld);
    ef_truncatedExponential.updateMomentFromNaturalParameters();
    System.out.println(ef_truncatedExponential.getMomentParameters().get(0));
    alpha=ef_truncatedExponential.getMomentParameters().get(0);
    System.out.println();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  Variables variables=new Variables();
  Variable word=variables.newSparseMultionomialVariable("String_Node_Str",2);
  Variable topicIndicator=variables.newMultinomialVariable("String_Node_Str",1);
  DAG dagLDA=new DAG(variables);
  dagLDA.setName("String_Node_Str");
  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);
  EF_Dirichlet dirichletOld=(EF_Dirichlet)ef_learningmodel.getDistributionList().get(2);
  EF_Dirichlet dirichletUnif=Serialization.deepCopy(dirichletOld);
  EF_Dirichlet dirichletNew=Serialization.deepCopy(dirichletOld);
  Variable expVar=variables.newTruncatedExponential("String_Node_Str");
  EF_TruncatedExponential ef_truncatedExponential=expVar.getDistributionType().newEFUnivariateDistribution();
  double alpha=1.0;
  for (int i=0; i < 10; i++) {
    double nUnif=0.1;
    dirichletUnif.getNaturalParameters().set(0,nUnif);
    dirichletUnif.getNaturalParameters().set(1,1000);
    dirichletUnif.updateMomentFromNaturalParameters();
    double distOld=0.01;
    double NOld=1e6;
    dirichletOld.getNaturalParameters().set(0,NOld * distOld);
    dirichletOld.getNaturalParameters().set(1,NOld * (1 - distOld));
    dirichletOld.updateMomentFromNaturalParameters();
    double distNew=0.05;
    double Nnew=9.7e3;
    dirichletNew.getNaturalParameters().set(0,Nnew * distNew + alpha * NOld * distOld + (1 - alpha) * nUnif);
    dirichletNew.getNaturalParameters().set(1,Nnew * (1 - distNew) + alpha * NOld * (1 - distOld) + (1 - alpha) * nUnif);
    dirichletNew.updateMomentFromNaturalParameters();
    double klOld=dirichletNew.kl(dirichletOld.getNaturalParameters(),dirichletOld.computeLogNormalizer());
    double klUnif=dirichletNew.kl(dirichletUnif.getNaturalParameters(),dirichletUnif.computeLogNormalizer());
    System.out.println(klOld);
    System.out.println(klUnif);
    System.out.println(klUnif - klOld);
    ef_truncatedExponential.getNaturalParameters().set(0,klUnif - klOld);
    ef_truncatedExponential.updateMomentFromNaturalParameters();
    System.out.println(ef_truncatedExponential.getMomentParameters().get(0));
    alpha=ef_truncatedExponential.getMomentParameters().get(0);
    System.out.println();
  }
}