Module: Musa::Markov
- Included in:
- All
- Defined in:
- lib/musa-dsl/generative/markov.rb
Overview
Markov chain generator for stochastic sequence generation.
Implements Markov chains that generate sequences of states based on probabilistic transition rules. Each state transitions to the next based on defined probabilities, creating pseudo-random but structured sequences.
Theory
A Markov chain is a stochastic model describing a sequence of possible events where the probability of each event depends only on the state attained in the previous event (memoryless property).
Transition Types
Array: Equal probability between all options
{ a: [:b, :c] }→ 50% chance of :b, 50% chance of :c
Hash: Weighted probabilities
{ a: { b: 0.2, c: 0.8 } }→ 20% :b, 80% :c- Probabilities are normalized (don't need to sum to 1.0)
Proc: Algorithmic transitions based on history
{ a: proc { |history| history.size.even? ? :b : :c } }- Proc receives full history and returns next state
Musical Applications
- Generate melodic sequences with style-based transitions
- Create rhythmic patterns with probabilistic variation
- Produce chord progressions with weighted likelihood
- Build dynamic musical structures with emergent behavior
Defined Under Namespace
Classes: Markov