Stats Module
datachart.utils.stats
The module containing the stats methods.
The stats module provides methods for calculating statistics.
| FUNCTION | DESCRIPTION |
|---|---|
count |
Counts the number of elements in the list. |
sum_values |
Calculates the sum of the values. |
mean |
Calculates the mean of the values. |
median |
Calculates the median of the values. |
stdev |
Calculates the standard deviation of the values. |
variance |
Calculates the variance of the values. |
quantile |
Calculates the quantile of the values. |
iqr |
Calculates the interquartile range (Q3 - Q1). |
minimum |
Gets the minimum of the values. |
maximum |
Gets the maximum of the values. |
correlation |
Calculates the Pearson correlation coefficient between two lists. |
Functions
datachart.utils.stats.count
datachart.utils.stats.sum_values
datachart.utils.stats.mean
datachart.utils.stats.median
datachart.utils.stats.stdev
datachart.utils.stats.variance
datachart.utils.stats.quantile
Calculates the quantile of the values.
Examples:
| PARAMETER | DESCRIPTION |
|---|---|
values
|
The list of values.
TYPE:
|
q
|
The quantile to calculate (0-100).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The quantile of the values. |
datachart.utils.stats.iqr
Calculates the interquartile range (Q3 - Q1).
The interquartile range is the difference between the 75th percentile (Q3) and the 25th percentile (Q1). It is a measure of statistical dispersion and is useful for identifying outliers.
Examples:
| PARAMETER | DESCRIPTION |
|---|---|
values
|
The list of values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The interquartile range of the values. |
datachart.utils.stats.minimum
datachart.utils.stats.maximum
datachart.utils.stats.correlation
Calculates the Pearson correlation coefficient between two lists.
The Pearson correlation coefficient measures the linear relationship between two datasets. It ranges from -1 (perfect negative correlation) to 1 (perfect positive correlation), with 0 indicating no linear correlation.
Examples:
>>> from datachart.utils.stats import correlation
>>> correlation([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
1.0
>>> correlation([1, 2, 3, 4, 5], [5, 4, 3, 2, 1])
-1.0
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The first list of values.
TYPE:
|
y
|
The second list of values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The Pearson correlation coefficient. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If x or y is not a list or numpy array. |
ValueError
|
If x and y have different lengths. |