HW-Q 2: Calculate \(e^2\) with appropriate code (show the code & the output as well).
exp(2)
## [1] 7.389056
HW-Q 3: Calculate the natural \(log\) of 0 and natural \(log\) of 10.
log(0, base = exp(1))
## [1] -Inf
log(10, base = exp(1))
## [1] 2.302585
HW-Q 4: Calculate the mean of \(y\) with the missing values removed. Use only the mean() function.
y = c(0, 2, NA, 3, 4, 1, 9, 0)
mean(y, na.rm = TRUE)
## [1] 2.714286
HW-Q 5: Given that,
x = 1:100
Now, for the following expression \(\sum_{i=1}^{n}ln(x_i)\)
- What is the value of \(n\)?
n = 100
- Calculate the expression given in the question above. (That is, sum the natural \(log\) of each element of \(x\).)
sum(log(x, base = exp(1)))
## [1] 363.7394