I have an equation to compute the bit-error rate of a binary symmetric channel: $$P_{err}(n,p) = \sum_{k = \frac{n-1}{2} + 1}^n\binom n k p^k(1-p)^{n-k}$$
I then want to find the smallest $n$-repetition code assuming that I can tolerate $P_{err}\leq\frac{1}{8}$. I tried using:
Subscript[P, err][n_, p_] =
Sum[Binomial[n, k]*p^k*(1 - p)^(n - k), {k, (n - 1)/2 + 1, n}];
FindInstance[Subscript[P, err][n, 1/4] < 1/8, n, Integers, 5]
But I'm getting {{n -> 555}, {n -> 1165}, {n -> 887}, {n -> 831}, {n -> 1119}}
as the answer. However,
Table[{n, Subscript[P, err][n, 1/4] < 1/8}, {n, 1, 10, 2}]
Gives me {{1, False}, {3, False}, {5, True}, {7, True}, {9, True}}
, showing that 5
is the first solution.
Why is this happening and how can I fix this? I'm assuming this must be something to do with the way FindInstance
reacts to values of n
that are even - any way to limit the search space to only odd numbers?