### mean

prob39= c(70,60,66,54,66,60,55,57,67,71,62,69,57,63,69,58,60,52,63,63,61,65,60,60,73)
range(prob39)
## [1] 52 73
xbar<-sum(prob39)/length(prob39)

compare with default mean function in R

mean(prob39)
## [1] 62.44

### Weighted Mean

x<-c(86, 96, 82, 98, 100)
w<-c(0.5, 0.15, 0.2, 0.1, 0.05)
xw<-x*w
xw 
## [1] 43.0 14.4 16.4  9.8  5.0
sum(xw)
## [1] 88.6
Weighted_mean<-sum(xw)/sum(w)
Weighted_mean
## [1] 88.6

TO find the weighted mean or with classes, consider mid value of classes as x and frequency as weight(w).

### Standard Deviation

$$varince(s^2)=\frac{\sum(x_{i}-\bar{x})^2}{n-1}$$

std<-sd(prob39)  ##default R function

var<-sum((prob39-xbar)^2)/(length(prob39)-1)
std1<-sqrt(var) # compare the result with default output
# square of standard deviation is called variance
variance<-(std)^2
variance
## [1] 30.34
cv<-std/xbar
cv
## [1] 0.08822

### Standard Deviation with frequency

$$varince(s^2)=\frac{\sum(x_{i}-\bar{x})^2f}{n-1}$$

x<-c(3,5,7,9,11) ##  for data with classes, x must be mid-value of the classes
f<-c(30,45,70,55,10) # frequency(weight)
xbar<- sum(x*f)/sum(f)
variance<- sum((x-xbar)^2*f)/(sum(f)-1) ## if weight is count, you need to subtract 1. here, n=sum(f)-1
variance
## [1] 4.894
sd<-sqrt(variance)
sd
## [1] 2.212

### Data Summary, boxplot

summary(prob39)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
##    52.0    60.0    62.0    62.4    66.0    73.0

### box plot

boxplot(prob39)

### Side by side Box plot

KD<-c(42,25, 38, 27, 27, 23, 38, 28, 31)
LJ<-c(27, 36,37, 29,38,34, 17, 32, 13, 17)
boxplot(KD)

boxplot(LJ)

boxplot(KD,LJ,names=c("Lebron","Kevin"))