计算变异系数非常基本。在edx-python课程中,我偶然发现了一个用python计算CV的问题。我以为R会更快,但是答案是错误的。
我实际上感兴趣的是哪一个更正确?
Python:
from scipy.stats import variation
cvtest = [10, 4, 12, 15, 20, 5]
variation(cvtest)
# Answer: 0.5034317492677621 - answer was accepted
R:
cvtest = c(10, 4, 12, 15, 20, 5)
sd(cvtest)/mean(cvtest)
# Answer: 0.5514819 - answer was not accepted