Skip to main content

Crate use_random_walk

Crate use_random_walk 

Source
Expand description

Repeatable one-dimensional random walk helpers.

The walk uses SimulationSeed to derive deterministic left and right moves so repeated runs with the same configuration produce the same path.

§Examples

use use_random_walk::{random_walk, summarize_walk, RandomWalkConfig};
use use_seed::SimulationSeed;

let path = random_walk(RandomWalkConfig {
    start: 0.0,
    step_size: 1.0,
    steps: 4,
    seed: SimulationSeed::new(5),
})
.unwrap();
let summary = summarize_walk(&path).unwrap();

assert_eq!(path.len(), 5);
assert_eq!(summary.final_position, *path.last().unwrap());

Structs§

RandomWalkConfig
RandomWalkSummary

Enums§

RandomWalkError

Functions§

random_walk
summarize_walk