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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -