COMP 200 Elements of Computer Science &
COMP 130 Elements of Algorithms and Computation
Spring 2012

Markov Chain Analysis of the Beatles' Eight Days a Week

These lyrics generate the following chains and sample riffs.

1st-Order Markov Chains

The probabilities

The following assumes that we split the text into case-sensitive words and ignore whitespace and punctuation. The 1-word sequences are listed in alphabetical order.

{('One',): {'thing': 1.0},
 ('the',): {'time': 1.0},
 ('Hold',): {'me': 1.0},
 ('on',): {'my': 1.0},
 ('my',): {'love': 0.5, 'mind': 0.5},
 ('guess',): {'you': 1.0},
 ('I',): {'I': 0.09090909090909091, 'need': 0.36363636363636365, 'love': 0.18181818181818182, 'can': 0.18181818181818182, 'care': 0.18181818181818182},
 ('Hope',): {'you': 1.0},
 ('like',): {'I': 1.0},
 ('me',): {',': 1.0},
 ('to',): {'show': 1.0},
 ('need',): {'you': 0.3333333333333333, 'my': 0.3333333333333333, 'your': 0.3333333333333333},
 ('but',): {'love': 1.0},
 ('girl',): {',': 1.0},
 ("nothin'",): {'but': 1.0},
 ('day',): {'girl': 1.0},
 ("ev'ry",): {'day': 1.0},
 ("it's",): {'true': 1.0},
 ('babe',): {',': 0.75, 'just': 0.25},
 ('care',): {'.': 1.0},
 ('show',): {'I': 1.0},
 ('say',): {'girl': 1.0},
 ('Ooh',): {'I': 1.0},
 ("Ain't",): {'got': 1.0},
 ('.',): {'Love': 0.2857142857142857, 'Eight': 0.5714285714285714, 'Ooh': 0.14285714285714285},
 ('you',): {'need': 0.16666666666666666, 'all': 0.16666666666666666, 'know': 0.16666666666666666, "ev'ry": 0.16666666666666666, ',': 0.3333333333333333},
 ('know',): {"it's": 1.0},
 ('a',): {'week': 1.0},
 ('Love',): {'you': 1.0},
 ('is',): {'not': 1.0},
 ('week',): {'I': 0.2, 'is': 0.2, '.': 0.6},
 ('thing',): {'I': 1.0},
 ('mind',): {',': 1.0},
 ('enough',): {'to': 1.0},
 ('not',): {'enough': 1.0},
 (',',): {'guess': 0.05555555555555555, 'love': 0.2777777777777778, 'always': 0.05555555555555555, 'One': 0.05555555555555555, 'Eight': 0.16666666666666666, "Ain't": 0.1111111111111111, 'Hold': 0.2222222222222222, 'Hope': 0.05555555555555555},
 ('Eight',): {'days': 1.0},
 ('can',): {'say': 1.0},
 ('true',): {',': 1.0},
 ('time',): {',': 1.0},
 ('all',): {'the': 1.0},
 ('your',): {'love': 1.0},
 ('always',): {'on': 1.0},
 ('love',): {'me': 0.4, 'you': 0.2, 'babe': 0.4},
 ('just',): {'like': 1.0},
 ('days',): {'a': 1.0},
 ('got',): {"nothin'": 1.0}}

Sample riffs

say girl , love babe , Eight days a week is not enough to show I I need your love me , Ain't got nothin' but love babe , Eight days a week . Love you , love babe , Hold me , love babe , love you , always on my love me , Eight days a week . Eight days a week . Eight days a week . Love you need you , Hold me , Eight days a week . Love you all the time , Hold me , love me , love babe , love babe

you need you , love me , love babe , Eight days a week . Love you , Eight days a week . Eight days a week . Eight days a week I need my love me , Hold me , Hold me , Eight days a week . Eight days a week is not enough to show I care . Eight days a week is not enough to show I care . Love you all the time , love you know it's true , Eight days a week is not enough to show I need my mind , One

2nd-Order Markov Chain

The probabilities

{('Eight', 'days'): {'a': 1.0},
 ('love', 'babe'): {',': 0.75, 'just': 0.25},
 ("Ain't", 'got'): {"nothin'": 1.0},
 ('always', 'on'): {'my': 1.0},
 ('me', ','): {'love': 0.5, 'Hold': 0.25, "Ain't": 0.25},
 ('got', "nothin'"): {'but': 1.0},
 (',', 'One'): {'thing': 1.0},
 ('Ooh', 'I'): {'need': 1.0},
 ('enough', 'to'): {'show': 1.0},
 ('say', 'girl'): {',': 1.0},
 ('is', 'not'): {'enough': 1.0},
 ('Hope', 'you'): {'need': 1.0},
 (',', 'Eight'): {'days': 1.0},
 ('my', 'mind'): {',': 1.0},
 ('your', 'love'): {'babe': 1.0},
 ('you', ','): {'Hold': 0.5, 'Eight': 0.5},
 ('One', 'thing'): {'I': 1.0},
 ('know', "it's"): {'true': 1.0},
 ('you', 'need'): {'my': 1.0},
 ('you', 'know'): {"it's": 1.0},
 ('.', 'Love'): {'you': 1.0},
 ('babe', 'just'): {'like': 1.0},
 ('to', 'show'): {'I': 1.0},
 (',', 'love'): {'me': 0.8, 'you': 0.2},
 ('you', 'all'): {'the': 1.0},
 ('mind', ','): {'One': 1.0},
 (',', 'Hope'): {'you': 1.0},
 (',', 'always'): {'on': 1.0},
 ('girl', ','): {'always': 0.5, 'love': 0.5},
 ('time', ','): {'Hold': 1.0},
 ('can', 'say'): {'girl': 1.0},
 ('like', 'I'): {'need': 1.0},
 ('all', 'the'): {'time': 1.0},
 ('.', 'Ooh'): {'I': 1.0},
 (',', 'guess'): {'you': 1.0},
 ('not', 'enough'): {'to': 1.0},
 ('week', '.'): {'Love': 0.2, 'Eight': 0.8},
 ('.', 'Eight'): {'days': 1.0},
 ('but', 'love'): {'babe': 1.0},
 ('need', 'need'): {'your': 1.0},
 ('I', 'love'): {'you': 1.0},
 ('thing', 'I'): {'can': 1.0},
 ("ev'ry", 'day'): {'girl': 1.0},
 ('babe', ','): {'guess': 0.3333333333333333, 'Eight': 0.6666666666666666},
 ('love', 'you'): {'all': 0.5, ',': 0.5},
 ('a', 'week'): {'I': 0.2, 'is': 0.2, '.': 0.6},
 ("it's", 'true'): {',': 1.0},
 ('true', ','): {'Hope': 1.0},
 ('week', 'I'): {'love': 1.0},
 ('the', 'time'): {',': 1.0},
 (',', "Ain't"): {'got': 1.0},
 ('guess', 'you'): {'know': 1.0},
 ('Hold', 'me'): {',': 1.0},
 ('I', 'need'): {'need': 0.25, 'you': 0.5, 'your': 0.25},
 ('my', 'love'): {'babe': 1.0},
 ('need', 'your'): {'love': 1.0},
 ('need', 'you'): {',': 1.0},
 ('need', 'my'): {'love': 1.0},
 ('show', 'I'): {'care': 1.0},
 ("nothin'", 'but'): {'love': 1.0},
 ('I', 'can'): {'say': 1.0},
 ('care', '.'): {'Love': 0.5, 'Ooh': 0.5},
 ('I', 'care'): {'.': 1.0},
 (',', 'Hold'): {'me': 1.0},
 ('Love', 'you'): {"ev'ry": 1.0},
 ('you', "ev'ry"): {'day': 1.0},
 ('just', 'like'): {'I': 1.0},
 ('on', 'my'): {'mind': 1.0},
 ('love', 'me'): {',': 1.0},
 ('day', 'girl'): {',': 1.0},
 ('days', 'a'): {'week': 1.0},
 ('week', 'is'): {'not': 1.0}}

Sample riffs

Since almost all of the keys have only one option for the successor word, riffs will look a lot like the original text.

", Hold me , Hold me , Ain't got nothin' but love babe just like I need you , Eight days a week . Love you ev'ry day girl , love you , Eight days a week is not enough to show I care . Love you ev'ry day girl , always on my mind , One thing I can say girl , love me , love me , love me , Hold me , love me , Ain't got nothin' but love babe , Eight days a week . Eight days a week . Love you ev'ry day girl"

"Hold me , Ain't got nothin' but love babe , Eight days a week . Eight days a week is not enough to show I care . Ooh I need you , Eight days a week . Love you ev'ry day girl , love you , Eight days a week is not enough to show I care . Ooh I need need your love babe , Eight days a week I love you , Eight days a week is not enough to show I care . Love you ev'ry day girl , love me , love you , Hold me"