expyfun.stimuli.TrackerBinom#

class expyfun.stimuli.TrackerBinom(callback, alpha, chance, max_trials, min_trials=0, stop_early=True, x_current=nan)[source]#

Binomial hypothesis testing tracker

This class implements a tracker that runs a test at each trial with the null hypothesis that the stimulus presented has no effect on the subject’s response. This would happen in the case where the subject couldn’t hear a stimulus, they were not able to do a task, or they did not understand the task. This function’s main use is training: a subject may move on to the experiment when the null hypothesis that they aren’t doing the task has been rejected.

Parameters:
callbackcallable | ExperimentController | None

The function that will be used to print the data, usually to the experiment .tab file. It should follow the prototype of ExperimentController.write_data_line. If an instance of ExperimentController is given, then it will take that object’s write_data_line function. If None is given, then it will not write the data anywhere.

alphafloat

The p-value which is considered significant. Must be between 0 and 1. Note that if stop_early is True there is the potential for multiple comparisons issues and a more stringent alpha should be considered.

chancefloat

The chance level of the task being performed. Must be between 0 and 1.

max_trialsint

The maximum number of trials to run before stopping the track without reaching alpha.

min_trialsint

The minimum number of trials to run before allowing the track to stop on reaching alpha. Has no effect if stop_early is False.

stop_earlyboolean

Whether to stop the adaptive track as soon as the track is not able to reach alpha even if the remaining responses are all correct and at least min_trials have been presented.

x_currentfloat

The level that you want to run the test at. This has no bearing on how the track runs, and it will never change, but it is both useful to document the level and required to exist if using TrackerDealer.

Attributes:
alpha
chance
max_p_val
max_trials
min_p_val
n_correct

The number of correct trials so far

n_trials
n_wrong

The number of incorrect trials so far

p_val
pc

Proportion correct (0-1, NaN before any responses made)

responses

The response history

stop_early
stop_rule
stopped

Is the tracker stopped

success

Has the p-value reached significance

x

Included only for compatibility with TrackerDealer

x_current

Included only for compatibility with TrackerDealer

Methods

respond(correct)

Update the tracker based on the last response.

Returns:
trackerinstance of TrackerBinom

The binomial tracker object.

Notes

The task, unlike with an adaptive tracker, should be done all at one stimulus level, usually an easy one. The point of this tracker is to confirm that the subject understands the task instructions and is capable of following them.

property n_correct#

The number of correct trials so far

property n_wrong#

The number of incorrect trials so far

property pc#

Proportion correct (0-1, NaN before any responses made)

respond(correct)[source]#

Update the tracker based on the last response.

Parameters:
correctboolean

Was the most recent subject response correct?

property responses#

The response history

property stopped#

Is the tracker stopped

property success#

Has the p-value reached significance

property x#

Included only for compatibility with TrackerDealer

property x_current#

Included only for compatibility with TrackerDealer