I've been asked (as part of homework) to design a Java program that does the following:
Basically there are 3 cards:
Now if I take a card randomly and place it on the table. The side facing up is black. What is the probability that the other side is also black?
Implement a program using Java and try to discover the probability, the program should simulate the card trick a large number of times and should output the probability that the other side of the card is black (it does this by counting how many times the other side also black).
However I've been told that my code is wrong (algorithm wise)... apparently the answer should not be 0.50. Have I made a mistake in trying to understand the algorithm?
Can anyone point me in the right direction please? (I'm not asking you to provide me with a fully working implementation, just on how the algorithm should work).
This article was very helpful: https://blog.codinghorror.com/finishing-the-game/
In algorithmic information theory, algorithmic probability, also known as Solomonoff probability, is a mathematical method of assigning a prior probability to a given observation. It was invented by Ray Solomonoff in the 1960s. It is used in inductive inference theory and analyses of algorithms.
This might not help with the algorithm, but this is how I would derive the answer myself:
When you draw a random card and place it on the table, there are six equally probable things that could happen:
Of these six events, 3 out of 6 result in a black-side up card on the table.
Of these 3 events, in exactly two of them is the other side of the card black.
Therefore the answer to the question "What is the probability that the other side is also black?" is 2/3.
Your algorithm fails because you are only counting the black_black
card coming up as a single event, when it is actually two.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With