A Quick Recap Maths (Statistics) with Python | Statistics | it2edu |
Here we will see the practice example of following formal using in Python-
- Mean
- Median
- Mode
- Variance
- Standard Deviation
- Range
- Comparision etc.
==========================================================
# A Quick Recap Maths (Statistics) with Python | Statistics | it2edu
# Here we will see the practice example of following formal using in Python-
# Mean
# Median
# Mode
# Variance
# Standard Deviation
# Range
# Comparision etc.
# ==========================================================
import statistics
from matplotlib import pyplot as plt
from statistics import*
import statistics as statistics
# Derive Data
A=[10,15,8.9,6,8,16,11.5,9.3,7,14]
B=[14.2,13.2,12,14,15.3,13.5,13,11,9,13.1]
print("Given Data A = ",A)
print("Given Data B = ",B)
####################################
#finding mean of A and B
x=statistics.mean(A)
y=statistics.mean(B)
print("Mean of A = ",x)
print("Mean of B = ",y)
#################################
#comparing mean of A and B
if x> y:
print("Mean of A is greater than B. ")
elif x == y:
print("Mean of A and B are equal.")
else:
print("Mean of B is greater than A. ")
#################################
# finding median of A and B
print("Median of A:",statistics.median(A))
print("Median of B:",statistics.median(B))
#################################
#finding mode of A and B
print("Mode of A = ",statistics.mode(A))
print("Mode of B = ",statistics.mode(B))
################################
#finding minimum and maximum of A and B
#minimum
print("Minimum of A = ",min(A))
print("Minimum of B = ",min(B))
#maximum
print("Maximum of A = ",max(A))
print("Maximum of B = ",max(B))
##############################
#finding Standard deviation of A and B
p=statistics.stdev(A)
q=statistics.stdev(B)
print("Standard deviation of A = ",p)
print("Standard deviaion of B = ",q)
#############################
#comparing the standard deviation of A and B
if p> q:
print("Standard deviation of A is greater than B.")
elif p == q:
print("Standard deviation of A and B are equal.")
else:
print("Standard deviation of B is greater than A.")
##############################
#finding variance of A and B
print("variance of A = ",statistics.variance(A))
print("variance of B = ",statistics.variance(B))
###############################
#finding range of A and B
for i in range(len(A)):
print("Range of A = ",A[i])
for i in range(len(B)):
print("Range of B = ",B[i])
# graph
# fig,ax=plt.subplots(figsize=(10,7))
# ax.hist(A,bins=[0,25,50,75,100])
plt.plot(A, B,)
plt.title('Graph representation of A and B ')
plt.ylabel('Data of B')
plt.xlabel('Data of A')
plt.show()