You are on page 1of 11

LAB ASSIGNMENT-1

LANKA JASWANTH
19BIT0061
Statistics for Engineering
MAT2001

EXPERIMENT-1
Measures of Central tendency and Variability

Q. Write the R programming code for computing the


mean ,median ,mode ,quartile deviation, variance,
standard deviation ,co-efficient of variation ,first four
moments about the mean and Pearson’ co-efficient for
the following frequency distribution.

R-code:
> x=seq(175,245,10)

>x

[1] 175 185 195 205 215 225 235 245

> f=c(52,68,85,92,100,95,70,28)

>f

[1] 52 68 85 92 100 95 70 28
> #Mean

> h=10

> N=sum(f)

> M=(sum(x*f))/N

>M

[1] 208.9831

> #Median

> x=seq(175,245,10)

> f=c(52,68,85,92,100,95,70,28)

> cf=cumsum(f)

> N=sum(f)

> mc=min(which(cf>=N/2))

> mcf=f[mc]

> c=cf[mc-1]

> l=x[mc]-h/2

> Md=l+(h/mcf)*(((N/2)-c))

> Md

[1] 209.7826
> #Mode

> h=10

> x=seq(175,245,10)

> f=c(52,68,85,92,100,95,70,28)

> mc=which(f==max(f))

> f1=f[mc]

> f0=f[mc-1]

> f2=f[mc+1]

> l=x[mc]-h/2

> Mo=l+((f1-f0)/(2*f1-f0-f2))*h

> Mo

[1] 216.1538

> #Quartile deviation

> h=10

> x=seq(175,245,10)
> f=c(52,68,85,92,100,95,70,28)

> cf=cumsum(f)

> N=sum(f)

> q1=min(which(cf>=N/4))

> q2=min(which(cf>=(3*N)/4))

> Q1=x[q1]

> Q3=x[q2]

> Qd=(1/2)*(Q3-Q1)

> Qd

[1] 15

> #Variance ,Standard deviation and coefficient ofvariance

> h=10

> x=seq(175,245,10)

> f=c(52,68,85,92,100,95,70,28)

> N=sum(f)

> M=(sum(x*f))/N

>M

[1] 208.9831
> Var=((1/N)*(sum(x^2*f)))-((1/N)*(sum(x*f)))^2

> Var

[1] 388.0336

> SD=sqrt(Var)

> SD

[1] 19.69857

> Cv=100*(SD/M)

> Cv

[1] 9.425917

> # Moments and Pearson’sco-efficient

> h=10

> x=seq(175,245,10)

> f=c(52,68,85,92,100,95,70,28)

> N=sum(f)

> M=(sum(x*f))/N

> M1=sum(((x-M)^1)*f)/N

> M2=sum(((x-M)^2)*f)/N

> M3=sum(((x-M)^3)*f)/N
> M4=sum(((x-M)^4)*f)/N

> B1=(M3^2)/(M2^3)

> B2=(M4)/(M2^2)

> G1=abs(sqrt(B1))

> G2=B2-3

> B1

[1] 0.003424753

> B2

[1] 2.034009

> G1

[1] 0.05852139

> G2

[1] -0.9659908

Result:
Mean=208.9831
Median=209.7826
Mode=216.1538
Quartiledeviation(Q)=15
Variance=388.0336
Standarddeviation=19.69857
Co-efficient ofvariance=9.425917
Moments and Pearson’s co-efficients
B1= 0.003424753
B2=2.034009
G1=0.05852139
G2= -0.9659908

You might also like