Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

15
Andrei Andreyevich Markov 1856 - 1922 QuickTime TIFF (Uncomp are needed t

Transcript of Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Page 1: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Andrei Andreyevich Markov 1856 - 1922Andrei Andreyevich Markov 1856 - 1922

QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.

Page 2: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Markov ChainsMarkov Chains

Page 3: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

ProbabilityProbability

• Typically measured between 0.0 and 1.0• For events following another event must

total 1.0• Important in statistics• Be careful in establishing (e.g., the

probability of heads up on a tossed coin is forever 0.5 no matter how many times the coin is tossed).

• Americans have 2.5 children

Page 4: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Zero order Markov Chain

Pseudo-random choices.

Zero order Markov Chain

Pseudo-random choices.

Page 5: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

First order Markov Chain

indicates that the current event will effect the choice

of the following event.

First order Markov Chain

indicates that the current event will effect the choice

of the following event.

Page 6: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

First order state transition matrix First order state transition matrix (stm)(stm)

A

B

C

A B C

.5 .5 0

.5 0 .5

0 .5 .5

Page 7: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Second order Markov chain

Two successive events will influence the next event

Second order Markov chain

Two successive events will influence the next event

Page 8: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

A B C

AA

AB

AC

BA

BB

BC

CA

CB

CC

0 1.0 0

.3 .3 .4

0 .2 .8

0 .6 .4

.2 .5 .3

0 1.0 0

.7 .2 .1

.1 .4 .5

.2 .8 0

Page 9: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Markov ChainsMarkov Chains

• Are a type of grammar (syntax)• Many types of grammars (e.g., finite state,

recursive, augmented transition, etc.)• These are typically linear• Robust grammars require hierarchy• Hierarchy is non-linear

Page 10: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Markov AnalysisMarkov Analysis

• Select data

• Extract pitches

• Place pitches in STM

• Create code for doing above

Page 11: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Details Details

• Some cope-events:

’((0 60 1000 1 127) (1000 60 1000 1 127)(2000 62 1000 1 127)

(3000 61 1000 1 127)(4000 60 1000 1 127)(5000 60 1000 1 127))

• Get the pitches: (mapcar #’second . . . .) = (60 60 62 61 60 60)

• Place in an stm (defvar *stm* ())

• Data can look like this

((60 (60 61 60))

(62 (61))

(61 (60)))

which equates to: QuickTime™ and a

TIFF (Uncompressed) decompressorare needed to see this picture.

Page 12: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Code detailsCode details

• Create a blank *stm*

• Create a function that adds stuff to *stm*

• Create two sub functions

1) that adds a new entry if none exists

2) adds a new following pitch to an

existing entry if one does exist

Page 13: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

NeedsNeeds

• “assoc” is a good function for testing whether or not an entry is present in a composite list as in

• (assoc 2 '((1 (2 2))(2 (3 3))) :test #'equal)

which returns

(2 (3 3))

Page 14: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Also Also

• (substitute ‘(2 (3 3 3)) '(2 (3 3)) '((1 (2 2))(2 (3 3))) :test #'equal) returns

((1 (2 2)) (2 (3 3 3)))

But “substitute” is not destructive. That is, “substitute” does not actually alter a global variable, you’ll have to reset the variable yourself. In other words, if:

(defvar *stm* ‘((2 (3 3))(4 (5 5)))) and you do (substitute ‘(4 (5 5 6)) ‘(4 (5 5)) *stm* :test #’equal) *stm* will remain the same you’ll have to (setf *stm* (substitute ‘(4 (5 5 6) ‘(4 (5 5)) *stm* :test #’equal))

Page 15: Andrei Andreyevich Markov 1856 - 1922. Markov Chains.

Markov CompositionMarkov Composition

• Use an STM

• Select first pitch randomly (careful)

• Continue until unable to proceed