|
27 | 27 | from pymc.distributions.logprob import logp
|
28 | 28 | from pymc.distributions.multivariate import Dirichlet
|
29 | 29 | from pymc.distributions.shape_utils import change_dist_size, to_tuple
|
30 |
| -from pymc.distributions.timeseries import AR, GARCH11, EulerMaruyama, GaussianRandomWalk |
| 30 | +from pymc.distributions.timeseries import ( |
| 31 | + AR, |
| 32 | + GARCH11, |
| 33 | + EulerMaruyama, |
| 34 | + GaussianRandomWalk, |
| 35 | + RandomWalk, |
| 36 | +) |
31 | 37 | from pymc.model import Model
|
32 | 38 | from pymc.sampling import draw, sample, sample_posterior_predictive
|
33 | 39 | from pymc.tests.distributions.util import (
|
|
40 | 46 | from pymc.tests.helpers import SeededTest, select_by_precision
|
41 | 47 |
|
42 | 48 |
|
| 49 | +class TestRandomWalk: |
| 50 | + def test_dists_types(self): |
| 51 | + init_dist = Normal.dist() |
| 52 | + innovation_dist = Normal.dist() |
| 53 | + |
| 54 | + with pytest.raises( |
| 55 | + TypeError, |
| 56 | + match="init_dist must be a univariate distribution variable", |
| 57 | + ): |
| 58 | + RandomWalk.dist(init_dist=5, innovation_dist=innovation_dist, steps=5) |
| 59 | + |
| 60 | + with pytest.raises( |
| 61 | + TypeError, |
| 62 | + match="innovation_dist must be a univariate distribution variable", |
| 63 | + ): |
| 64 | + RandomWalk.dist(init_dist=init_dist, innovation_dist=5, steps=5) |
| 65 | + |
| 66 | + def test_dists_not_registered_check(self): |
| 67 | + with Model(): |
| 68 | + init = Normal("init") |
| 69 | + innovation = Normal("innovation") |
| 70 | + |
| 71 | + init_dist = Normal.dist() |
| 72 | + innovation_dist = Normal.dist() |
| 73 | + with pytest.raises( |
| 74 | + ValueError, |
| 75 | + match="The dist init was already registered in the current model", |
| 76 | + ): |
| 77 | + RandomWalk("rw", init_dist=init, innovation_dist=innovation_dist, steps=5) |
| 78 | + |
| 79 | + with pytest.raises( |
| 80 | + ValueError, |
| 81 | + match="The dist innovation was already registered in the current model", |
| 82 | + ): |
| 83 | + RandomWalk("rw", init_dist=init_dist, innovation_dist=innovation, steps=5) |
| 84 | + |
| 85 | + |
43 | 86 | class TestGaussianRandomWalk:
|
44 | 87 | def test_logp(self):
|
45 | 88 | def ref_logp(value, mu, sigma):
|
|
0 commit comments