# coefficient of skewness for raw data
x=c(56, 6,45,10,35,66,18,2,9,7,40,5)

# skp
me=mean(x) 
med=median(x)
s=sd(x)
skp=3*(me-med)/s
cat("skp is ",skp, " ")

#skb
q1=quantile(x,0.25)
q2=quantile(x,0.50)
q3=quantile(x,0.75)

skb=(q3-2*q2+q1)/(q3-q1) #put bracket there  or wrong answer
cat("skb is ",skb)

#coefficient of skewness for discrete data 
x=seq(5, 75,10)#frequent error here don't make mistake
f=c(10,40,20,50, 10,40,16,14)
y=rep(x,f)
me=mean(y)
med=median(y)
s=sd(y)
skp=3*(me-med)/s


q1=quantile(y, 0.25)
q2=quantile(y,0.50)
q3=quantile(y,0.75)

skb=(q3-2*q2+q1)/(q3-q1) 
cat("skb is ",skb)

# kurtosis for group data
lb=seq(0,50,10)
ub=seq(10,60,10)
x=(lb+ub)/2
f=c(10, 20,30,50,40,30) 
y=rep(x,f)
me=mean(y) 
sumf=sum(f)
u2=(sum((y-me)^2))/sumf
u4=(sum((y-me)^4))/sumf

cat("\n meaw 2 is ",u2)
cat("\n mew 4 is", u4) 

gamma2=(u4/(u2^2))-3
cat("    ",gamma2)

#skewness and kurtosis for raw data
x=c(2, 3,7,8,10)
me=mean(x)
n=5
u2=sum((x-me)^2)/n
u3=sum((x-me)^3)/n
u4=sum((x-me)^4)/n
cat("\n u4 is ",u4)
gamma1=sqrt((u3^2)/(u2^3)) 
cat("gamma 1 is",gamma1)
gamma2=(u4/(u2^2)) -3
cat("gamma 2 is ",gamma2)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: