```python
from sympy import *
```


```python
q = Symbol('Pr(z_t=0|z_{t-1}=0)')
p = Symbol('Pr(z_t=0|z_{t-1}=1)')
M = Matrix([[q,1-q],[p,1-p]])
print M
P,D = M.diagonalize()
print P
print D
```

    Matrix([[Pr(z_t=0|z_{t-1}=0), -Pr(z_t=0|z_{t-1}=0) + 1], [Pr(z_t=0|z_{t-1}=1), -Pr(z_t=0|z_{t-1}=1) + 1]])
    Matrix([[1, (Pr(z_t=0|z_{t-1}=0) - 1)/Pr(z_t=0|z_{t-1}=1)], [1, 1]])
    Matrix([[1, 0], [0, Pr(z_t=0|z_{t-1}=0) - Pr(z_t=0|z_{t-1}=1)]])



```python
simplify( P*D*(P**(-1)))
D_lim = Matrix([[1,0],[0,0]])
M_lim = simplify( P*D_lim*(P**(-1)))
#(p + 1-q)
```

    Matrix([[Pr(z_t=0|z_{t-1}=1), -Pr(z_t=0|z_{t-1}=0) + 1], [Pr(z_t=0|z_{t-1}=1), -Pr(z_t=0|z_{t-1}=0) + 1]])



```python
r= Symbol('Pr(z_{t-1}=0)')
init = Matrix([[r,1-r]])

print simplify( init* M_lim)
```

    Matrix([[Pr(z_t=0|z_{t-1}=1)/(-Pr(z_t=0|z_{t-1}=0) + Pr(z_t=0|z_{t-1}=1) + 1), (-Pr(z_t=0|z_{t-1}=0) + 1)/(-Pr(z_t=0|z_{t-1}=0) + Pr(z_t=0|z_{t-1}=1) + 1)]])



```python
D_lim2 = Matrix([[1,0],[0,1]])
print simplify( init.T * P*D_lim2*(P**(-1)) )[0]
```

    Pr(z_{t-1}=0)



```python
D_lim3 = Matrix([[1,0],[0,-1]])
print simplify( init.T * P*D_lim3*(P**(-1)) )[0]
```

    (Pr(z_t=0|z_{t-1}=1)*(-Pr(z_{t-1}=0) + 1) + Pr(z_t=0|z_{t-1}=1) + Pr(z_{t-1}=0)*(Pr(z_t=0|z_{t-1}=0) - 1))/(-Pr(z_t=0|z_{t-1}=0) + Pr(z_t=0|z_{t-1}=1) + 1)



```python

```

d80fed92d5b77f09080bbfe9a4a2d42d45676683
ipynb
Jupyter Notebook
structural/diagonal.ipynb
ericschulman/creamers
880d510964ce2c74f1a3fe7ac4542a400edb096e
MIT
structural/diagonal.ipynb
ericschulman/creamers
880d510964ce2c74f1a3fe7ac4542a400edb096e
MIT
structural/diagonal.ipynb
ericschulman/creamers
880d510964ce2c74f1a3fe7ac4542a400edb096e
MIT
Qwen/Qwen-72B
1. YES
2. YES