In a POMDP the environment has a hidden state and emits observations. The agent's Markov state is the belief state , which can be updated recursively by Bayes' rule:
The model is given as an array P of shape (n_actions, d, d, n_obs) with P[a, x, i, o] : the probability that, after taking action in hidden state , the next hidden state is and the observation is .
Implement two functions:
belief_update(s, a, o, P) returns (new_s, prob_o), where prob_o is the denominator above and new_s is the updated belief. You may assume prob_o > 0.test_probability(s, test, P) returns the probability of a test , given as a list of (a, o) pairs: the probability that the observations occur if the actions are taken, starting from belief s. Return 0.0 as soon as any step has probability zero.Beliefs are float arrays of length .