A tester tries to identify a correct brand in a series of trials. Let \(\theta\) be the probability of choosing the correct brand in any trial. Let \(Y_i\) be a Bernoulli random variable taking value 1 for a correct guess in the \(i\)-th trial.
In the first 6 trials, the results are: \(1,1,1,1,1,0\).
We wish to test whether the tester has no discriminatory power against the alternative that she does. So our problem is:
\[H_0: \theta = \frac{1}{2} \quad \text{versus} \quad H_1: \theta > \frac{1}{2}\]
This is a simple versus composite case with:
We assume a uniform prior distribution on \(\theta\) under the alternative:
\[\pi_1(\theta) = 2 \quad \text{if} \quad \frac{1}{2} < \theta < 1\]
For the point null hypothesis, the implied prior distribution is:
\[\pi_0(\theta = \frac{1}{2}) = 1\]
Some similar problems involve waiting until the first failure, which follows a geometric distribution. However, in this problem:
| Distribution | When Used | Our Example |
|---|---|---|
| Bernoulli | Single trial outcome | Each \(Y_i\) individually |
| Binomial | Fixed number of trials, count successes | The entire sequence of 6 trials |
| Geometric | Number of trials until first failure | Not used here |
For independent Bernoulli trials with 5 successes and 1 failure:
\[f(y \mid \theta) = \theta^{\text{successes}} \cdot (1-\theta)^{\text{failures}} = \theta^5 \cdot (1-\theta)^1\]
So:
\[f(y \mid \theta) = \theta^5 (1-\theta)\]
Since \(H_0\) is a point null:
\[f(y \mid M_0) = f(y \mid \theta_0) = \left(\frac{1}{2}\right)^5 \left(1 - \frac{1}{2}\right) = \left(\frac{1}{2}\right)^5 \cdot \frac{1}{2} = \left(\frac{1}{2}\right)^6\]
\[f(y \mid M_0) = \frac{1}{64} = 0.015625\]
Under \(H_1\), we must integrate the likelihood over the prior \(\pi_1(\theta) = 2\):
\[f(y \mid M_1) = \int_{1/2}^{1} f(y \mid \theta) \, \pi_1(\theta) \, d\theta = \int_{1/2}^{1} \theta^5 (1-\theta) \cdot 2 \, d\theta\]
\[f(y \mid M_1) = 2 \int_{1/2}^{1} \theta^5 (1-\theta) \, d\theta\]
\[\int_{1/2}^{1} \theta^5 (1-\theta) \, d\theta = \int_{1/2}^{1} (\theta^5 - \theta^6) \, d\theta\]
\[= \left[ \frac{\theta^6}{6} - \frac{\theta^7}{7} \right]_{1/2}^{1}\]
Evaluate at \(\theta = 1\):
\[\frac{1}{6} - \frac{1}{7} = \frac{7}{42} - \frac{6}{42} = \frac{1}{42}\]
Evaluate at \(\theta = \frac{1}{2}\):
\[\frac{(1/2)^6}{6} - \frac{(1/2)^7}{7} = \frac{1/64}{6} - \frac{1/128}{7} = \frac{1}{384} - \frac{1}{896}\]
Find common denominator: \(384 = 2^7 \cdot 3\), \(896 = 2^7 \cdot 7\), LCM = \(2^7 \cdot 3 \cdot 7 = 2688\)
\[\frac{7}{2688} - \frac{3}{2688} = \frac{4}{2688} = \frac{1}{672}\]
So the definite integral:
\[\int_{1/2}^{1} (\theta^5 - \theta^6) \, d\theta = \frac{1}{42} - \frac{1}{672}\]
Convert \(\frac{1}{42}\) to denominator 672: \(\frac{16}{672}\)
\[\frac{16}{672} - \frac{1}{672} = \frac{15}{672} = \frac{5}{224} \approx 0.02232\]
\[f(y \mid M_1) = 2 \times \frac{5}{224} = \frac{10}{224} = \frac{5}{112} \approx 0.04464\]
\[B_{01}(y) = \frac{f(y \mid M_0)}{f(y \mid M_1)} = \frac{1/64}{5/112} = \frac{1}{64} \times \frac{112}{5} = \frac{112}{320}\]
Simplify:
\[\frac{112}{320} = \frac{56}{160} = \frac{28}{80} = \frac{14}{40} = \frac{7}{20} = 0.35\]
The problem states \(B_{01} = \frac{1}{2.86} \approx 0.35\), which matches:
\[2.86 = \frac{1}{0.35} = \frac{20}{7} \approx 2.857\]
# Compute Bayes factor numerically in R
# Likelihood under H0
lik_H0 <- (1/2)^6
# Prior under H1 (uniform on (0.5, 1))
prior_H1 <- function(theta) 2
# Likelihood function
likelihood <- function(theta) theta^5 * (1 - theta)
# Marginal likelihood under H1 (numerical integration)
marginal_H1 <- integrate(function(theta) likelihood(theta) * prior_H1(theta),
lower = 0.5, upper = 1)$value
# Bayes factor
B01 <- lik_H0 / marginal_H1
# Display results
cat("Likelihood under H0:", lik_H0, "\n")
## Likelihood under H0: 0.015625
cat("Marginal likelihood under H1:", marginal_H1, "\n")
## Marginal likelihood under H1: 0.04464286
cat("Bayes factor B01:", B01, "\n")
## Bayes factor B01: 0.35
cat("B01 as 1/x:", 1/B01, "\n")
## B01 as 1/x: 2.857143
The Bayes factor \(B_{01} = 0.35\) means:
\[B_{01} = \frac{P(\text{data} \mid H_0)}{P(\text{data} \mid H_1)} = 0.35\]
Equivalently:
\[\frac{P(\text{data} \mid H_1)}{P(\text{data} \mid H_0)} = \frac{1}{0.35} \approx 2.86\]
Conclusion: The data are about 2.86 times more likely under \(H_1\) (the tester has some ability, \(\theta > 0.5\)) than under \(H_0\) (pure guessing, \(\theta = 0.5\)). This provides positive evidence against the null hypothesis, though not overwhelming.
| Component | Value |
|---|---|
| Likelihood function | \(\theta^5 (1-\theta)\) |
| \(f(y \mid H_0)\) | \(\frac{1}{64} = 0.0156\) |
| \(f(y \mid H_1)\) | \(\frac{5}{112} \approx 0.0446\) |
| Bayes factor \(B_{01}\) | \(\frac{7}{20} = 0.35\) |
| Evidence for \(H_1\) | \(\frac{1}{B_{01}} \approx 2.86\) |
The geometric distribution does not appear in this example. The calculation uses the Bernoulli/Binomial likelihood because we have a fixed number of trials with a fixed number of successes.