Program: 189432
Project: 189432
Buggy source:
/** 
 * This method returns the predictive distribution over the conditional path. Note that the prior must be converted to this path's distance and direction, and the current vehicle state must have a value for its path state parameter.
 * @param prior
 * @return
 */
@Override public PathStateMixtureDensityModel createPredictiveDistribution(MultivariateGaussian prior){
  final List<PathStateDistribution> distributions=Lists.newArrayList();
  final List<Double> weights=Lists.newArrayList();
  double totalWeight=Double.NEGATIVE_INFINITY;
  if (this.path.isNullPath()) {
    MultivariateGaussian groundDistribution;
    if (prior.getInputDimensionality() == 4) {
      groundDistribution=prior.clone();
    }
 else {
      final PathState prevPathState=this.currentState.getPathStateParam().getValue();
      groundDistribution=PathUtils.getGroundBeliefFromRoad(prior.clone(),prevPathState.getEdge(),true,true);
    }
    distributions.add(new PathStateDistribution(this.path,groundDistribution));
    weights.add(0d);
    totalWeight=0d;
  }
 else {
    if (prior.getInputDimensionality() == 4) {
      final MultivariateGaussian roadDistribution=PathUtils.getRoadBeliefFromGround(prior,Iterables.getOnlyElement(this.path.getPathEdges()),true,this.currentState.getPathStateParam().getValue().getMotionState(),this.currentTimeDiff);
      if (roadDistribution.getMean().getElement(1) > 0d) {
        distributions.add(new PathStateDistribution(this.path,roadDistribution));
        weights.add(0d);
        totalWeight=0d;
      }
    }
 else {
      final MultivariateGaussian roadDistribution=prior;
      for (      final PathEdge edge : this.path.getPathEdges()) {
        final TruncatedRoadGaussian edgeResult=PathStateEstimatorPredictor.getPathEdgePredictive(roadDistribution,edge,this.currentState.getObservation().getObsProjected(),null,this.currentTimeDiff);
        final PathStateDistribution prediction=new PathStateDistribution(this.path.getPathTo(edge),edgeResult);
        distributions.add(prediction);
        final double edgeWeight=roadDistribution.getProbabilityFunction().logEvaluate(prediction.getMean());
        totalWeight=LogMath.add(totalWeight,edgeWeight);
        weights.add(edgeWeight);
      }
    }
  }
  final double[] nativeWeights=new double[weights.size()];
  int i=0;
  for (  final Double weight : weights) {
    nativeWeights[i]=weight - totalWeight;
    i++;
  }
  final PathStateMixtureDensityModel result=new PathStateMixtureDensityModel(distributions,nativeWeights);
  Preconditions.checkState(result.getDistributionCount() == 0 || Math.abs(Math.exp(result.getPriorWeightSum()) - 1d) < 1e-5);
  return result;
}

Fixed version (ground truth):
/** 
 * This method returns the predictive distribution over the conditional path. Note that the prior must be converted to this path's distance and direction, and the current vehicle state must have a value for its path state parameter.
 * @param prior
 * @return
 */
@Override public PathStateMixtureDensityModel createPredictiveDistribution(MultivariateGaussian prior){
  final List<PathStateDistribution> distributions=Lists.newArrayList();
  final List<Double> weights=Lists.newArrayList();
  double totalWeight=Double.NEGATIVE_INFINITY;
  if (this.path.isNullPath()) {
    MultivariateGaussian groundDistribution;
    if (prior.getInputDimensionality() == 4) {
      groundDistribution=prior.clone();
    }
 else {
      final PathState prevPathState=this.currentState.getPathStateParam().getValue();
      groundDistribution=PathUtils.getGroundBeliefFromRoad(prior.clone(),prevPathState.getEdge(),true,true);
    }
    distributions.add(new PathStateDistribution(this.path,groundDistribution));
    weights.add(0d);
    totalWeight=0d;
  }
 else {
    if (prior.getInputDimensionality() == 4) {
      final MultivariateGaussian roadDistribution=PathUtils.getRoadBeliefFromGround(prior,Iterables.getOnlyElement(this.path.getPathEdges()),true,this.currentState.getPathStateParam().getValue().getMotionState(),this.currentTimeDiff);
      if (roadDistribution.getMean().getElement(1) > 0d) {
        distributions.add(new PathStateDistribution(this.path,roadDistribution));
        weights.add(0d);
        totalWeight=0d;
      }
    }
 else {
      final MultivariateGaussian roadDistribution=prior;
      for (      final PathEdge edge : this.path.getPathEdges()) {
        final TruncatedRoadGaussian edgeResult=PathStateEstimatorPredictor.getPathEdgePredictive(roadDistribution,this.currentState.getOnRoadModelCovarianceParam().getValue(),edge,this.currentState.getObservation().getObsProjected(),null,this.currentTimeDiff);
        final PathStateDistribution prediction=new PathStateDistribution(this.path.getPathTo(edge),edgeResult);
        distributions.add(prediction);
        final double edgeWeight=roadDistribution.getProbabilityFunction().logEvaluate(prediction.getMean());
        totalWeight=LogMath.add(totalWeight,edgeWeight);
        weights.add(edgeWeight);
      }
    }
  }
  final double[] nativeWeights=new double[weights.size()];
  int i=0;
  for (  final Double weight : weights) {
    nativeWeights[i]=weight - totalWeight;
    i++;
  }
  final PathStateMixtureDensityModel result=new PathStateMixtureDensityModel(distributions,nativeWeights);
  Preconditions.checkState(result.getDistributionCount() == 0 || Math.abs(Math.exp(result.getPriorWeightSum()) - 1d) < 1e-5);
  return result;
}