markov-analyze sequence &key :order :format :stream :table-column-width :table-indent :sort :slot :key [Function]

Performs an analysis of the data in sequence and either prints or returns the results according to :format and :stream.

markov-analyze supports the following keywork arguments.

:stream { t | nil | stream}
If t, the results of the analysis are printed on *standard-output*. This is the default. nil means that no results are printed, but still (possibly) returned to the user as the value of the function. Otherwise, :stream should be the Lisp stream object to print the results on.
:format {:table | :markov | t | :graph}
If the value of :format is :table, a transition table detailing the distribution of weighted random outcomes is constructed and printed to the :stream. (If :format is :table, :stream may not be nil.) If the value of :format is :markov, a Lisp expression is constructed which, when evaluated, will create a markov item stream to generate new output according to the transition table discovered by the analysis. If the value of :format is t, the table is printed and the markov pattern is returned as the value. This is the default behavior for :format. If :format is :graph, a graph pattern description is returned as the value.
:order {number}
The order of the Markov analysis, defaults to 1.
:table-column-width {number}
Allows explict control over the table's cell width, normally determined automatically from the analysis.
:table-indent {number}
Provides explicitcontrol over the starting left position of the table, normally determined automatically by the analysis.
:sort
provides explicit control of the order of columns in the table, normally determined automatically by the funcion. If specified it should be a list of labels to print or a function suitable for passing to the sort function.
:key {function}
An optional Lisp function to be applied to each item in sequence to return the actual values to be analyzed.
:slot {slotname}
Applied to each object in sequence to access values in the the slot named slotname.

Example:

? (setf happy-birthday (notes c4 c d c f e c c d c g f
                              c c c5 a4 f e d bf bf a f g f))
#<CYCLIC-NOTE-STREAM #xD41111>

? (markov-analyze (read-items happy-birthday) :order 2)

         D4    C4    F4    E4    G4    C5    A4    BF4   
(D4 C4)   ----- ----- 0.500 ----- 0.500 ----- ----- ----- 
(D4 BF4)  ----- ----- ----- ----- ----- ----- ----- 1.000 
(C4 D4)   ----- 1.000 ----- ----- ----- ----- ----- ----- 
(C4 C4)   0.667 ----- ----- ----- ----- 0.333 ----- ----- 
(C4 F4)   ----- ----- ----- 1.000 ----- ----- ----- ----- 
(C4 G4)   ----- ----- 1.000 ----- ----- ----- ----- ----- 
(C4 C5)   ----- ----- ----- ----- ----- ----- 1.000 ----- 
(F4 C4)   ----- 1.000 ----- ----- ----- ----- ----- ----- 
(F4 E4)   0.500 0.500 ----- ----- ----- ----- ----- ----- 
(F4 G4)   ----- ----- 1.000 ----- ----- ----- ----- ----- 
(E4 D4)   ----- ----- ----- ----- ----- ----- ----- 1.000 
(E4 C4)   ----- 1.000 ----- ----- ----- ----- ----- ----- 
(G4 F4)   ----- 1.000 ----- ----- ----- ----- ----- ----- 
(C5 A4)   ----- ----- 1.000 ----- ----- ----- ----- ----- 
(A4 F4)   ----- ----- ----- 0.500 0.500 ----- ----- ----- 
(BF4 A4)  ----- ----- 1.000 ----- ----- ----- ----- ----- 
(BF4 BF4) ----- ----- ----- ----- ----- ----- 1.000 ----- 

(MARKOV (D4 C4 -> (F4 0.5) (G4 0.5))
        (D4 BF4 -> (BF4 1.0))
        (C4 D4 -> (C4 1.0))
        (C4 C4 -> (D4 0.6666666666666666) (C5 0.3333333333333333))
        (C4 F4 -> (E4 1.0))
        (C4 G4 -> (F4 1.0))
        (C4 C5 -> (A4 1.0))
        (F4 C4 -> (C4 1.0))
        (F4 E4 -> (C4 0.5) (D4 0.5))
        (F4 G4 -> (F4 1.0))
        (E4 D4 -> (BF4 1.0))
        (E4 C4 -> (C4 1.0))
        (G4 F4 -> (C4 1.0))
        (C5 A4 -> (F4 1.0))
        (A4 F4 -> (E4 0.5) (G4 0.5))
        (BF4 A4 -> (F4 1.0))
        (BF4 BF4 -> (A4 1.0)))

See Also:

graph, markov


Last Modified: 5-Mar-1998