Skip to content

Commit 20d9bbf

Browse files
committed
Update NB 8.1 with f-strings
1 parent e9c4260 commit 20d9bbf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

notebooks/8.1-The-t-distribution.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"alpha_known = np.ones(N_trial)/np.sqrt(N)\n",
7272
"\n",
7373
"# Create a wide plot\n",
74-
"fig, ax = plt.subplots(figsize=[12.8, 4.8]);\n",
74+
"fig, ax = plt.subplots(figsize=[12.8, 4.8])\n",
7575
"\n",
7676
"# Create errorbar plots using known and estimated standard errors,\n",
7777
"# shifting each error bar to the left or right by shift_x\n",
@@ -95,8 +95,10 @@
9595
"H0_est = (xbar - alpha_est < 0) & (xbar + alpha_est > 0)\n",
9696
"\n",
9797
"# Show the fraction of trials consistent with µ = 0 in each case\n",
98-
"print(\"Fraction of trials consistent with µ = 0, known uncertainty: {0:.1f} %\".format(100*np.sum(H0_known)/N_trial))\n",
99-
"print(\"Fraction of trials consistent with µ = 0, estimated uncertainty: {0:.1f} %\".format(100*np.sum(H0_est)/N_trial))\n",
98+
"print(\"Fraction of trials consistent with µ = 0, known uncertainty: \"\n",
99+
" f\"{100*np.sum(H0_known)/N_trial:.1f} %\")\n",
100+
"print(\"Fraction of trials consistent with µ = 0, estimated uncertainty: \"\n",
101+
" f\"{100*np.sum(H0_est)/N_trial:.1f} %\")\n",
100102
"\n",
101103
"# Show indices where the known and estimated uncertainties yield different results for H0\n",
102104
"print(\"Trials consistent with µ = 0 for known uncertainty but inconsistent for estimated uncertainty:\")\n",

0 commit comments

Comments
 (0)