Lecture 12, Addendum 1: Markov chains in MATLAB.

In this MATLAB session we learn how to define a discrete probability distribution on the basis of the uniform distribution of the random number generator of MATLAB. Discrete distributions will turn out to be extremely useful as, on the one hand, continuous distributions can always be approached by discrete distributions, and on the other hand discrete-state Markov chains defined on discrete probability distributions are good models of infinite-state Markov processes. As a first step we realize that any distribution can be described with a combination of uniform-distribution random numbers and disjoint intervals of the range of the random numbers we are generating. For instance, if we are thinking in terms of a two-state stochastic variable with values 1 and 2, and 1 is supposed to occur with the probability of 0.7 and 2 with, of course, 0.3, then we create two intervals for the random number: one is [0; 0.7] and the other is (0.7; 1]. Then we generate a string of random numbers, and if it falls into the first interval, [0; 0.7], our stochastic variable takes the value of 1; if, on the other hand, it falls into the second interval, (0.7; 1], it takes the value of 2. As a result, we have a string of random numbers taking the values of 1 and 2 with the probabilities of 0.7 and 0.3, respectively, and the string can be of any length, of course.

Published by Peter Galbács

Researcher and an ethusiastic defender of the theory and methodology of mainstream economics. Author, 'The Theory of New Classical Macroeconomics' (Springer, 2015).

Leave a comment