We obtain the coded message:
code = 'mprboydewyemo egfywhoptl gyed egybuyld yoel wyptgpxel gyrfyx tloemyretzyhbmpxp wyetyexx m oelpbtyldelydewyreuum gy xbtbkpwlwyetgyloeg owyldelyjpg tptqyqehydewyemeok gyldbw yjdbyjelxdyplyewyeywpqtemybuywlo wwyptyld yuptetxpemywfwl kybld owydes yhptt gyplybtyeyw op wybuyl xdtpxemyuexlbowywnxdyewyopwptqywdboll okyg rlywem wyrfyld ynwyqbs otk tlyetgyt jyxbohboel ylevyhbmpxp wybld oykeoz lwyldelyxetyr ylehh gyuboygbmmeowyptxmngptqyldobnqdyld ywjehwykeoz lyetgympinpgplfympt wykeptlept gyrfyqmbremyx tloemyretzwyeo tlyf lywdbjptqyeyrpqygbmmeoywin c '
print(code)
mprboydewyemo egfywhoptl gyed egybuyld yoel wyptgpxel gyrfyx tloemyretzyhbmpxp wyetyexx m oelpbtyldelydewyreuum gy xbtbkpwlwyetgyloeg owyldelyjpg tptqyqehydewyemeok gyldbw yjdbyjelxdyplyewyeywpqtemybuywlo wwyptyld yuptetxpemywfwl kybld owydes yhptt gyplybtyeyw op wybuyl xdtpxemyuexlbowywnxdyewyopwptqywdboll okyg rlywem wyrfyld ynwyqbs otk tlyetgyt jyxbohboel ylevyhbmpxp wybld oykeoz lwyldelyxetyr ylehh gyuboygbmmeowyptxmngptqyldobnqdyld ywjehwykeoz lyetgympinpgplfympt wykeptlept gyrfyqmbremyx tloemyretzwyeo tlyf lywdbjptqyeyrpqygbmmeoywin c
Goal: Decode this message.
** Assumption: ** Simple cipher which replaces each letter with some other letter. The possible letters are a-z and space.
We will use Python dictionaries to represent coders and decoders. There are several other possible data structures one could use.
Python dictionaries are key / value pairs.
d = {'key1':'value1','key2':'value2'}
print(d)
{'key1': 'value1', 'key2': 'value2'}
d['key1']
'value1'
import string
import numpy as np
from numpy import random
We obtain all of the ascii lowercase letters plus the ' ' symbol
letters = list(string.ascii_lowercase)
letters = letters + [' ']
print(letters)
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ']
letters_mix = letters.copy()
random.shuffle(letters_mix)
print(letters_mix)
['z', 'r', 'u', 'h', 'k', 'd', 'w', 'e', 'x', 'c', 'a', 's', 'o', 'v', 'f', 'm', 'i', 'b', 'j', 'q', ' ', 't', 'p', 'y', 'l', 'g', 'n']
cipher = dict(list(zip(letters,letters_mix)))
print(cipher['a']) ## a becomes
print(cipher['b']) ## b becomes
z r
sample = "the yellow cat chased the brown dog"
sample_coded = "".join(list(map(lambda x: cipher[x], sample)))
print(sample_coded)
print(sample)
qeknlkssfpnuzqnuezjkhnqeknrbfpvnhfw the yellow cat chased the brown dog
If we know the cipher, we can trivially invert it by reversing the role of keys and values in the dictionary.
decipher = dict(list(zip(letters_mix,letters)))
"".join(list(map(lambda x: decipher[x], sample_coded)))
'the yellow cat chased the brown dog'
Our goal is to find the deciper for the original code and use it to reconstruct the original message.
We download 'War and Peace' and count the number of times we see $\gamma\beta$ where $\gamma$ and $\beta$ are any characters a-z and ' '. This requires a bit of data cleaning.
## download all of "War and Peace"
from urllib import request
data = request.urlopen("http://www.gutenberg.org/files/2600/2600-0.txt")
raw = data.read().decode('utf8')
raw[:5000]
'\ufeff\r\nThe Project Gutenberg EBook of War and Peace, by Leo Tolstoy\r\n\r\nThis eBook is for the use of anyone anywhere at no cost and with almost\r\nno restrictions whatsoever. You may copy it, give it away or re-use\r\nit under the terms of the Project Gutenberg License included with this\r\neBook or online at www.gutenberg.org\r\n\r\n\r\nTitle: War and Peace\r\n\r\nAuthor: Leo Tolstoy\r\n\r\nTranslators: Louise and Aylmer Maude\r\n\r\nPosting Date: January 10, 2009 [EBook #2600]\r\n\r\nLast Updated: December 17, 2016\r\n\r\nLanguage: English\r\n\r\nCharacter set encoding: UTF-8\r\n\r\n*** START OF THIS PROJECT GUTENBERG EBOOK WAR AND PEACE ***\r\n\r\n\r\n\r\n\r\nAn Anonymous Volunteer, and David Widger\r\n\r\n\r\n\r\n\r\n\r\n\r\nWAR AND PEACE\r\n\r\n\r\nBy Leo Tolstoy/Tolstoi\r\n\r\n\r\n\r\n\r\n\r\n CONTENTS\r\n\r\n\r\n BOOK ONE: 1805\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n CHAPTER XX\r\n\r\n CHAPTER XXI\r\n\r\n CHAPTER XXII\r\n\r\n CHAPTER XXIII\r\n\r\n CHAPTER XXIV\r\n\r\n CHAPTER XXV\r\n\r\n CHAPTER XXVI\r\n\r\n CHAPTER XXVII\r\n\r\n CHAPTER XXVIII\r\n\r\n\r\n BOOK TWO: 1805\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n CHAPTER XX\r\n\r\n CHAPTER XXI\r\n\r\n\r\n BOOK THREE: 1805\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n\r\n BOOK FOUR: 1806\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n\r\n BOOK FIVE: 1806 - 07\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n CHAPTER XX\r\n\r\n CHAPTER XXI\r\n\r\n CHAPTER XXII\r\n\r\n\r\n BOOK SIX: 1808 - 10\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n CHAPTER XX\r\n\r\n CHAPTER XXI\r\n\r\n CHAPTER XXII\r\n\r\n CHAPTER XXIII\r\n\r\n CHAPTER XXIV\r\n\r\n CHAPTER XXV\r\n\r\n CHAPTER XXVI\r\n\r\n\r\n BOOK SEVEN: 1810 - 11\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n\r\n BOOK EIGHT: 1811 - 12\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n CHAPTER XX\r\n\r\n CHAPTER XXI\r\n\r\n CHAPTER XXII\r\n\r\n\r\n BOOK NINE: 1812\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n CHAPTER XX\r\n\r\n CHAPTER XXI\r\n\r\n CHAPTER XXII\r\n\r\n CHAPTER XXIII\r\n\r\n\r\n BOOK TEN: 1812\r\n\r\n CHAPTER I\r\n\r\n CHAPTER II\r\n\r\n CHAPTER III\r\n\r\n CHAPTER IV\r\n\r\n CHAPTER V\r\n\r\n CHAPTER VI\r\n\r\n CHAPTER VII\r\n\r\n CHAPTER VIII\r\n\r\n CHAPTER IX\r\n\r\n CHAPTER X\r\n\r\n CHAPTER XI\r\n\r\n CHAPTER XII\r\n\r\n CHAPTER XIII\r\n\r\n CHAPTER XIV\r\n\r\n CHAPTER XV\r\n\r\n CHAPTER XVI\r\n\r\n CHAPTER XVII\r\n\r\n CHAPTER XVIII\r\n\r\n CHAPTER XIX\r\n\r\n CHAPTER XX\r\n\r\n CHAPTER XXI\r\n\r\n CHAPTER XXII\r\n\r\n CHAPTER XXIII\r\n\r\n '
raw[10000:10500]
' seated himself on the sofa.\r\n\r\n“First of all, dear friend, tell me how you are. Set your friend’s\r\nmind at rest,” said he without altering his tone, beneath the\r\npoliteness and affected sympathy of which indifference and even irony\r\ncould be discerned.\r\n\r\n“Can one be well while suffering morally? Can one be calm in times\r\nlike these if one has any feeling?” said Anna Pávlovna. “You are\r\nstaying the whole evening, I hope?”\r\n\r\n“And the fete at the English ambassador’s? Today is Wednesday. I\r\nmust'
raw = raw.lower() ## make all lower case
raw = raw.replace("\r","")
raw = raw.replace("\n"," ") ## replace carriage return with space
cleaned = "".join(list(filter(lambda x: x in letters, raw))) ## remove all non letters
cleaned[:1000]
' the project gutenberg ebook of war and peace by leo tolstoy this ebook is for the use of anyone anywhere at no cost and with almost no restrictions whatsoever you may copy it give it away or reuse it under the terms of the project gutenberg license included with this ebook or online at wwwgutenbergorg title war and peace author leo tolstoy translators louise and aylmer maude posting date january ebook last updated december language english character set encoding utf start of this project gutenberg ebook war and peace an anonymous volunteer and david widger war and peace by leo tolstoytolstoi contents book one chapter i chapter ii chapter iii chapter iv chapter v chapter vi chapter vii chapter viii chapter ix chapter x chapter xi chapter xii chapter xiii chapter xiv chapter xv chapter xvi chapter xvii chapter xviii chapter xix chapter xx '
cleaned[10000:11000]
'we are ready to burn ours prince vasli always spoke languidly like an actor repeating a stale part anna pvlovna schrer on the contrary despite her forty years overflowed with animation and impulsiveness to be an enthusiast had become her social vocation and sometimes even when she did not feel like it she became enthusiastic in order not to disappoint the expectations of those who knew her the subdued smile which though it did not suit her faded features always played round her lips expressed as in a spoiled child a continual consciousness of her charming defect which she neither wished nor could nor considered it necessary to correct in the midst of a conversation on political matters anna pvlovna burst out oh dont speak to me of austria perhaps i dont understand things but austria never has wished and does not wish for war she is betraying us russia alone must save europe our gracious sovereign recognizes his high vocation and will be true to it that is the one thing i have faith '
Split cleaned
into character pairs, there are len(cleaned) -1
of these.
n = len(cleaned)
fromix = list(range(0,n-1))
toix = list(range(2,n+1))
fromtoix = list(zip(fromix,toix))
fromtoix[:10]
[(0, 2), (1, 3), (2, 4), (3, 5), (4, 6), (5, 7), (6, 8), (7, 9), (8, 10), (9, 11)]
cleaned[fromtoix[0][0]:fromtoix[0][1]]
' t'
pairs = list(map(lambda x: cleaned[x[0]:x[1]], fromtoix))
pairs
[' t', 'th', 'he', 'e ', ' p', 'pr', 'ro', 'oj', 'je', 'ec', 'ct', 't ', ' g', 'gu', 'ut', 'te', 'en', 'nb', 'be', 'er', 'rg', 'g ', ' e', 'eb', 'bo', 'oo', 'ok', 'k ', ' o', 'of', 'f ', ' w', 'wa', 'ar', 'r ', ' a', 'an', 'nd', 'd ', ' p', 'pe', 'ea', 'ac', 'ce', 'e ', ' b', 'by', 'y ', ' l', 'le', 'eo', 'o ', ' t', 'to', 'ol', 'ls', 'st', 'to', 'oy', 'y ', ' ', ' t', 'th', 'hi', 'is', 's ', ' e', 'eb', 'bo', 'oo', 'ok', 'k ', ' i', 'is', 's ', ' f', 'fo', 'or', 'r ', ' t', 'th', 'he', 'e ', ' u', 'us', 'se', 'e ', ' o', 'of', 'f ', ' a', 'an', 'ny', 'yo', 'on', 'ne', 'e ', ' a', 'an', 'ny', 'yw', 'wh', 'he', 'er', 're', 'e ', ' a', 'at', 't ', ' n', 'no', 'o ', ' c', 'co', 'os', 'st', 't ', ' a', 'an', 'nd', 'd ', ' w', 'wi', 'it', 'th', 'h ', ' a', 'al', 'lm', 'mo', 'os', 'st', 't ', ' n', 'no', 'o ', ' r', 're', 'es', 'st', 'tr', 'ri', 'ic', 'ct', 'ti', 'io', 'on', 'ns', 's ', ' w', 'wh', 'ha', 'at', 'ts', 'so', 'oe', 'ev', 've', 'er', 'r ', ' y', 'yo', 'ou', 'u ', ' m', 'ma', 'ay', 'y ', ' c', 'co', 'op', 'py', 'y ', ' i', 'it', 't ', ' g', 'gi', 'iv', 've', 'e ', ' i', 'it', 't ', ' a', 'aw', 'wa', 'ay', 'y ', ' o', 'or', 'r ', ' r', 're', 'eu', 'us', 'se', 'e ', ' i', 'it', 't ', ' u', 'un', 'nd', 'de', 'er', 'r ', ' t', 'th', 'he', 'e ', ' t', 'te', 'er', 'rm', 'ms', 's ', ' o', 'of', 'f ', ' t', 'th', 'he', 'e ', ' p', 'pr', 'ro', 'oj', 'je', 'ec', 'ct', 't ', ' g', 'gu', 'ut', 'te', 'en', 'nb', 'be', 'er', 'rg', 'g ', ' l', 'li', 'ic', 'ce', 'en', 'ns', 'se', 'e ', ' i', 'in', 'nc', 'cl', 'lu', 'ud', 'de', 'ed', 'd ', ' w', 'wi', 'it', 'th', 'h ', ' t', 'th', 'hi', 'is', 's ', ' e', 'eb', 'bo', 'oo', 'ok', 'k ', ' o', 'or', 'r ', ' o', 'on', 'nl', 'li', 'in', 'ne', 'e ', ' a', 'at', 't ', ' w', 'ww', 'ww', 'wg', 'gu', 'ut', 'te', 'en', 'nb', 'be', 'er', 'rg', 'go', 'or', 'rg', 'g ', ' ', ' ', ' t', 'ti', 'it', 'tl', 'le', 'e ', ' w', 'wa', 'ar', 'r ', ' a', 'an', 'nd', 'd ', ' p', 'pe', 'ea', 'ac', 'ce', 'e ', ' ', ' a', 'au', 'ut', 'th', 'ho', 'or', 'r ', ' l', 'le', 'eo', 'o ', ' t', 'to', 'ol', 'ls', 'st', 'to', 'oy', 'y ', ' ', ' t', 'tr', 'ra', 'an', 'ns', 'sl', 'la', 'at', 'to', 'or', 'rs', 's ', ' l', 'lo', 'ou', 'ui', 'is', 'se', 'e ', ' a', 'an', 'nd', 'd ', ' a', 'ay', 'yl', 'lm', 'me', 'er', 'r ', ' m', 'ma', 'au', 'ud', 'de', 'e ', ' ', ' p', 'po', 'os', 'st', 'ti', 'in', 'ng', 'g ', ' d', 'da', 'at', 'te', 'e ', ' j', 'ja', 'an', 'nu', 'ua', 'ar', 'ry', 'y ', ' ', ' ', ' e', 'eb', 'bo', 'oo', 'ok', 'k ', ' ', ' ', ' l', 'la', 'as', 'st', 't ', ' u', 'up', 'pd', 'da', 'at', 'te', 'ed', 'd ', ' d', 'de', 'ec', 'ce', 'em', 'mb', 'be', 'er', 'r ', ' ', ' ', ' ', ' l', 'la', 'an', 'ng', 'gu', 'ua', 'ag', 'ge', 'e ', ' e', 'en', 'ng', 'gl', 'li', 'is', 'sh', 'h ', ' ', ' c', 'ch', 'ha', 'ar', 'ra', 'ac', 'ct', 'te', 'er', 'r ', ' s', 'se', 'et', 't ', ' e', 'en', 'nc', 'co', 'od', 'di', 'in', 'ng', 'g ', ' u', 'ut', 'tf', 'f ', ' ', ' ', ' s', 'st', 'ta', 'ar', 'rt', 't ', ' o', 'of', 'f ', ' t', 'th', 'hi', 'is', 's ', ' p', 'pr', 'ro', 'oj', 'je', 'ec', 'ct', 't ', ' g', 'gu', 'ut', 'te', 'en', 'nb', 'be', 'er', 'rg', 'g ', ' e', 'eb', 'bo', 'oo', 'ok', 'k ', ' w', 'wa', 'ar', 'r ', ' a', 'an', 'nd', 'd ', ' p', 'pe', 'ea', 'ac', 'ce', 'e ', ' ', ' ', ' ', ' ', ' ', ' a', 'an', 'n ', ' a', 'an', 'no', 'on', 'ny', 'ym', 'mo', 'ou', 'us', 's ', ' v', 'vo', 'ol', 'lu', 'un', 'nt', 'te', 'ee', 'er', 'r ', ' a', 'an', 'nd', 'd ', ' d', 'da', 'av', 'vi', 'id', 'd ', ' w', 'wi', 'id', 'dg', 'ge', 'er', 'r ', ' ', ' ', ' ', ' ', ' ', ' ', ' w', 'wa', 'ar', 'r ', ' a', 'an', 'nd', 'd ', ' p', 'pe', 'ea', 'ac', 'ce', 'e ', ' ', ' ', ' b', 'by', 'y ', ' l', 'le', 'eo', 'o ', ' t', 'to', 'ol', 'ls', 'st', 'to', 'oy', 'yt', 'to', 'ol', 'ls', 'st', 'to', 'oi', 'i ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' c', 'co', 'on', 'nt', 'te', 'en', 'nt', 'ts', 's ', ' ', ' ', ' ', ' ', ' ', ' ', ' b', 'bo', 'oo', 'ok', 'k ', ' o', 'on', 'ne', 'e ', ' ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' i', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' i', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' i', 'ii', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' i', 'iv', 'v ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' v', 'v ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' v', 'vi', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' v', 'vi', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' v', 'vi', 'ii', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' i', 'ix', 'x ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'x ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xi', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xi', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xi', 'ii', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xi', 'iv', 'v ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xv', 'v ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xv', 'vi', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xv', 'vi', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xv', 'vi', 'ii', 'ii', 'i ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xi', 'ix', 'x ', ' ', ' ', ' ', ' ', ' ', ' c', 'ch', 'ha', 'ap', 'pt', 'te', 'er', 'r ', ' x', 'xx', 'x ', ' ', ' ', ' ', ' ', ' ', ' c', ...]
Count the number each pair. We use the Counter
function in collections
from collections import Counter
z = ['blue', 'red', 'blue', 'yellow', 'blue', 'red']
counts = dict(Counter(z))
counts
{'blue': 3, 'red': 2, 'yellow': 1}
counts.keys()
dict_keys(['yellow', 'blue', 'red'])
counts.values()
dict_values([1, 3, 2])
counts = dict(Counter(pairs))
counts
{' ': 17455, ' a': 69493, ' b': 25141, ' c': 21303, ' d': 17233, ' e': 11719, ' f': 21350, ' g': 9807, ' h': 49790, ' i': 30917, ' j': 1656, ' k': 4026, ' l': 13193, ' m': 19525, ' n': 15086, ' o': 34066, ' p': 18932, ' q': 1425, ' r': 15140, ' s': 40757, ' t': 87501, ' u': 5630, ' v': 3989, ' w': 40610, ' x': 450, ' y': 6735, ' z': 147, 'a ': 15006, 'aa': 25, 'ab': 3459, 'ac': 7018, 'ad': 11265, 'ae': 69, 'af': 1671, 'ag': 3379, 'ah': 325, 'ai': 8736, 'aj': 168, 'ak': 2534, 'al': 14225, 'am': 4602, 'an': 45444, 'ao': 42, 'ap': 4632, 'aq': 2, 'ar': 17676, 'as': 19823, 'at': 28005, 'au': 2512, 'av': 4330, 'aw': 2159, 'ax': 51, 'ay': 5206, 'az': 353, 'b ': 201, 'ba': 3189, 'bb': 229, 'bc': 4, 'bd': 20, 'be': 11355, 'bh': 2, 'bi': 1006, 'bj': 175, 'bk': 2, 'bl': 3638, 'bm': 70, 'bn': 22, 'bo': 4088, 'br': 1986, 'bs': 483, 'bt': 280, 'bu': 5275, 'bv': 47, 'bw': 20, 'by': 2563, 'bz': 3, 'c ': 610, 'ca': 6722, 'cc': 1050, 'cd': 9, 'ce': 13145, 'ch': 11607, 'ci': 2576, 'ck': 2624, 'cl': 2005, 'cm': 3, 'co': 12831, 'cq': 117, 'cr': 2072, 'cs': 99, 'ct': 4134, 'cu': 1694, 'cw': 9, 'cy': 310, 'cz': 5, 'd ': 75841, 'da': 2479, 'db': 84, 'dc': 12, 'dd': 1305, 'de': 13769, 'df': 116, 'dg': 437, 'dh': 80, 'di': 7811, 'dj': 236, 'dk': 69, 'dl': 1594, 'dm': 335, 'dn': 371, 'do': 4955, 'dp': 9, 'dq': 46, 'dr': 3591, 'ds': 2393, 'dt': 77, 'du': 1112, 'dv': 322, 'dw': 64, 'dy': 1188, 'dz': 2, 'e ': 110984, 'ea': 13396, 'eb': 277, 'ec': 5446, 'ed': 28674, 'ee': 7985, 'ef': 3192, 'eg': 2150, 'eh': 737, 'ei': 3501, 'ej': 85, 'ek': 280, 'el': 10266, 'em': 7116, 'en': 26217, 'eo': 1646, 'ep': 3439, 'eq': 255, 'er': 44090, 'es': 20468, 'et': 7478, 'eu': 316, 'ev': 5322, 'ew': 3226, 'ex': 3133, 'ey': 3726, 'ez': 170, 'f ': 19407, 'fa': 3879, 'fb': 29, 'fc': 46, 'fd': 34, 'fe': 4589, 'ff': 2840, 'fg': 1, 'fh': 9, 'fi': 4674, 'fj': 1, 'fk': 12, 'fl': 1210, 'fm': 6, 'fn': 13, 'fo': 8102, 'fp': 11, 'fr': 5675, 'fs': 229, 'ft': 2155, 'fu': 1862, 'fw': 32, 'fy': 85, 'g ': 22158, 'ga': 3374, 'gb': 2, 'gc': 6, 'gd': 54, 'ge': 5844, 'gf': 11, 'gg': 447, 'gh': 5965, 'gi': 2500, 'gk': 2, 'gl': 1485, 'gm': 19, 'gn': 937, 'go': 3096, 'gp': 4, 'gq': 1, 'gr': 2769, 'gs': 898, 'gt': 235, 'gu': 1338, 'gv': 10, 'gw': 26, 'gy': 138, 'gz': 8, 'h ': 15441, 'ha': 27466, 'hb': 69, 'hc': 65, 'hd': 63, 'he': 74926, 'hf': 70, 'hg': 28, 'hh': 13, 'hi': 25833, 'hk': 110, 'hl': 324, 'hm': 389, 'hn': 313, 'ho': 13683, 'hp': 9, 'hr': 1367, 'hs': 193, 'ht': 4213, 'hu': 1593, 'hv': 134, 'hw': 56, 'hy': 1055, 'hz': 2, 'i ': 5426, 'ia': 2911, 'ib': 1273, 'ic': 8518, 'id': 8677, 'ie': 8443, 'if': 3746, 'ig': 4294, 'ih': 7, 'ii': 460, 'ik': 1198, 'il': 8114, 'im': 9920, 'in': 48320, 'io': 7276, 'ip': 847, 'iq': 27, 'ir': 5921, 'is': 21216, 'it': 21141, 'iu': 130, 'iv': 3484, 'iw': 7, 'ix': 324, 'iy': 1, 'iz': 576, 'ja': 99, 'je': 565, 'ji': 11, 'jo': 716, 'ju': 1183, 'k ': 5059, 'ka': 513, 'kb': 12, 'kc': 52, 'kd': 4, 'ke': 5666, 'kf': 19, 'kg': 16, 'kh': 827, 'ki': 3388, 'kk': 2, 'kl': 369, 'km': 44, 'kn': 2278, 'ko': 255, 'kp': 3, 'kr': 140, 'ks': 777, 'kt': 15, 'ku': 666, 'kv': 92, 'kw': 89, 'ky': 146, 'l ': 12932, 'la': 7602, 'lb': 153, 'lc': 127, 'ld': 6919, 'le': 16808, 'lf': 2315, 'lg': 150, 'lh': 15, 'li': 9416, 'lk': 1057, 'll': 13218, 'lm': 399, 'ln': 416, 'lo': 8302, 'lp': 393, 'lq': 2, 'lr': 471, 'ls': 1649, 'lt': 1681, 'lu': 1484, 'lv': 496, 'lw': 479, 'lx': 1, 'ly': 10008, 'lz': 39, 'm ': 12491, 'ma': 9278, 'mb': 1088, 'mc': 52, 'md': 5, 'me': 15111, 'mf': 138, 'mg': 1, 'mh': 21, 'mi': 4830, 'mk': 36, 'ml': 231, 'mm': 1386, 'mn': 307, 'mo': 6643, 'mp': 3436, 'mr': 212, 'ms': 1951, 'mt': 278, 'mu': 1645, 'mv': 35, 'mw': 15, 'my': 2459, 'n ': 40747, 'na': 5548, 'nb': 157, 'nc': 9112, 'nd': 34588, 'ne': 14833, 'nf': 916, 'ng': 24995, 'nh': 155, 'ni': 5704, 'nj': 120, 'nk': 1492, 'nl': 2177, 'nm': 149, 'nn': 1962, 'no': 12571, 'np': 103, 'nq': 243, 'nr': 83, 'ns': 7224, 'nt': 17243, 'nu': 969, 'nv': 761, 'nw': 134, 'nx': 82, 'ny': 2086, 'nz': 30, 'o ': 26787, 'oa': 1392, 'ob': 891, 'oc': 1460, 'od': 3056, 'oe': 503, 'of': 16919, 'og': 771, 'oh': 365, 'oi': 2236, 'oj': 121, 'ok': 3373, 'ol': 7366, 'om': 11066, 'on': 26784, 'oo': 7220, 'op': 3057, 'oq': 25, 'or': 19747, 'os': 6765, 'ot': 10020, 'ou': 23549, 'ov': 5734, 'ow': 9913, 'ox': 141, 'oy': 705, 'oz': 117, 'p ': 3148, 'pa': 4408, 'pb': 12, 'pc': 128, 'pd': 2, 'pe': 8191, 'pf': 100, 'pg': 10, 'ph': 418, 'pi': 4204, 'pk': 20, 'pl': 4222, 'pm': 27, 'pn': 38, 'po': 4744, 'pp': 2629, 'pr': 7860, 'ps': 1084, 'pt': 2585, 'pu': 1164, 'pv': 185, 'pw': 23, 'py': 331, 'q ': 1, 'qc': 1, 'qu': 2329, 'r ': 31604, 'ra': 8086, 'rb': 222, 'rc': 1478, 'rd': 4434, 're': 35537, 'rf': 453, 'rg': 1498, 'rh': 229, 'ri': 13087, 'rj': 3, 'rk': 1013, 'rl': 1302, 'rm': 2969, 'rn': 2730, 'ro': 14720, 'rp': 547, 'rq': 14, 'rr': 4936, 'rs': 9094, 'rt': 4672, 'ru': 2896, 'rv': 745, 'rw': 305, 'ry': 5756, 'rz': 101, 's ': 62838, 'sa': 8433, 'sb': 442, 'sc': 2235, 'sd': 92, 'se': 17555, 'sf': 312, 'sg': 49, 'sh': 10861, 'si': 9100, 'sj': 4, 'sk': 2163, 'sl': 1485, 'sm': 1699, 'sn': 905, 'so': 8561, 'sp': 3245, 'sq': 169, 'sr': 48, 'ss': 9711, 'st': 17855, 'su': 3947, 'sv': 88, 'sw': 713, 'sy': 381, 'sz': 6, 't ': 58252, 'ta': 7606, 'tb': 37, 'tc': 662, 'td': 8, 'te': 19190, 'tf': 194, 'tg': 20, 'th': 73776, 'ti': 13921, 'tj': 3, 'tk': 93, 'tl': 3033, 'tm': 320, 'tn': 225, 'to': 23725, 'tp': 47, 'tr': 5703, 'ts': 6188, 'tt': 4441, 'tu': 2967, 'tv': 997, 'tw': 1190, 'tx': 1, 'ty': 3149, 'tz': 666, 'u ': 3841, 'ua': 1324, 'ub': 903, 'uc': 2048, 'ud': 1429, 'ue': 1896, 'uf': 331, 'ug': 3252, 'uh': 42, 'ui': 1759, 'uj': 1, 'uk': 96, 'ul': 6337, 'um': 1366, 'un': 8764, 'uo': 149, 'up': 2776, 'uq': 1, 'ur': 8068, 'us': 8795, 'ut': 10957, 'uu': 2, 'uv': 123, 'uw': 2, 'ux': 43, 'uy': 20, 'uz': 74, 'v ': 2677, 'va': 1694, 'vb': 1, 'vd': 14, 've': 14498, 'vg': 3, 'vh': 1, 'vi': 4718, 'vk': 11, 'vl': 259, 'vn': 629, 'vo': 1466, 'vr': 225, 'vs': 635, 'vt': 101, 'vu': 20, 'vv': 8, 'vw': 7, 'vy': 113, 'vz': 7, 'w ': 8261, 'wa': 12171, 'wb': 12, 'wc': 23, 'wd': 369, 'we': 7759, 'wf': 50, 'wg': 7, 'wh': 11926, 'wi': 10023, 'wk': 63, 'wl': 201, 'wm': 5, 'wn': 2226, 'wo': 4597, 'wp': 3, 'wr': 537, 'ws': 866, 'wt': 23, 'wu': 20, 'ww': 26, 'wy': 41, 'x ': 371, 'xa': 337, 'xc': 603, 'xe': 314, 'xf': 1, 'xh': 60, 'xi': 513, 'xl': 4, 'xm': 2, 'xo': 5, 'xp': 1355, 'xq': 4, 'xs': 6, 'xt': 471, 'xu': 17, 'xv': 156, 'xx': 158, 'xy': 7, 'y ': 31398, 'ya': 1193, 'yb': 157, 'yc': 172, 'yd': 17, 'ye': 2576, 'yf': 157, 'yg': 12, 'yh': 30, 'yi': 1091, 'yj': 1, 'yk': 54, 'yl': 230, 'ym': 168, 'yn': 149, 'yo': 5993, 'yp': 56, 'yr': 114, 'ys': 1591, 'yt': 852, 'yu': 53, 'yv': 25, 'yw': 99, 'yy': 12, 'yz': 35, 'z ': 140, 'za': 99, 'zb': 8, 'zc': 1, 'zd': 27, 'ze': 729, 'zh': 154, 'zi': 242, 'zk': 102, 'zl': 44, 'zm': 64, 'zn': 48, 'zo': 631, 'zs': 2, 'zt': 1, 'zu': 26, 'zv': 4, 'zw': 5, 'zy': 14, 'zz': 47}
There are len(counts.keys())
pairs in War and Peace
len(counts.keys())
613
Total possible pairs is.
27*27
729
So some pairs are missing because they never appeared in the book. We add these to counts. This is important to avoid python errors in the Metropolis algorithm. By adding (artificial) 1 counts to these pairs, we make the algorithm a bit more robust.
## construct all possible pairs (NOTE: bad code)
allpairs = []
for i in letters:
for j in letters:
allpairs = allpairs + [i + j]
absent = list(set(allpairs) - set(counts.keys()))
absent = dict(list(zip(absent,len(absent)*[1])))
counts = {**counts,**absent} ## merge together dictionaries
counts
{' ': 17455, ' a': 69493, ' b': 25141, ' c': 21303, ' d': 17233, ' e': 11719, ' f': 21350, ' g': 9807, ' h': 49790, ' i': 30917, ' j': 1656, ' k': 4026, ' l': 13193, ' m': 19525, ' n': 15086, ' o': 34066, ' p': 18932, ' q': 1425, ' r': 15140, ' s': 40757, ' t': 87501, ' u': 5630, ' v': 3989, ' w': 40610, ' x': 450, ' y': 6735, ' z': 147, 'a ': 15006, 'aa': 25, 'ab': 3459, 'ac': 7018, 'ad': 11265, 'ae': 69, 'af': 1671, 'ag': 3379, 'ah': 325, 'ai': 8736, 'aj': 168, 'ak': 2534, 'al': 14225, 'am': 4602, 'an': 45444, 'ao': 42, 'ap': 4632, 'aq': 2, 'ar': 17676, 'as': 19823, 'at': 28005, 'au': 2512, 'av': 4330, 'aw': 2159, 'ax': 51, 'ay': 5206, 'az': 353, 'b ': 201, 'ba': 3189, 'bb': 229, 'bc': 4, 'bd': 20, 'be': 11355, 'bf': 1, 'bg': 1, 'bh': 2, 'bi': 1006, 'bj': 175, 'bk': 2, 'bl': 3638, 'bm': 70, 'bn': 22, 'bo': 4088, 'bp': 1, 'bq': 1, 'br': 1986, 'bs': 483, 'bt': 280, 'bu': 5275, 'bv': 47, 'bw': 20, 'bx': 1, 'by': 2563, 'bz': 3, 'c ': 610, 'ca': 6722, 'cb': 1, 'cc': 1050, 'cd': 9, 'ce': 13145, 'cf': 1, 'cg': 1, 'ch': 11607, 'ci': 2576, 'cj': 1, 'ck': 2624, 'cl': 2005, 'cm': 3, 'cn': 1, 'co': 12831, 'cp': 1, 'cq': 117, 'cr': 2072, 'cs': 99, 'ct': 4134, 'cu': 1694, 'cv': 1, 'cw': 9, 'cx': 1, 'cy': 310, 'cz': 5, 'd ': 75841, 'da': 2479, 'db': 84, 'dc': 12, 'dd': 1305, 'de': 13769, 'df': 116, 'dg': 437, 'dh': 80, 'di': 7811, 'dj': 236, 'dk': 69, 'dl': 1594, 'dm': 335, 'dn': 371, 'do': 4955, 'dp': 9, 'dq': 46, 'dr': 3591, 'ds': 2393, 'dt': 77, 'du': 1112, 'dv': 322, 'dw': 64, 'dx': 1, 'dy': 1188, 'dz': 2, 'e ': 110984, 'ea': 13396, 'eb': 277, 'ec': 5446, 'ed': 28674, 'ee': 7985, 'ef': 3192, 'eg': 2150, 'eh': 737, 'ei': 3501, 'ej': 85, 'ek': 280, 'el': 10266, 'em': 7116, 'en': 26217, 'eo': 1646, 'ep': 3439, 'eq': 255, 'er': 44090, 'es': 20468, 'et': 7478, 'eu': 316, 'ev': 5322, 'ew': 3226, 'ex': 3133, 'ey': 3726, 'ez': 170, 'f ': 19407, 'fa': 3879, 'fb': 29, 'fc': 46, 'fd': 34, 'fe': 4589, 'ff': 2840, 'fg': 1, 'fh': 9, 'fi': 4674, 'fj': 1, 'fk': 12, 'fl': 1210, 'fm': 6, 'fn': 13, 'fo': 8102, 'fp': 11, 'fq': 1, 'fr': 5675, 'fs': 229, 'ft': 2155, 'fu': 1862, 'fv': 1, 'fw': 32, 'fx': 1, 'fy': 85, 'fz': 1, 'g ': 22158, 'ga': 3374, 'gb': 2, 'gc': 6, 'gd': 54, 'ge': 5844, 'gf': 11, 'gg': 447, 'gh': 5965, 'gi': 2500, 'gj': 1, 'gk': 2, 'gl': 1485, 'gm': 19, 'gn': 937, 'go': 3096, 'gp': 4, 'gq': 1, 'gr': 2769, 'gs': 898, 'gt': 235, 'gu': 1338, 'gv': 10, 'gw': 26, 'gx': 1, 'gy': 138, 'gz': 8, 'h ': 15441, 'ha': 27466, 'hb': 69, 'hc': 65, 'hd': 63, 'he': 74926, 'hf': 70, 'hg': 28, 'hh': 13, 'hi': 25833, 'hj': 1, 'hk': 110, 'hl': 324, 'hm': 389, 'hn': 313, 'ho': 13683, 'hp': 9, 'hq': 1, 'hr': 1367, 'hs': 193, 'ht': 4213, 'hu': 1593, 'hv': 134, 'hw': 56, 'hx': 1, 'hy': 1055, 'hz': 2, 'i ': 5426, 'ia': 2911, 'ib': 1273, 'ic': 8518, 'id': 8677, 'ie': 8443, 'if': 3746, 'ig': 4294, 'ih': 7, 'ii': 460, 'ij': 1, 'ik': 1198, 'il': 8114, 'im': 9920, 'in': 48320, 'io': 7276, 'ip': 847, 'iq': 27, 'ir': 5921, 'is': 21216, 'it': 21141, 'iu': 130, 'iv': 3484, 'iw': 7, 'ix': 324, 'iy': 1, 'iz': 576, 'j ': 1, 'ja': 99, 'jb': 1, 'jc': 1, 'jd': 1, 'je': 565, 'jf': 1, 'jg': 1, 'jh': 1, 'ji': 11, 'jj': 1, 'jk': 1, 'jl': 1, 'jm': 1, 'jn': 1, 'jo': 716, 'jp': 1, 'jq': 1, 'jr': 1, 'js': 1, 'jt': 1, 'ju': 1183, 'jv': 1, 'jw': 1, 'jx': 1, 'jy': 1, 'jz': 1, 'k ': 5059, 'ka': 513, 'kb': 12, 'kc': 52, 'kd': 4, 'ke': 5666, 'kf': 19, 'kg': 16, 'kh': 827, 'ki': 3388, 'kj': 1, 'kk': 2, 'kl': 369, 'km': 44, 'kn': 2278, 'ko': 255, 'kp': 3, 'kq': 1, 'kr': 140, 'ks': 777, 'kt': 15, 'ku': 666, 'kv': 92, 'kw': 89, 'kx': 1, 'ky': 146, 'kz': 1, 'l ': 12932, 'la': 7602, 'lb': 153, 'lc': 127, 'ld': 6919, 'le': 16808, 'lf': 2315, 'lg': 150, 'lh': 15, 'li': 9416, 'lj': 1, 'lk': 1057, 'll': 13218, 'lm': 399, 'ln': 416, 'lo': 8302, 'lp': 393, 'lq': 2, 'lr': 471, 'ls': 1649, 'lt': 1681, 'lu': 1484, 'lv': 496, 'lw': 479, 'lx': 1, 'ly': 10008, 'lz': 39, 'm ': 12491, 'ma': 9278, 'mb': 1088, 'mc': 52, 'md': 5, 'me': 15111, 'mf': 138, 'mg': 1, 'mh': 21, 'mi': 4830, 'mj': 1, 'mk': 36, 'ml': 231, 'mm': 1386, 'mn': 307, 'mo': 6643, 'mp': 3436, 'mq': 1, 'mr': 212, 'ms': 1951, 'mt': 278, 'mu': 1645, 'mv': 35, 'mw': 15, 'mx': 1, 'my': 2459, 'mz': 1, 'n ': 40747, 'na': 5548, 'nb': 157, 'nc': 9112, 'nd': 34588, 'ne': 14833, 'nf': 916, 'ng': 24995, 'nh': 155, 'ni': 5704, 'nj': 120, 'nk': 1492, 'nl': 2177, 'nm': 149, 'nn': 1962, 'no': 12571, 'np': 103, 'nq': 243, 'nr': 83, 'ns': 7224, 'nt': 17243, 'nu': 969, 'nv': 761, 'nw': 134, 'nx': 82, 'ny': 2086, 'nz': 30, 'o ': 26787, 'oa': 1392, 'ob': 891, 'oc': 1460, 'od': 3056, 'oe': 503, 'of': 16919, 'og': 771, 'oh': 365, 'oi': 2236, 'oj': 121, 'ok': 3373, 'ol': 7366, 'om': 11066, 'on': 26784, 'oo': 7220, 'op': 3057, 'oq': 25, 'or': 19747, 'os': 6765, 'ot': 10020, 'ou': 23549, 'ov': 5734, 'ow': 9913, 'ox': 141, 'oy': 705, 'oz': 117, 'p ': 3148, 'pa': 4408, 'pb': 12, 'pc': 128, 'pd': 2, 'pe': 8191, 'pf': 100, 'pg': 10, 'ph': 418, 'pi': 4204, 'pj': 1, 'pk': 20, 'pl': 4222, 'pm': 27, 'pn': 38, 'po': 4744, 'pp': 2629, 'pq': 1, 'pr': 7860, 'ps': 1084, 'pt': 2585, 'pu': 1164, 'pv': 185, 'pw': 23, 'px': 1, 'py': 331, 'pz': 1, 'q ': 1, 'qa': 1, 'qb': 1, 'qc': 1, 'qd': 1, 'qe': 1, 'qf': 1, 'qg': 1, 'qh': 1, 'qi': 1, 'qj': 1, 'qk': 1, 'ql': 1, 'qm': 1, 'qn': 1, 'qo': 1, 'qp': 1, 'qq': 1, 'qr': 1, 'qs': 1, 'qt': 1, 'qu': 2329, 'qv': 1, 'qw': 1, 'qx': 1, 'qy': 1, 'qz': 1, 'r ': 31604, 'ra': 8086, 'rb': 222, 'rc': 1478, 'rd': 4434, 're': 35537, 'rf': 453, 'rg': 1498, 'rh': 229, 'ri': 13087, 'rj': 3, 'rk': 1013, 'rl': 1302, 'rm': 2969, 'rn': 2730, 'ro': 14720, 'rp': 547, 'rq': 14, 'rr': 4936, 'rs': 9094, 'rt': 4672, 'ru': 2896, 'rv': 745, 'rw': 305, 'rx': 1, 'ry': 5756, 'rz': 101, 's ': 62838, 'sa': 8433, 'sb': 442, 'sc': 2235, 'sd': 92, 'se': 17555, 'sf': 312, 'sg': 49, 'sh': 10861, 'si': 9100, 'sj': 4, 'sk': 2163, 'sl': 1485, 'sm': 1699, 'sn': 905, 'so': 8561, 'sp': 3245, 'sq': 169, 'sr': 48, 'ss': 9711, 'st': 17855, 'su': 3947, 'sv': 88, 'sw': 713, 'sx': 1, 'sy': 381, 'sz': 6, 't ': 58252, 'ta': 7606, 'tb': 37, 'tc': 662, 'td': 8, 'te': 19190, 'tf': 194, 'tg': 20, 'th': 73776, 'ti': 13921, 'tj': 3, 'tk': 93, 'tl': 3033, 'tm': 320, 'tn': 225, 'to': 23725, 'tp': 47, 'tq': 1, 'tr': 5703, 'ts': 6188, 'tt': 4441, 'tu': 2967, 'tv': 997, 'tw': 1190, 'tx': 1, 'ty': 3149, 'tz': 666, 'u ': 3841, 'ua': 1324, 'ub': 903, 'uc': 2048, 'ud': 1429, 'ue': 1896, 'uf': 331, 'ug': 3252, 'uh': 42, 'ui': 1759, 'uj': 1, 'uk': 96, 'ul': 6337, 'um': 1366, 'un': 8764, 'uo': 149, 'up': 2776, 'uq': 1, 'ur': 8068, 'us': 8795, 'ut': 10957, 'uu': 2, 'uv': 123, 'uw': 2, 'ux': 43, 'uy': 20, 'uz': 74, 'v ': 2677, 'va': 1694, 'vb': 1, 'vc': 1, 'vd': 14, 've': 14498, 'vf': 1, 'vg': 3, 'vh': 1, 'vi': 4718, 'vj': 1, 'vk': 11, 'vl': 259, 'vm': 1, 'vn': 629, 'vo': 1466, 'vp': 1, 'vq': 1, 'vr': 225, 'vs': 635, 'vt': 101, 'vu': 20, 'vv': 8, 'vw': 7, 'vx': 1, 'vy': 113, 'vz': 7, 'w ': 8261, 'wa': 12171, 'wb': 12, 'wc': 23, 'wd': 369, 'we': 7759, 'wf': 50, 'wg': 7, 'wh': 11926, 'wi': 10023, 'wj': 1, 'wk': 63, 'wl': 201, 'wm': 5, 'wn': 2226, 'wo': 4597, 'wp': 3, 'wq': 1, 'wr': 537, 'ws': 866, 'wt': 23, 'wu': 20, 'wv': 1, 'ww': 26, 'wx': 1, 'wy': 41, 'wz': 1, 'x ': 371, 'xa': 337, 'xb': 1, 'xc': 603, 'xd': 1, 'xe': 314, 'xf': 1, 'xg': 1, 'xh': 60, 'xi': 513, 'xj': 1, 'xk': 1, 'xl': 4, 'xm': 2, 'xn': 1, 'xo': 5, 'xp': 1355, 'xq': 4, 'xr': 1, 'xs': 6, 'xt': 471, 'xu': 17, 'xv': 156, 'xw': 1, 'xx': 158, 'xy': 7, 'xz': 1, 'y ': 31398, 'ya': 1193, 'yb': 157, 'yc': 172, 'yd': 17, 'ye': 2576, 'yf': 157, 'yg': 12, 'yh': 30, 'yi': 1091, 'yj': 1, 'yk': 54, 'yl': 230, 'ym': 168, 'yn': 149, 'yo': 5993, 'yp': 56, 'yq': 1, 'yr': 114, 'ys': 1591, 'yt': 852, 'yu': 53, 'yv': 25, 'yw': 99, 'yx': 1, 'yy': 12, 'yz': 35, 'z ': 140, 'za': 99, 'zb': 8, 'zc': 1, 'zd': 27, 'ze': 729, 'zf': 1, 'zg': 1, 'zh': 154, 'zi': 242, 'zj': 1, 'zk': 102, 'zl': 44, 'zm': 64, 'zn': 48, 'zo': 631, 'zp': 1, 'zq': 1, 'zr': 1, 'zs': 2, 'zt': 1, 'zu': 26, 'zv': 4, 'zw': 5, 'zx': 1, 'zy': 14, 'zz': 47}
Transform the counts to conditional probabilities:
num_added = dict(Counter(list(map(lambda x: x[0], list(absent.keys())))))
num_added
{'b': 5, 'c': 8, 'd': 1, 'f': 4, 'g': 2, 'h': 3, 'i': 1, 'j': 22, 'k': 4, 'l': 1, 'm': 4, 'p': 4, 'q': 24, 'r': 1, 's': 1, 't': 1, 'v': 7, 'w': 5, 'x': 9, 'y': 2, 'z': 7}
counts_single = dict(Counter(cleaned))
for i in num_added:
counts_single[i] = counts_single[i] + num_added[i]
counts_single
{' ': 583077, 'a': 202717, 'b': 34663, 'c': 61630, 'd': 118299, 'e': 313575, 'f': 54905, 'g': 51329, 'h': 167418, 'i': 172258, 'j': 2596, 'k': 20436, 'l': 96533, 'm': 61653, 'n': 184184, 'o': 190083, 'p': 45537, 'q': 2355, 'r': 148432, 's': 162898, 't': 226415, 'u': 64399, 'v': 27094, 'w': 59214, 'x': 4393, 'y': 46237, 'z': 2395}
for i in counts:
counts[i] = counts[i] / counts_single[i[0]]
np.sum(np.array(list(counts.values())))
26.999998284960647
pairprob = counts
Normalize the counts of single letters.
n = np.sum(np.array(list(counts_single.values())))
n
3104725
for i in counts_single:
counts_single[i] = counts_single[i] / n
singleprob = counts_single
singleprob
{' ': 0.187803106555331, 'a': 0.06529306138224802, 'b': 0.01116459589818744, 'c': 0.01985038932594674, 'd': 0.03810289156044416, 'e': 0.10099928335037725, 'f': 0.01768433597178494, 'g': 0.016532543139891616, 'h': 0.05392361642335473, 'i': 0.05548253065891504, 'j': 0.0008361449081641691, 'k': 0.00658222547890715, 'l': 0.031092286756476017, 'm': 0.019857797389462833, 'n': 0.059323772636868, 'o': 0.06122377988388666, 'p': 0.014666999492708693, 'q': 0.0007585212861042443, 'r': 0.04780842103567949, 's': 0.052467770897583525, 't': 0.07292594352156793, 'u': 0.02074225575534065, 'v': 0.008726698821956856, 'w': 0.019072220567038948, 'x': 0.00141494013157365, 'y': 0.014892462295372376, 'z': 0.0007714048748278833}
test = 'hello'
n = len(test)
toix = list(range(2,n+1))
fromix = list(range(0,n-1))
fromtoix = list(zip(fromix,toix))
pairs = list(map(lambda x: test[x[0]:x[1]], fromtoix))
pairs
['he', 'el', 'll', 'lo']
X = dict(Counter(pairs))
X
{'el': 1, 'he': 1, 'll': 1, 'lo': 1}
p = np.array(list(map(lambda y: pairprob[y], X.keys())))
p
array([0.4475385 , 0.13692727, 0.03273858, 0.08600168])
ns = np.array(list(X.values()))
ns
array([1, 1, 1, 1])
out = np.sum(ns*np.log(p)) + np.log(singleprob[test[0]])
print(out)
print(np.exp(out))
-11.585074416515086 9.303923021188655e-06
## if all len(test) character strings were equally likely
1.0 / np.power(27.0,len(test))
6.969171937625632e-08
The posterior is proportional to the likelihood times the prior: $$ \pi(\theta|x) \propto f(x|\theta)\pi(\theta) $$ Here $\theta$ represents the inverse cipher, the function which maps the code back to the true letter. This is a discrete parameter that could take 26! possible values. We put a uniform prior on all possible parameter values. Therefore the posterior is proportional to just the likelihood $f(x|\theta)$.
In python, we can represent the $\theta$ parameter with a dictionary where the values are the coded message and the key are what letter the code corresponds to. One could also use a pandas data frame to accomplish this.
## random initial starting value for theta
theta = letters.copy()
random.shuffle(theta)
theta = dict(list(zip(letters,theta)))
theta
{' ': 'a', 'a': 'e', 'b': 'p', 'c': 't', 'd': 'f', 'e': 'd', 'f': 'g', 'g': 'h', 'h': 'q', 'i': 'y', 'j': 'i', 'k': 'o', 'l': 'k', 'm': 'w', 'n': 'z', 'o': 'v', 'p': 'j', 'q': 'c', 'r': 's', 's': 'm', 't': ' ', 'u': 'x', 'v': 'r', 'w': 'n', 'x': 'u', 'y': 'b', 'z': 'l'}
decoded = list(map(lambda x: theta[x], code))
decoded = "".join(decoded)
## decoded mesage does not appear to be correct, because theta was a random guess
decoded
'wjspvbfdnbdwvadhgbnqvj kahbdfadhbpxbkfabvdkanbj hjudkahbsgbua kvdwbsd lbqpwjujanbd bduuawavdkjp bkfdkbfdnbsdxxwahbaup pojnknbd hbkvdhavnbkfdkbijha j cbcdqbfdnbdwdvoahbkfpnabifpbidkufbjkbdnbdbnjc dwbpxbnkvannbj bkfabxj d ujdwbngnkaobpkfavnbfdmabqj ahbjkbp bdbnavjanbpxbkauf judwbxdukpvnbnzufbdnbvjnj cbnfpvkkavobhaskbndwanbsgbkfabznbcpmav oa kbd hb aibupvqpvdkabkdrbqpwjujanbpkfavbodvlaknbkfdkbud bsabkdqqahbxpvbhpwwdvnbj uwzhj cbkfvpzcfbkfabnidqnbodvlakbd hbwjyzjhjkgbwj anbodj kdj ahbsgbcwpsdwbua kvdwbsd lnbdva kbgakbnfpij cbdbsjcbhpwwdvbnyzaata'
Compute the log likelihood (= log posterior because uniform prior) in pieces.
n = len(code)
toix = list(range(2,n+1))
fromix = list(range(0,n-1))
fromtoix = list(zip(fromix,toix))
pairs = list(map(lambda x: decoded[x[0]:x[1]], fromtoix))
X = dict(Counter(pairs))
X
{' ': 1, ' a': 4, ' b': 5, ' c': 4, ' d': 2, ' h': 4, ' j': 2, ' k': 6, ' l': 2, ' o': 1, ' p': 1, ' u': 2, 'a ': 5, 'aa': 1, 'ab': 8, 'ad': 2, 'ah': 7, 'ai': 1, 'ak': 3, 'an': 7, 'ao': 1, 'as': 1, 'at': 1, 'au': 2, 'av': 7, 'aw': 1, 'b ': 1, 'ba': 1, 'bc': 3, 'bd': 14, 'bf': 4, 'bg': 1, 'bh': 3, 'bi': 3, 'bj': 5, 'bk': 13, 'bn': 11, 'bo': 3, 'bp': 6, 'bq': 3, 'bs': 8, 'bu': 4, 'bv': 2, 'bw': 2, 'bx': 3, 'bz': 1, 'c ': 1, 'cb': 5, 'cd': 1, 'cf': 1, 'cp': 1, 'cw': 1, 'd ': 8, 'db': 3, 'df': 1, 'dh': 3, 'dj': 2, 'dk': 8, 'dm': 1, 'dn': 5, 'dq': 3, 'dr': 1, 'du': 2, 'dv': 6, 'dw': 9, 'dx': 1, 'f ': 1, 'fa': 7, 'fb': 3, 'fd': 7, 'fp': 4, 'fv': 1, 'ga': 1, 'gb': 5, 'gn': 1, 'ha': 3, 'hb': 11, 'hg': 1, 'hj': 3, 'hp': 2, 'ib': 1, 'id': 2, 'if': 1, 'ij': 2, 'j ': 13, 'ja': 3, 'jc': 2, 'jd': 1, 'jh': 2, 'jk': 3, 'jn': 2, 'jp': 1, 'js': 1, 'ju': 4, 'jy': 1, 'ka': 7, 'kb': 10, 'kd': 3, 'kf': 11, 'kg': 1, 'kj': 1, 'kk': 1, 'kn': 2, 'kp': 1, 'ku': 1, 'kv': 4, 'la': 2, 'lb': 1, 'ln': 1, 'ma': 2, 'na': 2, 'nb': 21, 'nd': 1, 'nf': 2, 'ng': 1, 'ni': 1, 'nj': 2, 'nk': 3, 'nn': 1, 'nq': 1, 'ny': 1, 'nz': 1, 'oa': 2, 'ob': 2, 'od': 3, 'oj': 1, 'p ': 3, 'pb': 1, 'pi': 1, 'pk': 2, 'pm': 1, 'pn': 1, 'po': 1, 'ps': 1, 'pv': 6, 'pw': 4, 'px': 3, 'pz': 1, 'qa': 1, 'qb': 1, 'qj': 1, 'qn': 1, 'qp': 3, 'qq': 1, 'qv': 1, 'rb': 1, 'sa': 1, 'sd': 4, 'sg': 3, 'sj': 1, 'sk': 1, 'sp': 1, 'ta': 1, 'ua': 3, 'ud': 3, 'uf': 3, 'uj': 3, 'uk': 1, 'up': 2, 'uu': 1, 'uw': 1, 'v ': 1, 'va': 3, 'vb': 4, 'vd': 6, 'vj': 3, 'vk': 1, 'vl': 2, 'vn': 4, 'vo': 2, 'vp': 1, 'vq': 1, 'wa': 3, 'wb': 6, 'wd': 3, 'wj': 5, 'wp': 1, 'wv': 1, 'ww': 2, 'wz': 1, 'xb': 3, 'xd': 1, 'xj': 1, 'xp': 1, 'xw': 1, 'xx': 1, 'yz': 2, 'za': 1, 'zc': 1, 'zh': 1, 'zj': 1, 'zn': 1, 'zu': 1}
p = np.array(list(map(lambda y: pairprob[y], X.keys())))
ns = np.array(list(X.values()))
out = np.sum(ns*np.log(p)) + np.log(singleprob[decoded[0]])
out
-3443.725205736844
We put the above code in functions which we can call in Metropolis.
def decode(theta):
decoded = list(map(lambda x: theta[x], code))
decoded = "".join(decoded)
return decoded
def logpost(theta):
decoded = decode(theta)
pairs = list(map(lambda x: decoded[x[0]:x[1]], fromtoix))
X = dict(Counter(pairs))
p = np.array(list(map(lambda y: pairprob[y], X.keys())))
ns = np.array(list(X.values()))
return np.sum(ns*np.log(p)) + np.log(singleprob[decoded[0]])
## check that function output matches scratch work
logpost(theta)
-3443.725205736844
The proposal distribution considers switching pairs of letters in the deciper theta.
def thetaproposal(theta):
thetanew = theta.copy()
ixs = random.choice(list(theta.keys()),size=2,replace=False)
thetanew[ixs[0]] = theta[ixs[1]]
thetanew[ixs[1]] = theta[ixs[0]]
return thetanew
## random initial starting value for theta
theta = letters.copy()
random.shuffle(theta)
theta = dict(list(zip(letters,theta)))
## metropolis
niter = 10000
for ii in np.arange(niter):
thetanew = thetaproposal(theta)
if (ii % 100) == 0:
print("==== The " + str(ii) + " iteration estimate is: ====")
print(decode(theta))
if np.exp(logpost(thetanew) - logpost(theta)) > np.random.uniform():
theta = thetanew
==== The 0 iteration estimate is: ==== wjspvbfdnbdwvadhgbnqvj kahbdfadhbpxbkfabvdkanbj hjudkahbsgbua kvdwbsd lbqpwjujanbd bduuawavdkjp bkfdkbfdnbsdxxwahbaup pojnknbd hbkvdhavnbkfdkbijha j cbcdqbfdnbdwdvoahbkfpnabifpbidkufbjkbdnbdbnjc dwbpxbnkvannbj bkfabxj d ujdwbngnkaobpkfavnbfdmabqj ahbjkbp bdbnavjanbpxbkauf judwbxdukpvnbnzufbdnbvjnj cbnfpvkkavobhaskbndwanbsgbkfabznbcpmav oa kbd hb aibupvqpvdkabkdrbqpwjujanbpkfavbodvlaknbkfdkbud bsabkdqqahbxpvbhpwwdvnbj uwzhj cbkfvpzcfbkfabnidqnbodvlakbd hbwjyzjhjkgbwj anbodj kdj ahbsgbcwpsdwbua kvdwbsd lnbdva kbgakbnfpij cbdbsjcbhpwwdvbnyzaata ==== The 100 iteration estimate is: ==== vsberazonaovrgohdanfrs tghaozgohaepatzgarotgnas hsiotghabdaig trovabo uafevsisgnao aoiigvgrotse atzotazonaboppvghagie eysntnao hatrohgrnatzotalshg s cacofazonaovoryghatzengalzealotizastaonaoansc ovaepantrgnnas atzgaps o isovandntgyaetzgrnazojgafs ghastae aoangrsgnaepatgiz siovapoiternanmizaonarsns canzerttgryahgbtanovgnabdatzgamnacejgr yg tao ha glaierferotgatokafevsisgnaetzgrayorugtnatzotaio abgatoffghaperahevvornas ivmhs catzremczatzganlofnayorugtao havsqmshstdavs gnayos tos ghabdacvebovaig trovabo unaorg tadgtanzels caoabscahevvoranqmggxg ==== The 200 iteration estimate is: ==== v ferocanoavrlahyondr stlhoaclahoepotcloratlno sh iatlhofyoilstravofasuodev i lnoasoaiilvlrat esotcatocanofappvlholiesez ntnoashotrahlrnotcatom hls sbobadocanoavarzlhotcenlomceomatico toanoaon bsavoepontrlnno sotclop sasi avonyntlzoetclrnocajlod sslho toesoaonlr lnoepotlics iavopaiternonwicoanor n sboncerttlrzohlftonavlnofyotclownobejlrszlstoashoslmoierderatlotakodev i lnoetclrozarultnotcatoiasoflotaddlhoperohevvarno sivwh sbotcrewbcotclonmadnozarultoashov gw h tyov slnoza sta slhofyobvefavoilstravofasunoarlstoyltoncem sboaof bohevvarongwllql ==== The 300 iteration estimate is: ==== d merocanoadrlayfongr stlyoaclayoepotcloratlno sy iatlyomfoilstradomaszoged i lnoasoaiildlrat esotcatocanomappdlyolieseu ntnoasyotraylrnotcatoh yls sbobagocanoadarulyotcenlohceohatico toanoaon bsadoepontrlnno sotclop sasi adonfntluoetclrnocajlog sslyo toesoaonlr lnoepotlics iadopaiternonwicoanor n sboncerttlruoylmtonadlnomfotclownobejlrsulstoasyoslhoiergeratlotakoged i lnoetclrouarzltnotcatoiasomlotagglyoperoyeddarno sidwy sbotcrewbcotclonhagnouarzltoasyod qw y tfod slnoua sta slyomfobdemadoilstradomasznoarlstofltonceh sboaom boyeddaronqwllvl ==== The 400 iteration estimate is: ==== domar cen edrleyf ngrosily ecley ap icl reiln osyoteily mf tlsired mesu gadotoln es ettldlreioas icei cen meppdly ltasabonin esy ireylrn icei hoylsosk keg cen ederbly icanl hca heitc oi en e noksed ap nirlnn os icl posestoed nfnilb aiclrn cezl gossly oi as e nlroln ap iltcsoted petiarn nwtc en ronosk ncariilrb ylmi nedln mf icl wn kazlrsblsi esy slh targareil iej gadotoln aiclr berulin icei tes ml ieggly par yaddern ostdwyosk icrawkc icl nhegn beruli esy doqwoyoif dosln beosieosly mf kdamed tlsired mesun erlsi fli ncahosk e mok yadder nqwllvl ==== The 500 iteration estimate is: ==== riman ted ernleyf dgnisoly etley ap otl neold isyiceoly mf clsoner mesu garicild es ecclrlneoias oteo ted mepprly lcasabidod esy oneylnd oteo hiylsisk keg ted erenbly otadl hta heoct io ed e dikser ap donldd is otl pisescier dfdolb aotlnd tezl gissly io as e dlnild ap olctsicer pecoand dwct ed nidisk dtanoolnb ylmo derld mf otl wd kazlnsblso esy slh canganeol oej garicild aotln benulod oteo ces ml oeggly pan yarrend iscrwyisk otnawkt otl dhegd benulo esy riqwiyiof risld beisoeisly mf kramer clsoner mesud enlso flo dtahisk e mik yarren dqwllvl ==== The 600 iteration estimate is: ==== riman ted ernoeyf dgnisloy etoey ap lto nelod isyiceloy mf coslner mesu gariciod es eccoronelias ltel ted mepproy ocasabidld esy lneyond ltel kiyosish heg ted erenboy ltado kta kelct il ed e dihser ap dlnodd is lto pisescier dfdlob altond tevo gissoy il as e doniod ap loctsicer pecland dwct ed nidish dtanllonb yoml derod mf lto wd havonsbosl esy sok canganelo lej gariciod alton benuold ltel ces mo leggoy pan yarrend iscrwyish ltnawht lto dkegd benuol esy riqwiyilf risod beisleisoy mf hramer coslner mesud enosl fol dtakish e mih yarren dqwoozo ==== The 700 iteration estimate is: ==== riman hed ernoelf dgnistol ehoel ap tho netod islicetol mf costner mesy gariciod es eccoronetias thet hed mepprol ocasabidtd esl tnelond thet wilosisk keg hed erenbol thado wha wetch it ed e dikser ap dtnodd is tho pisescier dfdtob athond hevo gissol it as e doniod ap tochsicer pectand duch ed nidisk dhanttonb lomt derod mf tho ud kavonsbost esl sow canganeto tez gariciod athon benyotd thet ces mo teggol pan larrend iscrulisk thnaukh tho dwegd benyot esl riquilitf risod beisteisol mf kramer costner mesyd enost fot dhawisk e mik larren dquoojo ==== The 800 iteration estimate is: ==== rimal hen erloedf nglistod ehoed ap tho leton isdicetod mf costler mesy garicion es eccoroletias thet hen mepprod ocasabintn esd tledoln thet widosisk keg hen erelbod thano wha wetch it en e nikser ap ntlonn is tho pisescier nfntob atholn hevo gissod it as e nolion ap tochsicer pectaln nuch en linisk nhalttolb domt neron mf tho un kavolsbost esd sow calgaleto tez garicion athol belyotn thet ces mo teggod pal darreln iscrudisk thlaukh tho nwegn belyot esd riquiditf rison beisteisod mf kramer costler mesyn elost fot nhawisk e mik darrel nquoojo ==== The 900 iteration estimate is: ==== rifal hen erloemd nglistom ehoem ap tho leton ismicetom fd costler fesy garicion es eccoroletias thet hen fepprom ocasabintn esm tlemoln thet wimosisk keg hen erelbom thano wha wetch it en e nikser ap ntlonn is tho pisescier ndntob atholn hevo gissom it as e nolion ap tochsicer pectaln nuch en linisk nhalttolb moft neron fd tho un kavolsbost esm sow calgaleto tez garicion athol belyotn thet ces fo teggom pal marreln iscrumisk thlaukh tho nwegn belyot esm riquimitd rison beisteisom fd krafer costler fesyn elost dot nhawisk e fik marrel nquoojo ==== The 1000 iteration estimate is: ==== rifal hes erloemy sglintom ehoem ap tho letos inmicetom fy contler fend garicios en eccoroletian thet hes fepprom ocanabists enm tlemols thet wimonink keg hes erelbom thaso wha wetch it es e sikner ap stloss in tho pinencier systob athols hevo ginnom it an e solios ap tochnicer pectals such es lisink shalttolb moft seros fy tho us kavolnbont enm now calgaleto tez garicios athol beldots thet cen fo teggom pal marrels incrumink thlaukh tho swegs beldot enm riquimity rinos beinteinom fy krafer contler fends elont yot shawink e fik marrel squoojo ==== The 1100 iteration estimate is: ==== limar hes elroedy sbrintod ehoed ap tho retos indicetod my contrel menf balicios en eccoloretian thet hes mepplod ocanagists end tredors thet widonink keb hes elergod thaso wha wetch it es e siknel ap stross in tho pinenciel systog athors hevo binnod it an e sorios ap tochnicel pectars such es risink sharttorg domt selos my tho us kavorngont end now carbareto tez balicios athor gerfots thet cen mo tebbod par dallers includink thraukh tho swebs gerfot end liquidity linos geinteinod my klamel contrel menfs eront yot shawink e mik daller squoojo ==== The 1200 iteration estimate is: ==== liber has alroady smrintod ahoad ep tho ratos indicatod by contral banf melicios an accoloratien that has bapplod ocenegists and tradors that widonink kam has alargod theso whe watch it as a siknal ep stross in tho pinancial systog ethors havo minnod it en a sorios ep tochnical pacters such as risink sherttorg dobt salos by tho us kevorngont and now cermerato taz melicios ethor garfots that can bo tammod per dellars includink threukh tho swams garfot and liquidity linos gaintainod by klebal contral banfs aront yot shewink a bik dellar squoojo ==== The 1300 iteration estimate is: ==== liber has alroady smrintod ahoad ef tho ratos indicatod by contral banv melicios an accoloratien that has bafflod ocenegists and tradors that widonink kam has alargod theso whe watch it as a siknal ef stross in tho financial systog ethors hapo minnod it en a sorios ef tochnical facters such as risink sherttorg dobt salos by tho us keporngont and now cermerato taz melicios ethor garvots that can bo tammod fer dellars includink threukh tho swams garvot and liquidity linos gaintainod by klebal contral banvs aront yot shewink a bik dellar squoojo ==== The 1400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central banv policies an acceleration that has baffled econokists and traders that widening gap has alarked those who watch it as a signal of stress in the financial systek others hame pinned it on a series of technical factors such as rising shortterk debt sales by the us gomernkent and new corporate taz policies other karvets that can be tapped for dollars including through the swaps karvet and liquidity lines kaintained by global central banvs arent yet showing a big dollar squeeje ==== The 1500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central banv policies an acceleration that has baffled econokists and traders that widening gap has alarked those who watch it as a signal of stress in the financial systek others hame pinned it on a series of technical factors such as rising shortterk debt sales by the us gomernkent and new corporate tax policies other karvets that can be tapped for dollars including through the swaps karvet and liquidity lines kaintained by global central banvs arent yet showing a big dollar squeeje ==== The 1600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central banv policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others hake pinned it on a series of technical factors such as rising shortterm debt sales by the us gokernment and new corporate tax policies other marvets that can be tapped for dollars including through the swaps marvet and liquidity lines maintained by global central banvs arent yet showing a big dollar squeeze ==== The 1700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central banv policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others hake pinned it on a series of technical factors such as rising shortterm debt sales by the us gokernment and new corporate tax policies other marvets that can be tapped for dollars including through the swaps marvet and liquidity lines maintained by global central banvs arent yet showing a big dollar squeeje ==== The 1800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central banv policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others hake pinned it on a series of technical factors such as rising shortterm debt sales by the us gokernment and new corporate tax policies other marvets that can be tapped for dollars including through the swaps marvet and liquidity lines maintained by global central banvs arent yet showing a big dollar squeeje ==== The 1900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central banv policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others hake pinned it on a series of technical factors such as rising shortterm debt sales by the us gokernment and new corporate tax policies other marvets that can be tapped for dollars including through the swaps marvet and liquidity lines maintained by global central banvs arent yet showing a big dollar squeeje ==== The 2000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 2100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 2200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 2300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 2400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeze ==== The 2500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 2600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 2700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 2800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 2900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 3000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 3100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 3200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 3300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 3400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeje ==== The 3500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 3600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 3700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 3800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 3900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 4900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haze pinned it on a series of technical factors such as rising shortterm debt sales by the us gozernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haze pinned it on a series of technical factors such as rising shortterm debt sales by the us gozernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haze pinned it on a series of technical factors such as rising shortterm debt sales by the us gozernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haje pinned it on a series of technical factors such as rising shortterm debt sales by the us gojernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haje pinned it on a series of technical factors such as rising shortterm debt sales by the us gojernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haje pinned it on a series of technical factors such as rising shortterm debt sales by the us gojernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haze pinned it on a series of technical factors such as rising shortterm debt sales by the us gozernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 5900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haze pinned it on a series of technical factors such as rising shortterm debt sales by the us gozernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others haze pinned it on a series of technical factors such as rising shortterm debt sales by the us gozernment and new corporate tav policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 6900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 7900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 8900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 9000 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 9100 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 9200 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 9300 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 9400 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe ==== The 9500 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeze ==== The 9600 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeze ==== The 9700 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeze ==== The 9800 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeze ==== The 9900 iteration estimate is: ==== libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate tax policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeeze
decode(theta)
'libor has already sprinted ahead of the rates indicated by central bank policies an acceleration that has baffled economists and traders that widening gap has alarmed those who watch it as a signal of stress in the financial system others have pinned it on a series of technical factors such as rising shortterm debt sales by the us government and new corporate taz policies other markets that can be tapped for dollars including through the swaps market and liquidity lines maintained by global central banks arent yet showing a big dollar squeexe'
There are 27 factorial different possible encodings. In a Markov chain with 10,000 iterations you check at most
10./np.math.factorial(27)
9.183689863795546e-28
fraction of all encodings.
** Exercise: ** Try other proposal distributions, such as randomly permuting 3 letters. Does this improve / worsen convergence?
** Exercise: ** Rerun this demo with a different coded message. How does you ability to recover the truth change with message length?
** Exercise: ** We computed bigram counts from "War and Peace." More generally one could compute ngrams. Try finding all 3 grams and calculating the conditional problability of any letter given the last two letters. So P(hello) = $P(h)P(e|h)P(l|he)P(l|el)P(o|ll)$.
** Exercise: ** Write a "random word generator." Here the input to the function is a character sequence length $n$ and the output is a random text sequence drawn from a 1,2,or 3 gram distribution. Random sequences from 3 gram distributions should produce character strings with many real words.
** Exercise: ** We are really more focused on the mode of the posterior than the full posterior distribution. Since the prior is flat, the mode of the posterior is equivalent to maximum likelihood estimation. Simulated tempering (Section 26.6 of Lange) is one method for finding the MLE / posterior mode for multimodal models. It shares many similarities with Metropolis. Implement simulated annealing for this problem. Does you algorithm converge more often to the correct solution than Metropolis?
Read more about this problem (and a lot of MCMC theory) in The MCMC Revolution.