sample_action#
- hybrid_aif.planning.sample_action(
- key,
- q_pi_or_marginals,
- policies=None,
- num_controls=None,
- mode='marginal',
- selection='stochastic',
- alpha=None,
Select an action from a policy posterior: a control level per control node, or a vector.
After pymdp’s
control.sample_actionandcontrol.sample_policy(pymdp/control.py): the marginal and policy modes, deterministic and stochastic selection, and thealphaprecision on log-probabilities follow pymdp’sAgent.sample_action; thealpha-sharpened action marginal is SPM’s action selection inspm_MDP_VB_X.mode="marginal"acts from the first-step action marginals (given as a tuple, or computed fromq_pi, which then requirespoliciesandnum_controls);mode="policy"from a policy drawn fromq_pi.selection="deterministic"takes the argmax (ties: lowest index;keyunused).alphasharpens marginal logits before stochastic selection. Over continuous actions onlymode="policy"is defined; it returns the sequence’s first step, dtype preserved, and"marginal"raises. A mixed policy set, aControlStepwith leading axes(P, policy_len), takesmode="policy"and returns the drawn policy’s first step as aControlStepwith one entry per control node.selectionis the action’s realisation:"stochastic"corresponds to the realisationsample(a draw) and"deterministic"tomode(the argmax); a mixed strategy (stats) is not emitted here. Design: nesting-and-coupling.md N3.