这题要好好做还是要花一点时间,我只做第一问,后面的你自己再加一点就好了。
先上第一问的答案
Let $X_{ij}$ be a Bernoulli random variable where
\begin{align*}
x_{ij} = \begin{cases} 1 \text{ if cell $(i,j)$ is empty at time 1}\\ 0 \text{ if cell $(i,j)$ is nonempty at time 1, }\end{cases}
\end{align*}
then we know that $E[X_{ij}] = p_{ij}$, where $p_{ij}$ is the probability that cell $(i,j)$ is empty at time 1.
There are 3 types of cells: Cell with 2 neighbors (corner cells: (0,0),(0,3),(3,0),(3,3))
\begin{align*}
p_{00} &= P(\text{mouse in cell (0,1) does not jump to (0,0)})\times P(\text{mouse in cell (1,0) does not jump to (0,0)})\\
&= \frac{2}{3}\times \frac{2}{3} = \frac{4}{9}.
\end{align*}
So by similar reasoning we have
\begin{align*}
p_{30} = \frac{4}{9},\quad p_{03} = \frac{4}{9},\quad p_{33} = \frac{4}{9}.
\end{align*}
Cell with 3 neighbors (boarder cells: (0,1)(0,2),(1,0),(2,0),(3,1)(3,2),(1,3),(2,3))
\begin{align*}
p_{01} =& P(\text{mouse in cell (0,0) does not jump to (0,1)})\times P(\text{mouse in cell (1,1) does not jump to (0,1)})\\ &\times P(\text{mouse in cell (0,2) does not jump to (0,1)})\\
=& \frac{1}{2}\times \frac{3}{4}\times \frac{2}{3} = \frac{1}{4}.
\end{align*}
So by similar reasoning we have
\begin{align*}
p_{01} = p_{02} = p_{10} = p_{20} = p_{31} = p_{31} = p_{13} = p_{23} = \frac{1}{4}.
\end{align*}
Cell with 4 neighbors (boarder cells: (1,1)(1,2),(2,1),(2,2))
\begin{align*}
p_{01} =& P(\text{mouse in cell (0,1) does not jump to (1,1)})\times P(\text{mouse in cell (1,0) does not jump to (1,1)})\\ &\times P(\text{mouse in cell (1,2) does not jump to (1,1)})\times P(\text{mouse in cell (2,1) does not jump to (1,1)})\\
=& \frac{2}{3}\times \frac{2}{3}\times \frac{3}{4}\times \frac{3}{4} = \frac{1}{4}.
\end{align*}
So by similar reasoning we have
\begin{align*}
p_{11} = p_{12} = p_{21} = p_{22} = \frac{1}{4}.
\end{align*}
Now, let $Y$ be the random variable of the number of empty cells at time 1, then we have
\begin{align*}
E[Y] = E\left[\sum\limits_{i=0}^3\sum\limits_{j=0}^3X_{ij}\right] = \sum\limits_{i=0}^3\sum\limits_{j=0}^3E[X_{ij}] = \sum\limits_{i=0}^3\sum\limits_{j=0}^3p_{ij} = \frac{43}{9} \approx 4.78.
\end{align*}
再给你贴一段验证第一问答案的代码
- import random
- possible_moves = [[-1, 0], [1, 0], [0, -1], [0, 1]]
- def is_valid(i, j):
- return i >= 0 and i <= 3 and j >= 0 and j <= 3
- def moves(i, j):
- res = []
- for k in possible_moves:
- s, t = k
- if is_valid(i + s, t + j):
- res.append([i + s, t + j])
- return res
- def print_board(a):
- for i in range(len(a)):
- print
- for j in range(len(a[0])):
- print a[i][j],
- print
- print
- def count_zeros(a):
- res = 0
- for i in range(len(a)):
- for j in range(len(a[0])):
- if a[i][j] == 0:
- res += 1
- return res
- total_zeros = 0
- experiment = 10000
- for k in range(experiment):
- a = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]
- print_board(a)
- for i in range(4):
- for j in range(4):
- moves_set = moves(i, j)
- b = random.randint(0, len(moves_set) - 1)
- a[i][j] -= 1
- m_a, m_b = moves_set[b]
- a[m_a][m_b] += 1
- # print_board(a)
- # print count_zeros(a)
- total_zeros += count_zeros(a)
- print total_zeros
- print total_zeros / float(experiment)
复制代码
实验10000次得到的第一问的答案是4.7732.
第二三问都需要simulation了,在我贴的代码基础上再加改进就好。