Note
Go to the end to download the full example code.
Do an adaptive track staircase#
This shows how to make and use an adaptive track using
expyfun.stimuli.TrackerUD
.
@author: rkmaddox
tracker_identify: {"tracker_id": "139793738442800-1732030353998256", "tracker_type": "TrackerUD"}
tracker_139793738442800-1732030353998256_init:{"callback": null, "up": 1, "down": 1, "step_size_up": [9.0, 3.0], "step_size_down": [3.0, 1.0], "stop_reversals": 30, "stop_trials": Infinity, "start_value": 60, "change_indices": [4], "change_rule": "reversals", "x_min": -Infinity, "x_max": Infinity, "repeat_limit": "reversals"}
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_respond:True
tracker_139793738442800-1732030353998256_respond:False
tracker_139793738442800-1732030353998256_stop:{"responses": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1], "reversals": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 5, 0, 6, 0, 7, 0, 8, 0, 0, 9, 10, 0, 11, 12, 0, 0, 0, 0, 0, 0, 13, 14, 0, 0, 0, 0, 15, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 0, 19, 20, 0, 0, 0, 0, 21, 22, 23, 24, 0, 25, 26, 0, 27, 28, 29, 30], "x": [60.0, 57.0, 54.0, 51.0, 48.0, 45.0, 42.0, 39.0, 36.0, 33.0, 30.0, 27.0, 36.0, 33.0, 42.0, 41.0, 40.0, 39.0, 38.0, 37.0, 36.0, 39.0, 42.0, 41.0, 40.0, 43.0, 46.0, 45.0, 44.0, 43.0, 46.0, 45.0, 44.0, 47.0, 46.0, 45.0, 44.0, 43.0, 42.0, 41.0, 40.0, 43.0, 42.0, 41.0, 40.0, 39.0, 38.0, 41.0, 40.0, 39.0, 38.0, 37.0, 36.0, 35.0, 34.0, 33.0, 32.0, 31.0, 30.0, 29.0, 32.0, 31.0, 30.0, 33.0, 32.0, 31.0, 30.0, 29.0, 28.0, 31.0, 30.0, 33.0, 32.0, 31.0, 34.0, 33.0, 32.0, 35.0, 34.0, 37.0]}
import numpy as np
from expyfun.analyze import sigmoid
from expyfun.stimuli import TrackerUD
print(__doc__)
# 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 = 35
slope = 0.1
chance = 0.5
# Make a tracker that uses the weighted up-down procedure to find 75%
tr = TrackerUD(callback, 1, 1, [9, 3], [3, 1], 30, np.inf, 60, [4])
# 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(4, ax=ax)
ax.set_title(f"Adaptive track of model human (true threshold is {true_thresh})")
Total running time of the script: (0 minutes 0.093 seconds)