ymendel / markov

simple markov chains

This URL has Read+Write access

ymendel (author)
Mon Oct 06 16:19:28 -0700 2008
commit  f62a7fc6fff4431119386891b584e97b2cc67bfa
tree    f66a07c800d6c3a14d1bf1fe0aa3eda278cea31c
parent  de0a9e0c0fd33bfafb64ebbb85f821c22775c095
markov /
name age message
file .gitignore Thu Oct 02 19:22:01 -0700 2008 Ignoring pkg for later [ymendel]
file History.txt Mon Oct 06 16:19:28 -0700 2008 Filling out README, other housekeeping. [ymendel]
file License.txt Thu Oct 02 20:08:59 -0700 2008 Adding License.txt [ymendel]
file Manifest.txt Sun Oct 05 17:26:22 -0700 2008 Adding Array#random. Markov chains require som... [ymendel]
file README.rdoc Mon Oct 06 16:19:28 -0700 2008 Filling out README, other housekeeping. [ymendel]
file Rakefile Thu Oct 02 19:21:32 -0700 2008 Initial creation [ymendel]
directory config/ Mon Oct 06 16:19:28 -0700 2008 Filling out README, other housekeeping. [ymendel]
directory lib/ Mon Oct 06 16:19:04 -0700 2008 Allowing limit when generating. [ymendel]
directory script/ Thu Oct 02 19:21:32 -0700 2008 Initial creation [ymendel]
file setup.rb Thu Oct 02 19:21:32 -0700 2008 Initial creation [ymendel]
directory spec/ Mon Oct 06 16:19:04 -0700 2008 Allowing limit when generating. [ymendel]
directory tasks/ Thu Oct 02 19:21:32 -0700 2008 Initial creation [ymendel]
README.rdoc

markov

DESCRIPTION:

A simple Markov chain implementation.

FEATURES/PROBLEMS:

  • Presently only uses chains of length 1

SYNOPSIS:

  require 'markov'

  m = Markov.new
  words = [ ... ]
  m.add(*words)
  m.generate(10)  # => ["show", "off", "what", "Houston", "is", "far", "from", "a", "cow", "grazing"]

  m.reset

  m.add(*(1..10).to_a)
  m.add(2,4,6,8)
  m.add(1,3,5,7,9)
  m.add(1,5,7)
  m.add(2,6,10)
  m.generate  # => [2, 3, 5, 6, 10]

REQUIREMENTS:

  • Ruby

INSTALL:

  • gem install markov