Implement a function bellman_expectation_value that computes the state-value function for all states under a given stochastic policy by solving the Bellman expectation equation.
The Bellman expectation equation relates the value of a state to the values of its successor states under a particular policy. Given the MDP components and a fixed policy, the state-value function satisfies a system of equations that can be solved exactly.
Parameters:
P: A numpy array of shape (num_states, num_actions, num_states) representing transition probabilities. P[s, a, s'] is the probability of transitioning from state s to state s' when taking action a.R: A numpy array of shape (num_states, num_actions, num_states) representing rewards. R[s, a, s'] is the reward received when transitioning from state s to s' via action a.policy: A numpy array of shape (num_states, num_actions) representing the stochastic policy. policy[s, a] is the probability of selecting action a in state s.gamma: A float representing the discount factor (between 0 and 1 inclusive).Returns:
(num_states,) containing the state-value for each state under the given policy.Notes: