View Javadoc
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  
19  import org.hipparchus.linear.ArrayRealVector;
20  import org.hipparchus.linear.RealVector;
21  
22  /** Unscented transform as defined by Julier and Uhlmann.
23   * <p>
24   * The unscented transform uses three parameters: alpha, beta and kappa.
25   * Alpha determines the spread of the sigma points around the process state,
26   * kappa is a secondary scaling parameter, and beta is used to incorporate
27   * prior knowledge of the distribution of the process state.
28   * <p>
29   * The Julier transform is a particular case of {@link MerweUnscentedTransform} with alpha = 1 and beta = 0.
30   * </p>
31   * @see "S. J. Julier and J. K. Uhlmann. A New Extension of the Kalman Filter to Nonlinear Systems.
32   *       Proc. SPIE 3068, Signal Processing, Sensor Fusion, and Target Recognition VI, 182 (July 28, 1997)"
33   * @since 2.2
34   */
35  public class JulierUnscentedTransform extends AbstractUnscentedTransform {
36  
37      /** Default value for kappa, (0.0, see reference). */
38      public static final double DEFAULT_KAPPA = 0;
39  
40      /** Weights for covariance matrix. */
41      private final RealVector wc;
42  
43      /** Weights for mean state. */
44      private final RealVector wm;
45  
46      /** Factor applied to the covariance matrix during the unscented transform (lambda + process state size). */
47      private final double factor;
48  
49      /**
50       * Default constructor.
51       * <p>
52       * This constructor uses default value for kappa.
53       * </p>
54       * @param stateDim the dimension of the state
55       * @see #DEFAULT_KAPPA
56       * @see #JulierUnscentedTransform(int, double)
57       */
58      public JulierUnscentedTransform(final int stateDim) {
59          this(stateDim, DEFAULT_KAPPA);
60      }
61  
62      /**
63       * Simple constructor.
64       * @param stateDim the dimension of the state
65       * @param kappa fscaling factor
66       */
67      public JulierUnscentedTransform(final int stateDim, final double kappa) {
68  
69          // Call super constructor
70          super(stateDim);
71  
72          // Initialize multiplication factor for covariance matrix
73          this.factor = stateDim + kappa;
74  
75          // Initialize vectors weights
76          wm = new ArrayRealVector(2 * stateDim + 1);
77  
78          // Computation of unscented kalman filter weights (See Eq. 12)
79          wm.setEntry(0, kappa / factor);
80          for (int i = 1; i <= 2 * stateDim; i++) {
81              wm.setEntry(i, 1.0 / (2.0 * factor));
82          }
83  
84          // For the Julier unscented transform, there is no difference between covariance and state weights
85          wc = wm;
86  
87      }
88  
89      /** {@inheritDoc} */
90      @Override
91      public RealVector getWc() {
92          return wc;
93      }
94  
95      /** {@inheritDoc} */
96      @Override
97      public RealVector getWm() {
98          return wm;
99      }
100 
101     /** {@inheritDoc} */
102     @Override
103     protected double getMultiplicationFactor() {
104         return factor;
105     }
106 
107 }