ChoiceKernel#
- class ChoiceKernel(temperature_activations=0.5, temperature_kernel=0.5, activations=None, kernel=None, **kwargs)[source]#
Bases:
objectA class representing a choice kernel based on a softmax function that incorporates the frequency of choosing an action. It is based on Equation 7 in Wilson and Collins (2019).
- Parameters:
- temperature_activations
float The inverse temperature parameter for the softmax computation.
- temperature_kernel
float The inverse temperature parameter for the kernel computation.
- activations
ndarray, optional An array of activations for the softmax function.
- kernel
ndarray, optional An array of kernel values for the softmax function.
- temperature_activations
Notes
The choice kernel is defined as follows:
\[P(x) = \frac{e^{\theta_a a + \theta_k k}}{\sum_{i} e^{\theta_a a_i + \theta_k k_i}}\]where \(\theta_a\) is the inverse temperature parameter for the activations, \(\theta_k\) is the inverse temperature parameter for the kernel, \(a\) is the array of activations for each action, and \(k\) is the array of kernel values for each action. The kernel values represent the frequency of choosing each action in the past, and they are updated after each choice.
In order to get Equation 6 from Wilson and Collins (2019), either set
activationsto None (default) or set it to 0.References
Wilson, R. C., & Collins, A. G. E. (2019). Ten simple rules for the computational modeling of behavioral data. eLife, 8, Article e49547.
Examples
>>> activations = np.array([[0.1, 0, 0.2], [-0.6, 0, 0.9]]) >>> kernel = np.array([0.1, 0.9]) >>> choice_kernel = ChoiceKernel(temperature_activations=1, temperature_kernel=1, activations=activations, kernel=kernel) >>> choice_kernel.compute() array([0.44028635, 0.55971365])