Completed as a final project for Carnegie Mellon University's 36650 Graduate Statistical Computing course
See project description below:
Let
We assume that we can decrypt our text using a substitution decryption d which maps a given character
to another character bijectively. Then,
We assign each decryption
Large
The Markov chain we construct will sample the space of decryptions
-
Choose an initial decryption key d (e.g., the identity mapping).
-
Repeat the following steps for many iterations (e.g., 10 000):
-
Given the current decryption d, randomly sample a candidate decryption from a pre-specified proposal distribution q(d′|d).
-
Sample an independent Uniform(0, 1) random variable U.
-
If U <
$\frac{\pi(d')}{\pi(d)} = (\frac{L(d)}{\sum_{d'}L(d′)})^p$ , move to decryption d′, else remain in decryption d.
As we let the algorithm run, we store the decryption key with the largest value of L. This will produce our best-fitting decryption.