Skip to content

Commit fc90a62

Browse files
committed
Added section to walk through setting up a virtual environment
1 parent 1ca33ea commit fc90a62

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

examples/bayesian_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def log_likelihood(params):
109109
# Mean-function credible band: E[y|x,theta] = a + b*x
110110
# mu_draws[i,j] = a_i + b_i*x_j
111111
mu_draws = a_samples[:, None] + b_samples[:, None] * x[None, :] # Model mean draws for every posterior sample at every x
112-
y_hat_mean = mu_draws.mean(axis=0) # Average accross posterior draws for each x_j
112+
y_hat_mean = mu_draws.mean(axis=0) # Average across posterior draws for each x_j
113113
y_hat_low, y_hat_up = np.quantile(mu_draws, [0.05, 0.95], axis=0) # 90% interval for each x_j
114114

115115

notebooks/00_getting_started.ipynb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,46 @@
2424
"- How to load the correct .NET runtime and add the DLL reference from Python.\n",
2525
"- How to run a quick sanity check and diagnose common setup issues.\n",
2626
"\n",
27+
"## Virtual Python Environment\n",
28+
"Before we get to Numerics, we need to ensure Python is up and running on your device and in these notebooks. In the top right hand corner of this notebook click on the **\"Select Kernel\"** button. A Python environment should be available for you to chose from, assuming you've downloaded Python. If you have Python on your computer, but cannot find a Python kernel to select, don't worry we have a solution. We will create and virtual Python environment just for this library to work with.\n",
29+
"\n",
30+
"This virtual Python environment will give this library its own copy of Python, its own set of tools and libraries, and keeping it isolated from other projects. Before we start, please ensure you have the new version of Python installed locally on your device.\n",
31+
"\n",
32+
"1. Open a new terminal and make sure it is pointing to your project folder (you should see the folder path in the prompt)\n",
33+
"2. To create the virtual environment, run one of the commands below: \n",
34+
" ```bash \n",
35+
" # Mac/Linx\n",
36+
" python3 -m venv .venv\n",
37+
" # Windows\n",
38+
" python -m venv .venv\n",
39+
" ```\n",
40+
" This will create the .venv folder in your project. Double check that you can see this folder in the file explorer.\n",
41+
"3. Now we will activate the virtual environment:\n",
42+
" ```bash\n",
43+
" # Mac/Linx\n",
44+
" source .venv/bin/activate\n",
45+
" # Windows (Command Prompt)\n",
46+
" .venv\\Scripts\\activate.bat\n",
47+
" # Windows (PowerShell)\n",
48+
" .venv\\Scripts\\Activate.ps1\n",
49+
" ```\n",
50+
" You should now see `(.venv)` appear at the start of the terminal prompt. This means it's active!\n",
51+
"4. Instal ipykernel. This is what allows Jupyter to see your virtual environment as a kernel. With the `.venv` active run:\n",
52+
" ```bash\n",
53+
" pip install ipykernel\n",
54+
" ```\n",
55+
" Then register it: \n",
56+
" ```bash\n",
57+
" # Mac/Linx\n",
58+
" python3 -m ipykernel install --user --name=.venv --display-name \"Python (.venv)\"\n",
59+
" # Windows\n",
60+
" python -m ipykernel install --user --name=.venv --display-name \"Python (.venv)\"\n",
61+
" ```\n",
62+
"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",
63+
"6. Open the command palette (Crl+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",
64+
"\n",
65+
"Now we have ensured that we can use and run Python in there Jupyter notebooks. Time to get down to business in Numerics!\n",
66+
"\n",
2767
"## What is Numerics?\n",
2868
"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",
2969
"\n",

0 commit comments

Comments
 (0)