||To understand how the brain produces cognitive behavior, modern neuroscience relies on carefully designed experiments where animals are trained to perform various tasks. Powered with recent developments in experimental techniques, these experiments produce extremely rich data that record both the behavior and the neural activity of the animal during these tasks. In this talk, I will share works in which I use statistical approaches to make sense of these data and to generate neuroscientific insights. In the first part, I will present a Bayesian method for extracting the dynamics of animal behavior during learning, and how the method can be used to facilitate training or to understand the learning rules. In the second part, I will discuss an ongoing work on the inference of neural dynamics from a simultaneously recorded neural population in the presence of external stimuli.