all.moments 函数 奇怪的结果 [英] all.moments function weird outcome

查看:25
本文介绍了all.moments 函数 奇怪的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算分布的第 n 个矩.我正在尝试在 R 中使用库时刻"的 all.moments 函数.我已经以这种方式测试了 all.moments:

I want to calculate the n-th moment of a distribution. I am trying to using all.moments function of library 'moments' in R. I have tested all.moments in this way:

 library(moments)
 r<-rnorm(10000)
 rr<-all.moments(r,order.max=4)
 rr

 [1]  1.000000000  0.002403360  0.962201478 -0.022694670  2.852696159

在我看来这不是真的,因为我知道正态分布中的第 3 和第 4 时刻必须为 0.我的错误在哪里?

This seems to me that it's not true, cause i know that the 3-th and 4-th moment must be 0 in a normal distribution. Where is my mistake?

推荐答案

第三个时刻是偏斜.你是对的:对于正态分布,这是零.由于您只是从正态分布中抽样,因此您的结果将接近于零,确实如此.

The third moment is the skewness. You are correct: for a normal distribution this is zero. Since you are only sampling from a normal distribution, your results will be approximately zero, which it is.

四阶矩是峰度.对于正态分布,这是 3σ^4.在这种情况下,σ 是 1,所以你的结果应该是 3,它是.

The fourth order moment is the kurtosis. For a normal distribution this is 3σ^4. In this case, σ is 1, so your result should be 3, which it is.

要提高估算的准确性,请增加样本量.对于 1e7 观察样本:

To improve the accuracy of your estimate, improve the sample size. For a sample of 1e7 observations:

> library(moments)
> r <- rnorm(1e7)
> all.moments(r,order.max=4)
[1] 1.0000000000 0.0004028138 0.9995373115 0.0007276404 2.9976881271

这篇关于all.moments 函数 奇怪的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆