Living systems often attempt to calculate and predict the future state of the environment. Given the stochastic nature of many biological systems how is that possible? I will show that even a system as complicated as the immune system has reproducible outcomes. Yet predicting the future state of a complex environment requires weighing the trust in new observations against prior experiences. In this light, I will present a view of the adaptive immune system as a dynamic Bayesian machinery that updates its memory repertoire by balancing evidence from new pathogen encounters against past experience of infection to predict and prepare for future threats.