@@ -54,9 +54,9 @@ def pool_blocks(data: np.ndarray, max_tol=0, max_gap=np.inf, max_length=np.inf):
5454def psychometric (stimulus_level , threshold , width , gamma , lambda_ , sigmoid_name ):
5555 """ Psychometric function aka proportion correct function.
5656
57- Generates proportion correct values for a range of stimulus levels given a
58- sigmoid.
59- Implementation of Eq 1 in Schuett, Harmeling, Macke and Wichmann (2016)
57+ This is a convenience function used mostly for testing and demos, to make the intent of creating a psychometric
58+ function more explicit. The implementation simply combines creating a `Sigmoid` object using the sigmoid name,
59+ and calling the object to generate the proportion correct values corresponding to `stimulus_level`.
6060
6161 Parameters:
6262 stimulus_level: array
@@ -69,24 +69,59 @@ def psychometric(stimulus_level, threshold, width, gamma, lambda_, sigmoid_name)
6969 Guess rate
7070 lambda_: float
7171 Lapse rate
72- sigmoid: callable
73- Sigmoid function to use. Default is Gaussian
72+ sigmoid_name: callable
73+ Name of sigmoid function to use. See `psignifit.sigmoids.ALL_SIGMOID_NAMES` for the list of available
74+ sigmoids.
7475
7576 Returns:
7677 psi: array
77- proportion correct values for each stimulus level
78+ Proportion correct values for each stimulus level
7879
7980 """
80- # we use the defaults for pc and alpha in the sigmoids:
81- # pc = 0.5
82- # alpha = 0.05
8381 sigmoid = sigmoid_by_name (sigmoid_name )
8482 psi = sigmoid (stimulus_level , threshold = threshold , width = width , gamma = gamma , lambd = lambda_ )
8583 return psi
8684
8785
8886def psychometric_with_eta (stimulus_level , threshold , width , gamma , lambda_ ,
89- sigmoid_name , eta , random_state = np .random .RandomState (42 )):
87+ sigmoid_name , eta , random_state = None ):
88+ """ Psychometric function with overdispersion.
89+
90+ This is a convenience function used mostly for testing and demos. Just like the function `psychometric`, it
91+ computes proportion correct values for a given psychometric function type, specified by name. In addition,
92+ it adds some additional noise to the data, so that its variance is compatible with the overdispersion
93+ parameter `eta`.
94+
95+ See Section 2.2 in Schuett, Harmeling, Macke and Wichmann (2016).
96+
97+ Parameters:
98+ stimulus_level: array
99+ Values of the stimulus value
100+ threshold: float
101+ Threshold of the psychometric function
102+ width: float
103+ Width of the psychometric function
104+ gamma: float
105+ Guess rate
106+ lambda_: float
107+ Lapse rate
108+ sigmoid_name: callable
109+ Name of sigmoid function to use. See `psignifit.sigmoids.ALL_SIGMOID_NAMES` for the list of available
110+ sigmoids.
111+ eta: float
112+ Overdispersion parameter
113+ random_state: np.RandomState
114+ Random state used to generate the additional variance in the data.
115+ If None, NumPy's default random number generator is used.
116+
117+ Returns:
118+ psi: array
119+ Proportion correct values for each stimulus level
120+
121+ """
122+
123+ if random_state is None :
124+ random_state = np .random .default_rng ()
90125
91126 psi = psychometric (stimulus_level , threshold , width , gamma , lambda_ , sigmoid_name )
92127 new_psi = []
0 commit comments