Program: 37722
Project: 37722
Buggy source:
public static SegmentationResult viterbi_segmentation(double[][] y,double alpha_0,double beta_0,int nb_r,int r,double p,int m){
  @SuppressWarnings("String_Node_Str") ExtremeObjectTracker<Integer,Double>[][] map_j=new ExtremeObjectTracker[m + 1][y[0].length];
  SCMResult[] results=new SCMResult[y.length];
  for (int i=0; i < y.length; i++) {
    results[i]=calculate_segment_probabilities(y[i],alpha_0,beta_0,nb_r);
  }
  int n=y[0].length;
  double[][] log_q_j=new double[m + 1][n];
  double[] log_g=new double[n];
  double[] log_G=new double[n];
  double[] g0=new double[n];
  double[] G0=new double[n];
  log_G[0]=Double.NEGATIVE_INFINITY;
  for (int i=0; i < n; i++) {
    for (int j=0; j < m + 1; j++) {
      map_j[j][i]=new ExtremeObjectTracker<Integer,Double>(new Util.ComparableComparator<Double>());
    }
    log_g[i]=log_nb(i + 1,r,p);
    if (i > 0)     log_G[i]=log_G[i - 1];
    log_G[i]+=Util.logSum(Util.list(log_G[i],log_g[i]));
  }
{
    int j=m + 1 - 1;
    for (int t=n - 1; t > j - 1; t--) {
      int s=n - 1;
      double log_p_t_s=0;
      for (int i=0; i < results.length; i++) {
        log_p_t_s+=results[i].log_p[t][s];
      }
      log_q_j[j][t]=log_p_t_s + Math.log(1 - Math.exp(log_G[s - t + 1]));
      map_j[j][t].put(s + 1,log_p_t_s + Math.log(1 - Math.exp(log_G[s - t + 1])));
    }
  }
  for (int j=m + 1 - 2; j > -1; j--) {
    for (int t=n - m - 1 + j; t > j - 1; t--) {
      List<Double> log_probs=new LinkedList<Double>();
      for (int s=t; s < n - m - 1 + j + 1; s++) {
        double log_p_t_s=0;
        for (int i=0; i < results.length; i++) {
          log_p_t_s+=results[i].log_p[t][s];
        }
        log_probs.add(log_p_t_s + log_q_j[j + 1][s + 1] + log_g[s - t + 1]);
        map_j[j][t].put(s + 1,log_p_t_s + map_j[j + 1][s + 1].getExtremeValue() + log_g[s - t + 1]);
      }
      log_q_j[j][t]=Util.logSum(log_probs);
    }
  }
  MapList<String,Double[]> dat=new MapList<String,Double[]>();
  try {
    for (int i=0; i < n; i++) {
      int previousChangePoint=-1;
      double d=(results[0].log_p[previousChangePoint + 1][i] + results[1].log_p[previousChangePoint + 1][i] + results[2].log_p[previousChangePoint + 1][i]+ log_q_j[1][i + 1]+ log_g[i - previousChangePoint] - log_q_j[0][previousChangePoint + 1]);
      dat.put("String_Node_Str",new Double[]{i + 0.,d});
      System.out.println(d);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  try {
    int previousChangePoint=68;
    for (int i=previousChangePoint; i < n; i++) {
      double d=(results[0].log_p[previousChangePoint + 1][i] + results[1].log_p[previousChangePoint + 1][i] + results[2].log_p[previousChangePoint + 1][i]+ log_q_j[2][i + 1]+ log_g[i - previousChangePoint] - log_q_j[1][previousChangePoint + 1]);
      dat.put("String_Node_Str",new Double[]{i + 0.,d});
      System.out.println(d);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  try {
    int previousChangePoint=241;
    for (int i=previousChangePoint; i < n; i++) {
      double d=(results[0].log_p[previousChangePoint + 1][i] + results[1].log_p[previousChangePoint + 1][i] + results[2].log_p[previousChangePoint + 1][i]+ log_q_j[3][i + 1]+ log_g[i - previousChangePoint] - log_q_j[2][previousChangePoint + 1]);
      dat.put("String_Node_Str",new Double[]{i + 0.,d});
      System.out.println(d);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  List<Integer> mapCPs=new LinkedList<Integer>();
  List<Double> mapMLEs=new LinkedList<Double>();
  List<Double> mapLs=new LinkedList<Double>();
  int first=0;
  int j=0;
  int last=map_j[j][0].getExtreme();
  j++;
  while (j < m + 1) {
    mapCPs.add(last - 1);
    first=last;
    last=map_j[j][last].getExtreme();
    j++;
  }
  SegmentationResult segmentation=new SegmentationResult(ArrayUtils.toPrimitive(mapCPs.toArray(new Integer[0])),ArrayUtils.toPrimitive(mapMLEs.toArray(new Double[0])),ArrayUtils.toPrimitive(mapLs.toArray(new Double[0])),n);
  return segmentation;
}

Fixed version (ground truth):
public static SegmentationResult viterbi_segmentation(double[][] y,double alpha_0,double beta_0,int nb_r,int r,double p,int m){
  @SuppressWarnings("String_Node_Str") ExtremeObjectTracker<Integer,Double>[][] map_j=new ExtremeObjectTracker[m + 1][y[0].length];
  SCMResult[] results=new SCMResult[y.length];
  for (int i=0; i < y.length; i++) {
    results[i]=calculate_segment_probabilities(y[i],alpha_0,beta_0,nb_r);
  }
  int n=y[0].length;
  double[][] log_q_j=new double[m + 1][n];
  double[] log_g=new double[n];
  double[] log_G=new double[n];
  double[] g0=new double[n];
  double[] G0=new double[n];
  log_G[0]=Double.NEGATIVE_INFINITY;
  for (int i=0; i < n; i++) {
    for (int j=0; j < m + 1; j++) {
      map_j[j][i]=new ExtremeObjectTracker<Integer,Double>(new Util.ComparableComparator<Double>());
    }
    log_g[i]=log_nb(i + 1,r,p);
    if (i > 0)     log_G[i]=log_G[i - 1];
    log_G[i]+=Util.logSum(Util.list(log_G[i],log_g[i]));
  }
{
    int j=m + 1 - 1;
    for (int t=n - 1; t > j - 1; t--) {
      int s=n - 1;
      double log_p_t_s=0;
      for (int i=0; i < results.length; i++) {
        log_p_t_s+=results[i].log_p[t][s];
      }
      log_q_j[j][t]=log_p_t_s + Math.log(1 - Math.exp(log_G[s - t + 1]));
      map_j[j][t].put(s + 1,log_p_t_s + Math.log(1 - Math.exp(log_G[s - t + 1])));
    }
  }
  for (int j=m + 1 - 2; j > -1; j--) {
    for (int t=n - m - 1 + j; t > j - 1; t--) {
      List<Double> log_probs=new ArrayList<Double>();
      for (int s=t; s < n - m - 1 + j + 1; s++) {
        double log_p_t_s=0;
        for (int i=0; i < results.length; i++) {
          log_p_t_s+=results[i].log_p[t][s];
        }
        log_probs.add(log_p_t_s + log_q_j[j + 1][s + 1] + log_g[s - t + 1]);
        map_j[j][t].put(s + 1,log_p_t_s + map_j[j + 1][s + 1].getExtremeValue() + log_g[s - t + 1]);
      }
      log_q_j[j][t]=Util.logSum(log_probs);
    }
  }
  MapList<String,Double[]> dat=new MapList<String,Double[]>();
  try {
    for (int i=0; i < n; i++) {
      int previousChangePoint=-1;
      double d=(results[0].log_p[previousChangePoint + 1][i] + results[1].log_p[previousChangePoint + 1][i] + results[2].log_p[previousChangePoint + 1][i]+ log_q_j[1][i + 1]+ log_g[i - previousChangePoint] - log_q_j[0][previousChangePoint + 1]);
      dat.put("String_Node_Str",new Double[]{i + 0.,d});
      System.out.println(d);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  try {
    int previousChangePoint=68;
    for (int i=previousChangePoint; i < n; i++) {
      double d=(results[0].log_p[previousChangePoint + 1][i] + results[1].log_p[previousChangePoint + 1][i] + results[2].log_p[previousChangePoint + 1][i]+ log_q_j[2][i + 1]+ log_g[i - previousChangePoint] - log_q_j[1][previousChangePoint + 1]);
      dat.put("String_Node_Str",new Double[]{i + 0.,d});
      System.out.println(d);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  try {
    int previousChangePoint=241;
    for (int i=previousChangePoint; i < n; i++) {
      double d=(results[0].log_p[previousChangePoint + 1][i] + results[1].log_p[previousChangePoint + 1][i] + results[2].log_p[previousChangePoint + 1][i]+ log_q_j[3][i + 1]+ log_g[i - previousChangePoint] - log_q_j[2][previousChangePoint + 1]);
      dat.put("String_Node_Str",new Double[]{i + 0.,d});
      System.out.println(d);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  List<Integer> mapCPs=new ArrayList<Integer>();
  List<Double> mapMLEs=new ArrayList<Double>();
  List<Double> mapLs=new ArrayList<Double>();
  int first=0;
  int j=0;
  int last=map_j[j][0].getExtreme();
  j++;
  while (j < m + 1) {
    mapCPs.add(last - 1);
    first=last;
    last=map_j[j][last].getExtreme();
    j++;
  }
  SegmentationResult segmentation=new SegmentationResult(ArrayUtils.toPrimitive(mapCPs.toArray(new Integer[0])),ArrayUtils.toPrimitive(mapMLEs.toArray(new Double[0])),ArrayUtils.toPrimitive(mapLs.toArray(new Double[0])),n);
  return segmentation;
}