Assignment 2
Name : Saurabh Dinesh Chaudhari || Div : TEA || Roll No : TEA27
Plot the Normal Distribution for class test result of a particular subject. Identify the Skewness and Kurtosis.
from scipy.stats import skew, kurtosis
import matplotlib.pyplot as plt
import scipy.stats as stats
import pandas as pd
import numpy as np
df = pd.read_csv("score.csv")
x = df['math score']
x =x.to_numpy()[:15]
x.sort()
mean= np.mean(x)
sd = np.std(x,ddof =1)
median = np.median(x)
fit = stats.norm.pdf(x,mean,sd)
plt.hist(x, density = True, color ="yellow",ec ="white")
plt.plot(x, fit,"go:")
plt.title("Math Scores")
plt.xlabel("Marks")
plt.ylabel("Normal Distribution")
plt.show()
Skewness
Definition :
Skewness measures the shift of the distribution from the normal bell curve
Positive skew value denotes right shift whereas negative skew value denotes left shift.
def skewness(x,mean,sd):
return np.sum((x-mean)**3)/((len(x)-1)*(sd**3))
skewness(x,mean,sd)
Kurtosis
Definition :
Kurtosis define how thick the tail- ends of distribution, which gives the probability of finding extremes.
It is the fourth central movement.
def kurtosis(x,mean,sd):
return np.sum((x-mean)**4)/((len(x)-1)*(sd**4))
kurtosis(x,mean,sd)