14.4 Questions for the reader#
Exercise 91
Two dice. In the musical dice game attributed to Mozart, each measure is chosen by the sum of two dice (recall their distribution from Musical dice games).
What is the probability that a measure uses the snippet for a sum of \(7\)?
What is the probability that it uses the snippet for a sum of \(2\) or \(12\)?
What is the probability that every one of the \(16\) measures uses a snippet for a sum of \(6\), \(7\), or \(8\)?
Reveal solution
\(\frac{6}{36} = \frac{1}{6}\)
\(\frac{2}{36} = \frac{1}{18}\)
\(\left(\frac{4}{9}\right)^{16} \approx 2.3 \times 10^{-6}\)
Exercise 92
Unigrams and Markov chains. The first phrase of Mary Had a Little Lamb is E D C D E E E, or \(64, 62, 60, 62, 64, 64, 64\).
Fit a unigram model to this melody. What is the probability of each pitch?
What is the likelihood of the melody under this unigram model?
Fit a Markov chain to this melody. What is its transition matrix, with the states in the order C, D, E?
What is the likelihood of the melody under this Markov chain, if it always starts on E?
Reveal solution
\(P(X_i = 60) = \frac{1}{7}\), \(P(X_i = 62) = \frac{2}{7}\), and \(P(X_i = 64) = \frac{4}{7}\)
\(\frac{1024}{823{,}543} \approx \frac{1}{804}\)
\(\begin{bmatrix} 0 & 1 & 0 \\ \frac{1}{2} & 0 & \frac{1}{2} \\ 0 & \frac{1}{3} & \frac{2}{3} \end{bmatrix}\)
\(\frac{1}{27}\)
Exercise 93
Generating from a Markov chain. A Markov chain has two states, C and G. C is followed by C with probability \(\frac{1}{3}\), and by G with probability \(\frac{2}{3}\). G is always followed by C.
Starting on C, what is the probability that the chain generates C G C C?
Can the chain ever generate G G? Why or why not?
Reveal solution
\(\frac{2}{9}\)
No, since the transition from G to G has probability \(0\).
Exercise 94
The cost of context. Consider \(n\)-gram models of melodies whose alphabet is the \(12\) pitch classes, C, C♯, D, …, B.
How many probabilities does a trigram model have? How many does a \(5\)-gram model have?
How many trigrams does a melody of \(N = 100\) notes contain?
If we fit a trigram model to this melody, at most what fraction of its probabilities can be nonzero?
Reveal solution
\(1728\) and \(248{,}832\)
\(98\)
\(\frac{98}{1728} \approx 5.7\%\)
Exercise 95
Goldilocks. You fit \(n\)-gram models to a single, long piece of music, and generate new melodies from them. Describe what you would expect to hear with \(n = 1\), \(n = 2\), and \(n = 20\).
Reveal solution
With \(n = 1\), the pitches of the piece in the right proportions, but in a random order. With \(n = 2\), plausible steps from note to note that wander aimlessly. With \(n = 20\), long passages copied verbatim from the piece.
Exercise 96
Linear prediction. An LPC model of order \(K = 1\) has the coefficient \(h_1 = 0.9\).
For the signal \(x = [1.0, 1.0, 0.5]\), what are the predictions \(\hat{x}[1]\) and \(\hat{x}[2]\), and the prediction errors \(e[1]\) and \(e[2]\)?
Starting from \(x[0] = 1.0\), use the recursive filter \(x[n] = e[n] + h_1 \, x[n-1]\) and your prediction errors to recover \(x[1]\) and \(x[2]\).
Reveal solution
\(\hat{x}[1] = 0.9\) and \(\hat{x}[2] = 0.9\), so \(e[1] = 0.1\) and \(e[2] = -0.4\)
\(x[1] = 1.0\) and \(x[2] = 0.5\)
Exercise 97
Changing the pitch of a vowel. You fit an LPC filter to a vowel sung at \(110\) Hz, with \(f_s = 44{,}100\) Hz. To resynthesize the same vowel at \(220\) Hz, about how many samples apart should the impulses of your pulse train be? Should you change the filter?
Reveal solution
About \(200\) samples. No, the filter sets the vowel, not the pitch.
Exercise 98
A musical Turing test. Starting in 1981, the composer David Cope developed Experiments in Musical Intelligence (EMI), a program that composes new music in the style of a given composer [Cop96]. EMI analyzes a collection of the composer’s pieces for the patterns that characterize them, and recombines fragments of those pieces into new ones. For each pair of excerpts below, one was composed by the human composer, and the other by EMI. Can you tell which is which? (This one is just for fun.)
Two pairs of piano excerpts, in the styles of Béla Bartók and Scott Joplin.
Reveal solution
Bartók: A is Bartók’s Allegro barbaro (1911), and B is EMI’s Kosmos (after Bartók). Joplin: A is EMI’s Rag (after Joplin), and B is Joplin’s Weeping Willow (1903).