MarkovChainSimulator

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

MarkovChainSimulator

Go Report Card Go Coverage

A Markov Chain simulator that runs against the provided yaml state configuration file.

Quick Start

Installation

This application can be installed onto the command line with the following command:

go install github.com/Kilemonn/MarkovChainSimulator@latest

Simulation Configuration

The simulation configuration, which contains the simulation states, initial state, interations and transitions between states is defined in a sample below:

initialState: A
stepCount: 100
states:
  - id: A
    transitions:
      - state: A
        chance: 0.10
      - state: B
        chance: 0.28
      - state: C
        chance: 0.62
  - id: B
    transitions:
      - state: C
        chance: 0.5
      - state: A
        chance: 0.5
  - id: C
    transitions:
      - state: A
        chance: 0.7
      - state: B
        chance: 0.3
  • initialState is used to define the state where the simulation will start from (it must match one of the defined state ids in the states array below).
  • stepCount indicates the amount of steps between states that will be performed before the simulation finishes. Once stepCount amount of state changes has occurred the simulation will finish.
  • states defines the list of states that are available in the simulation.

States are made up of the following properties:

  • id a unique ID to identify the state
  • transitions which is a list of:
    • state the state.id of the state that it can transition into from the current state
    • chance the percentage change as a float, where 1.0 is 100% and 0.0 is 0%.

All chance amounts must add up to exactly 1.0.

Usage

Lets say the above configuration is in a file called sample.yaml then we can execute the simulation against it using the following command:

MarkovChainSimulator.exe -f sample.yaml

Some example output for the above would look like the below (state order is not guaranteed in output):

A - 37/100 = 37.00%
B - 25/100 = 25.00%
C - 38/100 = 38.00%

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL