ModellingWebLab / project_issues

An issues-only repository for issues that cut across multiple repositories
1 stars 0 forks source link

Make sure simulations match Kylie's ~exactly~ well enough #14

Closed MichaelClerx closed 6 years ago

MichaelClerx commented 6 years ago

We want to recreate Kylie's IKr work in Web Lab (like Aidan has done) but using Pints as a back-end. In order to test Pints - before it becomes possible to do so in the web lab - we need to be able to recreate the simulation predictions exactly. Currently there's some small differences. Will need to fix this.

jonc125 commented 6 years ago

Or explain how the differences arise - solvers written in different languages, slightly different ODE solver algorithms, slightly different compiler optimisation, etc. all can add up!

MichaelClerx commented 6 years ago

I created some more accurate matlab files of Kylie's stuff, and now getting this for the difference between her protocol and the myokit one: figure_1 All in the order of 1e-13, so that seems good enough to me. Here's a zoom on the sine wave part: figure_1_zoom That looks like truncation error (or maybe underflow?) to me!

This is the difference between the currents (kylie's matlab one versus my myokit one) figure_2 There is still a big-ish error at the point where the sine waves stop. The protocol doesn't have any particular differences at this point, so it must be down to (how we use) the solver.

In the region before the end of the sine waves, the maximum error is 1.5e-6, so pretty close!

MichaelClerx commented 6 years ago

This is the difference in currents again, using abstol=reltol=1e-10 in both Matlab and Myokit figure_3

I think this means it's good enough! @jonc125 @mirams ?

To summarise:

MichaelClerx commented 6 years ago

When I evaluate the log likelihoods I get:

Myokit signal comparison:
  Log-likelihood: -1.51042757394234696e+06
Matlab signal comparison:
  Log-likelihood: -1.51042762220851122e+06

So that seems pretty good!

The value reported by Kylie's matlab code is slighty different though:

My value for Kylie's signal:
  -1.51042762220851122e+06
The value in her stored matlab files
  -1.51063175578740e+006

Not really sure how to find the source of this mismatch without digging deeply into Kylie's code. Don't think it's very important though (probably some truncation in storing the value in a file somewhere) so will accept the above as good enough!

mirams commented 6 years ago

Yep looks as if it will be good enough. Next step is probably just doing the CMA-ES and checking it gets there too, and then repeating the MCMC and comparing with both Kylie and Aidan's posteriors.

jonc125 commented 6 years ago

If you've changed the tolerances then I'd expect a different value from her Matlab code?

But yes, this is probably fine!

mirams commented 6 years ago

Good detective work by the way!

MichaelClerx commented 6 years ago

Thanks!