R - Code

>X=c(2,2,2,3,1,1,1,4,5,6,8,8,9)
> cat("given data =", X,"\n")
given data = 2 2 2 3 1 1 1 4 5 6 8 8 9
>Mean=mean(X)
> Median=median(X)
> mode=function(X)
+ {
+ uni=unique(X)
+ uni[which.max(tabulate(match(X,uni)))]
+ }
> Mode=mode(X)
> S.D=sd(X)
> Variance=var(X)
> Range=range(X)
> Quartile=quantile(X,c(0.25,0.50,0.75))
> Deciles=quantile(X,c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1))
> Percentile=quantile(X,c(0.26,0.76,0.85))
> IQR=IQR(X)
> QD=IQR/2
> n=length(X)
> CV=(S.D/Mean)*100
> MDMean= (sum(abs(X-Mean)))/n
> MD
> MDMedian= (sum(abs(X-Median)))/n
> GM=prod(X)^(1/n)
> HM=n/sum(1/X)
> cat("Mean of the given data =", Mean,"\n")
Mean of the given data = 4
> cat("Median of the given data =", Median,"\n")
Median of the given data = 3
> cat("Mode of the given data=",Mode,"\n")
Mode of the given data= 2
> cat("Standard Deviation of the given data=",S.D,"\n")
Standard Deviation of the given data= 2.915476
> cat("Variance of the given data=",Variance,"\n")
Variance of the given data= 8.5
> cat("Range of the given data=",Range,"\n")
Range of the given data= 1 9
> cat("Quartile of the given data:",Quartile,"\n")
Quartile of the given data: 2 3 6
> cat("Deciles of the given data:",Deciles,"\n")
Deciles of the given data: 1 1.4 2 2 3 4.2 5.4 7.2 8 9
> cat("Percentiles of the given data for 26%,76% and 85%:",Percentile,"\n")
Percentiles of the given data for 26%,76% and 85%: 2 6.24 8
> cat("Inter Quartile Range of the given data =",IQR,"\n")
Inter Quartile Range of the given data = 4
> cat("Quartile Deviation of the given data =",QD,"\n")
Quartile Deviation of the given data = 2
> cat("Coefficient of Variation of the given data =",CV,"\n")
Coefficient of Variation of the given data = 72.8869
> cat("Mean Deviation about Mean of the given data =",MDMean,"\n")
Mean Deviation about Mean of the given data = 2.461538
> cat("Mean Deviation about Median of the given data =",MDMedian,"\n")
Mean Deviation about Median of the given data = 2.384615
> cat("Geometric Mean of the given data =",GM,"\n")
Geometric Mean of the given data = 3.009174
> cat("Harmonic Mean of the given data =",HM,"\n")
Harmonic Mean of the given data = 2.237094