# Solution {-}

PVA Markov model


```python
from sympy import Matrix, symbols, sqrt, eye, integrate, inverse_laplace_transform

s, dt, beta, q = symbols('s dt beta q', positive=True)

F = Matrix([[0, 1, 0],
            [0, 0, 1],
            [0, 0, -beta]])

G = Matrix([[0],
            [0],
            [sqrt(q)]])

phi = inverse_laplace_transform((s*eye(3) - F).inv(), s, dt)
phi
```




$\displaystyle \left[\begin{matrix}1 & dt & \frac{dt}{\beta} - \frac{1}{\beta^{2}} + \frac{e^{- \beta dt}}{\beta^{2}}\\0 & 1 & \frac{1}{\beta} - \frac{e^{- \beta dt}}{\beta}\\0 & 0 & e^{- \beta dt}\end{matrix}\right]$




```python
# Process noise
Q = integrate(phi@G@G.T@phi.T, dt)
Q
```




$\displaystyle \left[\begin{matrix}\frac{dt^{3} q}{3 \beta^{2}} - \frac{dt^{2} q}{\beta^{3}} + \frac{dt q}{\beta^{4}} + \frac{- 4 \beta^{5} dt q e^{- \beta dt} - \beta^{4} q e^{- 2 \beta dt}}{2 \beta^{9}} & \frac{dt^{2} q}{2 \beta^{2}} - \frac{dt q}{\beta^{3}} + \frac{\beta^{4} q e^{- 2 \beta dt} + \left(2 \beta^{5} dt q - 2 \beta^{4} q\right) e^{- \beta dt}}{2 \beta^{8}} & \frac{- 2 \beta^{3} dt q e^{- \beta dt} - \beta^{2} q e^{- 2 \beta dt}}{2 \beta^{5}}\\\frac{dt^{2} q}{2 \beta^{2}} - \frac{dt q}{\beta^{3}} + \frac{\beta^{4} q e^{- 2 \beta dt} + \left(2 \beta^{5} dt q - 2 \beta^{4} q\right) e^{- \beta dt}}{2 \beta^{8}} & \frac{dt q}{\beta^{2}} + \frac{4 \beta^{3} q e^{- \beta dt} - \beta^{3} q e^{- 2 \beta dt}}{2 \beta^{6}} & \frac{- 2 \beta^{2} q e^{- \beta dt} + \beta^{2} q e^{- 2 \beta dt}}{2 \beta^{4}}\\\frac{- 2 \beta^{3} dt q e^{- \beta dt} - \beta^{2} q e^{- 2 \beta dt}}{2 \beta^{5}} & \frac{- 2 \beta^{2} q e^{- \beta dt} + \beta^{2} q e^{- 2 \beta dt}}{2 \beta^{4}} & - \frac{q e^{- 2 \beta dt}}{2 \beta}\end{matrix}\right]$




```python
from numpy import array, sqrt
from lib.vanloan import numeval

# System conditions
dt = 0.1
beta = 0.2
q = 10

F = array([[0, 1, 0],
           [0, 0, 1],
           [0, 0, -beta]])

G = array([[0],
           [0],
           [sqrt(q)]])

# Numerical evaulation
[phi, Q] = numeval(F, G, dt)

# Transition matrix
print(phi)

# Process noise covariance matrix
print(Q)
```

    [[1.         0.1        0.00496683]
     [0.         1.         0.09900663]
     [0.         0.         0.98019867]]
    [[4.94483906e-06 1.23347134e-04 1.63369713e-03]
     [1.23347134e-04 3.28379669e-03 4.90115674e-02]
     [1.63369713e-03 4.90115674e-02 9.80264021e-01]]


9177054d654d73dc35b649313bd3b715014ca8fe
ipynb
Jupyter Notebook
Problem 4.3.ipynb
mfkiwl/GMPE340
3602b8ba859a2c7db2cab96862472597dc1ac793
MIT
Problem 4.3.ipynb
mfkiwl/GMPE340
3602b8ba859a2c7db2cab96862472597dc1ac793
MIT
Problem 4.3.ipynb
mfkiwl/GMPE340
3602b8ba859a2c7db2cab96862472597dc1ac793
MIT
Qwen/Qwen-72B
1. YES
2. YES