Bayes' theorem to know how many of my dates (fruit) are bad!

49 Views Asked by At

I bought a container of dates (fruit) (containing $57$ dates in total). I started opening them to see if they're good or bad (do have warms inside or not), and after opening $7$ of them I found that the first $5$ were bad whereas the $2$ last were good.

I usually buy these dates' containers and I would estimate that one third of it are bad dates$^{(*)}$.

How can I estimate (or rather improve my estimation, I guess using Bayes' theorem) the number of bad dates I have in the container considering the evidence I have (i.e. $5$ first opened dates are good and last $2$ bad).

$^{(*)}$: I still buy them though because they're cheap ;-)

Spoiler alert: I can check the real numbers after I open all dates :-)

2

There are 2 best solutions below

9
On BEST ANSWER

It depends on how strongly you believe in your prior knowledge. Say $k$ represents the strength of your belief. The higher $k$ is, the more you believe in your prior. Using beta distribution as the conjugate prior, $B(\alpha=k/3, \beta=2k/3)$ and modeling with binomial, the posterior distribution is proportional to $p^{5+\alpha-1}(1-p)^{2+\beta-1}$.

Your new estimate for proportion of bad dates becomes $\frac{5+\alpha}{7+\alpha+\beta}=\frac{5+k/3}{7+k}$. In other words, it's like you're adding imaginary dates ($k/3$ good ones and $2k/3$ bad ones) to your samples and use the frequentist method.

1
On

This isn't really my territory, but I actually don't think you'd need to / can apply Bayes' Theorem here. Rather, it's more of a statistics problem, like a 1-sample proportion t-test, where the observed value is $5/7$, or $71.4\%$, the degrees of freedom is $(n-1) = 6$, and the null hypothesis of $33\%$. Working this out, we get a p-value of around $0.015$, which means that around $1.5\%$ of the time, you'd expect to get at more than or equal to $5/7$ bad dates! Doesn't totally answer your question of the expected value, but know that if you're testing to see if you had a normal container, statistically speaking you probably don't!