The utils Module¶
Some functions that come in handy when working with psychophysics datasets.
Provides¶
- d_prime : Calculate the sensitivity index d’ (“d-prime”).
- criterion : Calculate the decision criterion C.
- pphelper.sdt.a_prime(hits, false_alarms, n, nafc=1)¶
Calculate the sensitivity index A’.
Parameters: - hits (float) – The number of hits when detecting a signal.
- false_alarms (float) – The number of false alarms.
- n (int) – The number of trials in target and no-target trials.
- nafc (int, optional) – The number of alternative choices in the task. A value of 1 implies a Yes/No task. Defaults to 1.
Returns: A – The calculated A’.
Return type: float
Example
>>> from pphelper import sdt >>> sdt.A_prime(20, 10, 25) 0.79166666666666674
- pphelper.sdt.criterion(hits, false_alarms, n, nafc=1)¶
Calculate the decision criterion C.
Parameters: - hits (float) – The number of hits when detecting a signal.
- false_alarms (float) – The number of false alarms.
- n (int) – The number of trials in target and no-target trials.
- nafc (int, optional) – The number of alternative choices in the task. A value of 1 implies a Yes/No task. Defaults to 1.
Returns: C – The decision criterion. This will be zero for an unbiased observer, and non-zero otherwise. In a 1-AFC (Yes/No) task, a value smaller than 0 implies a bias to responding “Yes”, and a value greater than 0 a bias to responding “No”.
Return type: float
Example
>>> from pphelper import sdt >>> sdt.criterion(20, 10, 25) -0.29413706521855731
- pphelper.sdt.d_prime(hits, false_alarms, n, nafc=1)¶
Calculate the sensitivity index d’ (“d-prime”).
Parameters: - hits (float) – The number of hits when detecting a signal.
- false_alarms (float) – The number of false alarms.
- n (int) – The number of trials in target and no-target trials.
- nafc (int, optional) – The number of alternative choices in the task. A value of 1 implies a Yes/No task. Defaults to 1.
Returns: d – The calculated d’ value, z(hit_rate) - z(fa_rate).
Return type: float
Example
>>> from pphelper import sdt >>> sdt.d_prime(20, 10, 25) 1.094968336708714