gpt4 book ai didi

r - 我在哪里可以找到 R 中 Kolmogorov-Smirnov 距离的极限分布?

转载 作者:行者123 更新时间:2023-12-04 12:31:42 24 4
gpt4 key购买 nike

在进行重要性抽样实验时,我模拟了 Kolmogorov-Smirnov 距离的值

$$
D_n =\max_x |\hat{F}_n(x)-F(x)|
$$

其中 $n$ 是原始重要性样本的大小,我想将这些值与 the asymptotic distribution of the Kolmogorov-Smirnov test 进行比较, 或 Kolmogorov distribution , IE。

$$
\sqrt{N} D_n\longrightarrow\sup_{t\in[0,1]}|B(t)|
$$

其中 $B$ 是布朗桥。

由于ks.test依赖于这种渐近分布,它的 cdf 已经存在于 R 中的某个地方,我想知道如何访问它。 R函数ks.test包含指令

PVAL <- 1 - if (alternative == "two.sided") 
.Call(C_pKolmogorov2x, STATISTIC, n)

但我自己调用 C_pKolmogorov2x不起作用。

最佳答案

“编写 R 扩展”manual 的相关摘录

Then, the directive in the NAMESPACE file

useDynLib(myDLL, .registration = TRUE)

causes the DLL to be loaded and also for the R variables foo, bar_sym, R_call_sym and R_version_sym to be defined in the package’s namespace.



翻译成人类语言,这意味着(大致)所有非 R 代码的默认位置都在包命名空间中。因此需要三重结肠。

因此,如果您在代码中找到 .Call(something,args) ,您可以通过 .Call(package:::something,args) 从命令行调用它.这就是为什么简单调用 C_pKolmogorovx不工作。 R 没有找到它,因为包命名空间是为包而不是用户设计的。

如果您想找出外部代码所在的位置,您需要查看 2 个文件。先看包的NAMESPACE是否为 useDynLib用于注册外部代码功能,然后查看 src/init.c包中所有可用的外部代码函数都在其中注册的文件。

关于r - 我在哪里可以找到 R 中 Kolmogorov-Smirnov 距离的极限分布?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24697706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com