TITLE: What is a Markov Chain?
QUESTION [28 upvotes]: What is an intuitive explanation of Markov chains, and how they work? Please provide at least one practical example.

REPLY [3 votes]: I had a programming project in college where we generated large amounts of psuedo-English text using Markov chains. The assignment is here, although I don't know if that link will be good forever. From that page:

For example, suppose that [our Markov chains are of length] 2 and the sample file
  contains
I like the big blue dog better than the big elephant with the big blue hat on his tusk. 

Here is how the first three words
  might be chosen:

A two-word sequence is chosen at random to become the initial prefix.
  Let's suppose that "the big" is
  chosen.
The first word must be chosen based on the probability that it
  follows the prefix (currently "the
  big") in the source. The source
  contains three occurrences of "the
  big". Two times it is followed by
  "blue", and once it is followed by
  "elephant". Thus, the next word must
  be chosen so that there is a 2/3
  chance that "blue" will be chosen, and
  a 1/3 chance that "elephant" will be
  chosen. Let's suppose that we choose
  "blue" this time.
The next word must be chosen based on the probability that it
  follows the prefix (currently "big
  blue") in the source. The source
  contains two occurrences of "big
  blue". Once it is followed by "dog",
  and the other time it is followed by
  "hat". Thus, the next word must be
  chosen so that there is a 50-50
  probability of choosing "dog" vs.
  "hat". Let's suppose that we choose
  "hat" this time.
The next word must be chosen based on the probability that it
  follows the prefix (currently "blue
  hat") in the source. The source
  contains only one occurrence of "blue
  hat", and it is followed by "on".
  Thus, the next word must be "on" (100%
  probability).
Thus, the first three words in the output text would be "blue hat
  on".


You keep going like that, generating text that is completely nonsensical, but ends up having sort of the same "tone" as the original text. For example, if your sample file is the complete text of Alice In Wonderland (one of the texts we tried it on) then your nonsense comes out kind of whimsical and Carrollian (if that's a word). If your sample file is The Telltale Heart, you get somewhat dark, morbid nonsense.
Anyway, while not a rigorous, formal, definition, I hope this helps give you a sense of what a Markov chain is.