Note - this version contains a delierate bug!
Please see here for the fixed version, and see our notebook for a full walkthrough.