You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear John,
This pull request updates the Markov chain animation for different initial distributions.
In addition, this pull request also updates the descriptions of the code.
The previous pull request #492 can be closed as this one has no merge conflict.
Best,
Longye
Copy file name to clipboardExpand all lines: lectures/markov_chains_I.md
+28-23Lines changed: 28 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -812,43 +812,48 @@ P = np.array([[0.971, 0.029, 0.000],
812
812
P @ P
813
813
```
814
814
815
-
Let's pick an initial distribution $\psi_0$ and trace out the sequence of distributions $\psi_0 P^t$ for $t = 0, 1, 2, \ldots$
815
+
Let's pick some initial distributions $\psi_1, \psi_2, \psi_3$ and trace out the sequence of distributions $\psi_iP^t$ for $t = 0, 1, 2, \ldots$ and $i=1, 2, 3$.
816
816
817
-
First, we write a function to iterate the sequence of distributions for `ts_length` period
818
817
819
818
```{code-cell} ipython3
820
-
def iterate_ψ(ψ_0, P, ts_length):
821
-
n = len(P)
822
-
ψ_t = np.empty((ts_length, n))
823
-
ψ_t[0 ]= ψ_0
824
-
for t in range(1, ts_length):
825
-
ψ_t[t] = ψ_t[t-1] @ P
826
-
return ψ_t
827
-
```
819
+
ψ_1 = (0.0, 0.0, 1.0)
820
+
ψ_2 = (1.0, 0.0, 0.0)
821
+
ψ_3 = (0.0, 1.0, 0.0) # Three initial conditions
822
+
colors = ['blue','red', 'green'] # Different colors for each initial point
0 commit comments