Neural Sync Active
Stochastic Processes
Registry Synced
Stochastic Processes
68 words
1 min read
Reading compass
Now · Markov Chain Simulation
Stochastic Processes
Markov Chain Simulation
pythonimport numpy as np # Define transition matrix P = np.array([[0.7, 0.3], [0.4, 0.6]]) # Simulate chain n_steps = 1000 states = np.zeros(n_steps, dtype=int) for t in range(1, n_steps): states[t] = np.random.choice([0, 1], p=P[states[t-1]]) print(f"Proportion in state 0: {np.mean(states == 0):.3f}")