Program: 189476
Project: 189476
Buggy source:
private void updateStats(DataDistribution<VehicleState> vehicleStateDist,VehicleState trueVehicleState,SufficientStatistic obsErrorSS,SufficientStatistic obsCovErrorSS,SufficientStatistic onRoadCovErrorSS,SufficientStatistic offRoadCovErrorSS,SufficientStatistic transitionsSS,boolean generalizeMoveDiff){
  SufficientStatistic obsErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic obsCovErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic onRoadCovErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic offRoadCovErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic transitionsErrorStat=new MultivariateGaussian.SufficientStatistic();
  for (  VehicleState state : vehicleStateDist.getDomain()) {
    AssertJUnit.assertEquals(trueVehicleState.getObservation(),state.getObservation());
    final Vector obsError=trueVehicleState.getObservation().getProjectedPoint().minus(state.getMeanLocation());
    obsErrorStat.update(obsError);
    final Matrix obsCovMean=((ErrorEstimatingRoadTrackingFilter)state.getMovementFilter()).getObsVariancePrior().getMean();
    final Matrix obsCovError=obsCovMean.minus(trueVehicleState.getMovementFilter().getObsCovar());
    obsCovErrorStat.update(obsCovError.convertToVector());
    final Matrix onRoadCovMean=((ErrorEstimatingRoadTrackingFilter)state.getMovementFilter()).getOnRoadStateVariancePrior().getMean();
    final Matrix onRoadCovFactor=state.getMovementFilter().getCovarianceFactor(true);
    final Matrix onRoadCovError=onRoadCovFactor.times(onRoadCovMean).times(onRoadCovFactor.transpose()).minus(trueVehicleState.getMovementFilter().getOnRoadStateTransCovar());
    onRoadCovErrorStat.update(onRoadCovError.convertToVector());
    final Matrix offRoadCovMean=((ErrorEstimatingRoadTrackingFilter)state.getMovementFilter()).getOffRoadStateVariancePrior().getMean();
    final Matrix offRoadCovFactor=state.getMovementFilter().getCovarianceFactor(false);
    final Matrix offRoadCovError=offRoadCovFactor.times(offRoadCovMean).times(offRoadCovFactor.transpose()).minus(trueVehicleState.getMovementFilter().getOffRoadStateTransCovar());
    offRoadCovErrorStat.update(offRoadCovError.convertToVector());
    final VehicleState parentState=state.getParentState();
    if (parentState != null) {
      Vector transType=OnOffEdgeTransDirMulti.getTransitionType(parentState.getBelief().getEdge().getInferredEdge(),state.getBelief().getEdge().getInferredEdge());
      if (parentState.getBelief().isOnRoad()) {
        transType=transType.stack(AbstractRoadTrackingFilter.zeros2D);
      }
 else {
        transType=AbstractRoadTrackingFilter.zeros2D.stack(transType);
      }
      final Vector trueTransProbs=trueVehicleState.getEdgeTransitionDist().getEdgeMotionTransPrior().getMean().stack(trueVehicleState.getEdgeTransitionDist().getFreeMotionTransPrior().getMean());
      transitionsErrorStat.update(transType.minus(trueTransProbs));
    }
  }
  obsErrorSS.update(obsErrorStat.getMean());
  obsCovErrorSS.update(obsCovErrorStat.getMean());
  onRoadCovErrorSS.update(onRoadCovErrorStat.getMean());
  offRoadCovErrorSS.update(offRoadCovErrorStat.getMean());
  if (transitionsErrorStat.getMean() != null)   transitionsSS.update(transitionsErrorStat.getMean());
  System.out.println("String_Node_Str" + obsErrorSS.getMean());
  System.out.println("String_Node_Str" + obsCovErrorSS.getMean());
  System.out.println("String_Node_Str" + onRoadCovErrorSS.getMean());
  System.out.println("String_Node_Str" + offRoadCovErrorSS.getMean());
  System.out.println("String_Node_Str" + transitionsSS.getMean());
  final long approxRuns=sim.getSimParameters().getDuration() / sim.getSimParameters().getFrequency();
  if (obsErrorSS.getCount() > Math.min(approxRuns / 16,25)) {
    if (obsErrorZeroArray == null)     obsErrorZeroArray=VectorFactory.getDefault().createVector(obsErrorSS.getMean().getDimensionality()).toArray();
    AssertJUnit.assertArrayEquals(obsErrorSS.getMean().getDimensionality() == 4 ? fourZeros : twoZeros,obsErrorSS.getMean().toArray(),5);
  }
}

Fixed version (ground truth):
private void updateStats(DataDistribution<VehicleState> vehicleStateDist,VehicleState trueVehicleState,SufficientStatistic obsErrorSS,SufficientStatistic obsCovErrorSS,SufficientStatistic onRoadCovErrorSS,SufficientStatistic offRoadCovErrorSS,SufficientStatistic transitionsSS,boolean generalizeMoveDiff){
  SufficientStatistic obsErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic obsCovErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic onRoadCovErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic offRoadCovErrorStat=new MultivariateGaussian.SufficientStatistic();
  SufficientStatistic transitionsErrorStat=new MultivariateGaussian.SufficientStatistic();
  for (  VehicleState state : vehicleStateDist.getDomain()) {
    AssertJUnit.assertEquals(trueVehicleState.getObservation(),state.getObservation());
    final Vector obsError=trueVehicleState.getObservation().getProjectedPoint().minus(state.getMeanLocation());
    obsErrorStat.update(obsError);
    final Matrix obsCovMean=((ErrorEstimatingRoadTrackingFilter)state.getMovementFilter()).getObsVariancePrior().getMean();
    final Matrix obsCovError=obsCovMean.minus(trueVehicleState.getMovementFilter().getObsCovar());
    obsCovErrorStat.update(obsCovError.convertToVector());
    final Matrix onRoadCovMean=((ErrorEstimatingRoadTrackingFilter)state.getMovementFilter()).getOnRoadStateVariancePrior().getMean();
    final Matrix onRoadCovError=onRoadCovMean.minus(trueVehicleState.getMovementFilter().getQr());
    onRoadCovErrorStat.update(onRoadCovError.convertToVector());
    final Matrix offRoadCovMean=((ErrorEstimatingRoadTrackingFilter)state.getMovementFilter()).getOffRoadStateVariancePrior().getMean();
    final Matrix offRoadCovError=offRoadCovMean.minus(trueVehicleState.getMovementFilter().getQg());
    offRoadCovErrorStat.update(offRoadCovError.convertToVector());
    final VehicleState parentState=state.getParentState();
    if (parentState != null) {
      Vector transType=OnOffEdgeTransDirMulti.getTransitionType(parentState.getBelief().getEdge().getInferredEdge(),state.getBelief().getEdge().getInferredEdge());
      if (parentState.getBelief().isOnRoad()) {
        transType=transType.stack(AbstractRoadTrackingFilter.zeros2D);
      }
 else {
        transType=AbstractRoadTrackingFilter.zeros2D.stack(transType);
      }
      final Vector trueTransProbs=trueVehicleState.getEdgeTransitionDist().getEdgeMotionTransPrior().getMean().stack(trueVehicleState.getEdgeTransitionDist().getFreeMotionTransPrior().getMean());
      transitionsErrorStat.update(transType.minus(trueTransProbs));
    }
  }
  obsErrorSS.update(obsErrorStat.getMean());
  obsCovErrorSS.update(obsCovErrorStat.getMean());
  onRoadCovErrorSS.update(onRoadCovErrorStat.getMean());
  offRoadCovErrorSS.update(offRoadCovErrorStat.getMean());
  if (transitionsErrorStat.getMean() != null)   transitionsSS.update(transitionsErrorStat.getMean());
  System.out.println("String_Node_Str" + obsErrorSS.getMean());
  System.out.println("String_Node_Str" + obsCovErrorSS.getMean());
  System.out.println("String_Node_Str" + onRoadCovErrorSS.getMean());
  System.out.println("String_Node_Str" + offRoadCovErrorSS.getMean());
  System.out.println("String_Node_Str" + transitionsSS.getMean());
  final long approxRuns=sim.getSimParameters().getDuration() / sim.getSimParameters().getFrequency();
  if (obsErrorSS.getCount() > 0) {
    if (obsErrorZeroArray == null)     obsErrorZeroArray=VectorFactory.getDefault().createVector(obsErrorSS.getMean().getDimensionality()).toArray();
    AssertJUnit.assertArrayEquals(obsErrorSS.getMean().getDimensionality() == 4 ? fourZeros : twoZeros,obsErrorSS.getMean().toArray(),3d * Math.sqrt(trueVehicleState.getMovementFilter().getObsCovar().normFrobenius()));
    AssertJUnit.assertArrayEquals(oneZero,onRoadCovErrorSS.getMean().toArray(),0.4d * trueVehicleState.getMovementFilter().getQr().normFrobenius());
    AssertJUnit.assertArrayEquals(fourZeros,offRoadCovErrorSS.getMean().toArray(),0.4d * trueVehicleState.getMovementFilter().getQg().normFrobenius());
  }
}