Program: 189443
Project: 189443
Buggy source:
@Override public void update(DataDistribution<VehicleStateDistribution<O>> target,O obs){
  final CountedDataDistribution<VehicleStateDistribution<O>> resampleDist=new CountedDataDistribution<VehicleStateDistribution<O>>(true);
  for (  final VehicleStateDistribution<O> state : target.getDomain()) {
    final int count;
    if (target instanceof CountedDataDistribution<?>) {
      count=((CountedDataDistribution)target).getCount(state);
    }
 else {
      count=1;
    }
    final double logCount=Math.log(count);
    VehicleStateDistribution<O> predictedState=new VehicleStateDistribution<O>(state);
    predictedState.setObservation(obs);
    predictedState=this.updater.update(predictedState);
    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];
      final double edgeTransitionLogLikelihood=predictedState.getEdgeTransitionParam().getConditionalDistribution().getProbabilityFunction().logEvaluate(predictedPathStateDist.getPathState().getEdge().getInferenceGraphEdge());
      final VehicleStateDistribution<O> predictedChildState=new VehicleStateDistribution<O>(predictedState);
      predictedChildState.setPathStateParam(SimpleBayesianParameter.create(predictedPathStateDist.getPathState(),predictedPathStateMixture,predictedPathStateDist));
      final MultivariateGaussian measurementPredictionDist=predictedState.getMotionStateEstimatorPredictor().getMeasurementBelief(predictedPathStateDist);
      predictedChildState.setMotionStateParam(SimpleBayesianParameter.create(measurementPredictionDist.getMean(),measurementPredictionDist,predictedPathStateDist.getMotionStateDistribution()));
      final double predictiveLogLikelihood=this.getUpdater().computeLogLikelihood(predictedChildState,obs);
      predictedChildState.setParentState(state);
      resampleDist.increment(predictedChildState,predictiveLogLikelihood + pathStateDistLogLikelihood + edgeTransitionLogLikelihood+ logCount);
    }
  }
  final Random rng=this.getRandom();
  Preconditions.checkState(!resampleDist.isEmpty());
  if (this.isDebug)   this.lastResampleDistribution=resampleDist;
  final ArrayList<VehicleStateDistribution<O>> smoothedStates=resampleDist.sample(rng,this.getNumParticles());
  target.clear();
  for (  final VehicleStateDistribution<O> state : smoothedStates) {
    final VehicleStateDistribution<O> updatedState=state.clone();
    final PathStateDistribution pathStateDist=updatedState.getPathStateParam().getParameterPrior();
    final MultivariateGaussian updatedMotionState=pathStateDist.getGroundBelief().clone();
    updatedState.getMotionStateEstimatorPredictor().update(updatedMotionState,obs.getProjectedPoint());
    final PathStateEstimatorPredictor pathStateEstimator=new PathStateEstimatorPredictor(state,pathStateDist.getPathState().getPath());
    pathStateDist.setGroundDistribution(updatedMotionState);
    pathStateEstimator.update(pathStateDist,obs.getProjectedPoint());
    updatedState.getPathStateParam().setValue(pathStateDist.getPathState());
    updatedState.getPathStateParam().setParameterPrior(pathStateDist);
    updatedState.getMotionStateParam().setParameterPrior(pathStateDist.getMotionStateDistribution());
    MultivariateGaussian obsMotionDist=updatedState.getMotionStateEstimatorPredictor().getObservationDistribution(pathStateDist.getMotionStateDistribution(),pathStateDist.getPathState().getEdge());
    updatedState.getMotionStateParam().setConditionalDistribution(obsMotionDist);
    updatedState.getMotionStateParam().setValue(obsMotionDist.getMean());
    final InferenceGraphEdge graphEdge=updatedState.getParentState().getPathStateParam().getValue().getEdge().getInferenceGraphEdge();
    final OnOffEdgeTransitionEstimatorPredictor edgeTransitionEstimatorPredictor=new OnOffEdgeTransitionEstimatorPredictor(updatedState,graphEdge);
    OnOffEdgeTransPriorDistribution prior=updatedState.getEdgeTransitionParam().getParameterPrior();
    edgeTransitionEstimatorPredictor.update(prior,graphEdge);
    updatedState.getEdgeTransitionParam().getConditionalDistribution().setFreeMotionTransProbs(prior.getFreeMotionTransProbPrior().getMean());
    updatedState.getEdgeTransitionParam().getConditionalDistribution().setEdgeMotionTransProbs(prior.getEdgeMotionTransProbPrior().getMean());
    updatedState.getEdgeTransitionParam().setValue(prior.getMean());
    target.increment(updatedState,0d);
  }
  Preconditions.checkState(target.getDomainSize() > 0);
}

Fixed version (ground truth):
@Override public void update(DataDistribution<VehicleStateDistribution<O>> target,O obs){
  final CountedDataDistribution<VehicleStateDistribution<O>> resampleDist=new CountedDataDistribution<VehicleStateDistribution<O>>(true);
  for (  final VehicleStateDistribution<O> state : target.getDomain()) {
    final int count;
    if (target instanceof CountedDataDistribution<?>) {
      count=((CountedDataDistribution)target).getCount(state);
    }
 else {
      count=1;
    }
    final double logCount=Math.log(count);
    VehicleStateDistribution<O> predictedState=new VehicleStateDistribution<O>(state);
    predictedState.setObservation(obs);
    predictedState=this.updater.update(predictedState);
    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];
      final double edgeTransitionLogLikelihood=predictedState.getEdgeTransitionParam().getConditionalDistribution().getProbabilityFunction().logEvaluate(predictedPathStateDist.getPathState().getEdge().getInferenceGraphEdge());
      final VehicleStateDistribution<O> predictedChildState=new VehicleStateDistribution<O>(predictedState);
      predictedChildState.setPathStateParam(SimpleBayesianParameter.create(predictedPathStateDist.getPathState(),predictedPathStateMixture,predictedPathStateDist));
      final MultivariateGaussian measurementPredictionDist=predictedState.getMotionStateEstimatorPredictor().getMeasurementBelief(predictedPathStateDist);
      predictedChildState.setMotionStateParam(SimpleBayesianParameter.create(measurementPredictionDist.getMean(),measurementPredictionDist,predictedPathStateDist.getMotionDistribution()));
      final double predictiveLogLikelihood=this.getUpdater().computeLogLikelihood(predictedChildState,obs);
      predictedChildState.setParentState(state);
      resampleDist.increment(predictedChildState,predictiveLogLikelihood + pathStateDistLogLikelihood + edgeTransitionLogLikelihood+ logCount);
    }
  }
  final Random rng=this.getRandom();
  Preconditions.checkState(!resampleDist.isEmpty());
  if (this.isDebug)   this.lastResampleDistribution=resampleDist;
  final ArrayList<VehicleStateDistribution<O>> smoothedStates=resampleDist.sample(rng,this.getNumParticles());
  target.clear();
  for (  final VehicleStateDistribution<O> state : smoothedStates) {
    final VehicleStateDistribution<O> updatedState=state.clone();
    final PathStateDistribution pathStateDist=updatedState.getPathStateParam().getParameterPrior().clone();
    final MultivariateGaussian updatedMotionState=pathStateDist.getGroundDistribution().clone();
    updatedState.getMotionStateEstimatorPredictor().update(updatedMotionState,obs.getProjectedPoint());
    final PathStateEstimatorPredictor pathStateEstimator=new PathStateEstimatorPredictor(state,pathStateDist.getPathState().getPath());
    pathStateDist.setGroundDistribution(updatedMotionState);
    pathStateEstimator.update(pathStateDist,obs.getProjectedPoint());
    updatedState.getPathStateParam().setValue(pathStateDist.getPathState());
    updatedState.getPathStateParam().setParameterPrior(pathStateDist);
    updatedState.getMotionStateParam().setParameterPrior(pathStateDist.getMotionDistribution());
    MultivariateGaussian obsMotionDist=updatedState.getMotionStateEstimatorPredictor().getObservationDistribution(pathStateDist.getMotionDistribution(),pathStateDist.getPathState().getEdge());
    updatedState.getMotionStateParam().setConditionalDistribution(obsMotionDist);
    updatedState.getMotionStateParam().setValue(obsMotionDist.getMean());
    final InferenceGraphEdge graphEdge=updatedState.getParentState().getPathStateParam().getValue().getEdge().getInferenceGraphEdge();
    final OnOffEdgeTransitionEstimatorPredictor edgeTransitionEstimatorPredictor=new OnOffEdgeTransitionEstimatorPredictor(updatedState,graphEdge);
    OnOffEdgeTransPriorDistribution prior=updatedState.getEdgeTransitionParam().getParameterPrior();
    edgeTransitionEstimatorPredictor.update(prior,graphEdge);
    updatedState.getEdgeTransitionParam().getConditionalDistribution().setFreeMotionTransProbs(prior.getFreeMotionTransProbPrior().getMean());
    updatedState.getEdgeTransitionParam().getConditionalDistribution().setEdgeMotionTransProbs(prior.getEdgeMotionTransProbPrior().getMean());
    updatedState.getEdgeTransitionParam().setValue(prior.getMean());
    target.increment(updatedState,0d);
  }
  Preconditions.checkState(target.getDomainSize() > 0);
}