Program: 72760
Project: 72760
Buggy source:
public void assignWeight() throws IllegalActionException, NameDuplicationException {
  Token _result;
  Token _particleCovariance;
  Parameter p;
  if (this.getSize() != _stateVariables.length) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    for (int i=0; i < _stateVariables.length; i++) {
      if (ParticleFilter.this.getAttribute(_stateVariables[i]) != null) {
        p=(Parameter)(ParticleFilter.this.getAttribute(_stateVariables[i]));
      }
 else {
        p=new Parameter(_measurementEquation,_stateVariables[i]);
      }
      p.setExpression(_particleValue.get(i).toString());
    }
    try {
      PtParser parser=new PtParser();
      _parseTree=parser.generateParseTree(_measurementEquation.expression.getExpression());
      _result=_parseTreeEvaluator.evaluateParseTree(_parseTree,_scope);
      _parseTree=parser.generateParseTree(_measurementCovariance.expression.getExpression());
      _particleCovariance=_parseTreeEvaluator.evaluateParseTree(_parseTree,_scope);
    }
 catch (    Throwable throwable) {
      throw new IllegalActionException("String_Node_Str");
    }
    if (_result == null) {
      throw new IllegalActionException("String_Node_Str" + _measurementEquation.expression.getExpression());
    }
 else     if (_particleCovariance == null) {
      throw new IllegalActionException("String_Node_Str" + _measurementCovariance.expression.getExpression());
    }
    Type t=_measurementEquation.output.getType();
    if (t.equals(BaseType.DOUBLE)) {
      double _meanEstimate=((DoubleToken)_result).doubleValue();
      double z_t=((DoubleToken)_measurementValues.get(_measurementVariable)).doubleValue();
      _weight=1 / (Math.pow(2 * Math.PI,0.5) * DoubleMatrixMath.determinant(_Sigma)) * Math.exp(-Math.pow(z_t - _meanEstimate,2) / (2 * Math.pow(_Sigma[0][0],2)));
    }
 else {
      MatrixToken z_t=(MatrixToken)_measurementValues.get(_measurementVariable);
      int k=z_t.getRowCount();
      MatrixToken X=(DoubleMatrixToken)z_t.subtract((Token)_result);
      MatrixToken Covariance=(DoubleMatrixToken)_particleCovariance;
      MatrixToken Xt=new DoubleMatrixToken(DoubleMatrixMath.transpose(X.doubleMatrix()));
      double multiplier=Math.pow(2 * Math.PI,-0.5 * k) * Math.pow(DoubleMatrixMath.determinant(Covariance.doubleMatrix()),-0.5);
      Token exponent=Xt.multiply(Covariance);
      exponent=exponent.multiply(X);
      double value=((DoubleMatrixToken)exponent).getElementAt(0,0);
      _weight=multiplier * Math.exp(-0.5 * value);
    }
  }
}

Fixed version (ground truth):
public void assignWeight(Expression measurementEquation,String[] _stateVariables) throws IllegalActionException, NameDuplicationException {
  Token _result;
  Token _particleCovariance;
  Parameter p;
  if (this.getSize() != _stateVariables.length) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    for (int i=0; i < _stateVariables.length; i++) {
      if ((ParticleFilter.this).getAttribute(_stateVariables[i]) == null) {
        p=new Parameter(ParticleFilter.this,_stateVariables[i]);
      }
 else {
        p=(Parameter)(ParticleFilter.this).getAttribute(_stateVariables[i]);
      }
      p.setExpression(_particleValue.get(i).toString());
      _tokenMap.put(_stateVariables[i],new DoubleToken((double)_particleValue.get(i)));
    }
    try {
      PtParser parser=new PtParser();
      _parseTree=parser.generateParseTree(measurementEquation.expression.getExpression());
      _result=_parseTreeEvaluator.evaluateParseTree(_parseTree,_scope);
      _parseTree=parser.generateParseTree(_measurementCovariance.expression.getExpression());
      _particleCovariance=_parseTreeEvaluator.evaluateParseTree(_parseTree,_scope);
    }
 catch (    Throwable throwable) {
      throw new IllegalActionException("String_Node_Str");
    }
    if (_result == null) {
      throw new IllegalActionException("String_Node_Str" + measurementEquation.expression.getExpression());
    }
    Type t=_measurementEquation.output.getType();
    if (t.equals(BaseType.DOUBLE)) {
      double _meanEstimate=((DoubleToken)_result).doubleValue();
      double z_t=((DoubleToken)_measurementValues.get(_measurementVariable)).doubleValue();
      _weight=1 / (Math.pow(2 * Math.PI,0.5) * DoubleMatrixMath.determinant(_Sigma)) * Math.exp(-Math.pow(z_t - _meanEstimate,2) / (2 * Math.pow(_Sigma[0][0],2)));
    }
 else {
      MatrixToken z_t=(MatrixToken)_measurementValues.get(_measurementVariable);
      int k=z_t.getRowCount();
      MatrixToken X=(DoubleMatrixToken)z_t.subtract((Token)_result);
      MatrixToken Covariance=(DoubleMatrixToken)_particleCovariance;
      MatrixToken Xt=new DoubleMatrixToken(DoubleMatrixMath.transpose(X.doubleMatrix()));
      double multiplier=Math.pow(2 * Math.PI,-0.5 * k) * Math.pow(DoubleMatrixMath.determinant(Covariance.doubleMatrix()),-0.5);
      Token exponent=Xt.multiply(Covariance);
      exponent=exponent.multiply(X);
      double value=((DoubleMatrixToken)exponent).getElementAt(0,0);
      _weight=multiplier * Math.exp(-0.5 * value);
    }
  }
}