如何将这个峰度公式从java文档翻译成Ruby?
我对java文档中使用的奇怪峰度公式有一个问题:如何将这个峰度公式从java文档翻译成Ruby?,java,ruby,statistics,Java,Ruby,Statistics,我对java文档中使用的奇怪峰度公式有一个问题: 峰度有四种稍有不同的定义: 过剩峰度是给定分布的峰度与正态分布的峰度之间的差异。偏差是被估计参数的期望值和真实值之间的差值。可以在和中找到更完整的解释 只能比较属于同一峭度版本的峭度值。nist网站()解释了有偏的版本,Java文档()解释了无偏的超额峰度。通常,这两个值根据您的结果而不同 您可以更好地查看Java类的源代码。 Computes the Kurtosis of the available values. We use the
峰度有四种稍有不同的定义: 过剩峰度是给定分布的峰度与正态分布的峰度之间的差异。偏差是被估计参数的期望值和真实值之间的差值。可以在和中找到更完整的解释
只能比较属于同一峭度版本的峭度值。nist网站()解释了有偏的版本,Java文档()解释了无偏的超额峰度。通常,这两个值根据您的结果而不同 您可以更好地查看Java类的源代码。
Computes the Kurtosis of the available values.
We use the following (unbiased) formula to define kurtosis:
kurtosis = { [n(n+1) / (n -1)(n - 2)(n-3)] sum[(x_i - mean)^4] / std^4 } - [3(n-1)^2 / (n-2)(n-3)]
where n is the number of values, mean is the Mean and std is the StandardDeviation
Note that this statistic is undefined for n < 4. Double.Nan is returned when there is not sufficient data to compute the statistic.
def kurtosis
return 0 if @values.length == 1
cached_mean = mean
n = @values.length.to_f
rku = @values.sum { |x| (x - cached_mean)**4 }
rkb = standard_deviation**4
real_kurtosis = rku / rkb
bk = (n * (n + 1)) / ((n - 1) * (n - 2) * (n - 3))
ak = (3 * (n - 1)**2) / ((n - 2) * (n - 3))
(bk * real_kurtosis) - ak
end