pysdt |
A module for computing signal detection theory measures. |
pysdt
– Signal Detection Theory Measures¶
A module for computing signal detection theory measures. Some of the functions in this module have been ported to python from the ‘psyphy’ R package of Kenneth Knoblauch http://cran.r-project.org/web/packages/psyphy/index.html
-
pysdt.
compute_proportions
(nCA, nTA, nIB, nTB, corr)[source]¶ - Compute proportions with optional corrections for extreme proportions.
Parameters: - nCA : float
Number of correct ‘A’ trials
- nTA : int
Number of total ‘A’ trials
- nIB : float
Number of incorrect ‘B’ trials
- nTB : int
Number of total ‘B’ trials
- corr : string
The correction to apply, none for no correction, ‘loglinear` for the log-linear correction, and 2N for the ‘2N’ correction.
Returns: - HR : float
Hit rate
- FA : float
False alarm rate
References
[1] Hautus, M. J. (1995). Corrections for extreme proportions and their biasing effects on estimated values of d’. Behavior Research Methods, Instruments, & Computers, 27(I), 46–51. http://doi.org/10.3758/BF03203619 [2] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. Examples
>>> H,F = compute_proportions(8, 10, 2, 10, "loglinear") >>> H,F = compute_proportions(10, 10, 2, 10, "loglinear") >>> H,F = compute_proportions(10, 10, 2, 10, "2N")
-
pysdt.
dprime_ABX
(H, FA, meth)[source]¶ Compute d’ for ABX task from ‘hit’ and ‘false alarm’ rates.
Parameters: - H : float
Hit rate.
- FA : float
False alarms rate.
- meth : string
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
Returns: - dprime : float
d’ value
References
[1] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. Examples
>>> dp = dprime_ABX(0.7, 0.2, 'IO') >>> dp = dprime_ABX(0.7, 0.2, 'diff')
-
pysdt.
dprime_ABX_from_counts
(nCA, nTA, nCB, nTB, meth, corr)[source]¶ Compute d’ for ABX task from counts of correct and total responses.
Parameters: - nCA : int
Number of correct responses in ‘same’ trials.
- nTA : int
Total number of ‘same’ trials.
- nCB : int
Number of correct responses in ‘different’ trials.
- nTB : int
Total number of ‘different’ trials.
- meth : string
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
- corr : logical
if True, apply the correction to avoid hit and false alarm rates of 0 or one.
Returns: - dprime : float
d’ value
References
[1] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. Examples
>>> dp = dprime_ABX(0.7, 0.2, 'IO')
-
pysdt.
dprime_SD
(H, FA, meth)[source]¶ Compute d’ for one interval same/different task from ‘hit’ and ‘false alarm’ rates.
Parameters: - H : float
Hit rate.
- FA : float
False alarms rate.
- meth : string
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
Returns: - dprime : float
d’ value
References
[1] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. [2] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press. Examples
>>> dp = dprime_SD(0.7, 0.2, 'IO')
-
pysdt.
dprime_SD_from_counts
(nCA, nTA, nCB, nTB, meth, corr)[source]¶ Compute d’ for one interval same/different task from counts of correct and total responses.
Parameters: - nCA : int
Number of correct responses in ‘same’ trials.
- nTA : int
Total number of ‘same’ trials.
- nCB : int
Number of correct responses in ‘different’ trials.
- nTB : int
Total number of ‘different’ trials.
- meth : string
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
- corr : logical
if True, apply the correction to avoid hit and false alarm rates of 0 or one.
Returns: - dprime : float
d’ value
References
[1] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. [2] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press. Examples
>>> dp = dprime_SD(0.7, 0.2, 'IO')
-
pysdt.
dprime_mAFC
(Pc, m)[source]¶ - Compute d’ corresponding to a certain proportion of correct responses in m-AFC tasks.
Parameters: - Pc : float
Proportion of correct responses.
- m : int
Number of alternatives.
Returns: - dprime : float
d’ value
References
[1] Green, D. M., & Swets, J. A. (1988). Signal Detection Theory and Psychophysics. Los Altos, California: Peninsula Publishing. [2] Green, D. M., & Dai, H. P. (1991). Probability of being correct with 1 of M orthogonal signals. Perception & Psychophysics, 49(1), 100–101. Examples
>>> dp = dprime_mAFC(0.7, 3)
-
pysdt.
dprime_oddity
(prCorr, meth=u'diff')[source]¶ Compute d’ for oddity task from proportion of correct responses. Only valid for the case in which there are three presentation intervals.
Parameters: - prCorr : float
Proportion of correct responses.
- meth : string
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
Returns: - dprime : float
d’ value
References
[1] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. [2] Versfeld, N. J., Dai, H., & Green, D. M. (1996). The optimum decision rules for the oddity task. Perception & Psychophysics, 58(1), 10–21. Examples
>>> dp = dprime_oddity(0.7) >>> dp = dprime_oddity(0.8)
-
pysdt.
dprime_yes_no
(H, FA)[source]¶ Compute d’ for one interval ‘yes/no’ type tasks from hits and false alarm rates.
Parameters: - H : float
Hit rate.
- FA : float
False alarms rate.
Returns: - dprime : float
d’ value
References
[1] Green, D. M., & Swets, J. A. (1988). Signal Detection Theory and Psychophysics. Los Altos, California: Peninsula Publishing. [2] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. Examples
>>> dp = dprime_yes_no(0.7, 0.2)
-
pysdt.
dprime_yes_no_from_counts
(nCA, nTA, nCB, nTB, corr)[source]¶ Compute d’ for one interval ‘yes/no’ type tasks from counts of correct and total responses.
Parameters: - nCA : int
Number of correct responses in ‘signal’ trials.
- nTA : int
Total number of ‘signal’ trials.
- nCB : int
Number of correct responses in ‘noise’ trials.
- nTB : int
Total number of ‘noise’ trials.
- corr : logical
if True, apply the correction to avoid hit and false alarm rates of 0 or one.
Returns: - dprime : float
d’ value
References
[1] Green, D. M., & Swets, J. A. (1988). Signal Detection Theory and Psychophysics. Los Altos, California: Peninsula Publishing. [2] Macmillan, N. A., & Creelman, C. D. (2004). Detection Theory: A User’s Guide (2nd ed.). London: Lawrence Erlbraum Associates. Examples
>>> dp = dprime_yes_no_from_counts(nCA=70, nTA=100, nCB=80, nTB=100, corr=True)
-
pysdt.
gaussianPsy
(x, alphax, betax, gammax, lambdax)[source]¶ Compute the gaussian psychometric function.
Parameters: - x :
Stimulus level(s).
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function (guess rate).
- lambdax:
The lapse rate.
Returns: - pc :
Proportion correct at the stimulus level(s) x.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.
-
pysdt.
gumbelPsy
(x, alphax, betax, gammax, lambdax)[source]¶ Compute the gumbel psychometric function.
Parameters: - x :
Stimulus level(s).
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function (guess rate).
- lambdax:
The lapse rate.
Returns: - pc :
Proportion correct at the stimulus level(s) x.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.
-
pysdt.
invGaussianPsy
(p, alphax, betax, gammax, lambdax)[source]¶ Compute the inverse gaussian psychometric function.
Parameters: - p :
Proportion correct on the psychometric function.
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function.
- lambdax:
The lapse rate.
Returns: - x :
Stimulus level at which proportion correct equals p for the listener specified by the function.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.
-
pysdt.
invGumbelPsy
(p, alphax, betax, gammax, lambdax)[source]¶ Compute the inverse gumbel psychometric function.
Parameters: - p :
Proportion correct on the psychometric function.
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function.
- lambdax:
The lapse rate.
Returns: - x :
Stimulus level at which proportion correct equals p for the listener specified by the function.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.
-
pysdt.
invLogisticPsy
(p, alphax, betax, gammax, lambdax)[source]¶ Compute the inverse logistic psychometric function.
Parameters: - p :
Proportion correct on the psychometric function.
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function.
- lambdax:
The lapse rate.
Returns: - x :
Stimulus level at which proportion correct equals p for the listener specified by the function.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.
-
pysdt.
invWeibullPsy
(p, alphax, betax, gammax, lambdax)[source]¶ Compute the inverse weibull psychometric function.
Parameters: - p :
Proportion correct on the psychometric function.
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function.
- lambdax:
The lapse rate.
Returns: - x :
Stimulus level at which proportion correct equals p for the listener specified by the function.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.
-
pysdt.
logisticPsy
(x, alphax, betax, gammax, lambdax)[source]¶ Compute the logistic psychometric function.
Parameters: - x :
Stimulus level(s).
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function (guess rate).
- lambdax:
The lapse rate.
Returns: - pc :
Proportion correct at the stimulus level(s) x.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.
-
pysdt.
weibullPsy
(x, alphax, betax, gammax, lambdax)[source]¶ Compute the weibull psychometric function.
Parameters: - x :
Stimulus level(s).
- alphax:
Mid-point(s) of the psychometric function.
- betax:
The slope of the psychometric function.
- gammax:
Lower limit of the psychometric function (guess rate).
- lambdax:
The lapse rate.
Returns: - pc :
Proportion correct at the stimulus level(s) x.
References
[1] Kingdom, F. A. A., & Prins, N. (2010). Psychophysics: A Practical Introduction. Academic Press.