用于解决给定硬币输出的 HMM

发布于 2024-12-20 02:55:26 字数 411 浏览 2 评论 0原文

我在 HMM 上遇到了这个作业问题,我已经解决了。我想知道我是否正确。问题是:

假设一个不诚实的经销商有两枚硬币,一枚公平,一枚偏向;有偏见的硬币 正面朝上的概率为 1/4。假设庄家从不更换硬币。哪个 硬币更有可能生成序列HTTTHHHTTTTHTHHTT?它可能 了解 log2(3) = 1.585

很有用

我计算了公平硬币和有偏差硬币的 P。 公平硬币的 P 为 7.6*10-6,而偏差硬币的 P 为 3.43*10-6。我没有使用对数术语,如果我以其他方式解决它就可以使用它。因此,我得出的结论是,给定的序列更有可能是由公平的硬币生成的。

我说得对吗?

非常感谢任何帮助。

I have got this assignment question on HMM and I have solved it. I would like to know if I am correct. The problem is:

Suppose a dishonest dealer has two coins, one fair and one biased; the biased coin
has heads probability 1/4. Assume that the dealer never switches the coins. Which
coin is more likely to have generated the sequence HTTTHHHTTTTHTHHTT? It may
be useful to know that log2(3) = 1.585

I calculated the P for fair coin and biased coin.
The P for fair coin is 7.6*10-6 where as P for biased coin is 3.43*10-6. I didn't use log term, which can be used if I solve it the other way. So, I concluded that it is more likely that the given sequence is generated by a fair coin.

Am I right?

Any help is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清引 2024-12-27 02:55:26

因此,您将得到以下内容。

P(H|Fake) = 1/4 P(T|Fake) = 3/4
P(H|Fair) = 1/2 P(T|Fair) = 1/2
P(Fair) = 1/2 P(Fake) = 1/2

要回答这个问题,您需要回答 P(Fake/HTTTHHHTTTTHTHHTT)P(Fair/HTTTHHHTTTTHTHHTT) ,您需要应用贝叶斯:

X 是 HTTTHHHTTTTHTHHTT

P(Fake|X) = (P(X|Fake) * P(Fake)) / P(X)
P(Fair|X) = (P(X|Fair) * P(Fair)) / P(X)

其中

P(X) = P(X|Fake) * P(Fake) + P(X|Fair) * P(Fair)
P(X) = (3.43710e-6 * 0.5) + (7.629e-6 * 0.5) = 5.533e-6

因此

P(Fake|X) = (3.43710e-6 * 0.5) / 5.533e-6 = 0.3106
P(Fair|X) = (7.629e-6 * 0.5) / 5.533e-6 = 0.6894

因此,更有可能使用的硬币是公平的。尽管直觉上人们可能会认为所选硬币是假币,但事实似乎并非如此。给定的分布更接近 0.5 尾 0.5 头,而不是 0.25 头 0.75 尾。例如,对于尾部 10/17 为 0.58,它更接近于 P(T|Fair)=.5,而不是 P(T|Fake)=.75 >

So you are given the following.

P(H|Fake) = 1/4 P(T|Fake) = 3/4
P(H|Fair) = 1/2 P(T|Fair) = 1/2
P(Fair) = 1/2 P(Fake) = 1/2

To answer the question you need to answer P(Fake/HTTTHHHTTTTHTHHTT) and P(Fair/HTTTHHHTTTTHTHHTT) for which you need to apply bayes:

Let X be HTTTHHHTTTTHTHHTT

P(Fake|X) = (P(X|Fake) * P(Fake)) / P(X)
P(Fair|X) = (P(X|Fair) * P(Fair)) / P(X)

Where

P(X) = P(X|Fake) * P(Fake) + P(X|Fair) * P(Fair)
P(X) = (3.43710e-6 * 0.5) + (7.629e-6 * 0.5) = 5.533e-6

And therefore

P(Fake|X) = (3.43710e-6 * 0.5) / 5.533e-6 = 0.3106
P(Fair|X) = (7.629e-6 * 0.5) / 5.533e-6 = 0.6894

So therefore, is more likely that the used coin is the FAIR one. Even though intuitively one might think that the selected coin is the Fake it seems that this is not the case. The given distribution is closer to 0.5 tail 0.5 heads than to 0.25 heads 0.75 tails. For example, in the case of tails 10/17 is 0.58 that is closer to P(T|Fair)=.5 than to P(T|Fake)=.75

悸初 2024-12-27 02:55:26

对于这个例子来说,HMM 有点过分了。正面朝上的概率呈二项分布,公平硬币的情况为 p = 0.5,另一枚硬币的情况为 p = 0.25。对于两者来说,试验次数n = 17(如果我的计数正确的话)。从 17 个样本中,您获得了 7 个成功(7 个头)。使用 Wolfram Alpha,生成此样本的公平硬币的概率为 大约 0.15,而不是 大约 0.07 对于不公平的硬币。请注意,我没有费心计算确切的数字,只是查看了绘图。如果您愿意,该公式可供您使用。

编辑
如果您绝对必须使用 HMM,请将隐藏状态集设置为 {fair;不公平} .转换概率为:从隐藏状态“公平”到隐藏状态“公平”= 1,从公平到不公平0等,因为荷官不允许在试验中途换币。隐藏状态“公平”的发射概率对于可观察状态“头”为 0.5,对于可观察状态“尾”为 0.5(来自“不公平”的为 0.25 和 0.75)。您可以假设在 t=0 时刻,隐藏状态“公平”和“不公平”的可能性是相同的。

HMM is a bit of an overkill for this example. The probability of getting heads in binomially distributed, with p = 0.5 for the fair coin and p = 0.25 for the other one. For both of them, the number of trials n = 17 (if my counting is correct). From the 17 samples you got 7 successes (7 heads). Using Wolfram Alpha, the probability of the fair coin generating this sample is approx 0.15, as opposed to approx 0.07 for the unfair coin. Note I did not bother calculating the exact numbers, just looked at the plots. The formula is there for you to work with if you want to.

EDIT
If you absolutely must use a HMM, set the set of hidden states to be {fair; unfair} . The transition probabilities are: from a hidden state "fair" to a hidden state "fair"= 1, from a fair to unfair 0, etc, because the dealer is not allowed to change coins halfway through the trial. The emission probability from a hidden state "fair" are 0.5 for observable state "heads" and 0.5 for observable state "tails" (0.25 and 0.75 from "unfair"). You can assume at time t=0 hidden state "fair" and "unfair" are equally likely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文