@@ -255,8 +255,6 @@ Then we can address a range of questions, such as
255255
256256We'll cover such applications below.
257257
258-
259-
260258### Defining Markov Chains
261259
262260So far we've given examples of Markov chains but now let's define them more
@@ -308,9 +306,6 @@ chain $\{X_t\}$ as follows:
308306
309307By construction, the resulting process satisfies {eq}` mpp ` .
310308
311-
312-
313-
314309## Simulation
315310
316311``` {index} single: Markov Chains; Simulation
@@ -864,10 +859,8 @@ Importantly, the result is valid for any choice of $\psi_0$.
864859
865860Notice that the theorem is related to the law of large numbers.
866861
867- TODO -- link to our undergrad lln and clt lecture
868-
869862It tells us that, in some settings, the law of large numbers sometimes holds even when the
870- sequence of random variables is not IID.
863+ sequence of random variables is [ not IID] ( iid_violation ) .
871864
872865
873866(mc_eg1-2)=
@@ -919,7 +912,7 @@ for i in range(n_state):
919912 axes[i].set_xlabel('t')
920913 axes[i].set_ylabel(fr'average time spent at {i}')
921914
922- # Compute the fraction of time spent, for each x
915+ # Compute the fraction of time spent, starting from different x_0s
923916 for x0, col in ((0, 'blue'), (1, 'green'), (2, 'red')):
924917 # Generate time series that starts at different x0
925918 X = mc.simulate(n, init=x0)
948941The diagram of the Markov chain shows that it is ** irreducible**
949942
950943``` {code-cell} ipython3
944+ :tags: [hide-input]
945+
951946dot = Digraph(comment='Graph')
952947dot.attr(rankdir='LR')
953948dot.node("0")
@@ -1077,6 +1072,7 @@ In the case of Hamilton's Markov chain, the distribution $\psi P^t$ converges to
10771072P = np.array([[0.971, 0.029, 0.000],
10781073 [0.145, 0.778, 0.077],
10791074 [0.000, 0.508, 0.492]])
1075+
10801076# Define the number of iterations
10811077n = 50
10821078n_state = P.shape[0]
@@ -1096,7 +1092,7 @@ for i in range(n):
10961092# Loop through many initial values
10971093for x0 in x0s:
10981094 x = x0
1099- X = np.zeros((n,n_state))
1095+ X = np.zeros((n, n_state))
11001096
11011097 # Obtain and plot distributions at each state
11021098 for t in range(0, n):
@@ -1294,7 +1290,7 @@ In this exercise,
12941290
129512911. show this process is asymptotically stationary and calculate the stationary distribution using simulations.
12961292
1297- 1. use simulation to show ergodicity.
1293+ 1. use simulations to demonstrate ergodicity of this process .
12981294
12991295````
13001296
@@ -1322,7 +1318,7 @@ codes_B = ( '1','2','3','4','5','6','7','8')
13221318np.linalg.matrix_power(P_B, 10)
13231319```
13241320
1325- We find rows transition matrix converge to the stationary distribution
1321+ We find rows of transition matrix converge to the stationary distribution
13261322
13271323``` {code-cell} ipython3
13281324mc = qe.MarkovChain(P_B)
@@ -1353,7 +1349,7 @@ ax.legend()
13531349plt.show()
13541350```
13551351
1356- We can see that the time spent at each state quickly converges to the stationary distribution.
1352+ Note that the average time spent at each state quickly converges to the stationary distribution.
13571353
13581354``` {solution-end}
13591355```
@@ -1451,10 +1447,9 @@ However, another way to verify irreducibility is by checking whether $A$ satisfi
14511447
14521448Assume A is an $n \times n$ $A$ is irreducible if and only if $\sum_{k=0}^{n-1}A^k$ is a positive matrix.
14531449
1454- (see more at \cite{zhao_power_2012} and [here](https://math.stackexchange.com/questions/3336616/how-to-prove-this-matrix-is-a-irreducible-matrix))
1450+ (see more: {cite}`zhao_power_2012` and [here](https://math.stackexchange.com/questions/3336616/how-to-prove-this-matrix-is-a-irreducible-matrix))
14551451
14561452Based on this claim, write a function to test irreducibility.
1457-
14581453```
14591454
14601455``` {solution-start} mc_ex3
0 commit comments