伪随机二进制序列预测
给定一个有限值的伪随机二进制序列(例如:00101010010101
),预测该序列将如何继续。有人可以告诉我最简单的方法吗?或者,如果对于几乎无法在计算机上玩纸牌的人来说这太困难了,有人可以告诉我从哪里开始我的第一步吗? PS:这个技术可以用来预测下一个电子轮盘号码的颜色吗(例如:分别将1
和0
分配给红色和黑色)?
Given a pseudo-random binary sequence (e.g.: 00101010010101
) of finite values, predict how the sequence will continue. Can someone please tell me the easiest way to do it? Or in case it's too difficult for someone who can barely play solitaire on its computer, can someone tell me where to get my first steps...
PS: can this technique be used to predict the colour of the next electronic roulette number (e.g.: assigning 1
and 0
to red and black respectively)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是一个不错的问题,但我认为如果“你几乎不会玩纸牌”,那么现在可能超出你的能力范围。
您应该考虑选择一种基本语言,大多数人会说 PHP,但我对向初学者推荐它持谨慎态度(尽管它很容易上手,请参阅:XAMPP)。 Java 可能是一种“易于运行和使用”的语言,但我确信这里有更好的线程关于从哪种语言开始(Python 或其他语言可能会获胜,因为有经验的程序员喜欢它)。
顺便说一句,你的英语很好(我没注意到你的母语不是英语)。
现在,对于你的问题,如果你正在寻找真正的模式匹配。我倾向于将这个想法转换为代码:
如果您只是猜测随机生成器暂时有偏差,并且这种偏差将在合理的短期内重新建立基线(平衡的 0 和 1),那么您可以比较每个 0 和 1 的计数,并根据与基线的偏差判断另一个更有可能。但是,请注意蒙特卡罗谬误。
This is a decent question but I think if "you can barely play solitaire" it might be out of your reach right now.
You should look into picking up a basic language, and most are going to say PHP but I'm wary of recommending that to a beginner (it's pretty easy to get working though, see:XAMPP). Java is probably an "easy-to-get-running-and-work-with" language but I'm sure there's better threads on here about which language to start with (Python or something probably wins because experienced programmers love it).
By the way, your English is fine (I didn't notice you were a non-native English speaker).
Now, as for your question, if you're looking at true pattern matching. I'd be inclined to convert this idea to code:
If you're just guessing that the random generator is temporarily biased, and that this bias will re-establish a baseline (balanced 0s and 1s) in the reasonably short-term then you can compare the count of each 0s and 1s and say the other is more likely based on the deviation from your baseline. However, be careful of the Monte Carlo fallacy.
首先回答 PS:不,因为轮盘赌旋转是独立事件,所以结果的历史顺序没有任何预测性。
一般问题很难而且很有趣。
该网站可以从初始值推断出数量惊人的序列:
http://www.research.att.com/~njas/sequences/" rel="nofollow noreferrer">http://www. Research.att.com/~njas/sequences/
请注意,它适用于任意整数序列。
我在像 {0,0,1,1,0,0,1,1,...} 这样的简单模式上尝试过,它说的是正确的。
To answer the PS first: No, because roulette spins are independent events so there's nothing predictive in the historical sequence of outcomes.
The general question is hard and interesting.
This website can infer a surprising number of sequences from their initial values:
http://www.research.att.com/~njas/sequences/
Note that it's for arbitrary integer sequences.
I tried it on simple patterns like {0,0,1,1,0,0,1,1,...} and it says the right thing.
我注意到没有人告诉你周期性。
伪随机序列总是适用于数学运算。 (直到量子计算机^^)
生成一个的常用方法是将两个素数相除(不确定它是正确的词,但无论如何)。
例如,
这些数字相当小,我们注意到什么?周期性。
素数越大,在这种情况下序列就越大:3 和 142857 就会很大
所以如果你长时间观察伪随机序列,你可能会发现周期性并能够“猜测”下一个数字。但这可能需要一段时间。
PS:对不起我的英语,我有点生疏^^
I noticed that nobody told you about periodicity.
Pseudo-random sequence always works on mathematical operation. (until the quantic computer ^^)
An usual way to generate one is to divide two prime number (not sure it's the right word but whatever).
for instance
Those are fairly small number and what do we notice? Periodicity.
The more big is the prime number the more the sequence in that case: 3 and 142857 will be big
So if you look to a pseudo-random sequence for a long time you may find a periodicity and be able to "guess" the next number. But that could take a while.
PS: sorry for my English, I’m a bit rusty ^^
你需要考虑的是随机性的特性,研究它们。例如,“随机性成串运行”。将随机序列与可预测序列进行比较:通常不会在可预测序列中找到一串序列。要利用一堆等待一堆。如果运气好的话,你就会赢。
What you need to think about is the properties of randomness, study those. For example, "Randomness runs in bunches". Compare a random sequence against a predictable sequence: you won't normally find bunches in the predictable one. To take advantage of bunches wait for the bunch. And with a little luck you will win.
加密安全的伪随机数生成器专门用于使您想做的事变得不可能。特别是,它们满足“下一位测试”:给定其输出的
k
位,您无法以大于1/2 的概率猜测位
。k+1
不满足下一位测试的普通伪随机数生成器可能会受到攻击,事实上,由于选择了 PRNG,在现实世界的系统中已经发现了安全漏洞。特别是,已知线性同余生成器在某种程度上(或完全)可预测,并且某些版本的 Unix random 可能使用此算法。不过,这种方法的数学运算量很大。如果您想走这条路,可以从搜索“线性同余生成器预测”开始。
如果您了解 PRNG 实现,另一种攻击是尝试确定用于生成您正在分析的序列的种子。种子有时基于可猜测的信息,例如一天中的时间、进程 ID 等。
Cryptographically secure pseudorandom number generators are intended specifically to make what you want to do impossible. In particular, they satisfy the "next bit test": given
k
bits of their output, you cannot guess bitk+1
with probability greater than1/2
.Plain pseudorandom number generators that do not satisfy the next bit test can be attacked and in fact security vulnerabilities have been discovered in real world systems due to the choice of PRNG. In particular, linear congruential generators are known to be somewhat (or completely) predictable, and some versions of Unix random may use this algorithm. This method is quite math intensive though. If you want to go down this path a search for "linear congruential generator prediction" is a place to start.
Another attack if you are aware of the PRNG implementation is to try to determine the seed used to generate the sequence you are analyzing. The seed is sometimes based on guessable information like time of day, process ID, etc.
好吧,对于伪随机序列,唯一的可能性是计算每种可能性之前出现过的数量。如果 1 超过 0,则下一个为 0 的可能性更大。可能性的大小取决于每个 1 的相对出现次数。
请注意,这不适用于真正的随机性,因为事件是独立的,不管统计学家告诉你什么:-)
当你第一次在桌子上得到 13 个红色时,你会发现这一点(痛苦地)。正在使用轮盘赌的双输方法。无论如何,庄家的优势来自于 0(在某些牌桌上是双 0),既不是红色也不是黑色。
Well, for pseudo-random sequences, the only possibility is to keep count how many of each possibility has come before. If the 1s outweigh the 0s, it's more likely that the next one will be 0. How much more likely depends on the relative occurrences of each.
Note that this won't work for true randomness since the events are independent, despite what the statisticians tell you :-)
You'll find that out (painfully) the first time you get a run of 13 reds on the table when you're using the double-on-loss method of playing roulette. In any case, the house derives its advantage from 0 (and double-0 on some tables) which are neither red nor black.