Package gov.sandia.cognition.statistics.bayesian

Examples of gov.sandia.cognition.statistics.bayesian.KalmanFilter


    LinearDynamicalSystem model2 = new LinearDynamicalSystem(
        MatrixFactory.getDefault().copyArray(new double[][] {{truePsis.get(1).getElement(1)}}),
        MatrixFactory.getDefault().copyArray(new double[][] {{1d}}),
        MatrixFactory.getDefault().copyArray(new double[][] {{1d}})
      );
    KalmanFilter trueKf1 = new KalmanFilter(model1, modelCovariance1, measurementCovariance);
    trueKf1.setCurrentInput(VectorFactory.getDefault().copyValues(truePsis.get(0).getElement(0)));
    KalmanFilter trueKf2 = new KalmanFilter(model2, modelCovariance2, measurementCovariance);
    trueKf2.setCurrentInput(VectorFactory.getDefault().copyValues(truePsis.get(1).getElement(0)));
   
    Vector initialClassProbs = VectorFactory.getDefault()
            .copyArray(new double[] { 0.5d, 0.5d });
    Matrix classTransProbs = MatrixFactory.getDefault().copyArray(
                new double[][] { { 0.5d, 0.5d },
View Full Code Here


    LinearDynamicalSystem model2 = new LinearDynamicalSystem(
        MatrixFactory.getDefault().copyArray(new double[][] {{truePsis.get(1).getElement(1)}}),
        MatrixFactory.getDefault().copyArray(new double[][] {{1d}}),
        MatrixFactory.getDefault().copyArray(new double[][] {{1d}})
      );
    KalmanFilter trueKf1 = new KalmanFilter(model1, modelCovariance1, measurementCovariance);
    trueKf1.setCurrentInput(VectorFactory.getDefault().copyValues(truePsis.get(0).getElement(0)));
    KalmanFilter trueKf2 = new KalmanFilter(model2, modelCovariance2, measurementCovariance);
    trueKf2.setCurrentInput(VectorFactory.getDefault().copyValues(truePsis.get(1).getElement(0)));
   
    Vector initialClassProbs = VectorFactory.getDefault()
            .copyArray(new double[] { 0.4d, 0.6d });
    Matrix classTransProbs = MatrixFactory.getDefault().copyArray(
                new double[][] { { 0.9d, 0.1d },
View Full Code Here

    final Random rng = new Random();//829351983l);
   
    /*
     * Sample from a logit model.
     */
    final KalmanFilter initialFilter = new KalmanFilter(
          new LinearDynamicalSystem(
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {1d}}),
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {0d}}),
View Full Code Here

    final Random rng = new Random();//829351983l);
   
    /*
     * Sample from a logit model.
     */
    final KalmanFilter initialFilter = new KalmanFilter(
          new LinearDynamicalSystem(
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {1d}}),
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {0d}}),
View Full Code Here

    final Random rng = new Random(829351983l);
   
    /*
     * Sample from a logit model.
     */
    final KalmanFilter initialFilter = new KalmanFilter(
          new LinearDynamicalSystem(
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {1d, 0d},
                  {0d, 1d}}),
              MatrixFactory.getDefault().copyArray(new double[][] {
View Full Code Here

    final Random rng = new Random(829351983l);
   
    /*
     * Sample from a logit model.
     */
    final KalmanFilter initialFilter = new KalmanFilter(
          new LinearDynamicalSystem(
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {1d}}),
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {0d}}),
View Full Code Here

    final Random rng = new Random();//829351983l);
   
    /*
     * Sample from a logit model.
     */
    final KalmanFilter initialFilter = new KalmanFilter(
          new LinearDynamicalSystem(
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {1d}}),
              MatrixFactory.getDefault().copyArray(new double[][] {
                  {0d}}),
View Full Code Here

     * Sample psi
     */
    final MultivariateGaussian priorPsi = prevState.getPsiSS();
    final Vector priorPsiSmpl = priorPsi.sample(this.getRandom());

    final KalmanFilter kf = prevState.getFilter().clone();

    /*
     * Update the filter parameters with the new psi.
     */
    final Matrix smplArTerms = MatrixFactory.getDefault().createDiagonal(
        priorPsiSmpl.subVector(
            priorPsiSmpl.getDimensionality()/2,
            priorPsiSmpl.getDimensionality() - 1));
    kf.getModel().setA(smplArTerms);

    final Vector smplOffsetTerm = priorPsiSmpl.subVector(0,
            priorPsiSmpl.getDimensionality()/2 - 1);
    kf.getModel().setState(smplOffsetTerm);
    kf.setCurrentInput(smplOffsetTerm);
 
    /*
     * Perform the Kalman update to get the posterior state suff. stats.
     */
    final InverseGammaDistribution priorSigma2 = prevState.getSigma2SS().clone();
    final double sigma2Sample = priorSigma2.sample(this.getRandom());
    MultivariateGaussian posteriorState = prevState.getState().clone();
    // TODO FIXME gross hack!
//    posteriorState.getCovariance().scaleEquals(sigma2Sample);
//    kf.setMeasurementCovariance(Iy.scale(sigma2Sample));
//    kf.setModelCovariance(Ix.scale(sigma2Sample));
    kf.predict(posteriorState);
    kf.update(posteriorState, data.getObservedValue());
//    kf.setMeasurementCovariance(Iy);
//    kf.setModelCovariance(Ix);
   

    final GaussianArHpWfParticle newTransState =
View Full Code Here

      Matrix F, Matrix G, Matrix  modelCovariance,
      int numCategories, Random rng) {
    Preconditions.checkArgument(F.getNumRows() == 1);
    Preconditions.checkArgument(F.getNumColumns() == G.getNumRows());
    Preconditions.checkArgument(G.getNumColumns() == modelCovariance.getNumRows());
    this.initialFilter = new KalmanFilter(
            new LinearDynamicalSystem(
                G,
                MatrixFactory.getDefault().createMatrix(G.getNumRows(), G.getNumColumns()),
                F),
            modelCovariance,
View Full Code Here

      double lambdaSum = 0d;
      Vector sampledAugResponse = VectorFactory.getDefault().createVector(this.numCategories);
      for (int i = 0; i < this.numCategories; i++) {
  //        final Vector betaSample = particle.getLinearState().sample(this.random);
        final MultivariateGaussian predictivePrior = particle.getLinearState().clone();
        KalmanFilter kf = particle.getRegressionFilter(i);
        final Matrix G = kf.getModel().getA();
        predictivePrior.setMean(G.times(predictivePrior.getMean()));
        predictivePrior.setCovariance(
            G.times(predictivePrior.getCovariance()).times(G.transpose())
              .plus(kf.getModelCovariance()));
 
        // X * beta
        final double lambda = Math.exp(data.getObservedData().times(
            predictivePrior.getMean()).getElement(0));
        lambdaSum += lambda;
View Full Code Here

TOP

Related Classes of gov.sandia.cognition.statistics.bayesian.KalmanFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.