Lab 0 Instructions

Question 1

Suppose vec <- c(10, 8, 10, 8, 8, 4).

  1. What is wrong with a call to c(sqrt(10), sqrt(8), sqrt(10), sqrt(8), sqrt(8), sqrt(4))?

  2. For vector \(x = c(x_1, \cdots, x_n)\), the formula for calculating sample standard deviation is

\[ s = \sqrt{\frac{\sum_i^n(x_i - \bar x)^2}{n-1}},\]

where \(\bar x = \frac{\sum_i^n x_i}{n}\) and \(n\) is the length of the vector \(x\). Please compute the sample standard deviation for vec = c(10, 8, 10, 8, 8, 4) using the formula. You may use the vectorised functions like mean(), sum() and the operators.

  1. Compare the result with sd(vec). Are they the same?