Cant seem to get this var command to work! help?

Hello! Im a first year statistics student and i just cant seem to figurs this out. Im trying to calculate Variation(x) as learned in class: Var(x)= (X-u)^2 * P(x)..
im copying my consule
value <- c(2,3,4,5,6,7,8) #values of X
probval <- c(1/16,2/16,3/16,4/16,3/16,2/16,1/16) #prob values

value%*%probval #E
bg <- sample(value, 100000, replace = T, prob = probval)#chart
var(bg) #Var(x)
char <- sample(value, 1000000, replace = T, prob = probval)
var(chart)

The bolded one gives me the right answer (2.5) but for some reason, though i literaly copy pasted it, the "char" gives me a weird number, 3219.
wth?!
https://serving.photos.photobox.com/7966930957beb1b14be83778a38f5878a8796577fefbedcdd22d708b53acbd075fdc99ad.jpg

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.