Antibias ignores the per-condition probability prior
Summary
When trial_selection is staircase or biased with antibias enabled, the realized condition distribution does not follow the experimenter-defined prior. With random the same prior is honored. Over 150 trials, staircase+antibias drifts toward a balanced/uniform distribution instead of the intended one.
Where
src/ethopy/core/experiment.py
_random_selection (line ~680)
_anti_bias (line ~635)
_staircase_selection (line ~713)
_biased_selection (line ~739)
un_choices / un_blocks setup in log_conditions (line ~478)
Root cause
random honors the prior because it samples self.conditions directly:
return np.random.choice(self.conditions)
This is a uniform draw over the conditions list, whose multiplicity encodes the prior (A×3, B×3, C×4 → 30/30/40).
The antibias path discards that multiplicity in two places:
self.un_choices = np.unique(...) — antibias operates only on unique [response_port, difficulty] choices, so it can't see that C appeared 4× and A only 3×.
_anti_bias returns a choice with fixed_p = 1 - mean(recent == choice),normalized. That deliberately drives presentation toward equalizing the animal's recent choices (uniform target), not toward the experimenter prior.
- The final
np.random.choice(valid_conditions) is also uniform among the conditions matching the chosen choice.
result: with antibias the distribution depends on how many unique choices A/B/C map to and on the animal's behavior
This is "working as designed" for antibias (bias correction targets uniform), but it is incompatible with also reproducing a fixed prior.
Antibias ignores the per-condition probability prior
Summary
When
trial_selectionisstaircaseorbiasedwithantibiasenabled, the realized condition distribution does not follow the experimenter-defined prior. Withrandomthe same prior is honored. Over 150 trials, staircase+antibias drifts toward a balanced/uniform distribution instead of the intended one.Where
src/ethopy/core/experiment.py_random_selection(line ~680)_anti_bias(line ~635)_staircase_selection(line ~713)_biased_selection(line ~739)un_choices/un_blockssetup inlog_conditions(line ~478)Root cause
randomhonors the prior because it samplesself.conditionsdirectly:This is a uniform draw over the conditions list, whose multiplicity encodes the prior (A×3, B×3, C×4 → 30/30/40).
The antibias path discards that multiplicity in two places:
self.un_choices = np.unique(...)— antibias operates only on unique[response_port, difficulty]choices, so it can't see that C appeared 4× and A only 3×._anti_biasreturns a choice withfixed_p = 1 - mean(recent == choice),normalized. That deliberately drives presentation toward equalizing the animal's recent choices (uniform target), not toward the experimenter prior.np.random.choice(valid_conditions)is also uniform among the conditions matching the chosen choice.result: with antibias the distribution depends on how many unique choices A/B/C map to and on the animal's behavior
This is "working as designed" for antibias (bias correction targets uniform), but it is incompatible with also reproducing a fixed prior.