From 55a300c635f2de92fe0baabf4d794d1f038ab8de Mon Sep 17 00:00:00 2001 From: Sriparno Roy Date: Thu, 30 Jan 2025 09:55:28 +0530 Subject: [PATCH 1/4] [Term Entry] Python:SciPy scipy.stats: Descriptive Stats --- .../descriptive-stats/descriptive-stats.md | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md diff --git a/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md new file mode 100644 index 00000000000..99526440631 --- /dev/null +++ b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md @@ -0,0 +1,65 @@ +--- +Title: 'Descriptive Stats' +Description: 'Refers to the process of summarizing and describing the essential features of a dataset.' +Subjects: + - 'Computer Science' + - 'Data Science' +Tags: + - 'Data' + - 'Functions' + - 'Math' + - 'Python' +CatalogContent: + - 'learn-python-3' + - 'paths/computer-science' +--- + +In SciPy, **descriptive stats** refers to the process of summarizing and describing the essential features of a dataset. It enables users to understand the basic characteristics of the given data through various metrics such as central tendency, variability, and distribution shape. + +The **`.describe()`** function in the `scipy.stats` module is used to calculate common descriptive statistics of a given array, such as: + +- Number of observations (`nobs`) +- Minimum and maximum values (`minmax`) +- Mean (`mean`) +- Variance (`variance`) +- Skewness (`skewness`) +- Kurtosis (`kurtosis`) + +## Syntax + +```pseudo +stats.describe(a, axis=0, ddof=1, bias=True, nan_policy='propagate') +``` + +- `a`: The input data to describe. +- `axis` (Optional): The axis along which to compute the descriptive statistics (default is `0`). If set to `None`, the statistics are calculated for the whole array. +- `ddof` (Optional): Delta Degrees of Freedom for calculating variance (default is `1`). +- `bias` (Optional): If set to `False`, it corrects the skewness and kurtosis calculations for statistical bias. +- `nan_policy` (Optional): Defines the handling method to use when the input contains NaN. The options include: + - `propagate` (Default): Returns NaN. + - `raise`: Raises an error. + - `omit`: Ignores NaN values and performs the calculations. + +## Example + +The following example demonstrates the usage of the `.describe()` function to calculate the descriptive statistics of a given array: + +```py +import numpy as np +from scipy import stats + +# Define an array +arr = np.array([12, 23, 34, 45, 56]) + +# Calculate the descriptive statistics of the array +res = stats.describe(arr) + +# Print the result +print(res) +``` + +The above code produces the following output: + +```shell +DescribeResult(nobs=5, minmax=(12, 56), mean=34.0, variance=302.5, skewness=0.0, kurtosis=-1.3) +``` From 609ab25f0d697c202f6ebeae57c6e5df4a8b7a90 Mon Sep 17 00:00:00 2001 From: Sriparno Roy <89148144+Sriparno08@users.noreply.github.com> Date: Thu, 30 Jan 2025 18:55:53 +0530 Subject: [PATCH 2/4] Update content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md Co-authored-by: Pragati Verma --- .../scipy-stats/terms/descriptive-stats/descriptive-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md index 99526440631..c5a1daaf9f2 100644 --- a/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md +++ b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md @@ -1,6 +1,6 @@ --- Title: 'Descriptive Stats' -Description: 'Refers to the process of summarizing and describing the essential features of a dataset.' +Description: 'Summarizes and describes the essential features of a dataset.' Subjects: - 'Computer Science' - 'Data Science' From 061b77514a35fb916259b3b8832eab24f22d3634 Mon Sep 17 00:00:00 2001 From: Sriparno Roy <89148144+Sriparno08@users.noreply.github.com> Date: Thu, 30 Jan 2025 18:56:00 +0530 Subject: [PATCH 3/4] Update content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md Co-authored-by: Pragati Verma --- .../scipy-stats/terms/descriptive-stats/descriptive-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md index c5a1daaf9f2..0a3c4e82cb6 100644 --- a/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md +++ b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md @@ -14,7 +14,7 @@ CatalogContent: - 'paths/computer-science' --- -In SciPy, **descriptive stats** refers to the process of summarizing and describing the essential features of a dataset. It enables users to understand the basic characteristics of the given data through various metrics such as central tendency, variability, and distribution shape. +In SciPy, **descriptive statistics** refers to summarizing and analyzing a dataset's key characteristics. It helps summarize essential properties such as central tendency, variability, and distribution shape. The **`.describe()`** function in the `scipy.stats` module is used to calculate common descriptive statistics of a given array, such as: From cfcdb3f31ceddee9536b637c7eaaf6ee0500d095 Mon Sep 17 00:00:00 2001 From: Sriparno Roy Date: Thu, 30 Jan 2025 19:03:49 +0530 Subject: [PATCH 4/4] Made suggested changes --- .../descriptive-stats/descriptive-stats.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md index 0a3c4e82cb6..204f5cd55dc 100644 --- a/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md +++ b/content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md @@ -63,3 +63,21 @@ The above code produces the following output: ```shell DescribeResult(nobs=5, minmax=(12, 56), mean=34.0, variance=302.5, skewness=0.0, kurtosis=-1.3) ``` + +## Codebyte Example + +The following codebyte example demonstrates the usage of the `.describe()` function to calculate the descriptive statistics of a given array: + +```codebyte/python +import numpy as np +from scipy import stats + +# Define an array +arr = np.array([5, 10, 20, 40, 80]) + +# Calculate the descriptive statistics of the array +res = stats.describe(arr) + +# Print the result +print(res) +```