--- # edu-7cp2 title: 'Markov exercise: Weather Model (Rust)' status: completed type: task priority: high created_at: 2026-03-10T23:30:00Z updated_at: 2026-03-10T23:30:00Z --- Write Section 4 of edu/markov.md: Exercise 1 — Weather Model\n\nLearning objectives:\n- Translate a transition matrix into a Rust struct\n- Use a weighted random draw to implement a single Markov step\n- Run a simulation and print or collect the resulting sequence\n\nContent to produce:\n- Setup instructions (new Cargo project, add rand crate)\n- Step-by-step hints:\n 1. Define the Weather enum and index conversion\n 2. Implement WeatherChain::step using rand::Rng::gen::()\n 3. Implement WeatherChain::simulate as a loop collecting states\n 4. Run with transition matrix [[0.8, 0.2], [0.4, 0.6]] from Sunny\n 5. Count sunny vs rainy days and compare to stationary distribution\n- Full reference solution (collapsed or at end)\n\nTarget: replace the stub in edu/markov.md §4