  Animal learning has interested ecologists and psychologists for over a
century. Mathematical models that explain how animals store and recall
information have gained attention recently. Central to this work is statistical
decision theory (SDT), which relates information uptake in animals to Bayesian
inference. SDT effectively explains many learning tasks in animals, but
extending this theory to predict how animals will learn in changing
environments still poses a challenge for ecologists. We addressed this
shortcoming with a novel implementation of Bayesian Markov Chain Monte Carlo
(MCMC) sampling to simulate how animals sample environmental information and
learn as a result. We applied our framework to an individual-based model
simulating complex foraging tasks encountered by wild animals. Simulated
``animals" learned behavioral strategies that optimized foraging returns simply
by following the principles of an MCMC sampler. In these simulations,
behavioral plasticity was most conducive to efficient foraging in unpredictable
and uncertain environments. Our model suggests that animals prioritize highly
concentrated resources even when these resources are less available overall, in
line with existing knowledge on optimal foraging and ideal free distribution
theory. Our innovative computational modelling framework can be applied more
widely to simulate the learning of many other tasks in animals and humans.
