我对 java 文档中使用的峰度的奇怪公式有问题:http : //commons.apache.org/proper/commons-math//javadocs/api-3.0/org/apache/commons/math3/stat/descriptive/时刻/峰度.html
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.
我最接近 java 程序产生的值是当我使用这个公式https://www.itl.nist.gov/div898/handbook/eda/section3/eda35b.htm但我仍然比预期的值高 0.2价值。
我不理解方括号,当我尝试实现公式时,我与所需值相差 3 个数量级。
是否可以将 java 文档公式转换为 Ruby 或某种有意义的数学符号?
这是我的 Ruby 翻译,比 java 程序生成的值大 0.2 左右。
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
峰度有四种略有不同的定义:
的过量峰度是一个给定分布的峰度和正常分布的峰度之间的差。该偏置是被估计的预期值和所述参数的真值之间的差。更完整的解释可以在https://en.wikipedia.org/wiki/Kurtosis和https://en.wikipedia.org/wiki/Bias_of_an_estimator 中找到。
您只能比较属于同一峰度版本的峰度值。nist 网站 ( https://www.itl.nist.gov/div898/handbook/eda/section3/eda35b.htm ) 解释了有偏见的版本、Java 文档 ( http://commons.apache.org/proper/ commons-math//javadocs/api-3.0/org/apache/commons/math3/stat/descriptive/moment/Kurtosis.html )无偏超峰度。通常,这两个值会根据您的结果而有所不同。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句