Question: Write an Rcpp function `varC(x)` which computes the sample variance of a numeric vector `x` (assume no missing values). Benchmark your function with a vector

Write an Rcpp function `varC(x)` which computes the sample variance of a numeric vector `x` (assume no missing values). Benchmark your function with a vector of length 1e5 and compare with `var(x)`.
##### (b) Write an Repp function 'varc(x) which computes the sample variance of a numeric vector x assume no missing values). Benchmark your function with a vector of length 1e5 and compare with var(x). Hint: 1. Use the computational formula of sample variance! 2. Sample variance is not defined if length(x)' is 1, return NON in this case. . ##### (b) Write an Repp function 'varc(x) which computes the sample variance of a numeric vector x assume no missing values). Benchmark your function with a vector of length 1e5 and compare with var(x). Hint: 1. Use the computational formula of sample variance! 2. Sample variance is not defined if length(x)' is 1, return NON in this case
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
