@@ -13,8 +13,8 @@ functions using symbolic differentiation and common subexpression elimination.
1313In either case the functions are compiled using numba and the resulting
1414C-function is passed to sunode, so that there is no python overhead.
1515
16- sunode comes with a theano wrapper so that parameters of an ode can be estimated
17- using pymc3 .
16+ ` sunode ` comes with an Aesara wrapper so that parameters of an ODE can be estimated
17+ using PyMC .
1818
1919### Installation
2020sunode is available on conda-forge. Set up a conda environment to use conda-forge
@@ -28,8 +28,8 @@ conda config --set channel_priority strict
2828conda install sunode
2929```
3030
31- You can also install the development version. One windows you have to make
32- sure the correct visual studio version is install and in the PATH.
31+ You can also install the development version. On Windows you have to make
32+ sure the correct Visual Studio version is installed and in the PATH.
3333```
3434git clone [email protected] :aseyboldt/sunode 3535# Or if no ssh key is configured:
@@ -40,7 +40,7 @@ conda install --only-deps sunode
4040pip install -e .
4141```
4242
43- ### Solve an ode outside of a pymc3 model
43+ ### Solve an ODE outside a PyMC model
4444
4545We will use the Lotka-Volterra equations as an example ODE:
4646
@@ -118,22 +118,22 @@ plt.plot(output.view(problem.state_dtype)['hares']
118118```
119119
120120For this example the BDF solver (which isn' t the best solver for a small non-stiff
121- example problem like this) takes ~ 200 μs, while the scipy.integrate.solve_ivp solver
122- take about 40ms at a tolerance of 1e-10 , 1e-10 . So we are faster by a factor of 200 .
121+ example problem like this) takes ~ 200 μs, while the ` scipy.integrate.solve_ivp` solver
122+ takes about 40ms at a tolerance of 1e-10 , 1e-10 . So we are faster by a factor of 200 .
123123This advantage will get somewhat smaller for large problems however, when the
124- python overhead of the ODE solver has a smaller impact.
124+ Python overhead of the ODE solver has a smaller impact.
125125
126- # ## Usage in pymc3
126+ # ## Usage in PyMC
127127
128- Let' s use the same ODE, but fit the parameters using pymc3 , and gradients
129- computed using sunode.
128+ Let' s use the same ODE, but fit the parameters using PyMC , and gradients
129+ computed using ` sunode` .
130130
131131We' ll use some time artificial data:
132132```python
133133import numpy as np
134134import sunode
135135import sunode.wrappers.as_aesara
136- import pymc3 as pm
136+ import pymc as pm
137137
138138times = np.arange(1900 ,1921 ,1 )
139139lynx_data = np.array([
@@ -164,18 +164,18 @@ def lotka_volterra(t, y, p):
164164
165165
166166with pm.Model() as model:
167- hares_start = pm.HalfNormal(' hares_start' , sd = 50 )
168- lynx_start = pm.HalfNormal(' lynx_start' , sd = 50 )
167+ hares_start = pm.HalfNormal(' hares_start' , sigma = 50 )
168+ lynx_start = pm.HalfNormal(' lynx_start' , sigma = 50 )
169169
170170 ratio = pm.Beta(' ratio' , alpha = 0.5 , beta = 0.5 )
171171
172- fixed_hares = pm.HalfNormal(' fixed_hares' , sd = 50 )
172+ fixed_hares = pm.HalfNormal(' fixed_hares' , sigma = 50 )
173173 fixed_lynx = pm.Deterministic(' fixed_lynx' , ratio * fixed_hares)
174174
175- period = pm.Gamma(' period' , mu = 10 , sd = 1 )
175+ period = pm.Gamma(' period' , mu = 10 , sigma = 1 )
176176 freq = pm.Deterministic(' freq' , 2 * np.pi / period)
177177
178- log_speed_ratio = pm.Normal(' log_speed_ratio' , mu = 0 , sd = 0.1 )
178+ log_speed_ratio = pm.Normal(' log_speed_ratio' , mu = 0 , sigma = 0.1 )
179179 speed_ratio = np.exp(log_speed_ratio)
180180
181181 # Compute the parameters of the ode based on our prior parameters
@@ -217,18 +217,18 @@ with pm.Model() as model:
217217 pm.Deterministic(' lynx_mu' , y_hat[' lynx' ])
218218
219219 sd = pm.HalfNormal(' sd' )
220- pm.Lognormal (' hares' , mu = y_hat[' hares' ], sd = sd, observed = hare_data)
221- pm.Lognormal (' lynx' , mu = y_hat[' lynx' ], sd = sd, observed = lynx_data)
220+ pm.LogNormal (' hares' , mu = y_hat[' hares' ], sigma = sd, observed = hare_data)
221+ pm.LogNormal (' lynx' , mu = y_hat[' lynx' ], sigma = sd, observed = lynx_data)
222222```
223223
224- We can sample using pymc3 (You need `cores=1 ` on windows for the moment):
224+ We can sample using PyMC (You need `cores=1 ` on Windows for the moment):
225225```
226226with model:
227- trace = pm.sample(tune = 1000 , draws = 1000 , chains = 6 , cores = 6 )
227+ idata = pm.sample(tune = 1000 , draws = 1000 , chains = 6 , cores = 6 )
228228```
229229
230230Many solver options can not be specified with a nice interface for now,
231- we can call the raw sundials functions howeve :
231+ we can call the raw sundials functions however :
232232
233233```
234234lib = sunode._cvodes.lib
0 commit comments