JulierUnscentedTransform.java

  1. /*
  2.  * Licensed to the Hipparchus project under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The Hipparchus project licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      https://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.hipparchus.util;

  18. import org.hipparchus.linear.ArrayRealVector;
  19. import org.hipparchus.linear.RealVector;

  20. /** Unscented transform as defined by Julier and Uhlmann.
  21.  * <p>
  22.  * The unscented transform uses three parameters: alpha, beta and kappa.
  23.  * Alpha determines the spread of the sigma points around the process state,
  24.  * kappa is a secondary scaling parameter, and beta is used to incorporate
  25.  * prior knowledge of the distribution of the process state.
  26.  * <p>
  27.  * The Julier transform is a particular case of {@link MerweUnscentedTransform} with alpha = 1 and beta = 0.
  28.  * </p>
  29.  * @see "S. J. Julier and J. K. Uhlmann. A New Extension of the Kalman Filter to Nonlinear Systems.
  30.  *       Proc. SPIE 3068, Signal Processing, Sensor Fusion, and Target Recognition VI, 182 (July 28, 1997)"
  31.  * @since 2.2
  32.  */
  33. public class JulierUnscentedTransform extends AbstractUnscentedTransform {

  34.     /** Default value for kappa, (0.0, see reference). */
  35.     public static final double DEFAULT_KAPPA = 0;

  36.     /** Weights for covariance matrix. */
  37.     private final RealVector wc;

  38.     /** Weights for mean state. */
  39.     private final RealVector wm;

  40.     /** Factor applied to the covariance matrix during the unscented transform (lambda + process state size). */
  41.     private final double factor;

  42.     /**
  43.      * Default constructor.
  44.      * <p>
  45.      * This constructor uses default value for kappa.
  46.      * </p>
  47.      * @param stateDim the dimension of the state
  48.      * @see #DEFAULT_KAPPA
  49.      * @see #JulierUnscentedTransform(int, double)
  50.      */
  51.     public JulierUnscentedTransform(final int stateDim) {
  52.         this(stateDim, DEFAULT_KAPPA);
  53.     }

  54.     /**
  55.      * Simple constructor.
  56.      * @param stateDim the dimension of the state
  57.      * @param kappa fscaling factor
  58.      */
  59.     public JulierUnscentedTransform(final int stateDim, final double kappa) {

  60.         // Call super constructor
  61.         super(stateDim);

  62.         // Initialize multiplication factor for covariance matrix
  63.         this.factor = stateDim + kappa;

  64.         // Initialize vectors weights
  65.         wm = new ArrayRealVector(2 * stateDim + 1);

  66.         // Computation of unscented kalman filter weights (See Eq. 12)
  67.         wm.setEntry(0, kappa / factor);
  68.         for (int i = 1; i <= 2 * stateDim; i++) {
  69.             wm.setEntry(i, 1.0 / (2.0 * factor));
  70.         }

  71.         // For the Julier unscented transform, there is no difference between covariance and state weights
  72.         wc = wm;

  73.     }

  74.     /** {@inheritDoc} */
  75.     @Override
  76.     public RealVector getWc() {
  77.         return wc;
  78.     }

  79.     /** {@inheritDoc} */
  80.     @Override
  81.     public RealVector getWm() {
  82.         return wm;
  83.     }

  84.     /** {@inheritDoc} */
  85.     @Override
  86.     protected double getMultiplicationFactor() {
  87.         return factor;
  88.     }

  89. }