开发者

Dynamic Frequency Evaluation on Massive Random Numbers

开发者 https://www.devze.com 2023-01-20 06:27 出处:网络
I use a random function(Let\'s call it randomNum()) to 开发者_如何学Gogenerate random numbers(unsigned long) continuously(will generate about one million numbers in total).My question is How to determ

I use a random function(Let's call it randomNum()) to 开发者_如何学Gogenerate random numbers(unsigned long) continuously(will generate about one million numbers in total).My question is How to determine whether the frequency of current number generated is greater than 20%(among the total numbers generated so far) efficiently?

Please write down your opinion or your c code?Thanks.


A hash-table, whose entries are the count for each value?


If I understand your question you are asking:

If I draw 10^6 samples from an RNG which can produce any integer in the range 0..(2^32)-1 what is the probability that 0.2 x 10^6 of the samples will have the same value ?

Unless your RNG is seriously flawed the answer is 0 probability, to more decimal places than you ought to worry about in any realistic set of circumstances.

So, obviously, I have misunderstood the question ...

0

精彩评论

暂无评论...
验证码 换一张
取 消