Adaptive Staircase with Random Selection of Steps

Hello!

I have a typical adaptive staircase like this:

trials = data.StairHandler(startVal=Target_Duration, extraInfo=expInfo,
stepSizes=[0.017], stepType=‘lin’,
nReversals=4, nTrials=50,
nUp=1, nDown=3, # set threshold
minVal=0.01, maxVal=1,
originPath=-1, name=‘trials’)
thisExp.addLoop(trials)

for Target_Duration in trials:
currentLoop = trials

But I would like to change the number of steps for the threshold calculation every trial. So, every trial in the experiment it would randomly select between 2 and 3 steps to go down.

Something like this:

np.random.choice([2,3],1)

Someone knows how to do that?

So, I found that one way to solve it is to set a new value inside every trial by adding:

# -------Prepare the StairCase "trials"--------
# set up handler to look after next chosen value etc
trials = data.StairHandler(startVal=Target_Duration, extraInfo=expInfo,
    stepSizes=[0.017], stepType='lin', 
    nReversals=4, nTrials=50,
    nUp=1, nDown=3,
    minVal=0.01, maxVal=1,
    originPath=-1, name='trials')
thisExp.addLoop(trials) 

for Target_Duration in trials:
    currentLoop = trials

    # Randomly select next nDown value
    trials.nDown = np.random.choice([2,3],1)