Several complex problems arising from biology and computer science (e.g., sequence alignment, gene finding, inference for population sequence data) can not be solved at the same time efficiently and optimally by using deterministic methods. In such cases, stochastic methods are used to advantage. Building on the foundations of probability theory and statistics, this course lays the basis for stochastic computing (i.e., representation of distributions in the computer, computations with small probabilities, efficient generation of random numbers with given distribution, test of the quality of random number generators). As an important tool, the Markov chain Monte Carlo (MCMC) methods are presented via examples (Metropolis-Hastings, Gibbs sampling). Importance sampling methods and simulation of rare events are as well presented.