0% found this document useful (0 votes)
5 views4 pages

63) Statistics Module

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

63) Statistics Module

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

statistics module in python

Functions defined in statistics module


 This module provides functions for calculating mathematical statistics of numeric (Real
valued) data. There are three functions in this module:

 mean() , median() and mode()

1. mean() :- The arithmetic mean is the sum of the data divided by the number of values (i.e.
Average of the given set of values).

import statistics import statistics as st


a = [Link]([3,2,5]) a = [Link]([5,8,4,3])
print(a) print(a)
Output :- 3.3333333333 Output :- 5.0
Functions defined in statistics module
2. median() :- Return the median (middle value) of sorted numeric data if the number of
values are odd and if number of values are even than “mean of middle two values” is
evaluated. If data is empty, Statistics Error is raised.

Data must be in sorted order.

import statistics import statistics


a = [Link]([2,3,4,5,8]) a = [Link]([2,5,8,14,30,70])
print(a) print(a)
Output :- 4 Output :- 11
Functions defined in statistics module
3. mode() :- Return the most common(having more frequency) data point from discrete or
nominal data. If there is not exactly one most common value, then there are three
possible answers:

(i) Statistics Error is raised.

(ii) Return smallest number having same frequency

(iii) Return the number that comes first.

import statistics import statistics


a = [Link]([7,4,9,4,2,4,9]) a = [Link]([5,8,5,2,4,2])
print(a) print(a)
Output :- 4 Output :- Statistics Error or 2 or 5

You might also like