Note :range( )function of R returns the minimum value and the maxim value of the data set.
2. The Variance and The Standard Deviation
EXAMPLE 24. 위의 예에서 Data Set 2의 sample variance와 sample standard deviation을 구하라.
[Solution]
x <- c(46, 37, 40, 33, 42, 36, 40, 47, 34, 45)
# 1. Variance
n <- length(x); n
y <- (x - mean(x)); y
var_x <- sum(y^2)/(n-1); var_x
# 2. R Function for Variance : var()
var(x)
# 3. R Function for Standard Deviation : sd()
sd(x)
> # 1. Variance
> n <- length(x); n
## [1] 10
> y <- (x - mean(x)); y
## [1] 6 -3 0 -7 2 -4 0 7 -6 5
> var_x <- sum(y^2)/(n-1); var_x
## [1] 24.88889
>
> # 2. R Function for Variance : var()
> var(x)
## [1] 24.88889
> # 3. R Function for Standard Deviation : sd()
> sd(x)
## [1] 4.988877
Note : In R, var() returns the sample variance, i.e. the denominator used in var() function is (n-1).
Thesample varianceof a set ofnsample data is the numbers2defined by the formula
s2=n−1Σ(x−xˉ)2
which by algebra is equivalent to the formula
s2=n−1Σx2−n1(Σx)2
The sample standard deviationof a set ofnsample data is the square root of the sample variance, hence is the numbersgiven by the formulas
s=n−1Σ(x−xˉ)2=n−1Σx2−n1(Σx)2
EXAMPLE 25. 무작위로 선발한 10명의 학생의 평균 평점은 다음과 같다. sample variance와 sample standard deviation을 구하라.
In probability theory and statistics, the coefficient of variation (CV), also known as relative standard deviation (RSD), is a standardized measure of dispersion of a probability distribution or frequency distribution. It is often expressed as a percentage, and is defined as the ratio of the standard deviation σ to the mean μ (or its absolute value, ∣μ∣ ).
평균에 대한 상대적인 변동성의 크기를 설명할 때에 변동계수(Coefficient of Variation)을 사용한다.
CV=xˉs
평균에 대한 표준편차의 비율로 표현된다.
변동계수가 클수록, 즉 표준편차가 표본평균에 비해 클수록 자료의 퍼짐진 정도가 더 크다고 할 수 있다.
EXAMPLE 26. Example 25.의 CV를 구하라.
[ Solution ]
# install.packages("goeveg")
library(goeveg)
x <- c(1.90, 3.00, 2.53, 3.71, 2.12, 1.76, 2.71, 1.39, 4.00, 3.33)
# 1. Calculation of CV
cv_x <- sd(x) / mean(x); cv_x
# 2. R Function : cv() in 'goeveg' package
cv(x)
> # 1. Calculation of CV
> cv_x <- sd(x) / mean(x); cv_x
## [1] 0.3279493
>
> # 2. R Function : cv() in 'goeveg' package
> cv(x)
## [1] 0.3279493