如何确定一个算法的偏见?偏见、算法

2023-09-11 07:14:37 作者:刀下论成败

让我们说我有是应该重新present抛硬币的算法。如何确定这枚硬币的偏见?具体而言,我已经写了算法此的jsfiddle 。

Let's say I have an algorithm that is supposed to represent a coin flip. How do I determine the bias of this coin? Specifically, I have written the algorithm in this JSFiddle.

小提琴运行一系列的20次测试。每个测试翻转硬币100次,吻合的结果。在系列的结尾它报告头/尾为在所有测试翻转的总数。这个结果似乎是接近1(双方的),但我没有做这个任何严格的测试。

The fiddle runs a series of 20 tests. Each test flips the coin 100 times and tallies the results. At the end of the series it reports Heads/Tails for the total number of flips across all tests. This result seems to be approaching 1 (from both sides), but I have not done any rigorous testing of this.

请注意,这不是功课。这纯粹是个人兴趣。

Note, this is not homework. This is purely a personal interest.

推荐答案

您不能想出一个办法,以保证检测的偏见,但可以将其确定到一定程度的确定性(比如95%)。你要做的就是测试的 N 的时间,算你有多少次获得头,把这个变量的 ^ h 的。

You can't come up with a way to guarantee detecting a bias, but you can determine it to a certain degree of certainty (say 95%). What you do is test n times and count how many times you get heads, call this variable h.

那么,如果的 ^ h / N 的< 0.5 - 1.96 * SQRT(0.25 / N 的),那么硬币偏向尾部(具有95%的可能性),并且如果ħ / N 的> 0.5 + 1.96 * SQRT(0.25 / N 的),那么硬币偏于头。

Then if h / n < 0.5 - 1.96 * sqrt(0.25 / n) then the coin is biased towards tails (with a 95% probability) and if h / n > 0.5 + 1.96 * sqrt(0.25 / n) then the coin is biased towards heads.

此决定是基于所谓的正常逼近二项分布的,你可以阅读更多关于它在这里:http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Normal_approximation_interval

This decision is based on something called normal approximation to a binomial distribution, you can read more about it here: http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Normal_approximation_interval