楼主: lugoo
15482 14

[问答] ks test [推广有奖]

  • 0关注
  • 0粉丝

已卖:580份资源

大专生

80%

还不是VIP/贵宾

-

威望
0
论坛币
2691 个
通用积分
40.0619
学术水平
2 点
热心指数
2 点
信用等级
2 点
经验
750 点
帖子
39
精华
0
在线时间
70 小时
注册时间
2005-3-13
最后登录
2023-7-13

楼主
lugoo 发表于 2011-6-6 18:43:07 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我现在有一组数据,我想知道它是不是服从uniform distribution的,请问这如何在matlab里实现啊?我看了 kstest,默认的One-sample Kolmogorov-Smirnov test是测试 standard normal cdf的,请问如何应用于均匀分布呢?
另外,matlab里好像没有AD test,请问在哪儿能找到做ad  test 的代码呢?

谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:test Est distribution kolmogorov Standard test

沙发
liuxin9023 发表于 2011-6-7 09:47:54
试试卡方检验吧 chi2gof 自己做个uniform distribution的分布函数就OK了

藤椅
tulipsliu 在职认证  发表于 2011-6-7 10:37:10
朋友,你给我发的消息我看到了。不过没看全,最近好像“短消息”老时无法读完。不过找到你这里的程序提问。
我还没看,也暂时还没有答案。
Kolmogorov-Smirnov test 。这个检验,应该不止只是能检验是否时标准正态分布吧?比如还有一些统计图;
Q-Q plot .这个就是我们说的 Q-Q 图。

kolmogorov  是现代概率公里理论的奠基人。概率论的几大公理,都是以他的名字命名。呵呵,扯远了。
你也问的比较细致了。
你说系统给的 K-S test 是  one sample 的。那么你需要其他的,好像条件时  均匀分布的检验。如果时这样,我建议你继续在看看系统手册。
doc kstest
然后看看里面参数的说明,通常这些函数的调用都有很大的灵活性。比如 random 函数,后面加入一些参数,就可以产生不同的随机数,比如 random('Normal',100,1),这样的应该时产生标准正态分布随机数。而另一个参数较少的,就是叫正在随机数发生函数  randn(m,n) etc。不一而足。


我才起床,还没开始运行 MATLAB 。一会儿我也看看。
另外如果你需要其他的 kstest 的检验程序,应该在 Lesage 的 JPL7 里,检验程序中有超过一个维的检验程序。曾经看到过有一个叫 kstest2()  这样的函数。

先聊到这里,深入看过后再继续给你回复。
劳动经济学

板凳
tulipsliu 在职认证  发表于 2011-6-7 10:39:16
对了,你说的 AD test 是什么?
系统自带的 Econometrics toolbox 里,有大量的经济学建模检验程序。
adf 检验的话,很简单,名字都很好记。叫    adftest()  ,还有  kpsstest  这样的检验函数。

至于基础的检验,比如你刚才说的 KS 这样的检验,在统计工具箱里。


你说的 AD test 是什么?
劳动经济学

报纸
tulipsliu 在职认证  发表于 2011-6-7 16:22:00
kstest

One-sample Kolmogorov-Smirnov test
Syntax

h = kstest(x)
h = kstest(x,CDF)
h = kstest(x,CDF,alpha)
h = kstest(x,CDF,alpha,type)
[h,p,ksstat,cv] = kstest(...)

Description

h = kstest(x) performs a Kolmogorov-Smirnov test to compare the values in the data vector x to a standard normal distribution. The null hypothesis is that x has a standard normal distribution. The alternative hypothesis is that x does not have that distribution. The result h is 1 if the test rejects the null hypothesis at the 5% significance level, 0 otherwise.

The test statistic is:

where F(x) is the empirical cdf and G(x) is the standard normal cdf.

h = kstest(x,CDF) compares the distribution of x to the hypothesized continuous distribution defined by CDF, which is either a two-column matrix or a ProbDist object of the ProbDistUnivParam class or ProbDistUnivKernel class. When CDF is a matrix, column 1 contains a set of possible x values, and column 2 contains the corresponding hypothesized cumulative distribution function values G(x). If possible, define CDF so that column 1 contains the values in x. If there are values in x not found in column 1 of CDF, kstest approximates G(x) by interpolation. All values in x must lie in the interval between the smallest and largest values in the first column of CDF. If the second argument is empty ([]), kstest uses the standard normal distribution.
劳动经济学

地板
tulipsliu 在职认证  发表于 2011-6-7 16:28:29
h=kstest(x,CDF), 这个时一个参数。你的问题只需要这个检验。因为你就一个样本,想知道它服从均匀分布与否。
其中,一些调用不输入CDF 参数。要么就是  h=kstest(x).  这个函数的默认CDF 是 标准正态分布,检验时X这个样本服从 标准正态分布与否。

另外的调用是这样的。
[h,p,ksstat,cv] = kstest(x,[],alpha,type)
将第二个参数设置为空,也是代表是标准正态分布,手册里提示,要做是否服从标准正态分布,还有 liliktest 吧,这个拼写不一定正确。


我还没理解 CDF 这个参数怎么赋值。你问问论坛的其他人,因为我平时很少用 KSTEST 函数。


系统统计工具箱里,还有一个 KSTEST2 函数。是检验两个样本的分布是否一样。
比如有两个样本,分别为 X,Y 。
h=kstest2(x,y)
这样调用就可以。
我只能回答这么多了。不好意思。
劳动经济学

7
lugoo 发表于 2011-6-7 17:34:11
6# tulipsliu
谢谢你的热心回复!我看了kstest的句法说明,但发现里面并没有对h = kstest(x,CDF,alpha) 中的CDF做说明,也不清楚这个CDF是字符型的还是一个vector,但感觉像是个数值的vector。如果是那样的话,这儿的uniform cdf 如何定义?xx=-100:.1:100; h=kstest(data,unifcdf(xx)) ? 好像不对啊,我有点搞糊涂了,呵呵


AD-test是指Anderson-Darling Test,我好像没在toolbox里看到这个test?

8
lugoo 发表于 2011-6-7 17:37:21
2# liuxin9023
谢谢你的回复!我现在有点糊涂了,不知道你能不能写一下具体怎么做呢?怎么做一个uniform distribution的分布函数?是xx=-100:.1:100; cdf=unifcdf(xx))这样吗?

9
yucongy 发表于 2011-6-8 10:59:47
一定要用matlab么?
S-Plus中倒是有现成的程序
不过我觉得参照S-Plus中的程序再把它转换成matlab语言应该不难哦
不经意间一年过去了,发现学到的东西不少,但是要学的东西却越来越多
若有问题咨询,请邮件联系:yucong134@163.com

10
liuxin9023 发表于 2011-6-8 11:20:45
Anderson-Darling Test国外一般都讲 国内一般都不讲

做uniform distribution的分布函数意思就是说 比如说把0到1分成100段 算每个部分的分布函数值 就可以用卡方检验来进行分析了 要是统计懂得多的话 ks检验 也可以对应做的

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-3 11:44