-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ABC rejection comparing two time series in deterministic Lotka-Volterra model #222
Comments
Hi, the problem is that ELFI expects the outputs of these operations to be
However your simulator should also wrap the results in numpy arrays with length
We should think a way to detect these cases and report a better error message since these seem to be quite common. |
Thanks for the quick response and suggested adjustment. I made the adjustment to the distance function and continued on with the example. However, now the rejection sampler hangs and if I kill the process (ctrl-C) and plot the parameter space that's being explored then it looks like it's searching in the correct area but it seems to take a while to reach the result (roughly a,b = 1). I was curious about ways to speed this up? # (as example above ...)
def SSE(x, y):
return np.atleast_1d(np.sum((x-y)**2))
rej = elfi.Rejection(d_lv, batch_size = 1, seed = seed)
result = rej.sample(1000, threshold = 30.0)
# kill the process after about a minute (ctrl-C)
# Plot the parameter space that's been explored
fig, ax = plt.subplots()
rej.plot_state(ax = ax)
ax.set_xlim([-11, 11])
ax.set_ylim([-11, 11])
plt.savefig("parameter_space.png")
plt.close() Additionally, when outputting the result with rej.extract_result()
|
There are several things you can try to speed things up, for example:
Since you killed the process, what you get using |
Thanks for those ideas. I used a threshold of 30.0 because that is what is quoted as the first threshold in ABC-SMC in the paper by Toni et al., (2009) (assuming the first threshold of ABC-SMC would be a suitable threshold for ABC-rejection). They report ~26,000 data generation steps to find 1000 accepted samples (with ABC-SMC). |
Also ABC-SMC speeds up the inference compared to Rejection ABC. You might be interested in the iterative advancing of the algorithm: http://elfi.readthedocs.io/en/latest/usage/tutorial.html#iterative-advancing Basically you set the objective and then you can advance the inference step by step and investigate the result at any point. Internally the |
Summary:
Running a deterministic Lotka-Volterra example parameterised using ABC rejection. This follows the example outlined in Toni et al, (2009) where two parameters are to be found in predator-prey system. It is required to choose parameters that minimize the sum of squared errors between the observed and simulated time series. Priors for the parameters are taken from the paper, observed data are estimated from the paper above.
Rather than outputting a multi-dimensional array from the LV model, I've concatenated results from the model into a 1D array.
Not quite sure which of these functions I need to change. Perhaps the
LV()
function needs to allow processing of vector inputs? Any help would be much appreciated!Description:
The Lotka-Volterra system of ODEs is created in Python, priors are defined, a Simulator object is defined (and tested), distance measure defined (and tested), ABC rejection sampler defined, but sampling from the rejection sampler throws an error.
Reproducible Steps:
The following code reproduces the error.
Current Output:
Current output gives the following error
ELFI Version:
0.6.0
Python Version:
3.6.1
Operating System:
OSX 10.12.5
The text was updated successfully, but these errors were encountered: