If I flip three coins, and guess the outcome before each flip, what is the probability I get at least two correct out of three? I can't wrap my head around this...a simple explanation would be great!
I know the answer is 50%, but I don't know why. I wrote a quick program to verify this.
import java.util.Random;
public class Random1 {
public static void main(String args[]) {
double twoRight = 0;
int numTrials = 10000000;
for (int i = 0; i < numTrials; i++) {
Random r = new Random();
int guess1 = r.nextInt(2), guess2 = r.nextInt(2), guess3 = r.nextInt(2);
int actual1 = r.nextInt(2), actual2 = r.nextInt(2), actual3 = r.nextInt(2);
int correct = 0;
if (guess1 == actual1) { correct++; }
if (guess2 == actual2) { correct++; }
if (guess3 == actual3) { correct++; }
if (correct >= 2) {twoRight++;}
}
System.out.println("two right: " + twoRight);
System.out.println("numTrials: " + numTrials);
System.out.println("% both right: " + (twoRight / numTrials * 100.0) );
}
}