Repository navigation
Release 0.5.2 — EstimationTaskModel (magnitude estimation observer) - #7
Merged
Merged
Conversation
…on on a bounded integer scale Weber / constant / power-law encoding noise; true, fitted or empirical prior; posterior mean or median readout; censored discretised motor noise; free lapse; optional leakage of an uncued magnitude (mixture or average). Observed Categorical likelihood, so LOO and posterior-predictive draws come from PyMC. Tests: builds + finite gradients for every option, analytic checks, MAP and hierarchical NUTS parameter recovery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… GaussianPrior / lapse) replacing MagnitudeEstimationModel Encoding is Gaussian in a Box-Cox power space f_alpha (alpha free or fixed; 0 = log/Weber, 1 = linear). Prior: uniform (e.g. the task range) or Gaussian in the same space (log-normal for log). Posterior-mean readout, rounded and censored to the response scale; lapse uniform over options; optional Gaussian motor noise. Closed-form likelihood for log space + log-normal prior; else a grid whose estimate n_hat(m) is inverted at the response-option edges, which keeps the likelihood exact and smooth. Noise nu and prior width are in log units at a reference magnitude so they stay comparable across alpha. Tests: every combination builds with finite gradients, closed form = grid, alpha -> 0 = log, uniform-prior compression, flat s.d. for linear + Gaussian, MAP and hierarchical NUTS recovery (incl. free alpha). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mean; CHANGELOG Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aths, efficient-coding equivalence) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ncoding noise (r > .93 in a 19 x 500 recovery) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er trial The motor-noise integral was a per-trial (T, M, R) tensor: 0.75 s per gradient on 9,928 trials, so the hierarchical fits timed out at 12 h. Computing the (S, K, R) option table per participant x unique magnitude (a batched matmul) gives identical log-probabilities at 0.04 s per gradient (19x faster). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ault, or continuous) and discrete UniformPrior The fitted Gaussian prior had support on the whole hypothesis grid (1..50), so the observer did not know the task's bounds. TruncatedGaussianPrior(lo, hi) restricts it to the task range; discrete=True puts the mass on the integers lo..hi only (weights = the prior's density in n at each integer). UniformPrior(lo, hi, discrete=True) likewise. The measurement grid no longer depends on the hypothesis grid. Tests: narrow truncated = untruncated Gaussian; very wide truncated = uniform in f_alpha space (= UniformPrior for the linear space). Discrete vs continuous truncation differ by <= .002 in any option probability at the fitted group parameters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A censored trial's likelihood is the summed option probability at and beyond the final position (cumsum + one-hot gather), via pm.CustomDist with an elementwise logp, so pointwise log-likelihoods / LOO still work; posterior- predictive draws are the intended reports. Without a censor column the model is unchanged (Categorical). Tests: censor = 0 reproduces the Categorical logp and gradient exactly; a censored trial equals the tail sum of its option probabilities; MAP with censoring recovers nu from simulated reports cut short on a third of trials, ignoring the censoring does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…draws Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tor noise; grid-accuracy test Checked at fitted parameters against M = 4000 over a 3.5x wider range: with motor noise 200 points give |dP| <= 5e-5 (total log-lik change <= .006 per participant); the no-motor inversion of n_hat(m) needed 600 (|dP| 6.9e-3 -> 5.6e-4, log-lik .50 -> .08). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…chosen parameters
x[s, c] = x_s + (1/2 - c)(delta + delta_s) on the untransformed scale, group
delta ({p}_cond_mu, level 0 minus level 1) and non-centred participant
deviations; the option table is computed per (participant, condition).
Test: builds, finite gradient, zero offsets reproduce the plain likelihood.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…~ N(f(n) + beta nu_f z, nu_f^2)) and noise_modulator (nu_t = nu exp(gamma u), the observer decodes with its trial noise) Covariates are binned within participant into equally filled quantile bins (bin means); the option table is computed per (participant, u bin) x (n, z bin). Tests: zero effects reproduce the plain likelihood exactly; 7 bins vs per-trial evaluation differ by .002 nats per trial at beta = .4, gamma = .3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dependent of alpha Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n) + w f(n_u) (uncued magnitude leaks into encoding; observer decodes as if from n); per unique (n, n_u) pair Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mu) per trial (parameter prior_leak_k), observer decodes with that prior; table per (participant, n_u); combines with leak Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(n_u - n_hat), w = pull_k (n_hat/15)^(1 - alpha), per (participant, n_u) rows; needs motor noise) and swap=<column> (mixture with the exchanged-roles option probabilities, logit p = swap_a + swap_b (n - 15)/10; lapses outside); both reduce exactly to the plain model Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'beta_pooled' -- one rate for all subjects, for datasets with lapses ~ 0 where the hierarchical Beta concentration is unidentified (centred funnel, NUTS saturates the tree depth); likelihood identical to the hierarchical model at equal rates Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and the pooled lapse reduce exactly to the plain model; swap probability 1 = exchanged roles Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… x 80 grid, 250 trials, 2 x 50 draws (~1.5 min locally; ~1 h on CI before, same recovery r > .95) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new observer model for magnitude estimation (a slider / integer response
scale),
bauer.models.EstimationTaskModel, developed for the retinonumeralpaper (two simultaneous numerosities, one cued for report). No changes to
existing models; the only change to shared code is a new
beta_pooledtransform in
bauer.core.build_hierarchical_nodes.Added
bauer.models.EstimationTaskModel: hierarchical Bayesian observer formagnitude estimation on a bounded, discrete (integer) response scale, built
from a few components:
PowerSpace(alpha)(Box-Cox;alpha=None= free,hierarchical), with
LogSpace()(Weber) andLinearSpace()(constantnoise) as fixed ends; efficient coding for a power-law prior is the same
family (documented);
UniformPrior(lo, hi)(e.g. the task range) orGaussianPrior()(Gaussian in the encoding space; log-normal for log space);
uniform lapse (default on); optional Gaussian motor noise;
(
covariates={'nu': column}).Closed-form likelihood for log space + log-normal prior, otherwise an exact
grid path (n_hat(m) inverted at the response-option edges). Observed
pm.Categoricallikelihood: LOO and posterior-predictive draws come fromPyMC directly.
simulate,predict,posterior_predictive,parameter_recovery.tests/test_estimation_task.py: every component combination builds withfinite gradients, closed form = grid, alpha -> 0 = log, uniform-prior
compression, flat s.d. for linear + Gaussian, MAP and hierarchical NUTS
recovery (incl. free alpha), covariates.
EstimationTaskModelextensions:TruncatedGaussianPrior(lo, hi, discrete=True, space='internal'|'n')(prior restricted to the known task bounds;
space='n'= Gaussian initems, independent of alpha) and a discrete
UniformPrior;censorcolumn, -1 / 0 / +1, e.g.time-outs at the slider ends);
condition=<column>, condition_parameters=(...): two-level conditionoffsets (e.g. cued side) on chosen parameters;
measurement_shift(shifts the measurementmean) and
noise_modulator(scales the encoding noise per trial; theobserver decodes with its trial noise);
n_u, a column):leak(measurement centred on (1 - w) f(n) + w f(n_u)),prior_leak(prior centre shifted towards n_u),
response_pull(report centre pulledtowards n_u, weight growing with the encoding noise) and
swap(occasionally reporting the other magnitude, rate may depend on n).
Each reduces exactly to the plain model when its parameter is 0;
lapse='pooled': one lapse rate shared by all subjects (newbeta_pooledtransform). Use it when lapses are near zero: thehierarchical Beta concentration is then unidentified and NUTS funnels
(in one dataset 26 min -> >24 h with raised
target_accept; pooled:21-45 min, 0 divergences, identical other parameters);
gathered per trial; 600-point measurement grid by default without
motor noise.
tests/test_estimation_task.pycovers the extensions (each reduces to theplain model, swap probability 1 = exchanged roles, pooled lapse = the
hierarchical model at equal rates).
🤖 Generated with Claude Code