Monte Carlo methods. Simulation, estimation, data assimilation, and optimal control for time-discrete and time-continuous Markov chains