code: def Q_discrete_white_noise(
      dim, dt=1.0, var=1.0, block_size=1, order_by_dim=True
  ):
      """
      Returns the Q matrix for the Discrete Constant White Noise
      Model. dim may be either 2, 3, or 4 dt is the time step, and sigma
      is the variance in the noise.
  
      Q is computed as the G * G^T * variance, where G is the process noise per
      time step. In other words, G = [[.5dt^2][dt]]^T for the constant velocity
      model.
  
      Parameters
      -----------
  
      dim : int (2, 3, or 4)
          dimension for Q, where the final dimension is (dim x dim)
  
      dt : float, default=1.0
          time step in whatever units your filter is using for time. i.e. the
          amount of time between innovations
  
      var : float, default=1.0
          variance in the noise
  
      block_size : int >= 1
          If your state variable contains more than one dimension, such as
          a 3d constant velocity model [x x' y y' z z']^T, then Q must be
          a block diagonal matrix.
  
      order_by_dim : bool, default=True
          Defines ordering of variables in the state vector. `True` orders
          by keeping all derivatives of each dimensions)
  
          [x x' x'' y y' y'']
  
          whereas `False` interleaves the dimensions
  
          [x y z x' y' z' x'' y'' z'']
  
  
      Examples
      --------
      >>> # constant velocity model in a 3D world with a 10 Hz update rate
      >>> Q_discrete_white_noise(2, dt=0.1, var=1., block_size=3)
      array([[0.000025, 0.0005  , 0.      , 0.      , 0.      , 0.      ],
             [0.0005  , 0.01    , 0.      , 0.      , 0.      , 0.      ],
             [0.      , 0.      , 0.000025, 0.0005  , 0.      , 0.      ],
             [0.      , 0.      , 0.0005  , 0.01    , 0.      , 0.      ],
             [0.      , 0.      , 0.      , 0.      , 0.000025, 0.0005  ],
             [0.      , 0.      , 0.      , 0.      , 0.0005  , 0.01    ]])
  
      References
      ----------
  
      Bar-Shalom. "Estimation with Applications To Tracking and Navigation".
      John Wiley & Sons, 2001. Page 274.
      """
  
      if dim not in [2, 3, 4]:
          raise ValueError("dim must be between 2 and 4")
  
      if dim == 2:
          Q = [
              [0.25 * dt**4, 0.5 * dt**3],
              [0.5 * dt**3, dt**2],
          ]
      elif dim == 3:
          Q = [
              [0.25 * dt**4, 0.5 * dt**3, 0.5 * dt**2],
              [0.5 * dt**3, dt**2, dt],
              [0.5 * dt**2, dt, 1],
          ]
      else:
          Q = [
              [
                  (dt**6) / 36,
                  (dt**5) / 12,
                  (dt**4) / 6,
                  (dt**3) / 6,
              ],
              [
                  (dt**5) / 12,
                  (dt**4) / 4,
                  (dt**3) / 2,
                  (dt**2) / 2,
              ],
              [(dt**4) / 6, (dt**3) / 2, dt**2, dt],
              [(dt**3) / 6, (dt**2) / 2, dt, 1.0],
          ]
  
      if order_by_dim:
          return block_diag(*[Q] * block_size) * var
      return order_by_derivative(array(Q), dim, block_size) * var
  
file_path: filterpy/filterpy/common/discretization.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from numpy import zeros, vstack, eye, array
  from numpy.linalg import inv
  from scipy.linalg import expm, block_diag
label_desc: Use image node_id 2 for calling a global function with example usage: Q_discrete_white_noise(dim, dt, var, block_size, order_by_dim) and returns: unknown, unknown