pfjax.models.bm_model
Classes:
| Name | Description |
|---|---|
BMModel |
Brownian motion state space model. |
BMModel
Bases: BaseModel
Brownian motion state space model.
The model is:
::
x_0 ~ pi(x_0) \propto 1
x_t ~ N(x_{t-1} + mu dt, sigma^2 dt)
y_t ~ N(x_t, tau^2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
Interobservation time. |
required | |
unconstrained_theta
|
Whether or not to use the regular parameters scale |
False
|
Methods:
| Name | Description |
|---|---|
state_lpdf |
Calculates the log-density of |
state_sample |
Samples from |
meas_lpdf |
Log-density of |
meas_sample |
Sample from |
pf_init |
Get particles for initial state |
loglik_exact |
Marginal loglikelihood of the BM model. |
Source code in src/pfjax/models/bm_model.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
state_lpdf(x_curr, x_prev, theta)
Calculates the log-density of p(x_curr | x_prev, theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_curr
|
State variable at current time |
required | |
x_prev
|
State variable at previous time |
required | |
theta
|
Parameter value. |
required |
Returns:
| Type | Description |
|---|---|
|
The log-density of |
Source code in src/pfjax/models/bm_model.py
state_sample(key, x_prev, theta)
Samples from x_curr ~ p(x_curr | x_prev, theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNG key. |
required | |
x_prev
|
State variable at previous time |
required | |
theta
|
Parameter value. |
required |
Returns:
| Type | Description |
|---|---|
|
Sample of the state variable at current time |
Source code in src/pfjax/models/bm_model.py
meas_lpdf(y_curr, x_curr, theta)
Log-density of p(y_curr | x_curr, theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_curr
|
Measurement variable at current time |
required | |
x_curr
|
State variable at current time |
required | |
theta
|
Parameter value. |
required |
Returns:
| Type | Description |
|---|---|
|
The log-density of |
Source code in src/pfjax/models/bm_model.py
meas_sample(key, x_curr, theta)
Sample from p(y_curr | x_curr, theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNG key. |
required | |
x_curr
|
State variable at current time |
required | |
theta
|
Parameter value. |
required |
Returns:
| Type | Description |
|---|---|
|
Sample of the measurement variable at current time |
Source code in src/pfjax/models/bm_model.py
pf_init(key, y_init, theta)
Get particles for initial state x_init = x_state[0].
Samples from an importance sampling proposal distribution
::
x_init ~ q(x_init) = q(x_init | y_init, theta)
and calculates the log weight
::
logw = log p(y_init | x_init, theta) + log p(x_init | theta) - log q(x_init)
In this case we have an exact proposal
::
q(x_init) = p(x_init | y_init, theta)
<=> x_init ~ N(y_init, tau)
Moreover, due to symmetry of arguments we have q(x_init) = p(y_init | x_init, theta), and since p(x_init | theta) \propto 1 we have logw = 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNG key. |
required | |
y_init
|
Measurement variable at initial time |
required | |
theta
|
Parameter value. |
required |
Returns:
Tuple:
- **x_init** - A sample from the proposal distribution for `x_init`.
- **logw** - The log-weight of `x_init`.
Source code in src/pfjax/models/bm_model.py
loglik_exact(y_meas, theta)
Marginal loglikelihood of the BM model.
Actually calculates log p(y_{1:N} | theta, y_0), since for the flat prior on x_0 the marginal likelihood p(y_{0:N} | theta) does not exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_meas
|
Vector of observations |
required | |
theta
|
Parameter value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
|
|
|
The marginal loglikelihood |