In: Statistics and Probability
Calculate the mean, median, mode, variance, and standard deviation for the following data set. (5 answers, 0.4 pts each)
Number of cigarettes smoked per day was recorded for 10 study subjects.
Study Subject | # of cigarettes smoked/day |
A | 5 |
B | 7 |
C | 3 |
D | 10 |
E | 6 |
F | 10 |
G | 20 |
H | 0 |
I | 5 |
J | 12 |
Solution-:
X-Number of cigarettes smoked per day was recorded.
By using R-software:
> #for mean
> mean=mean(x);mean
[1] 7.8
> #for median
> Med=median(x);Med
[1] 6.5
> #for mode
> tx=table(x);tx
x
0 3 5 6 7 10 12 20
1 1 2 1 1 2 1 1
> m=which(tx==max(tx))
> stx=sort(unique(x))
> Mode=stx[m];
> Mode
[1] 5 10
> #for variance and S.D.
> n=10
> v=var(x);v
[1] 31.06667
> var=((n-1)/n)*v;var # Variance
[1] 27.96
> sd=sqrt(var);sd
[1] 5.287722
R-Code:
x=c(5,7,3,10,6,10,20,0,5,12);x
#for mean
mean=mean(x);mean
#for median
Med=median(x);Med
#for mode
tx=table(x);tx
m=which(tx==max(tx))
stx=sort(unique(x))
Mode=stx[m];
Mode
#for variance and S.D.
n=10
v=var(x);v
var=((n-1)/n)*v;var # Variance
sd=sqrt(var);sd