测试PRNG的质量 [英] Testing the quality of PRNGs

查看:198
本文介绍了测试PRNG的质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩PRNG(例如Mersenne Twister和stdlib的rand()函数),我想要一个很好的测试来帮助我确定PRNG产生的随机数据的质量. 我已经使用PRNG生成的随机数计算了Pi的值,我发现rand()和Mersenne Twister非常接近以提供区别(我需要仔细检查10个小数点后吗?).

I am playing around with PRNGs (like Mersenne Twister and rand() function of stdlib) and I would want a good test that would help me ascertain the quality of random data produced by the PRNGs. I have calculated the value of Pi using random numbers generated by the PRNGs, and I find rand() and Mersenne Twister to be very close to offer a distinction (do I need to scrutinize after 10 decimal points?).

我对蒙特卡洛模拟不怎么了解;请让我知道一些算法/应用程序(可能有些简单但可以提供良好的推断),可以帮助我从质量上区分它们.

I do not have much idea about Monte Carlo simulations; please let me know about some algorithm/application (possibly something simple yet which could provide good inferences) that would help me distinguish them in terms of quality.

我之前没有注意到,但是有一个类似的主题:

EDIT 1: I didn't notice before, but there is a similar thread: How to test random numbers?

我无法解释其中一项评论中提到的NIST的结果.我想到了从 random.org 直观地解释模式的想法,并且正在关注因为它很简单.如果有人可以对我的测试过程发表评论,我将感到非常高兴:

EDIT 2: I am not able to interprete the results of NIST, as mentioned in one of the comments. I got this idea of visually interpreting the pattern (if any) from random.org and am following that because of it's simplicity. I would be very glad if someone could comment on the process of my testing:

  1. 使用rand()和MT1997从[0,1]生成N个随机数
  2. 如果(round(genrand_real1() / rand_0_1())),则为红色像素,否则为黑色
  1. Generate N randoms from [0,1] using rand() and MT1997
  2. if (round(genrand_real1() / rand_0_1())) then red pixel, else black

据我了解,这不是一个非常精确的解决方案,但是如果可以提供一个合理的估计,那么我现在可以接受.

As I understand that this is not a very precise solution, but if this provides a reasonable estimate, then I could live with this at the present moment.

推荐答案

有两个用于测试随机数的标准测试套件.

There are two standard test suites for testing random numbers.

  1. NIST 测试套件.他们有在C中的实现.
  2. Diehard测试套件(由George Marsaglia开发).这些测试有一个 C库实现.
  1. NIST test suite. They have an implementation in C.
  2. Diehard Test Suite (developed by George Marsaglia). There is a C library implementation of these tests.

Dieharder库有一个R接口,称为 RDieHarder .该库提供了NIST和Diehard测试套件的接口.

There is a R interface to the Dieharder library, called RDieHarder. This library provides an interface to both the NIST and Diehard test suites.

这篇关于测试PRNG的质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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