A summation in R software -
i need work out summation
(xi-m)^3
- i takes values 1 25
- xi elements of vector x
- m mean of vector x
is following code correct?
s<-sum((xi-m)^3)
some data first:
set.seed(1) x = rnorm(100, 20, 3)
instead of using x - mean(x)
, can use scale
, avoiding divide standard deviation using scale=f
argument:
sum(scale(x[1:25], scale=f)^3) #> sum((x[1:25]-mean(x[1:25]))^3)==sum(scale(x[1:25], scale=f)^3) #[1] true
Comments
Post a Comment