Premium problem113. Majority Vote of n Classifiers

Medium Locked

n independent classifiers each have accuracy p, with n odd. Return the accuracy of their majority vote.

Sum the binomial tail from ⌊n/2⌋+1\lfloor n/2 \rfloor + 1 upwards. Above p=0.5p = 0.5 the vote beats any single model and improves with n; below it, the ensemble is worse than one model, because the errors reinforce.

Input

n = 5
p = 0.6

Output

0.68256

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)