Skip to content

Commit

Permalink
plot error probabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
nvaytet committed Oct 10, 2024
1 parent fa4ac49 commit c41e1f7
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions docs/wfm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f97e9772-7aa8-426a-a0ba-3a0d0b6babf0",
"id": "ce1df677-098e-4bec-9278-07fe16d0379f",
"metadata": {},
"source": [
"We can see that the WFM estimate clearly outperforms the naive computation.\n",
Expand Down Expand Up @@ -556,7 +557,34 @@
"id": "1d28f370-dd84-41f9-af44-d1363a069772",
"metadata": {},
"source": [
"This once again illustrates the superiority of the WFM estimate."
"This once again illustrates the superiority of the WFM estimate.\n",
"\n",
"An alternative way of comparing the accuracy of the methods is to look at the probability that a computed wavelength has relative error above $x$,\n",
"as a function of $x$:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "23dde7e5-c2d2-4601-bf1e-fc3b85be7c85",
"metadata": {},
"outputs": [],
"source": [
"true_wavs = events.flatten(to='event').coords['wavelength']\n",
"\n",
"err_wfm = sc.abs(true_wavs - flat.coords['wavelength']) / true_wavs\n",
"err_naive = sc.abs(true_wavs - naive.coords['wavelength']) / true_wavs\n",
"\n",
"bins = sc.geomspace('relative_error', 1e-3, 0.2, 101)\n",
"err_wfm = sc.cumsum(err_wfm.hist(relative_error=bins))\n",
"err_naive = sc.cumsum(err_naive.hist(relative_error=bins))\n",
"\n",
"p = pp.plot(\n",
" {'naive': 1 - err_naive / sc.max(err_naive), 'wfm': 1 - err_wfm / sc.max(err_wfm)},\n",
" scale={'relative_error': 'log'},\n",
")\n",
"p.canvas.ylabel = 'Probability of $rel. err. > x$'\n",
"p"
]
}
],
Expand Down

0 comments on commit c41e1f7

Please sign in to comment.