Note
Go to the end to download the full example code
Do an adaptive track staircase with MHW procedureΒΆ
This shows how to make and use an adaptive track with the modified
Hughson-Westlake (MHW) procedure using
expyfun.stimuli.TrackerMHW
.
tracker_identify: {"tracker_id": "139750324763280-1690312115130718", "tracker_type": "TrackerMHW"}
tracker_139750324763280-1690312115130718_init:{"callback": null, "base_step": 5, "factor_down": 2, "factor_up_nr": 4, "start_value": 80, "x_min": 0, "x_max": 120, "n_up_stop": 2, "repeat_limit": "reversals"}
tracker_139750324763280-1690312115130718_respond:False
tracker_139750324763280-1690312115130718_respond:False
tracker_139750324763280-1690312115130718_respond:True
tracker_139750324763280-1690312115130718_respond:False
tracker_139750324763280-1690312115130718_respond:True
tracker_139750324763280-1690312115130718_respond:False
tracker_139750324763280-1690312115130718_respond:False
/home/circleci/project/expyfun/stimuli/_tracker.py:1249: UserWarning: Tracker 139750324763280-1690312115130718 exceeded x_min or x_max bounds 1 times.
warnings.warn('Tracker {} exceeded x_min or x_max bounds {} times.'
tracker_139750324763280-1690312115130718_stop:{"responses": [0, 0, 1, 0, 1, 0, 0, 1], "reversals": [0, 0, 1, 2, 3, 4, 0, 5], "x": [80.0, 100.0, 120.0, 110.0, 115.0, 105.0, 110.0, 115.0], "threshold": 115, "n_correct_levels": {"0": 0, "5": 0, "10": 0, "15": 0, "20": 0, "25": 0, "30": 0, "35": 0, "40": 0, "45": 0, "50": 0, "55": 0, "60": 0, "65": 0, "70": 0, "75": 0, "80": 0, "85": 0, "90": 0, "95": 0, "100": 0, "105": 0, "110": 0, "115": 2, "120": 1}}
import numpy as np
from expyfun.stimuli import TrackerMHW
from expyfun.analyze import sigmoid
# Make a callback function that prints to the console, rather than log file
def callback(event_type, value=None, timestamp=None):
print((str(event_type) + ':').ljust(40) + str(value))
# Define parameters for modeled human subject (sigmoid probability)
true_thresh = 115
slope = 0.8
chance = 0.08 # if you don't hear it, you don't respond
# Make a tracker that uses the weighted up-down procedure to find 75%
tr = TrackerMHW(callback, 0, 120, base_step=5, start_value=80)
# Initialize human state
rng = np.random.RandomState(1)
# Do the task until the tracker stops
while not tr.stopped:
tr.respond(rng.rand() < sigmoid(tr.x_current - true_thresh,
lower=chance, slope=slope))
# Plot the results
fig, ax, lines = tr.plot()
lines += tr.plot_thresh()
ax.set_title('Adaptive track of model human (true threshold is {})'
.format(true_thresh))
Total running time of the script: ( 0 minutes 0.091 seconds)