From f272e1a79706ab18e6155b586ef0fdf9ec245736 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Fri, 13 Nov 2026 09:32:15 +0000 Subject: [PATCH 1/2] Separate the function writing challenge into two challenges --- episodes/03-numpy_essential.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/episodes/03-numpy_essential.md b/episodes/03-numpy_essential.md index 5300e01e..0ae0d85a 100644 --- a/episodes/03-numpy_essential.md +++ b/episodes/03-numpy_essential.md @@ -183,12 +183,6 @@ where **x** is an array, **µ** is the position of the centre of the curve/peak 1. Create a function called `gauss` which will take three arguments (inputs): **x**, **µ**, and **σ**, as defined above. *Hint*: you may wish to use the NumPy constant `pi`, and NumPy functions `square`, `sqrt` and `exp` for calcuating the square, square-root and exponential of **e** respectively for all elements in an array. -2. Create a NumPy array using the Numpy function `linspace` which will contain 1000 - points equally spaced between **x**=-100 and **x**=100. *Hint*: You can print the help - documentation of a function with 'help(name\_of\_the\_function)'. -3. Using the above gauss function and the array, create an array which contains the values - of the Gaussian from **x**=-100 to **x**=100. -4. Use the 'matplotlib' library to plot the curve with **µ**=0 and **σ**=10. ::::::::::::::: solution @@ -203,9 +197,26 @@ def gauss(x, mu=0, sigma=1): ::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::: + + +::::::::::::::::::::::::::::::::::::::: challenge + +## Using your Gaussian Function + +1. Create a NumPy array using the Numpy function `linspace` which will contain 1000 + points equally spaced between **x**=-100 and **x**=100. *Hint*: You can print the help + documentation of a function with 'help(name\_of\_the\_function)'. +2. Using the above gauss function and the array, create an array which contains the values + of the Gaussian from **x**=-100 to **x**=100. +3. Use the 'matplotlib' library to plot the curve with **µ**=0 and **σ**=10. + + +:::::::::::::::::::::::::::::::::::::::::::::::::: + ::::::::::::::: solution -## challenge 2: +## challenge 1: ```python x = np.linspace(-100, 100, 1000) @@ -215,7 +226,7 @@ x = np.linspace(-100, 100, 1000) ::::::::::::::: solution -## challenge 3: +## challenge 2: ```python mu = 0 # the position of the center of the peak @@ -227,7 +238,7 @@ g = gauss(x, mu, sigma) ::::::::::::::: solution -## challenge 4: +## challenge 3: ```python plt.plot(x, g) From ffbb849e9c83054596f99fb7f3c679603e5ada92 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Fri, 13 Nov 2026 11:19:22 +0000 Subject: [PATCH 2/2] Remove extraneous closing line --- episodes/03-numpy_essential.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/episodes/03-numpy_essential.md b/episodes/03-numpy_essential.md index 0ae0d85a..3561d09b 100644 --- a/episodes/03-numpy_essential.md +++ b/episodes/03-numpy_essential.md @@ -211,9 +211,6 @@ def gauss(x, mu=0, sigma=1): of the Gaussian from **x**=-100 to **x**=100. 3. Use the 'matplotlib' library to plot the curve with **µ**=0 and **σ**=10. - -:::::::::::::::::::::::::::::::::::::::::::::::::: - ::::::::::::::: solution ## challenge 1: