code: def test_hamilton_filter_order_zero_with_tvtp(self):
      k_regimes = 3
      nobs = 8
      initial_probabilities = np.ones(k_regimes) / k_regimes
  
      # We do not actually transition between the 3 regimes except from
      # t=3 to t=4 where we reset to regimes 1 and 2 being equally
      # likely.
      regime_transition = np.zeros((k_regimes, k_regimes, nobs))
      regime_transition[...] = np.eye(k_regimes)[:, :, np.newaxis]
      regime_transition[..., 4] = [
          [0, 0, 0],
          [1 / 2, 1 / 2, 1 / 2],
          [1 / 2, 1 / 2, 1 / 2],
      ]
  
      # Regime i correponds to a sequence of iid draws from discrete
      # random variables that are equally likely to be -1, i, and i + 1
      # for i = 0, 1, 2.  We observe the sequence:
      #
      #     t =  0, 1, 2,  3,  4, 5, 6,  7
      #   X_t = -1, 1, 2, -1, -1, 2, 3, -1
      #
      # The first observations tell us nothing, the second tells us that
      # regime 0 and 1 are equally likely, and the third tells us that we
      # must be in regime 1 for t = 0, 1, 2, 3.  At t=4 we transition to
      # state 1 or 2.  In this case, neither a -1 or 2 changes our view
      # that these states are equally likely, but a 3 tells we must be in
      # state 2 for the second four timestamps.
      conditional_likelihoods = np.empty((k_regimes, nobs))
      conditional_likelihoods[:, 0] = [1 / 3, 1 / 3, 1 / 3]
      conditional_likelihoods[:, 1] = [1 / 3, 1 / 3, 0]
      conditional_likelihoods[:, 2] = [0, 1 / 3, 1 / 3]
      conditional_likelihoods[:, 3:5] = [[1 / 3], [1 / 3], [1 / 3]]
      conditional_likelihoods[:, 5] = [0, 1 / 3, 1 / 3]
      conditional_likelihoods[:, 6] = [0, 0, 1 / 3]
      conditional_likelihoods[:, 7] = [1 / 3, 1 / 3, 1 / 3]
  
      expected_marginals = np.empty((k_regimes, nobs))
      expected_marginals[:, 0] = [1 / 3, 1 / 3, 1 / 3]
      expected_marginals[:, 1] = [1 / 2, 1 / 2, 0]
      expected_marginals[:, 2:4] = [[0], [1], [0]]
      expected_marginals[:, 4:6] = [[0], [1 / 2], [1 / 2]]
      expected_marginals[:, 6:8] = [[0], [0], [1]]
  
      cy_results = markov_switching.cy_hamilton_filter_log(
          initial_probabilities,
          regime_transition,
          np.log(conditional_likelihoods + 1e-20),
          model_order=0,
      )
      assert_allclose(cy_results[0], expected_marginals, atol=1e-15)
  
imports: import os
  import warnings
  import numpy
  from numpy.testing import assert_allclose, assert_raises
  import pandas
  import pytest
  from statsmodels.tsa.regime_switching import markov_switching, markov_regression
label_desc: Use image node_id 5 for calling the TestFedFundsConstShort obj's underlying member method code with example usage: obj.test_hamilton_filter_order_zero_with_tvtp() without return types