Stats¶
This section showcases the utility functions found in the datachart.utils.stats module.
Let us start by importing the supporting libraries:
import random
Statistics Submodule¶
The dataset.utils.stats submodule contains functions for calculating statistics. To showcase its use, let us create a list of random numbers:
random_values = random.sample(range(1, 100), 10)
random_values
[71, 95, 63, 76, 88, 29, 47, 35, 26, 8]
Let us now showcase the functions in the stats
module.
Count¶
The count
function returns the number of elements in the list.
from datachart.utils.stats import count
count(random_values)
10
Mean¶
The mean
function returns the mean of the values.
from datachart.utils.stats import mean
mean(random_values)
53.8
Median¶
The median
function returns the median of the values.
from datachart.utils.stats import median
median(random_values)
55.0
Standard Deviation¶
The stdev
function returns the standard deviation of the values.
from datachart.utils.stats import stdev
stdev(random_values)
27.61448895054913
Quantile¶
The quantile
function returns the quantile of the values.
from datachart.utils.stats import quantile
Show the 25th quantile:
quantile(random_values, 25)
29
Show the 75th quantile:
quantile(random_values, 75)
76
Minimum¶
The minimum
function returns the minimum of the values.
from datachart.utils.stats import minimum
minimum(random_values)
8
Maximum¶
The maximum
function returns the maximum of the values.
from datachart.utils.stats import maximum
maximum(random_values)
95
Under development
This theme is still under development. If you are interested in improving it, please let us know.