rvgtest-package(rvgtest)
rvgtest-package()所属R语言包:rvgtest
Tools for Analyzing Non-Uniform Pseudo-Random Variate Generators (RVG)
工具用于分析非均匀伪随机变量发生器(RVG)
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Suite for testing non-uniform random number generators.
非均匀分布的随机数生成器,用于测试套件。
Details
详细信息----------Details----------
</table>
</ TABLE>
rvgtest is a set of tools to investigate the quality of non-uniform pseudo-random random generators (RVG). Thus it provides functions to visualize and test for possible defects. There are three mean reasons for such defects and errors: <ol> Errors in the design of algorithms – The proof for theorem that claims the correctness of the algorithm is wrong.
rvgtest质量调查的非均匀伪随机的随机发电机组(RVG)是一组工具。因此,它提供的功能,可视化和测试可能存在的缺陷。平均有三个原因,这些缺陷和的错误:<OL>错误的对算法的设计 - 定理的证明,声称该算法的正确性是错误的。
Implementation errors -- Mistakes in computer programs.
在计算机程序中的执行错误 - 错误。
Limitations of floating point arithmetic and round-off errors in implementations of these algorithms in real world computers. </ol> Of course testing software is a self-evident part of software engineering. Implementation errors usually result in large deviations from the requested distribution and thus errors of type 2 are easily detected. However, this need not always be the case, for example for rather complicated algorithms like those based on patchwork methods.
浮点运算和舍入误差在实现这些算法在现实世界中的计算机的限制。 </ OL>课程测试软件,软件工程是一个不言自明的部分。实施通常会导致错误的请求的分布和2型错误很容易被发现在大的偏差。然而,这并不总是需要的情况下,例如像拼凑的方法的基础上的,而复杂的算法。
The same holds for errors of type 1. In the best of all worlds, there exists a correct proof for the validity of the algorithm. In our world however human can err. Then the deviations are rather small, since otherwise it would have been detected when testing the implementation for errors of type 2.
这同样适用于类型1的错误。在世界上最好的,存在一个正确的证明,该算法的有效性。然而,在我们的世界人可以犯错。的偏差是相当小的,否则它会被检测到时,测试执行的错误类型2。
Errors of type 3 can be a problem when the requested distribution has extreme properties. E.g., it is no problem to generate a sample of beta distributed random variates with shape parameters 0.001 using rbeta(n=100, shape1=0.001, shape2=0.001). However, due the limited resolution of floating point numbers it behaves like a discrete distribution (especially near 1). It is not always obvious whether such round-off errors will influence ones simulation results.
3型错误可能是一个问题,当请求的分布具有极端的性能。例如,它生成一个样本的β分布的随机变数与形状参数0.001rbeta(n=100, shape1=0.001, shape2=0.001)是没有问题的。然而,由于浮点数的分辨率有限,它的行为就像一个离散分布(尤其是接近1)。它并不总是显而易见的,这样的舍入误差影响的模拟结果。
It is the purpose of this package to provide some tools to find possible errors in RVGs. However, observing a defect in (the implementation of) a pseudo-random variate generator by purely statistical tools may require a large sample size which that exceeds the memory when hold in a single array in R. (Nevertheless, there is some chance that this defect causes an error in a particular simulation with a moderate sample size.) Hence we have implemented routines that can run tests on very large sample sizes (which are only limited by the available runtimes).
它的目的是这个包提供了一些工具,以发现可能存在的错误RVGs。然而,观察(执行)伪随机变量发生器由单纯的统计工具中的缺陷可能需要大样本的大小超过内存时保持在一个单一的阵列R.(不过,也有一些机会,这缺陷导致的错误在一个特定的模拟与适度的样本量。),因此,我们已经实施了非常大的样本量(只受限于可用的运行时),可以运行测试程序。
Currently there are two toolsets for testing random variate generators for continuous univariate distributions: <ol> Testing based on histograms for all kinds of RVGs.
目前有两个连续单变量分布的随机变量发生器,用于测试工具集:<OL>测试直方图各种RVGs的基础。
Estimating errors of RVGs that are based on numerical inversion methods. </ol>
估计错误,是基于数值反演方法的RVGs。 </ OL>
1。直方图----------1. Histograms----------
A frequently used method for testing continuous univariate distributions is based on the following strategy: Draw a sample, compute a histogram and run a goodness-of-fit test on the resulting frequency table.
以下策略:连续单变量分布测试是基于一个常用的方法抽取样本,计算直方图和产生的频率表上运行一个善良的拟合优度检验。
We have implemented a three step procedure: <ol> Create tables that can hold the information of huge random samples.
我们已经实施了三个步骤:<OL>创建表,可容纳巨大的随机样本的信息。
Perform some test for the null hypothesis on these tables.
零假设这些表上进行一些测试。
Visualize these tables as well the results of the tests. </ol>
这些表,以及测试结果的可视化。 </ OL>
The advantages of this procedure are:
此过程的优点是:
Huge total sample sizes are possible (only limited by available runtime but not by memory).
庞大的总样本量是可能的(仅受限于可用的运行,而不是由内存)。
Can run multiple tests on the same random sample.
可以同时运行多个相同的随机抽样测试。
Inspect data visually. </ul>
检查数据可视化。 </ ul>
In addition there are also some random functions for introducing defects in other random variate generators artificially. Thus one may investigate the power of tests.
此外,也有一些随机函数,在其他随机变量发电机人为引入的缺陷。因此,一个调查测试的力量。
<h4>List of Routines</h4> Data generation: rvgt.ftable.
<H4>列表例程</ H4>数据生成:rvgt.ftable。
Tests: rvgt.chisq, rvgt.Mtest.
测试:rvgt.chisq,rvgt.Mtest。
Visualization: plot (see plot.rvgt.ftable, plot.rvgt.htest for the respective syntax of the call).
可视化:plot(见plot.rvgt.ftable,plot.rvgt.htest的调用相应的语法)。
Perturbation of RVGs: pertadd, pertsub.
扰动的RVGs:pertadd,pertsub。
2。数值反演----------2. Numerical Inversion----------
Random variate generators that are based on inverting the distribution function preserve the structure of the underlying uniform random number generator. Given the fact that state-of-the-art uniform random number generators are well tested, it is sufficient to estimate (maximal) approximation errors.
反相分布函数是基于随机变量发生器保持底层的均匀分布的随机数发生器的结构。鉴于国家的最先进的均匀分布的随机数生成器是行之有效的,它是足够的估计(最大)的逼近误差。
Let G^[-1] denote the approximate inverse distribution function (quantile function) and F the (exact) cumulative distribution. Then the following measures for the approximation erros are implemented:
让我们G^[-1]表示的近似逆分布函数(分位数函数)和F(精确)累积分布。然后实施的近似误差修改以下措施:
u-error: e_u(u) = |u - F(G^[-1](u))|
U-错误:e_u(u) = |u - F(G^[-1](u))|
absolute x-error: e_x(u) = |F^[-1](u) - G^[-1](u)|
绝对的X-错误:e_x(u) = |F^[-1](u) - G^[-1](u)|
relative x-error: e_x(u) / |F^[-1](u)|
相对x错误:e_x(u) / |F^[-1](u)|
We are convinced that the u-error is the most convenient measure for the approximation error in the framework of Monte Carlo simulation. E.g., goodness-of-fit tests like the chi-square test or the Kolmogorov-Smirnov test look at this deviation.
我们相信,U型框架中的Monte Carlo模拟的逼近误差,错误是最方便的措施。例如,善良的拟合卡方检验或Kolmogorov-Smirnov检验测试,如在此偏差。
As for the histogram based tests we have implemented in such a way that sample sizes are not limited by memory. Again data generation and visualization is separated into to routines.
至于基于直方图的测试中,我们已经实现在这样一种方式,样本大小并不限于由存储器。同样数据的生成和可视化分离到的例程。
<h4>List of Routines</h4> Data generation: uerror, xerror.
<H4>列表套路</ H4>数据生成:uerror,xerror。
Visualization: plot (see plot.rvgt.ierror for the syntax of the call).
可视化:plot(见plot.rvgt.ierror的调用语法)。
(作者)----------Author(s)----------
Josef Leydold <a href="mailto:josef.leydold@wu.ac.at">josef.leydold@wu.ac.at</a>,
Sougata Chaudhuri <a href="mailto:sgtchaudhuri@gmail.com">sgtchaudhuri@gmail.com</a>
实例----------Examples----------
## ------------------------------------------------[#------------------------------------------------]
## 1. Histogram[#1。直方图]
## ------------------------------------------------[#------------------------------------------------]
## Use a poor Gaussian random variate generator[#使用一个贫穷的高斯分布随机变量生成]
## (otherwise we should not see a defect).[#(否则,我们不应该看到的缺陷)。]
RNGkind(normal.kind="Buggy Kinderman-Ramage")
## Create table of bin counts.[#创建表的bin计数。]
## Use a sample of 20 times 10^5 random variates.[#使用的样本,20倍,10 ^ 5个随机变数。]
table <- rvgt.ftable(n=1e5, rep=20, rdist=rnorm, qdist=qnorm)
## Plot histogram for (cumulated) data[#(累计)的数据绘制直方图]
plot(table)
## Perform a chi-square goodness-of-fit test and plot result[#执行卡方拟合优度的拟合优度检验和图的结果]
r1 <- rvgt.chisq(table)
plot(r1)
## Perform M-test and plot both results[M-#执行测试并绘制两个结果]
r2 <- rvgt.Mtest(table)
plot.rvgt.htest(list(r1,r2))
## ------------------------------------------------[#------------------------------------------------]
## 2. Numerical Inversion[#2。数值反演]
## ------------------------------------------------[#------------------------------------------------]
## Create a table of u-errors for spline interpolation of[#创建一个表,U-样条插值的错误]
## the inverse CDF of the standard normal distribution.[#逆CDF的标准正态分布。]
aqn <- splinefun(x=pnorm((-100:100)*0.05), y=(-100:100)*0.05,
method="monoH.FC")
## Use a sample of size of 10^5 random variates.[#使用的样本大小为10 ^ 5个随机变数。]
uerrn <- uerror(n=1e5, aqdist=aqn, pdist=pnorm)
## Plot u-errors[#PLOT U错误]
plot(uerrn)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|