Crates.io | entromatica |
lib.rs | entromatica |
version | 2.3.0 |
source | src |
created_at | 2022-12-18 17:57:14.577412 |
updated_at | 2023-05-17 08:37:22.581051 |
description | Entromatica is a library for constructing, simulating and analyzing markov chains. |
homepage | https://entromatica.com |
repository | https://github.com/DanielMeiborg/entromatica |
max_upload_size | |
id | 740525 |
size | 91,294 |
Entromatica is a library for constructing, simulating and analyzing markov chains.
It is split into two main parts: the simulation
module and the models
module
collection.
The simulation
module contains primarily the Simulation
struct, which takes
an initial state and a StateTransitionGenerator
. This generator is a function
that takes a state and returns a list of the next states in the markov chain
with their respective relative probabilities.
The models
module contains a collection of structs and functions that try
to make constructing the state transition generator easier. Currently this
includes only a single model: rules
.
// This is a simple onedimensional random walk
use entromatica::prelude::*;
use std::sync::Arc;
// The initial state. It has to be Hash + Clone + Send + Sync + PartialEq + Eq + Debug
let initial_state: i32 = 0;
// The state transition generator. The simulation panics if the probabilities don't sum up to 1.0
let state_transition_generator =
Arc::new(|state: i32| vec![(state + 1, "next", 0.5), (state - 1, "previous", 0.5)]);
let mut simulation = Simulation::new(initial_state, state_transition_generator);
// The Shannon-entropy at the given time
assert_eq!(simulation.entropy(0), 0.0);
simulation.next_step();
assert_eq!(simulation.entropy(1), 1.0);
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.