From d668b34829b6d005e3a903691e8d71f2142a9a48 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:27:23 +0530 Subject: [PATCH 1/6] Update index.md --- contrib/numpy/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index 50e8046..3abfb27 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -11,3 +11,4 @@ - [Sorting NumPy Arrays](sorting-array.md) - [NumPy Array Iteration](array-iteration.md) - [Concatenation of Arrays](concatenation-of-arrays.md) +- [Statistical Operations on Arrays](statistical-operations-on-arrays) From 06bdae004b468a6d2e4d72a3fa3dc513958752cf Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:28:01 +0530 Subject: [PATCH 2/6] Create statistical-operations-on-arrays.md --- contrib/numpy/statistical-operations-on-arrays.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 contrib/numpy/statistical-operations-on-arrays.md diff --git a/contrib/numpy/statistical-operations-on-arrays.md b/contrib/numpy/statistical-operations-on-arrays.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/contrib/numpy/statistical-operations-on-arrays.md @@ -0,0 +1 @@ + From f8699a52a752ac381190362594dd202a648837f3 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:28:42 +0530 Subject: [PATCH 3/6] Update index.md --- contrib/numpy/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index 3abfb27..4c3edce 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -11,4 +11,4 @@ - [Sorting NumPy Arrays](sorting-array.md) - [NumPy Array Iteration](array-iteration.md) - [Concatenation of Arrays](concatenation-of-arrays.md) -- [Statistical Operations on Arrays](statistical-operations-on-arrays) +- [Statistical Operations on Arrays](statistical-operations-on-arrays.md) From dc08f67d5603677a9b89baefda7236f787844c5d Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:22:10 +0530 Subject: [PATCH 4/6] Update statistical-operations-on-arrays.md --- .../numpy/statistical-operations-on-arrays.md | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/contrib/numpy/statistical-operations-on-arrays.md b/contrib/numpy/statistical-operations-on-arrays.md index 8b13789..06fbae2 100644 --- a/contrib/numpy/statistical-operations-on-arrays.md +++ b/contrib/numpy/statistical-operations-on-arrays.md @@ -1 +1,154 @@ +# Statistical Operations on Arrays +Statistics involves collecting data, analyzing it, and drawing conclusions from the gathered information. + +NumPy provides powerful statistical functions to perform efficient data analysis on arrays, including `minimum`, `maximum`, `mean`, `median`, `variance`, `standard deviation`, and more. + +## Minimum + +In NumPy, the minimum value of an array is the smallest element present. + +The smallest element of an array is calculated using the `np.min()` function. + +**Code** +```python +import numpy as np +array = np.array([100,20,300,400]) +#Calculating the minimum +result = np.min(array) +print("Minimum :", result) +``` + +**Output** +``` +Minimum : 20 +``` + +## Maximum + +In NumPy, the maximum value of an array is the largest element present. + +The largest element of an array is calculated using the `np.max()` function. + +**Code** +```python +import numpy as np +array = np.array([100,20,300,400]) +#Calculating the maximum +result = np.max(array) +print("Maximum :", result) +``` + +**Output** +``` +Maximum : 400 +``` + +## Mean + +The mean value of a NumPy array is the average of all its elements. + +It is calculated by summing all the elements and then dividing by the total number of elements. + +The mean of an array is calculated using the `np.mean()` function. + +**Code** +```python +import numpy as np +array = np.array([10,20,30,40]) +#Calculating the mean +result = np.mean(array) +print("Mean :", result) +``` + +**Output** +``` +Mean : 25.0 +``` + +## Median + +The median value of a NumPy array is the middle value in a sorted array. + +It separates the higher half of the data from the lower half. + +The median of an array is calculated using the `np.median()` function. + +It is important to note that: + +- If the number of elements is `odd`, the median is the middle element. +- If the number of elements is `even`, the median is the average of the two middle elements. + +**Code** +```python +import numpy as np +#The number of elements is odd +array = np.array([5,6,7,8,9]) +#Calculating the median +result = np.median(array) +print("Median :", result) +``` + +**Output** +``` +Median : 7.0 +``` + +**Code** +```python +import numpy as np +#The number of elements is even +array = np.array([1,2,3,4,5,6]) +#Calculating the median +result = np.median(array) +print("Median :", result) +``` + +**Output** +``` +Median : 3.5 +``` + +## Variance + +Variance in a NumPy array measures the spread or dispersion of data points. + +Calculated as the average of the squared differences from the mean. + +The variance of an array is calculated using the `np.var()` function. + +**Code** +```python +import numpy as np +array = np.array([10,70,80,50,30]) +#Calculating the variance +result = np.var(array) +print("Variance :", result) +``` + +**Output** +``` +Variance : 656.0 +``` + +## Standard Deviation + +The standard deviation of a NumPy array measures the amount of variation or dispersion of the elements in the array. + +It is calculated as the square root of the average of the squared differences from the mean, providing insight into how spread out the values are around the mean. + +The standard deviation of an array is calculated using the `np.std()` function. + +**Code** +```python +import numpy as np +array = np.array([25,30,40,55,75,100]) +#Calculating the standard deviation +result = np.std(array) +print("Standard Deviation :", result) +``` + +**Output** +``` +Standard Deviation : 26.365486699260625 +``` From e6359caf84689a4d6503b78123ca2b15e7551dd7 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 22 Jun 2024 16:33:01 +0530 Subject: [PATCH 5/6] Rename statistical-operations-on-arrays.md to statistical-functions.md --- ...atistical-operations-on-arrays.md => statistical-functions.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/numpy/{statistical-operations-on-arrays.md => statistical-functions.md} (100%) diff --git a/contrib/numpy/statistical-operations-on-arrays.md b/contrib/numpy/statistical-functions.md similarity index 100% rename from contrib/numpy/statistical-operations-on-arrays.md rename to contrib/numpy/statistical-functions.md From 41e7c65b297279380d1729a0acfee31d3ceb94c6 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sat, 22 Jun 2024 16:33:26 +0530 Subject: [PATCH 6/6] Update index.md --- contrib/numpy/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index 4c3edce..3f67375 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -11,4 +11,4 @@ - [Sorting NumPy Arrays](sorting-array.md) - [NumPy Array Iteration](array-iteration.md) - [Concatenation of Arrays](concatenation-of-arrays.md) -- [Statistical Operations on Arrays](statistical-operations-on-arrays.md) +- [Statistical Functions on Arrays](statistical-functions.md)