-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Term Entry] Python:SciPy scipy.stats: Descriptive Stats #6055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
55a300c
[Term Entry] Python:SciPy scipy.stats: Descriptive Stats
Sriparno08 e0e0cde
Merge branch 'main' into descriptive-stats
PragatiVerma18 609ab25
Update content/scipy/concepts/scipy-stats/terms/descriptive-stats/des…
Sriparno08 061b775
Update content/scipy/concepts/scipy-stats/terms/descriptive-stats/des…
Sriparno08 cfcdb3f
Made suggested changes
Sriparno08 f26b325
Merge branch 'main' into descriptive-stats
PragatiVerma18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
content/scipy/concepts/scipy-stats/terms/descriptive-stats/descriptive-stats.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
Title: 'Descriptive Stats' | ||
Description: 'Summarizes and describes 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 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: | ||
|
||
- 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) | ||
``` | ||
|
||
## 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) | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.