From ffa70ef08bb02fea0735f1b072d13a2e8a5281b4 Mon Sep 17 00:00:00 2001 From: rashedman <rashedman@gmail.com> Date: Fri, 19 Aug 2022 16:05:55 +0200 Subject: [PATCH] Update 100_Numpy_exercises_with_solutions.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### 22. Normalize a 5x5 random matrix (★☆☆) The formula for calculating normalized score: X new = (X — X min)/ (X max — X min) --- 100_Numpy_exercises_with_solutions.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/100_Numpy_exercises_with_solutions.md b/100_Numpy_exercises_with_solutions.md index 010a18ce..1b99299f 100644 --- a/100_Numpy_exercises_with_solutions.md +++ b/100_Numpy_exercises_with_solutions.md @@ -188,9 +188,10 @@ print(Z) ```python -Z = np.random.random((5,5)) -Z = (Z - np.mean (Z)) / (np.std (Z)) -print(Z) +x = np.random.random((5,5)) +xmax, xmin = x.max(), x.min() +x = (x - xmin)/(xmax - xmin) +print(x) ``` #### 23. Create a custom dtype that describes a color as four unsigned bytes (RGBA) (★☆☆) @@ -1243,4 +1244,4 @@ idx = np.random.randint(0, X.size, (N, X.size)) means = X[idx].mean(axis=1) confint = np.percentile(means, [2.5, 97.5]) print(confint) -``` \ No newline at end of file +```