真随机数? [英] True Random Numbers?
问题描述
我正在寻找一个像样的随机数生成器。我希望在很短的时间内制作一个大的随机数(大约100个左右,如果不是更多)
(尽可能快)。 />
我用来获取随机数的函数是
随机rn = new Random(System.currentTimeMillis());
但似乎系统没有经常更新毫秒数来导致真正的randomaziation(我只是在
for循环200次,只得到3个独特的结果)
关于如何获得大量真实随机数的任何建议?
谢谢
尼克
----- =通过Newsfeeds.Com发布,未经审查的Usenet新闻= -----
http://www.newsfeeds.com - 排名第一的新闻组服务世界!
----- ==超过100,000个新闻组 - 19个不同的服务器! = -----
Im looking for a decent random number generator. Im looking to make a large
number of random numbers (100 or so, if not more) in a short period of time
(as fast as possible).
the function i was using to get random numbers was
Random rn = new Random(System.currentTimeMillis());
but it seems that the system doesn''t update the milliseconds often enough to
cause a true randomaziation (i ran just the System.currentTimeMillis() in a
for loop 200 times and only got 3 unique results)
any suggestions on how to get a quantity of real random numbers?
Thanks
Nick
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
推荐答案
我遇到了类似的问题并将其添加到我的循环中:
Thread.sleep(1,2); //睡觉1毫升,2纳米生成更多随机种子
它会减慢数字生成但会保证随机随机
数字。
" Nicholas Geraldi" < NI ********* @ taconic.net>在消息中写道
新闻:3f ********** @ corp.newsgroups.com ...
I had a similar problem and added this in my loop:
Thread.sleep(1,2); //sleep fo 1 millis, 2 nanos to generate a more
random seed
It will slow the number generation but will guarantee uniquely random
numbers.
"Nicholas Geraldi" <ni*********@taconic.net> wrote in message
news:3f**********@corp.newsgroups.com...
我正在寻找一个体面的随机数生成器。我想在
时间的短时间内(尽可能快)制作一个
的大量随机数(100左右,如果不是更多)。
该功能我用来获取随机数是随机的rn = new Random(System.currentTimeMillis());
但似乎系统没有更新毫秒数通常足够
来引起真正的randomaziation(我在
a中只运行System.currentTimeMillis()循环200次并且只得到3个独特的结果)
有关如何的任何建议得到一些真实的随机数?
谢谢
尼克
----- =通过Newsfeeds.Com发布,未经审查的Usenet新闻= -----
http://www.newsfeeds.com - The世界排名第一的新闻组服务!
----- ==超过100,000个新闻组 - 19个不同的服务器! = -----
Im looking for a decent random number generator. Im looking to make a large number of random numbers (100 or so, if not more) in a short period of time (as fast as possible).
the function i was using to get random numbers was
Random rn = new Random(System.currentTimeMillis());
but it seems that the system doesn''t update the milliseconds often enough to cause a true randomaziation (i ran just the System.currentTimeMillis() in a for loop 200 times and only got 3 unique results)
any suggestions on how to get a quantity of real random numbers?
Thanks
Nick
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
世界因Nicholas Geraldi而高兴。 < NI ********* @ taconic.net>写道:
The world rejoiced as "Nicholas Geraldi" <ni*********@taconic.net> wrote:
关于如何获得一定数量的真实随机数的任何建议?
any suggestions on how to get a quantity of real random numbers?
这些天大多数操作系统都有一个名为 / dev / random",
从硬件设备收集值并将其组合
以加密方式生成高度随机的值。
由于这是一种有限的资源,通常还有一个/ dev / urandom
设备,它使用加密函数以更快的速率生成非常好的伪随机数据。 ..
-
如果这有用,< http://svcs.affero.net/rm.php?r = cbbrowne>给我打分
http://cbbrowne.com/info/linuxxian.html
MICROS~1:你今天想去哪里? Linux:去过那里,完成
那个。
Most operating systems these days have a device called "/dev/random",
which collects values from hardware devices and combines it
cryptographically to generate highly random values.
Since that is a limited resource, there is often also a "/dev/urandom"
device which uses crypto functions to generate very good pseudorandom
data at faster rates...
--
If this was helpful, <http://svcs.affero.net/rm.php?r=cbbrowne> rate me
http://cbbrowne.com/info/linuxxian.html
MICROS~1: Where do you want to go today? Linux: Been there, done
that.
你应该看一下Java附带的SecureRandom类。
当然,你不想在循环中间重新播种或重新创建它。
Nicholas Geraldi写道:
You should take a look at the SecureRandom class that comes with Java.
Of course, you don''t want to re-seed or re-create it in the middle of
the loop.
Nicholas Geraldi wrote:
我正在寻找一个体面的随机数发生器。我希望在很短的时间内制作大量的随机数(100左右,如果不是更多)
(尽可能快)。
功能我用来获取随机数是随机的rn = new Random(System.currentTimeMillis());
但似乎系统没有更新毫秒数经常足以引起一个真正的randomaziation(我在一个
for循环中运行System.currentTimeMillis()200次并且只得到3个独特的结果)
关于如何得到一定数量的真实随机数?
谢谢
尼克
----- =通过Newsfeeds.Com发布,未经审查的Usenet新闻= -----
http://www.newsfeeds.com - 世界排名第一的新闻组服务!
----- ==超过100,000个新闻组--19个不同的服务器! = -----
Im looking for a decent random number generator. Im looking to make a large
number of random numbers (100 or so, if not more) in a short period of time
(as fast as possible).
the function i was using to get random numbers was
Random rn = new Random(System.currentTimeMillis());
but it seems that the system doesn''t update the milliseconds often enough to
cause a true randomaziation (i ran just the System.currentTimeMillis() in a
for loop 200 times and only got 3 unique results)
any suggestions on how to get a quantity of real random numbers?
Thanks
Nick
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
这篇关于真随机数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!