MarkovSet:
Filter:
MathLib/Classes (extension) | Collections > Unordered | Libraries > MathLib > Markov & Fuzzy

MarkovSet
ExtensionExtension

first order markov set

Description

MarkovSet is a Dictionary that contains keys pointing to WeighBags that contain objects and their probabilities. By parsing in a stream the Set "learns" what element can possibly follow another.1

Part of MathLib, a diverse library of mathematical functions.

Class Methods

.new

Arguments:

args

A list of arrays that each represent one node in the set:

[element, [next_elements], [weigths]]

next_elementsThe next node is searched by simple equality. If nil, this is a terminator node
weightsThe array is normalized. If weigths is nil, equal weight is used.

If args is nil, the set is created and may be trained by the other methods.

updateSeeds

If set to true, each element is always added to the seeds

.fill

Arguments:

length

Number of items to read.

stream

A function or stream that returns items to read.

Instance Methods

.read

Read a pair of values.

.put

Insert a node. Any old node is overwritten.

.remove

Remove a pair of values.

.next

Return a next item for the arg value. If arg is nil, choose from seeds.

.parse

Read length items into the set from the stream.

.asStream

Returns a stream that creates a markov chain.

Examples

direct node definition

training by a stream

training bit by bit

creating streams

supermarkov

Authors

Julian Rohrhuber, 2004, 2007.