The Standard Deviation is a measure of how spread out numbers are, in other words it's the average distance that each value in the set is far from the set average.
Ex:
If we have a data set of { 1,2,3,4,5 } then the average will be 3, to calculate the Standard Deviation we use the below formula:
where "s" is the sample standard deviation, N is the number of observations in the data set, x is the data set, and x̄ is the mean of the given data set, and can be calculated from the following formula:
x̄ = ( 1 + 2 + 3 + 4 + 5 ) / 5
= 3
s = √( (1/(5-1) * ( ( sqr(1-3) + sqr(2-3) + sqr(3-3) + sqr(4-3) + sqr(5-3) ) ) )
Description
This function computes the standard deviation of the values in x. If na.rm is TRUE then missing values are removed before computation proceeds.
Usage
sd(x, na.rm = FALSE)
Arguments
x: a numeric vector or an R object which is coercible to one by as.vector(x, "numeric").
na.rm: logical. Should missing values be removed?
[1] 1.581139
Means that the average distance from any point to the set mean is 1.511
NB:
Standard Deviation for the population is:
while the Standard Deviation for a sample is:
Ex:
If we have a data set of { 1,2,3,4,5 } then the average will be 3, to calculate the Standard Deviation we use the below formula:
1. Find the average of the data set, .
To find the average, add up all the numbers and divide
by the number of numbers in the data set, n.
2. For each number, subtract the average from it.
3. Square each of the differences.
4. Add up all the results from Step 3.
5. Divide the sum of squares (Step 4) by the number of
numbers in the data set, minus one (n – 1).
If you do Steps 1 through 5 only, you have found
another measure of variability, called the variance.
6. Take the square root of the variance. This is the standard
deviation.
x̄ = ( 1 + 2 + 3 + 4 + 5 ) / 5
= 3
s = √( (1/(5-1) * ( ( sqr(1-3) + sqr(2-3) + sqr(3-3) + sqr(4-3) + sqr(5-3) ) ) )
= √ ( .25 * ( 4 + 1 + 0 + 1 + 4 ) )
= √ ( .25 * 10 )
= 1.5811
Implementation of sd in R example:
sd {stats} R Documentation
Standard DeviationDescription
This function computes the standard deviation of the values in x. If na.rm is TRUE then missing values are removed before computation proceeds.
Usage
sd(x, na.rm = FALSE)
Arguments
x: a numeric vector or an R object which is coercible to one by as.vector(x, "numeric").
na.rm: logical. Should missing values be removed?
EX:
> v <- c(1,2,3,4,5 )
> sd(v)[1] 1.581139
Means that the average distance from any point to the set mean is 1.511
NB:
Standard Deviation for the population is:
while the Standard Deviation for a sample is:




No comments:
Post a Comment