Thursday, October 15, 2026
Science
No Result
View All Result
  • Login
  • HOME
  • SCIENCE NEWS
  • CONTACT US
  • HOME
  • SCIENCE NEWS
  • CONTACT US
No Result
View All Result
Scienmag
No Result
View All Result
Home Science News Psychology & Psychiatry

New R Package Brings the Sampling Algorithms Behind Human Thinking to Every Lab

October 15, 2026
in Psychology & Psychiatry
Glenn Wilkins
By Glenn Wilkins Scienmag Editorial Profile - Clinical Psychology
Reading Time: 5 mins read
0
New R Package Brings the Sampling Algorithms Behind Human Thinking to Every Lab

New R Package Brings the Sampling Algorithms Behind Human Thinking to Every Lab

65
SHARES
587
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Why do people make systematic mistakes when judging probabilities? Why do repeated estimates of the same quantity drift in strange, long-range patterns? Why are we overconfident, and why does a choice we just made bias the very next number we produce? A growing body of research argues that all of these quirks share a single root cause: the human mind does not compute exact answers, but instead draws samples from internal probability distributions. Now, a team at the University of Warwick has released a software package designed to make that idea testable by anyone who can run R.

The package, called samplr, was introduced by Lucas Castillo, Yun-Xiao Li, and Adam N. Sanborn in the journal Behavior Research Methods. It bundles together a family of Markov chain Monte Carlo algorithms, including Metropolis–Hastings and Hamiltonian Monte Carlo, alongside cognitive models built on top of them, such as the Bayesian sampler and the autocorrelated Bayesian sampler. The core routines are written in C++ for speed, running up to four times faster than equivalent MATLAB code and far faster than base R. Diagnostic functions for analyzing autocorrelation and power spectral density round out the toolkit. The authors hope it will do for sampling-based models of cognition what packages for drift diffusion models did for sequential sampling: turn a technically demanding modeling approach into something ordinary labs can adopt.

The intellectual backdrop is a decades-long convergence between statistics and psychology. Statisticians use sampling algorithms for a practical reason: approximating complex probability distributions that cannot be computed exactly. Calculating a posterior distribution requires dividing by a normalizing constant, the sum of prior-times-likelihood across every possible event, which quickly becomes intractable. Markov chain Monte Carlo sidesteps this by requiring only ratios of probabilities, in which the constants cancel out. The price is autocorrelation: successive samples are dependent, and results depend on the starting point. Strikingly, those same dependencies appear in human behavior, in repeated judgments and in the anchoring effect, which is precisely why psychologists began proposing that the brain itself might run something like MCMC.

The package demonstrates its power on classic findings. Consider probability judgments, where people famously commit the conjunction fallacy, rating the probability of event A as smaller than that of A and B together, and violate binary complementarity, with estimates of A and not A summing to more than one. Two leading models, probability theory plus noise and the Bayesian sampler, make identical predictions for the mean of people’s judgments but differ in how judgment variance relates to the mean. In the Bayesian sampler, fewer samples pull the endpoints of the mean-variance curve toward the center, while in probability theory plus noise the endpoints stay fixed. samplr provides functions to compute the diagnostic Z identities and to simulate the Bayesian sampler directly, letting researchers distinguish the two accounts with their own data.

Another striking phenomenon is 1/f noise in cognition. In the 1990s, researchers found that when people repeatedly reproduce a duration, their errors are not independent but show long-range autocorrelations, with a power spectral exponent between white noise and Brownian noise. Within a sampling framework, these repeated estimates can be seen as raw samples drawn without aggregation into a decision. Work by the Warwick group compared Metropolis–Hastings, Metropolis-coupled MCMC, and Hamiltonian Monte Carlo and found that the multiple-chain algorithm best reproduced the long-range structure of human estimates. samplr implements all of these algorithms, so users can generate sample sequences and run the same spectral analyses on them.

Random generation offers a third case study. Asked to produce random heights as if drawing from a bag, people deviate systematically: distances between consecutive items are too small, and repetitions almost never occur. In recent experiments, participants generated random heights under Gaussian and Uniform conditions, and six sampling algorithms were pitted against the data. The winner was MCREC, an algorithm combining the gradient-based proposals of Hamiltonian Monte Carlo with the multiple chains of Metropolis-coupled MCMC and a sense of momentum that adds autocorrelation to the direction of proposals. All six algorithms are available in samplr through functions beginning with sampler_, and they can target mixtures or fully custom distributions.

The package is not limited to the authors’ own work. The article walks through a case study from research on learning across the lifespan, in which participants placed a bucket to catch bags dropped by a helicopter hidden in clouds, never knowing whether an odd drop reflected ordinary fluctuation or a genuine change in the helicopter’s position. A model from that study explained perseveration and anchoring biases by assuming people draw posterior samples with Metropolis–Hastings in resource-limited chunks, stopping early when the samples do not change the current belief. The authors show that samplr’s sampler_mh function could implement the same model, and on their machine it ran 31 times faster than the original code, illustrating how a shared, optimized code base can accelerate modeling across research groups.

Perhaps the most ambitious component is the autocorrelated Bayesian sampler, or ABS, which uses a single sampling process to explain probability judgments, point estimates, confidence intervals, choices, confidence judgments, and response times. For two-alternative choices, sampling continues until the accumulated difference in evidence between options crosses a threshold; raising the threshold yields the classic speed-accuracy trade-off, with slower but more accurate responses. The same framework predicts over-precise confidence intervals, because limited samples underrepresent distributional tails, and the resolution of confidence, because errors tend to arise when evidence stays balanced for a long time, inflating the sample count and lowering confidence. It even explains how choices bias later estimates: when the chosen value sits near the stimulus distribution, estimates are pushed away from it, the repulsion effect, while a distant value pulls estimates toward it, the anchoring effect. Both emerge from the same autocorrelated chain starting at the choice value.

Qualitative matches are only the beginning, and samplr also supports quantitative model comparison through likelihood-free inference. Because these models have no tractable likelihood function, the package leans on approximate Bayesian computation: simulate data from candidate models, compress each dataset into summary statistics, and keep only simulations close enough to the observed data. In the random generation example, rejection ABC with 10,000 simulations per model gave overwhelming support to MCREC, with a Bayes factor above 400 over the next best model. A more sophisticated variant using random forests, implemented in the external abcrf package, weighs summary statistics by their predictive value and needs fewer simulations; it pushed the Bayes factor above a thousand. The authors stress the accompanying Bayesian workflow: checking that priors produce sensible data and that the procedure can recover known models before trusting its verdicts.

The broader promise is unification. Sampling algorithms have already been applied to phenomena from low-level perception to causal reasoning, and they are not confined to simple representations; text descriptions could be mapped into semantic vector spaces and sampled using probabilities from a neural network. If a single sampling process, as ABS proposes, can quantitatively account for judgments, choices, response times, and confidence across tasks, psychologists will gain far more insight than separate models for separate response modes ever could. samplr is free, open-source software available on CRAN, with datasets from the group’s experiments in a companion package, and the authors are actively inviting feature requests and contributions from the community.

Subject of Research: An R software package implementing statistical sampling algorithms and sampling-based cognitive models of human judgment and decision-making

Article Title: The samplr package: A tool for modeling human cognition with sampling algorithms

Article References: The samplr package: A tool for modeling human cognition with sampling algorithms. (n.d.). https://doi.org/10.3758/s13428-026-03188-6

Image Credits: AI Generated

DOI: 10.3758/s13428-026-03188-6

Keywords: samplr, sampling algorithms, Markov chain Monte Carlo, Bayesian sampler, cognitive modeling, probability judgments, autocorrelation, anchoring effect, confidence intervals, approximate Bayesian computation, R package, Behavior Research Methods

Cite Scienmag News

Glenn Wilkins. (October 15, 2026). New R Package Brings the Sampling Algorithms Behind Human Thinking to Every Lab. Scienmag. https://scienmag.com/new-r-package-brings-the-sampling-algorithms-behind-human-thinking-to-every-lab/

Glenn Wilkins. "New R Package Brings the Sampling Algorithms Behind Human Thinking to Every Lab." Scienmag, 15 October 2026, https://scienmag.com/new-r-package-brings-the-sampling-algorithms-behind-human-thinking-to-every-lab/. Accessed 15 October 2026.

Glenn Wilkins. "New R Package Brings the Sampling Algorithms Behind Human Thinking to Every Lab." Scienmag. October 15, 2026. https://scienmag.com/new-r-package-brings-the-sampling-algorithms-behind-human-thinking-to-every-lab/

Tags: anchoring effectapproximate Bayesian computationautocorrelated Bayesian samplerautocorrelationBayesian modeling in psychologyBayesian samplerBehavior Research MethodsCognitive modelingcomputational models of overconfidenceconfidence intervalsdiagnostics for autocorrelation in samplingfast R tools for Bayesian cognitive modelsHamiltonian Monte Carlo for psychology researchhuman decision-making sampling algorithmsMarkov chain Monte CarloMarkov chain Monte Carlo methods for cognitive scienceprobability estimation drift analysisprobability judgment biasesprobability judgmentsR packageR package for cognitive sampling modelssampling algorithmssampling-based explanations of human biasessamplr
Share26Tweet16
Previous Post

New TRAILS framework tracks wildfire smoke layer by layer across the sky

Next Post

Ghost Crabs Reveal Hidden Seasonal Pitfalls in Beach Health Monitoring

Related Posts

Mapping the Mental Web: How Anxiety, Depression, and Resilience Interlock in Bangladeshi Students
Psychology & Psychiatry

Mapping the Mental Web: How Anxiety, Depression, and Resilience Interlock in Bangladeshi Students

October 15, 2026
New Scales Capture the Climate Fears Unique to Parents
Psychology & Psychiatry

New Scales Capture the Climate Fears Unique to Parents

October 15, 2026
Thyroid Hormones, Lead and Iron Linked to Brain Microstructure in Anxious Children with Autism
Psychology & Psychiatry

Thyroid Hormones, Lead and Iron Linked to Brain Microstructure in Anxious Children with Autism

October 15, 2026
Inside the Impulsive Moment: What Poisoning Survivors Reveal About Suicide Risk
Psychology & Psychiatry

Inside the Impulsive Moment: What Poisoning Survivors Reveal About Suicide Risk

October 15, 2026
A Quick Zoom Call at Recruitment Keeps Study Participants Engaged to the End
Psychology & Psychiatry

A Quick Zoom Call at Recruitment Keeps Study Participants Engaged to the End

October 15, 2026
Mindfulness Practitioners Show Sharper Working Memory Backed by Prefrontal Gamma Rhythms
Psychology & Psychiatry

Mindfulness Practitioners Show Sharper Working Memory Backed by Prefrontal Gamma Rhythms

October 15, 2026
Next Post
Ghost Crabs Reveal Hidden Seasonal Pitfalls in Beach Health Monitoring

Ghost Crabs Reveal Hidden Seasonal Pitfalls in Beach Health Monitoring

  • Mothers who receive childcare support from maternal grandparents show more optimized

    Mothers who receive childcare support from maternal grandparents show more parental warmth, finds NTU Singapore study

    27656 shares
    Share 11059 Tweet 6912
  • University of Seville Breaks 120-Year-Old Mystery, Revises a Key Einstein Concept

    1061 shares
    Share 424 Tweet 265
  • Bee body mass, pathogens and local climate influence heat tolerance

    682 shares
    Share 273 Tweet 171
  • Researchers record first-ever images and data of a shark experiencing a boat strike

    546 shares
    Share 218 Tweet 137
  • Groundbreaking Clinical Trial Reveals Lubiprostone Enhances Kidney Function

    531 shares
    Share 212 Tweet 133
Science

Embark on a thrilling journey of discovery with Scienmag.com—your ultimate source for cutting-edge breakthroughs. Immerse yourself in a world where curiosity knows no limits and tomorrow’s possibilities become today’s reality!

RECENT NEWS

  • Mediterranean Diet Linked to Healthier Teeth and Gums in Children, Study Finds
  • Ghost Crabs Reveal Hidden Seasonal Pitfalls in Beach Health Monitoring
  • New R Package Brings the Sampling Algorithms Behind Human Thinking to Every Lab
  • New TRAILS framework tracks wildfire smoke layer by layer across the sky

Categories

  • Agriculture
  • Anthropology
  • Archaeology
  • Athmospheric
  • Biology
  • Biotechnology
  • Blog
  • Bussines
  • Cancer
  • Chemistry
  • Climate
  • Earth Science
  • Editorial Policy
  • Marine
  • Mathematics
  • Medicine
  • Pediatry
  • Policy
  • Psychology & Psychiatry
  • Science Education
  • Science News
  • Social Science
  • Space
  • Technology and Engineering

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 5,150 other subscribers

© 2025 Scienmag - Science Magazine

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • HOME
  • SCIENCE NEWS
  • CONTACT US

© 2025 Scienmag - Science Magazine

Discover more from Science

Subscribe now to keep reading and get access to the full archive.

Continue reading