Full name
statistics.NormalDist.quantiles
Library
statistics
Syntax
statistics.NormalDist.quantiles(n = 4)
Description
The quantiles method of an object of type statistics.NormalDist divides the distribution into n continuous intervals with equal probability and returns a list with the n-1 values that separate these intervals.
Parameters
- n: Number of intervals to identify. The default value is 4, which implies the identification of the quartiles of the distribution.
Result
The statistics.NormalDist.quantiles method returns a list of values of type float.
Examples
If we start from the following normal distribution:
dist = statistics.NormalDist(mu = 5, sigma = 2)
...we can generate 100,000 samples and display their histogram with the following code:
plt.subplots(figsize = (9, 5))
plt.hist(dist.samples(100000), bins = 100, alpha = 0.6)
plt.grid()
plt.show()
plt.hist(dist.samples(100000), bins = 100, alpha = 0.6)
plt.grid()
plt.show()
Then we can obtain the quartiles of the distribution with the quantiles method:
dist.quantiles()
[3.651020499607837, 5.0, 6.348979500392163]