Liking cljdoc? Tell your friends :D

std.math.markov


collateclj

(collate tokens n)

generates an output probability map given a sequence

(collate (seq "AEAEAAAAAEAAAAAAEEAEEAEAEEEAAAEAAAA") 3) => '{(\A \E \A) {\E 2, \A 3}, (\E \A \E) {\A 2, \E 2}, (\E \A \A) {\A 4}, (\A \A \A) {\A 6, \E 3}, (\A \A \E) {\A 2, \E 1}, (\A \E \E) {\A 2, \E 1}, (\E \E \A) {\E 2, \A 1}, (\E \E \E) {\A 1}}

generates an output probability map given a sequence

(collate (seq "AEAEAAAAAEAAAAAAEEAEEAEAEEEAAAEAAAA") 3)
=> '{(\A \E \A) {\E 2, \A 3},
     (\E \A \E) {\A 2, \E 2},
     (\E \A \A) {\A 4},
     (\A \A \A) {\A 6, \E 3},
     (\A \A \E) {\A 2, \E 1},
     (\A \E \E) {\A 2, \E 1},
     (\E \E \A) {\E 2, \A 1},
    (\E \E \E) {\A 1}}
raw docstring

cumulativeclj

(cumulative probabilities)

Reassemble the map of probabilities in cumulative order

Reassemble the map of probabilities in cumulative order
raw docstring

generateclj

(generate probabilities-matrix)
(generate state probabilities-matrix)

generate takes a probability matrix, and produces an infinite stream of tokens, taking into consideration any remembered state

(->> (collate (seq "AEAEAAAAAEAAAAAAEEAEEAEAEEEAAAEAAAA") 1) (generate) (take 10) (apply str)) ;; "EAAAEAAAAE" => string?

generate takes a probability matrix, and produces an infinite stream of 
tokens, taking into consideration any remembered state

 (->> (collate (seq "AEAEAAAAAEAAAAAAEEAEEAEAEEEAAAEAAAA") 1)
      (generate)
      (take 10)
      (apply str))
 ;; "EAAAEAAAAE"
 => string?
raw docstring

selectclj

(select probabilities)
(select r probabilities)

Given a map of probabilities, select one at random.

Given a map of probabilities, select one at random.
raw docstring

tallyclj

(tally x)

helper function for collate

helper function for collate
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close