Examples of InverseGammaDistribution


Examples of gov.sandia.cognition.statistics.distribution.InverseGammaDistribution

        final int sampledClass =
            DiscreteSamplingUtil.sampleIndexFromProbabilities(
                this.rng, this.priorHmm.getClassMarginalProbabilities());

        final InverseGammaDistribution thisPriorInvScale = this.priorInvScale.clone();

        final DlmHiddenMarkovModel particlePriorHmm = this.priorHmm.clone();
        /*
         * In this model, covariance is the same across components;
         * the constant offset varies.
         * As well, we need to set/reset the kalman filters to adhere
         * to the intended model.
         */
        final List<MultivariateGaussian> thesePriorOffsets = Lists.newArrayList();
        final double invScaleSample = thisPriorInvScale.sample(this.rng);
        int k = 0;
        for (KalmanFilter kf : particlePriorHmm.getStateFilters()) {
          final MultivariateGaussian thisPriorOffset = priorOffsets.get(k).clone();
          thesePriorOffsets.add(thisPriorOffset);
          k++;
View Full Code Here

Examples of gov.sandia.cognition.statistics.distribution.InverseGammaDistribution

      /*
       * The following are the parameter learning updates;
       * they can be done off-line, but we'll do them now.
       * TODO FIXME check that the input/offset thing is working!
       */
      final InverseGammaDistribution invScaleSS = predState.getInvScaleSS().clone();
      final List<MultivariateGaussian> systemOffsetsSS =
          ObjectUtil.cloneSmartElementsAsArrayList(predState.getPsiSS());

      final int xDim = posteriorState.getInputDimensionality();
      final Matrix Ij = MatrixFactory.getDefault().createIdentity(xDim, xDim);
      final Matrix H = MatrixFactory.getDefault().createMatrix(xDim, xDim * 2);
      H.setSubMatrix(0, 0, Ij);
      H.setSubMatrix(0, xDim, MatrixFactory.getDefault().createDiagonal(predState.getStateSample()));
      final Vector postStateSample = posteriorState.sample(this.rng);
      final MultivariateGaussian priorPhi = predState.getPsiSS().get(predState.getClassId());
      final Vector phiPriorSmpl = priorPhi.sample(this.rng);
      final Vector xHdiff = postStateSample.minus(H.times(phiPriorSmpl));

      final double newN = invScaleSS.getShape() + 1d;
      final double d = invScaleSS.getScale() + xHdiff.dotProduct(xHdiff);
     
      invScaleSS.setScale(d);
      invScaleSS.setShape(newN);
     
      // FIXME TODO: crappy sampler
      final double newInvScaleSmpl = invScaleSS.sample(this.rng);
     
      /*
       * Update state and measurement covariances, which
       * have a strict dependency in this model (equality).
       */
 
View Full Code Here

Examples of gov.sandia.cognition.statistics.distribution.InverseGammaDistribution

        int numParticles) {
      final CountedDataDistribution<GaussianArHpWfParticle> initialParticles =
          CountedDataDistribution.create(numParticles, true);
      for (int i = 0; i < numParticles; i++) {

        final InverseGammaDistribution thisPriorScale = this.initialPriorSigma2.clone();

        final KalmanFilter thisKf = this.initialKf.clone();
        /*
         * In this model, covariance is the same across components;
         * the constant offset varies.
         * As well, we need to set/reset the kalman filters to adhere
         * to the intended model.
         */
        final double scaleSample = thisPriorScale.sample(this.rng);

        final MultivariateGaussian thisPriorOffset = initialPriorPsi.clone();

        final Vector systemSample = thisPriorOffset.sample(this.rng);
        final Vector offsetTerm = systemSample.subVector(0,
View Full Code Here

Examples of gov.sandia.cognition.statistics.distribution.InverseGammaDistribution

      /*
       * The following are the parameter learning updates;
       * they can be done off-line, but we'll do them now.
       * TODO FIXME check that the input/offset thing is working!
       */
      final InverseGammaDistribution scaleSS = predState.getSigma2SS().clone();
      final MultivariateGaussian systemOffsetsSS = predState.getPsiSS().clone();

      final int xDim = posteriorState.getInputDimensionality();
      final Matrix Ij = MatrixFactory.getDefault().createIdentity(xDim, xDim);
      final Matrix H = MatrixFactory.getDefault().createMatrix(xDim, xDim * 2);
      H.setSubMatrix(0, 0, Ij);
      H.setSubMatrix(0, xDim, MatrixFactory.getDefault().createDiagonal(predState.getStateSample()));
      final Vector postStateSample = posteriorState.sample(this.rng);
      final MultivariateGaussian priorPhi = predState.getPsiSS();
      final Vector phiPriorSmpl = priorPhi.sample(this.rng);
      final Vector xHdiff = postStateSample.minus(H.times(phiPriorSmpl));

      final double newN = scaleSS.getShape() + 1d;
      final double d = scaleSS.getScale() + xHdiff.dotProduct(xHdiff);
     
      scaleSS.setScale(d);
      scaleSS.setShape(newN);
     
      // FIXME TODO: crappy sampler
      final double newScaleSmpl = scaleSS.sample(this.rng);
     
      /*
       * Update state and measurement covariances, which
       * have a strict dependency in this model (equality).
       */
 
View Full Code Here

Examples of gov.sandia.cognition.statistics.distribution.InverseGammaDistribution

    MultivariateGaussian priorPredictedState = prevState.getState().clone();
    KalmanFilter kf = Iterables.get(prevState.getHmm().getStateFilters(), predClass);
    kf.predict(priorPredictedState);
   
    final DlmHiddenMarkovModel newHmm = prevState.getHmm().clone();
    final InverseGammaDistribution invScaleSS = prevState.getInvScaleSS().clone();
    final List<MultivariateGaussian> psiSS =
        ObjectUtil.cloneSmartElementsAsArrayList(prevState.getPsiSS());

    final GaussianArHpTransitionState newTransState =
        new GaussianArHpTransitionState(prevState, newHmm,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.