code: def predict(pdf, offset, kernel, mode="wrap", cval=0.0):
      """Performs the discrete Bayes filter prediction step, generating
      the prior.
  
      `pdf` is a discrete probability distribution expressing our initial
      belief.
  
      `offset` is an integer specifying how much we want to move to the right
      (negative values means move to the left)
  
      We assume there is some noise in that offset, which we express in `kernel`.
      For example, if offset=3 and kernel=[.1, .7., .2], that means we think
      there is a 70% chance of moving right by 3, a 10% chance of moving 2
      spaces, and a 20% chance of moving by 4.
  
      It returns the resulting distribution.
  
      If `mode='wrap'`, then the probability distribution is wrapped around
      the array.
  
      If `mode='constant'`, or any other value the pdf is shifted, with `cval`
      used to fill in missing elements.
  
      Examples
      --------
      .. code-block:: Python
  
          belief = [.05, .05, .05, .05, .55, .05, .05, .05, .05, .05]
          prior = predict(belief, offset=2, kernel=[.1, .8, .1])
      """
  
      if mode == "wrap":
          return convolve(np.roll(pdf, offset), kernel, mode="wrap")
  
      return convolve(
          shift(pdf, offset, cval=cval),
          kernel,
          cval=cval,
          mode="constant",
      )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy
  from scipy.ndimage.filters import convolve
  from scipy.ndimage.interpolation import shift
label_desc: Use image node_id 3 for calling a global function with example usage: predict(pdf, offset, kernel, mode, cval) and returns: convolve, convolve