Notation: x randomly chosen with weights from set S

70 Views Asked by At

I have implemented $\epsilon$-greedy policy in the context of reinforcement learning in Python code:

import numpy as np

p_distr = [1 - epsilon, epsilon]
exploitation_action = argmax(Q_sa[s, :]) # Own made argmax
exploration_action = np.random.randint(0, n_actions) # n_actions = 4
policy_options = [exploitation_action, exploration_action]
action = np.random.choice(policy_options, p=p_distr)

Now I want to write my code above into mathematical notation. I have been successful in doing that, except for:

action = np.random.choice(policy_options, p=p_distr)

I am not exactly sure how to write this in mathematical notation. I did find this notation: $x \in_R S$. However, this does not, I think, take into consideration the weights as specified by p_distr in my code above.

What is the correct mathematical notation for choosing $x$ randomly with weights from set $S$?

Thanks!