choose#
- choose(policy, uniform)[source]#
Sample an option from a policy, given a uniform random number in [0, 1).
This is the inverse-CDF step of
numpy.random.choice(len(policy), p=policy), which is how thechoice()methods of the decision classes sample. Withuniform = numpy.random.random_sample(), it returns the optionnumpy.random.choicewould have returned, so simulations can draw all uniforms with NumPy before a compiled loop and still be reproducible withnumpy.random.seed, and identical to the per-trial models.