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:
- nCAfloat
Number of correct ‘A’ trials
- nTAint
Number of total ‘A’ trials
- nIBfloat
Number of incorrect ‘B’ trials
- nTBint
Number of total ‘B’ trials
- corrstring
The correction to apply, none for no correction, ‘loglinear` for the log-linear correction, and 2N for the ‘2N’ correction.
- Returns:
- HRfloat
Hit rate
- FAfloat
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:
- Hfloat
Hit rate.
- FAfloat
False alarms rate.
- methstring
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
- Returns:
- dprimefloat
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:
- nCAint
Number of correct responses in ‘same’ trials.
- nTAint
Total number of ‘same’ trials.
- nCBint
Number of correct responses in ‘different’ trials.
- nTBint
Total number of ‘different’ trials.
- methstring
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
- corrlogical
if True, apply the correction to avoid hit and false alarm rates of 0 or one.
- Returns:
- dprimefloat
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:
- Hfloat
Hit rate.
- FAfloat
False alarms rate.
- methstring
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
- Returns:
- dprimefloat
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:
- nCAint
Number of correct responses in ‘same’ trials.
- nTAint
Total number of ‘same’ trials.
- nCBint
Number of correct responses in ‘different’ trials.
- nTBint
Total number of ‘different’ trials.
- methstring
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
- corrlogical
if True, apply the correction to avoid hit and false alarm rates of 0 or one.
- Returns:
- dprimefloat
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:
- Pcfloat
Proportion of correct responses.
- mint
Number of alternatives.
- Returns:
- dprimefloat
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='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:
- prCorrfloat
Proportion of correct responses.
- methstring
‘diff’ for differencing strategy or ‘IO’ for independent observations strategy.
- Returns:
- dprimefloat
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:
- Hfloat
Hit rate.
- FAfloat
False alarms rate.
- Returns:
- dprimefloat
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:
- nCAint
Number of correct responses in ‘signal’ trials.
- nTAint
Total number of ‘signal’ trials.
- nCBint
Number of correct responses in ‘noise’ trials.
- nTBint
Total number of ‘noise’ trials.
- corrlogical
if True, apply the correction to avoid hit and false alarm rates of 0 or one.
- Returns:
- dprimefloat
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.invLogisticPsyWd(p, alphax, width, gammax, lambdax, perc=90)[source]
Compute the inverse logistic psychometric function parametrized by width.
- Parameters:
- p
Proportion correct on the psychometric function.
- alphax:
Mid-point(s) of the psychometric function.
- width:
The width of the psychometric function.
- gammax:
Lower limit of the psychometric function.
- lambdax:
The lapse rate.
- perc:
The percentage of the psychometric function covered by the width. For example, if perc is 90, the width goes from 5% to 95% of the probability range covered by the psychometric function.
- 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.
[2]Alcalá-Quintana, R., & García-Pérez, M. A. (2004). The Role of Parametric Assumptions in Adaptive Bayesian Estimation. Psychological Methods, 9(2), 250–271. https://doi.org/10.1037/1082-989X.9.2.250
[3]Kuss, M., Jäkel, F., & Wichmann, F. A. (2005). Bayesian inference for psychometric functions. Journal of Vision, 5(5), 8. https://doi.org/10.1167/5.5.8
- 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.logisticPsyWd(x, alphax, width, gammax, lambdax, perc=90)[source]
Compute the logistic psychometric function parametrized in terms of width.
- Parameters:
- x
Stimulus level(s).
- alphax:
Mid-point(s) of the psychometric function.
- width:
The width of the psychometric function.
- gammax:
Lower limit of the psychometric function (guess rate).
- lambdax:
The lapse rate.
- perc:
The percentage of the psychometric function covered by the width. For example, if perc is 90, the width goes from 5% to 95% of the probability range covered by the psychometric function.
- 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.
[2]Alcalá-Quintana, R., & García-Pérez, M. A. (2004). The Role of Parametric Assumptions in Adaptive Bayesian Estimation. Psychological Methods, 9(2), 250–271. https://doi.org/10.1037/1082-989X.9.2.250
[3]Kuss, M., Jäkel, F., & Wichmann, F. A. (2005). Bayesian inference for psychometric functions. Journal of Vision, 5(5), 8. https://doi.org/10.1167/5.5.8
- pysdt.psychSlopeToWidth(sl, perc=90, sigmoid='logistic')[source]
Convert psychometric function slope to width. Currently works only for a logistic psychometric function.
- Parameters:
- sl
Psychometric function slope.
- perc:
The percentage of the psychometric function covered by the width. For example, if perc is 90, the width goes from 5% to 95% of the probability range covered by the psychometric function.
- sigmoid:
The psychometric function shape. Currently only logistic psychometric functions are accepted.
- Returns:
- width
The psychometric function width.
References
[1]Alcalá-Quintana, R., & García-Pérez, M. A. (2004). The Role of Parametric Assumptions in Adaptive Bayesian Estimation. Psychological Methods, 9(2), 250–271. https://doi.org/10.1037/1082-989X.9.2.250
[2]Kuss, M., Jäkel, F., & Wichmann, F. A. (2005). Bayesian inference for psychometric functions. Journal of Vision, 5(5), 8. https://doi.org/10.1167/5.5.8
- pysdt.psychWidthToSlope(wd, perc=90, sigmoid='logistic')[source]
Convert psychometric function width to slope. Currently works only for a logistic psychometric function.
- Parameters:
- wd
Psychometric function width.
- perc:
The percentage of the psychometric function covered by the width. For example, if perc is 90, the width goes from 5% to 95% of the probability range covered by the psychometric function.
- sigmoid:
The psychometric function shape. Currently only logistic psychometric functions are accepted.
- Returns:
- slope
The psychometric function slope.
References
[1]Alcalá-Quintana, R., & García-Pérez, M. A. (2004). The Role of Parametric Assumptions in Adaptive Bayesian Estimation. Psychological Methods, 9(2), 250–271. https://doi.org/10.1037/1082-989X.9.2.250
[2]Kuss, M., Jäkel, F., & Wichmann, F. A. (2005). Bayesian inference for psychometric functions. Journal of Vision, 5(5), 8. https://doi.org/10.1167/5.5.8
- 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.