Program: 189431
Project: 189431
Buggy source:
/** 
 * This method takes a prior predictive vehicle state distribution and returns a distribution over its possible transition states, with prior predictive likelihood weights.
 * @param predictedState
 * @param obs
 * @return
 */
protected CountedDataDistribution<VehicleStateDistribution<O>> internalPriorPrediction(VehicleStateDistribution<O> predictedState,O obs){
  final CountedDataDistribution<VehicleStateDistribution<O>> childDist=new CountedDataDistribution<VehicleStateDistribution<O>>(true);
  final PathStateMixtureDensityModel predictedPathStateMixture=predictedState.getPathStateParam().getConditionalDistribution();
  for (int i=0; i < predictedPathStateMixture.getDistributionCount(); i++) {
    final PathStateDistribution predictedPathStateDist=predictedPathStateMixture.getDistributions().get(i);
    final double pathStateDistLogLikelihood=predictedPathStateMixture.getPriorWeights()[i];
    OnOffEdgeTransProbabilityFunction edgeTransProbFunction=predictedState.getEdgeTransitionParam().getConditionalDistribution().getProbabilityFunction().clone();
    final double edgeTransitionLogLikelihood=edgeTransProbFunction.logEvaluate(predictedPathStateDist.getPathState().getEdge().getInferenceGraphSegment());
    final VehicleStateDistribution<O> predictedChildState=predictedState.clone();
    predictedChildState.setPathStateParam(SimpleBayesianParameter.create(predictedPathStateDist.getPathState(),predictedPathStateMixture,predictedPathStateDist));
    final MultivariateGaussian measurementPredictionDist=predictedState.getMotionStateEstimatorPredictor().getMeasurementDistribution(predictedPathStateDist);
    predictedChildState.setMotionStateParam(SimpleBayesianParameter.create(measurementPredictionDist.getMean(),measurementPredictionDist,predictedPathStateDist.getMotionDistribution()));
    final double predictiveLogLikelihood=this.getUpdater().computeLogLikelihood(predictedChildState,obs);
    predictedChildState.setParentState(predictedState.getParentState());
    predictedChildState.setObsLogLikelihood(predictiveLogLikelihood);
    predictedChildState.setPathStateDistLogLikelihood(pathStateDistLogLikelihood);
    predictedChildState.setEdgeTransitionLogLikelihood(edgeTransitionLogLikelihood);
    final double childLogLikTotal=predictiveLogLikelihood + pathStateDistLogLikelihood + edgeTransitionLogLikelihood;
    childDist.increment(predictedChildState,childLogLikTotal);
  }
  return childDist;
}

Fixed version (ground truth):
/** 
 * This method takes a prior predictive vehicle state distribution and returns a distribution over its possible transition states, with prior predictive likelihood weights.
 * @param predictedState
 * @param obs
 * @return
 */
protected CountedDataDistribution<VehicleStateDistribution<O>> internalPriorPrediction(VehicleStateDistribution<O> predictedState,O obs){
  final CountedDataDistribution<VehicleStateDistribution<O>> childDist=new CountedDataDistribution<VehicleStateDistribution<O>>(true);
  final PathStateMixtureDensityModel predictedPathStateMixture=predictedState.getPathStateParam().getConditionalDistribution();
  for (int i=0; i < predictedPathStateMixture.getDistributionCount(); i++) {
    final PathStateDistribution predictedPathStateDist=predictedPathStateMixture.getDistributions().get(i);
    final VehicleStateDistribution<O> predictedChildState=predictedState.clone();
    predictedChildState.setPathStateParam(SimpleBayesianParameter.create(predictedPathStateDist.getPathState(),predictedPathStateMixture,predictedPathStateDist));
    final MultivariateGaussian measurementPredictionDist=predictedState.getMotionStateEstimatorPredictor().getMeasurementDistribution(predictedPathStateDist);
    predictedChildState.setMotionStateParam(SimpleBayesianParameter.create(measurementPredictionDist.getMean(),measurementPredictionDist,predictedPathStateDist.getMotionDistribution()));
    final double childLogLikTotal;
    final double edgeTransitionLogLikelihood;
    final double predictiveLogLikelihood;
    final double pathStateDistLogLikelihood;
    if (predictedPathStateDist instanceof EvaluatedPathStateDistribution) {
      edgeTransitionLogLikelihood=((EvaluatedPathStateDistribution)predictedPathStateDist).getEdgeTransitionLogLikelihood();
      predictiveLogLikelihood=((EvaluatedPathStateDistribution)predictedPathStateDist).getObsLogLikelihood();
      pathStateDistLogLikelihood=((EvaluatedPathStateDistribution)predictedPathStateDist).getEdgeLogLikelihood();
      childLogLikTotal=predictedPathStateMixture.getPriorWeights()[i];
    }
 else {
      OnOffEdgeTransProbabilityFunction edgeTransProbFunction=predictedState.getEdgeTransitionParam().getConditionalDistribution().getProbabilityFunction().clone();
      edgeTransitionLogLikelihood=edgeTransProbFunction.logEvaluate(predictedPathStateDist.getPathState().getEdge().getInferenceGraphSegment());
      predictiveLogLikelihood=this.getUpdater().computeLogLikelihood(predictedChildState,obs);
      pathStateDistLogLikelihood=predictedPathStateMixture.getPriorWeights()[i];
      childLogLikTotal=predictiveLogLikelihood + pathStateDistLogLikelihood + edgeTransitionLogLikelihood;
    }
    predictedChildState.setParentState(predictedState.getParentState());
    predictedChildState.setObsLogLikelihood(predictiveLogLikelihood);
    predictedChildState.setPathStateDistLogLikelihood(pathStateDistLogLikelihood);
    predictedChildState.setEdgeTransitionLogLikelihood(edgeTransitionLogLikelihood);
    childDist.increment(predictedChildState,childLogLikTotal);
  }
  return childDist;
}