Skip to content

Commit

Permalink
update tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed Jan 31, 2024
1 parent 78d0671 commit a743bd2
Showing 1 changed file with 30 additions and 238 deletions.
268 changes: 30 additions & 238 deletions doc/notebooks/interactive.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cells": [
"cells": [
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -35,25 +35,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "af38533713414893a5a3160dd562341a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"rng = np.random.default_rng(1)\n",
"\n",
Expand Down Expand Up @@ -87,25 +71,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "014dec0572b3499a8907f7e5aa017a13",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"rng = np.random.default_rng(1)\n",
"\n",
Expand Down Expand Up @@ -140,25 +108,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c0f32bd8e6f44b51a3d0b4a95e465b03",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"def model(xe, f, mu, sigma, nuinv, slope):\n",
" nu = 1 / nuinv\n",
Expand Down Expand Up @@ -187,25 +139,9 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a69f7116f6464d81b70c64035439dd23",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"c = cost.BinnedNLL(n, xe, model)\n",
"\n",
Expand All @@ -229,25 +165,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e26e22400b26486cab10b81550c8e5a3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"def model(xe, s, mu, sigma, nuinv, b1, b2, b3):\n",
" nu = 1 / nuinv\n",
Expand Down Expand Up @@ -281,25 +201,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f5c78e9b501f42bf8cecff95d73f2462",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# Visualize signal and background components with different colors\n",
"class Plotter:\n",
Expand All @@ -321,25 +225,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7a127e1a231241f581d9ba86b67e6db2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"c = cost.ExtendedBinnedNLL(n, xe, model)\n",
"\n",
Expand All @@ -360,38 +248,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## BarlowBeestonLite"
"## Template"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/tl/pv6mt7z17tz0stm1fjfg01cc0000gn/T/ipykernel_62711/3926893965.py:10: VisibleDeprecationWarning: BarlowBeestonLite was renamed to Template, please import Template instead\n",
" c = cost.BarlowBeestonLite(n, xe, (b, s))\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3f292549fa924710b17a248500307a2b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"xe = np.linspace(0, 1, 20)\n",
"bm = np.diff(truncexpon.cdf(xe, 0, 1, 0, 1))\n",
Expand All @@ -402,7 +266,7 @@
"b = rng.poisson(1e4 * bm)\n",
"s = rng.poisson(1e2 * sm)\n",
"\n",
"c = cost.BarlowBeestonLite(n, xe, (b, s))\n",
"c = cost.Template(n, xe, (b, s))\n",
"\n",
"m = Minuit(c, 1000, 100, name=(\"b\", \"s\"))\n",
"m.limits = (0, None)\n",
Expand All @@ -412,35 +276,11 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/tl/pv6mt7z17tz0stm1fjfg01cc0000gn/T/ipykernel_62711/3285115150.py:1: VisibleDeprecationWarning: BarlowBeestonLite was renamed to Template, please import Template instead\n",
" c = cost.BarlowBeestonLite(n, xe, (b, s))\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bc4860f11843424690f3d9e6fdd724d3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"c = cost.BarlowBeestonLite(n, xe, (b, s))\n",
"c = cost.Template(n, xe, (b, s))\n",
"cx = 0.5 * (xe[1:] + xe[:-1])\n",
"c.mask = np.abs(cx - 0.5) > 0.2\n",
"\n",
Expand All @@ -460,25 +300,9 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b8ae78e9220c435c96e715b55c8e2b13",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"def model(x, a, b):\n",
" return a + b * x\n",
Expand All @@ -497,25 +321,9 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "af47103035ca4c7cb50c31a9e5fb2831",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"c = cost.LeastSquares(x, y, ye, model)\n",
"c.mask = (x > 0.6) | (x < 0.2)\n",
Expand All @@ -534,25 +342,9 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ea19670b589d4722b401f45f0b575bc3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Output(), VBox(children=(HBox(children=(Button(description='Fit', style=ButtonStyle()), ToggleB…"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"def model(xe, s, mu, sigma, nuinv):\n",
" nu = 1 / nuinv \n",
Expand Down Expand Up @@ -589,7 +381,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.9.18"
},
"vscode": {
"interpreter": {
Expand Down

0 comments on commit a743bd2

Please sign in to comment.