В Fri, 4 Oct 2024 19:14:30 +0800 Steven Yen <st...@ntu.edu.tw> пишет:
> I have a vector: > set.seed(123) > n<-3 > x<-rnorm(n); x [1] -0.56047565 -0.23017749 > 1.55870831 > var(x[1]) cov(x[1],x[2]) Are you sure you don't have a matrix? If you type var(x[1]) or cov(x[1],x[2]) into R, you can see that all these are NA: an unbiased estimate of variance or covariance requires dividing by (sample size - 1), which would be 0 for individual numbers. Even if you did divide by (sample size), the answers would all be 0, because a single number is always equal to the mean of the same one number. -- Best regards, Ivan ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.