Package gov.sandia.cognition.statistics.distribution

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


        MatrixFactory.getDefault().copyArray(new double[][] {{1}})
      );
    KalmanFilter trueKf1 = new KalmanFilter(model1, modelCovariance1, measurementCovariance);
    KalmanFilter trueKf2 = new KalmanFilter(model2, modelCovariance2, measurementCovariance);

    final UnivariateGaussian prior = new UnivariateGaussian(0d, sigma_y2);
    final UnivariateGaussian s1Likelihood = prior;
    final UnivariateGaussian s2Likelihood = s1Likelihood;
   
    Vector initialClassProbs = VectorFactory.getDefault()
            .copyArray(new double[] { 0.7d, 0.3d });
    Matrix classTransProbs = MatrixFactory.getDefault().copyArray(
                new double[][] { { 0.7d, 0.7d },
View Full Code Here


        MatrixFactory.getDefault().copyArray(new double[][] {{1}})
      );
    KalmanFilter trueKf1 = new KalmanFilter(model1, modelCovariance1, measurementCovariance);
    KalmanFilter trueKf2 = new KalmanFilter(model2, modelCovariance2, measurementCovariance);

    final UnivariateGaussian prior = new UnivariateGaussian(0d, sigma_y2);
    final UnivariateGaussian s1Likelihood = prior;
    final UnivariateGaussian s2Likelihood = s1Likelihood;
   
    Vector initialClassProbs = VectorFactory.getDefault()
            .copyArray(new double[] { 0.7d, 0.3d });
    Matrix classTransProbs = MatrixFactory.getDefault().copyArray(
                new double[][] { { 0.7d, 0.7d },
View Full Code Here

       * Expand particle set over mixture components
       */
      for (int j = 0; j < 10; j++) {
        double categoriesTotalLogLikelihood = 0d;

        final UnivariateGaussian componentDist =
            this.evDistribution.getDistributions().get(j);
 
        for (int k = 0; k < this.numCategories; k++) {
          /*
           * TODO could avoid cloning if we didn't change the measurement covariance,
           * but instead used the componentDist explicitly.
           */
          final FruehwirthMultiParticle predictiveParticle = particle.clone();
          predictiveParticle.setAugResponseSample(sampledAugResponse);
 
          predictiveParticle.setEVcomponent(componentDist);
         
          /*
           * Update the observed data for the regression component.
           */
          predictiveParticle.getRegressionFilter(k).getModel().setC(data.getObservedData());
 
          final Matrix compVar = MatrixFactory.getDefault().copyArray(
              new double[][] {{componentDist.getVariance()}});
          predictiveParticle.getRegressionFilter(k).setMeasurementCovariance(compVar);
         
          final double logLikelihood = this.updater.computeLogLikelihood(predictiveParticle, data)
              + Math.log(this.evDistribution.getPriorWeights()[j])
              + (particleEntry.getValue().doubleValue() - prevTotalLogLikelihood);
View Full Code Here

    final FruehwirthMultiParticle updatedParticle = priorParticle.clone();
   
    final Vector sampledAugResponse = priorParticle.getAugResponseSample();
    final KalmanFilter filter = updatedParticle.getRegressionFilter(
        priorParticle.getCategoryId());
    final UnivariateGaussian evComponent = updatedParticle.EVcomponent;
    // TODO we should've already set this, so it might be redundant.
    filter.setMeasurementCovariance(
        MatrixFactory.getDefault().copyArray(new double[][] {{
          evComponent.getVariance()}}));

    final MultivariateGaussian posteriorState = updatedParticle.getLinearState();
    filter.update(posteriorState, sampledAugResponse);
   
    return updatedParticle;
View Full Code Here

      predictivePrior.setCovariance(
          G.times(predictivePrior.getCovariance()).times(G.transpose())
            .plus(kf.getModelCovariance()));
      final Matrix F = kf.getModel().getC();

      final UnivariateGaussian evComponent = particle.getEVcomponent();
      final double predPriorObsMean = F.times(predictivePrior.getMean()).getElement(0)
          + evComponent.getMean();
      final double predPriorObsCov = F.times(predictivePrior.getCovariance()).times(F.transpose())
          .plus(kf.getMeasurementCovariance()).getElement(0, 0);
      particle.setPriorPredMean(predPriorObsMean);
      particle.setPriorPredCov(predPriorObsCov);
View Full Code Here

          final LogitMixParticle predictiveParticle = particle.clone();
          predictiveParticle.setPreviousParticle(particle);
          predictiveParticle.setBetaSample(betaMean);
          predictiveParticle.setLinearState(predictivePrior);

          final UnivariateGaussian componentDist =
              this.evDistribution.getDistributions().get(j);

          predictiveParticle.setEVcomponent(componentDist);
         
          /*
           * Update the observed data for the regression component.
           */
          predictiveParticle.getRegressionFilter().getModel().setC(F);

          // TODO would be great to have a 1x1 matrix class here...
          final Matrix compVar = MatrixFactory.getDefault().copyArray(
              new double[][] {{componentDist.getVariance()}});
          predictiveParticle.getRegressionFilter().setMeasurementCovariance(compVar);
         
          final double compPredPriorObsMean =
               F.times(betaMean).getElement(0)
               + componentDist.getMean();
          final double compPredPriorObsCov =
               F.times(predictivePrior.getCovariance()).times(F.transpose()).getElement(0, 0)
               + componentDist.getVariance();
          predictiveParticle.setPriorPredMean(compPredPriorObsMean);
          predictiveParticle.setPriorPredCov(compPredPriorObsCov);

          final double logLikelihood =
              this.updater.computeLogLikelihood(predictiveParticle, data);
View Full Code Here

      LogitMixParticle priorParticle, ObservedValue<Vector, Matrix> data) {

    final LogitMixParticle updatedParticle = priorParticle.clone();
    final KalmanFilter filter = updatedParticle.getRegressionFilter();

    final UnivariateGaussian evComponent = updatedParticle.EVcomponent;

    final boolean isOne = !data.getObservedValue().isZero();

    final int smplLowerIdx = DiscreteSamplingUtil.sampleIndexFromProportions(
        getRandom(), updatedParticle.getComponentLikelihoods());
//    final int smplLowerIdx = DiscreteSamplingUtil.sampleIndexFromProbabilities(
//        getRandom(), this.evDistribution.getPriorWeights());

    final UnivariateGaussian partComponent =
        this.evDistribution.getDistributions().get(smplLowerIdx);

    final double dsampledAugResponse = sampleAugResponse(
        updatedParticle.getPriorPredMean(),
        updatedParticle.getPriorPredCov(), isOne,
        partComponent);

    // TODO we should've already set this, so it might be redundant.
    filter.setMeasurementCovariance(
        MatrixFactory.getDefault().copyArray(new double[][] {{
          evComponent.getVariance() + partComponent.getVariance()}}));

    final Vector sampledAugResponse =
        VectorFactory.getDefault().copyValues(
            dsampledAugResponse
            - evComponent.getMean().doubleValue()
            - partComponent.getMean().doubleValue());

    updatedParticle.setAugResponseSample(sampledAugResponse);

    final MultivariateGaussian posteriorState = updatedParticle.getLinearState().clone();
    filter.update(posteriorState, sampledAugResponse);
View Full Code Here

      final double upperVar = particle.getPriorPredCov();
      double logLikelihood = Double.NEGATIVE_INFINITY;
      double[] componentLikelihoods = new double[10];
      for (int i = 0; i < 10; i++) {

        final UnivariateGaussian partComponent =
            this.evDistribution.getDistributions().get(i);

        // TODO FIXME: do this in log scale...
        double partLogLik =
            ExtStatisticsUtils.normalCdf(0d,
            upperMean - partComponent.getMean(),
            Math.sqrt(upperVar + partComponent.getVariance()),
            true);
        if (!observation.getObservedValue().isZero()) {
          partLogLik = LogMath.subtract(0d, partLogLik);
        }
View Full Code Here

      for (int i = 0; i < numParticles; i++) {
       
        final MultivariateGaussian initialPriorState = initialPrior.clone();
        final KalmanFilter kf = this.initialFilter.clone();
        final int componentId = this.rng.nextInt(10);
        final UnivariateGaussian evDist = this.evDistribution.
            getDistributions().get(componentId);
       
        final LogitMixParticle particleMvgDPDist =
            new LogitMixParticle(null,
                kf, initialPriorState, evDist);
View Full Code Here

      for (int i = 0; i < hmm.getNumStates(); i++) {

        /*
         * Perform the filtering step
         */
        final UnivariateGaussian priorDist = particle.getSuffStat();
        final double priorPredMean = a[i] * priorDist.getMean();
        final double priorPredCov = a[i] * a[i] * priorDist.getVariance() + sigma2[i];

        final double postCovariance = 1d/(1d/priorPredCov + 1d/sigma_y2);
        final double postMean = (priorPredMean/priorPredCov + data.getObservedValue()/sigma_y2)
            * postCovariance;

        final UnivariateGaussian postDist =
            new UnivariateGaussian(postMean, postCovariance);

        final GaussianArTransitionState transState =
            new GaussianArTransitionState(particle, newHmm,
                i, data, postDist);
       
View Full Code Here

TOP

Related Classes of gov.sandia.cognition.statistics.distribution.UnivariateGaussian

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.