Beispiel #1
0
 def test_copy(self):
     values = np.random.rand(3, 2)
     c = Categorical(values=values)
     c_copy = c.copy()
     self.assertTrue(np.array_equal(c_copy.values, c.values))
     c_copy.values = c_copy.values * 2
     self.assertFalse(np.array_equal(c_copy.values, c.values))
# get an observation, given the state
first_obs = gp_likelihood[:, first_state]

# turn observation into an index
first_obs = np.where(first_obs)[0][0]

print("Initial Location {}".format(first_state))
print("Initial Observation {}".format(first_obs))

# infer initial state, given first observation
qs = maths.softmax(A[first_obs, :].log() + D.log(), return_numpy=False)

# loop over time
for t in range(T):

    qs_past = qs.copy()

    s_t = env.set_state(s[t + 1])

    # evoke observation, given the state
    obs = gp_likelihood[:, s_t]

    # turn observation into an index
    obs = np.where(obs)[0][0]

    # get transition likelihood
    B = b.mean()

    # infer new hidden state
    qs = maths.softmax(A[obs, :].log() + B.dot(qs_past).log(),
                       return_numpy=False)