Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ authors:
email: "sadie.s.niblett@usace.army.mil"
affiliation: "U.S. Army Corps of Engineers, Risk Management Center"
orcid: "https://orcid.org/0009-0008-8588-4816"
- family-names: "Gonzalez"
given-names: "Julian"
email: "julian.t.gonzalez@usace.army.mil"
affiliation: "U.S. Army Corps of Engineers, Risk Management Center"
orcid: "https://orcid.org/0009-0009-9058-7653"
- family-names: "Smith"
given-names: "C. Haden"
email: "cole.h.smith@usace.army.mil"
affiliation: "U.S. Army Corps of Engineers, Risk Management Center"
orcid: "https://orcid.org/0000-0002-4651-9890"
reviewers:
- family-names: "McGraw"
given-names: "Dan"
email: "daniel.e.mcgraw@usace.army.mil"
affiliation: "U.S. Army Corps of Engineers, Risk Management Center"
orcid: "https://orcid.org/0009-0006-4859-0179"
- family-names: "Gonzalez"
given-names: "Julian"
email: "julian.t.gonzalez@usace.army.mil"
affiliation: "U.S. Army Corps of Engineers, Risk Management Center"
orcid: "https://orcid.org/0009-0009-9058-7653"
30 changes: 21 additions & 9 deletions notebooks/00_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"5. Now you should be able to select this virtual environment as a kernel. Click on the **\"Select Kernel\"** in the top right. Chose Python environments and select Python(.venv), the one you just created! If it doesn't show up right away, try reloading your window.\n",
"6. Open the command palette (Ctrl+Shift+P or Cmd+Shift+P) and find **\"Python:Select Interpreter\"**. Chose the .venv option to tell VS code to always use this interpreter going forward.\n",
"\n",
"Now we have ensured that we can use and run Python in there Jupyter notebooks. Time to get down to business in Numerics!\n",
"Now we have ensured that we can use and run Python in these Jupyter notebooks. Time to get down to business in Numerics!\n",
"\n",
"## What is Numerics?\n",
"Numerics is a comprehensive .NET library for numerical computing and statistical analysis, developed by the U.S. Army Corps of Engineers Risk Management Center [[1]](#1). It includes:\n",
Expand Down Expand Up @@ -220,7 +220,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "65dc539a",
"metadata": {
"execution": {
Expand All @@ -230,7 +230,19 @@
"shell.execute_reply": "2026-04-23T18:41:58.462306Z"
}
},
"outputs": [],
"outputs": [
{
"ename": "FileNotFoundException",
"evalue": "Unable to find assembly 'c:\\GIT\\BestFit-Python-Examples\\packages\\RMC.Numerics.2.0.1\\lib\\net8.0\\Numerics.dll'.\r\n at Python.Runtime.CLRModule.AddReference(String name) in /home/benedikt/.cache/uv/sdists-v6/.tmpkW03e6/pythonnet-3.0.5/src/runtime/Types/ClrModule.cs:line 117\r\n at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)\r\n at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)\r\n at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mFileNotFoundException\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 5\u001b[39m\n\u001b[32m 2\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mhelper_functions\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m resolve_numerics_dll\n\u001b[32m 4\u001b[39m dll_path = resolve_numerics_dll()\n\u001b[32m----> \u001b[39m\u001b[32m5\u001b[39m \u001b[43mclr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mAddReference\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mstr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mdll_path\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 7\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m✓ Loaded Numerics from: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdll_path\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n",
"\u001b[31mFileNotFoundException\u001b[39m: Unable to find assembly 'c:\\GIT\\BestFit-Python-Examples\\packages\\RMC.Numerics.2.0.1\\lib\\net8.0\\Numerics.dll'.\r\n at Python.Runtime.CLRModule.AddReference(String name) in /home/benedikt/.cache/uv/sdists-v6/.tmpkW03e6/pythonnet-3.0.5/src/runtime/Types/ClrModule.cs:line 117\r\n at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)\r\n at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)\r\n at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)"
]
}
],
"source": [
"import clr\n",
"from helper_functions import resolve_numerics_dll\n",
Expand All @@ -252,7 +264,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "b3a59cb5",
"metadata": {
"execution": {
Expand Down Expand Up @@ -291,7 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "f6b4f2fd",
"metadata": {
"execution": {
Expand Down Expand Up @@ -346,7 +358,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "d51dfbec",
"metadata": {
"execution": {
Expand Down Expand Up @@ -395,7 +407,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "3c61d5ad",
"metadata": {
"execution": {
Expand Down Expand Up @@ -441,7 +453,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "b2c575cc",
"metadata": {
"execution": {
Expand Down Expand Up @@ -591,7 +603,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/01_distributions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2531,7 +2531,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/02_distribution_fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
36 changes: 19 additions & 17 deletions notebooks/03_mcmc_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,14 @@
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✓ Setup complete\n"
"ename": "FileNotFoundException",
"evalue": "Unable to find assembly 'c:\\GIT\\BestFit-Python-Examples\\packages\\RMC.Numerics.2.0.1\\lib\\net8.0\\Numerics.dll'.\r\n at Python.Runtime.CLRModule.AddReference(String name) in /home/benedikt/.cache/uv/sdists-v6/.tmpkW03e6/pythonnet-3.0.5/src/runtime/Types/ClrModule.cs:line 117\r\n at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)\r\n at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mFileNotFoundException\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 12\u001b[39m\n\u001b[32m 10\u001b[39m \u001b[38;5;66;03m# Load Numerics DLL (auto-discovered from NuGet; see notebook 00 for details)\u001b[39;00m\n\u001b[32m 11\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mhelper_functions\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m resolve_numerics_dll\n\u001b[32m---> \u001b[39m\u001b[32m12\u001b[39m \u001b[43mclr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mAddReference\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mstr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mresolve_numerics_dll\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 14\u001b[39m \u001b[38;5;66;03m# Import MCMC and distribution classes\u001b[39;00m\n\u001b[32m 15\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mNumerics\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mSampling\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mMCMC\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m RWMH, MCMCResults, LogLikelihood, MCMCSampler\n",
"\u001b[31mFileNotFoundException\u001b[39m: Unable to find assembly 'c:\\GIT\\BestFit-Python-Examples\\packages\\RMC.Numerics.2.0.1\\lib\\net8.0\\Numerics.dll'.\r\n at Python.Runtime.CLRModule.AddReference(String name) in /home/benedikt/.cache/uv/sdists-v6/.tmpkW03e6/pythonnet-3.0.5/src/runtime/Types/ClrModule.cs:line 117\r\n at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)\r\n at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)"
]
}
],
Expand Down Expand Up @@ -150,7 +154,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"id": "8f4b903e",
"metadata": {
"execution": {
Expand All @@ -160,7 +163,6 @@
"shell.execute_reply": "2026-04-23T21:32:20.774600Z"
}
},
"outputs": [],
"source": [
"> **Note for demo users.** When calling Numerics MCMC samplers from Python via pythonnet, the samplers' internal parallel chains (`Parallel.For`) contend for Python's Global Interpreter Lock (GIL). This makes parallel execution slower than sequential. That's why every example below sets `sampler.ParallelizeChains = False`. It defaults to `True`, which works well in C# but slows the sampler down when driven from Python."
]
Expand All @@ -181,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "04138f5a",
"metadata": {
"execution": {
Expand Down Expand Up @@ -255,7 +257,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "68d30485",
"metadata": {
"execution": {
Expand Down Expand Up @@ -316,7 +318,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "e8aca3ab",
"metadata": {
"execution": {
Expand Down Expand Up @@ -394,7 +396,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "165d8ce2",
"metadata": {
"execution": {
Expand Down Expand Up @@ -457,7 +459,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "59d808ac",
"metadata": {
"execution": {
Expand Down Expand Up @@ -523,7 +525,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "8b653f22",
"metadata": {
"execution": {
Expand Down Expand Up @@ -662,7 +664,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "eb20ce0a",
"metadata": {
"execution": {
Expand Down Expand Up @@ -727,7 +729,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "2a1a8d09",
"metadata": {
"execution": {
Expand Down Expand Up @@ -917,7 +919,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "066f0505",
"metadata": {
"execution": {
Expand Down Expand Up @@ -1037,7 +1039,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -1051,7 +1053,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
22 changes: 10 additions & 12 deletions notebooks/04_mcmc_bayesian_inference.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "46006368",
"metadata": {
"execution": {
Expand Down Expand Up @@ -76,7 +76,6 @@
},
{
"cell_type": "markdown",
"execution_count": null,
"id": "d3ef7a3e",
"metadata": {
"execution": {
Expand All @@ -86,7 +85,6 @@
"shell.execute_reply": "2026-04-23T19:23:09.776975Z"
}
},
"outputs": [],
"source": [
"> **Note for demo users.** When calling Numerics MCMC samplers from Python via pythonnet, the samplers' internal parallel chains (`Parallel.For`) contend for Python's Global Interpreter Lock (GIL). This makes parallel execution slower than sequential. That's why every example below sets `sampler.ParallelizeChains = False`. It defaults to `True`, which works well in C# but slows the sampler down when driven from Python."
]
Expand All @@ -105,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "6d40f966",
"metadata": {
"execution": {
Expand Down Expand Up @@ -250,7 +248,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "9ebe9b66",
"metadata": {
"execution": {
Expand Down Expand Up @@ -436,7 +434,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "18a04004",
"metadata": {
"execution": {
Expand Down Expand Up @@ -610,7 +608,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "54366e57",
"metadata": {
"execution": {
Expand Down Expand Up @@ -798,7 +796,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "8bbd362c",
"metadata": {
"execution": {
Expand Down Expand Up @@ -1005,7 +1003,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "8ecdca79",
"metadata": {
"execution": {
Expand Down Expand Up @@ -1197,7 +1195,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "111be476",
"metadata": {
"execution": {
Expand Down Expand Up @@ -1479,7 +1477,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -1493,7 +1491,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
Loading