Options

# [Poll] Can YOU solve the frog riddle?

## Posts

• Options
Registered User regular
Larlar
MrBlarney wrote: »
Alternatively...

The code:
import random

# constants
num_frogs = 2
total_samples = 1000000

# initialise variables
sample = 0

while (sample < total_samples):
# Generate frogs
frogs = []
for i in range(num_frogs):
frogs.append(random.choice("MF"))

# Have one of them croak
croak = random.choice(frogs)

# Throw out sample if the croak was female since we heard a male
if (croak == 'F'):
continue

# Are there any lady frogs?
if (any(frog == "F" for frog in frogs)):

sample += 1



The results:
Found a lady frog 499756 times
Approximate probability of finding a lady frog = 0.499756


It's all about how you frame the generating mechanism underlying the scenario.

In your version you know which frog croaked, which affects the answer.

I didn't watch the video but my understanding was that you don't know which frog croaked, only that one of them did, and that added unknown affects the probability.

You can rewrite the code to only count male croak instead of discard female croaks and you get the same result.

Essentially this version has 8 outcomes: the original MM, MF, FM, FF, which is doubled by having one croak emit from one frog of each pair. So:
McM, MMc, McF, MFc, FcM, FMc, FcF, FFc

However, you heard a Male frog croak, which eliminates all pairs with female croaks (Fc). This leaves you with:
McM, MMc, McF, ---, ---, FMc, ---, ---

And that gives you your 50/50 odds. Half of the MF pairs are eliminated because they represent the space of female croaks in MF pairs.

• Options
Registered User regular
They’re both 50%. Flip a coin, lol
MrBlarney wrote: »
Alternatively...

The code:
import random

# constants
num_frogs = 2
total_samples = 1000000

# initialise variables
sample = 0

while (sample < total_samples):
# Generate frogs
frogs = []
for i in range(num_frogs):
frogs.append(random.choice("MF"))

# Have one of them croak
croak = random.choice(frogs)

# Throw out sample if the croak was female since we heard a male
if (croak == 'F'):
continue

# Are there any lady frogs?
if (any(frog == "F" for frog in frogs)):

sample += 1



The results:
Found a lady frog 499756 times
Approximate probability of finding a lady frog = 0.499756


It's all about how you frame the generating mechanism underlying the scenario.

In your version you know which frog croaked, which affects the answer.

I didn't watch the video but my understanding was that you don't know which frog croaked, only that one of them did, and that added unknown affects the probability.

But even if you don’t know which frog croaked, you can be sure that a specific frog croaked. Picking which one you think was that specific frog is a completely arbitrary decision.

• Options
Scritch scratch scritch scratch scritch scratch scritch scratch scritch scratch scritch scratch scritch scratch scritch scratch scritch scratch scritch scratch scritch scratch scritch scratchRegistered User regular
edited February 2022
Enlong wrote: »
MrBlarney wrote: »
Alternatively...

The code:
import random

# constants
num_frogs = 2
total_samples = 1000000

# initialise variables
sample = 0

while (sample < total_samples):
# Generate frogs
frogs = []
for i in range(num_frogs):
frogs.append(random.choice("MF"))

# Have one of them croak
croak = random.choice(frogs)

# Throw out sample if the croak was female since we heard a male
if (croak == 'F'):
continue

# Are there any lady frogs?
if (any(frog == "F" for frog in frogs)):

sample += 1



The results:
Found a lady frog 499756 times
Approximate probability of finding a lady frog = 0.499756


It's all about how you frame the generating mechanism underlying the scenario.

In your version you know which frog croaked, which affects the answer.

I didn't watch the video but my understanding was that you don't know which frog croaked, only that one of them did, and that added unknown affects the probability.

But even if you don’t know which frog croaked, you can be sure that a specific frog croaked. Picking which one you think was that specific frog is a completely arbitrary decision.

That's why I think you have to account for the scenario in which each frog croaked

You're kind of implicitly flipping a third coin. If heads, coin 1 is set to heads. If tails, coin 2 is set to heads. You don't know this coin's outcome.

Speed Racer on
• Options
Frictionless Spinning The VoidRegistered User regular
What if you hear this:

• Options
Registered User regular
At the risk guarantee of introducing more confusion and arguing, you can try to generalize the "have one of them croak" by introducing a parameter for how likely any given male is to croak, compared to any given female:
import random

### parameters
# num_frogs: number of frogs in the sample
# p_male: probability any frog is male. Probability of female is 1-p_male.
# male_croak_weight: likelihood a male will croak compared to females.
#  If weight=1, all frogs are equally likely to croak.
#  If weight=2, individual males are twice as likely to croak as females.
#  If weight=0.5, individual females are twice as likely to croak as males.
num_frogs = 2
p_male = 0.5
male_croak_weight = 1

# initialize tally variables
total_samples = 1000000
sample = 0

while (sample < total_samples):
# Generate set of frogs
frogs = random.choices(['M','F'], [p_male, 1-p_male], k=num_frogs)

# Have one of them croak
croak_weights = [male_croak_weight if frog == 'M' else 1/male_croak_weight
for frog in frogs]
croak = random.choices(frogs, croak_weights)

# Throw out sample and try again if the croak was female since we heard a male
if (croak[0] == 'F'):
continue

# Are there any lady frogs?
if (any(frog == "F" for frog in frogs)):

sample += 1



If the croak likelihood ratio is 1 (that is, in a pair, a male is just as likely to croak as a female), then you get the 1/2 answer out. But if the croak likelihood ratio is some large number like 1,000,000 (such that a male will almost certainly croak when paired with a female) then you get the 2/3 answer out.

Is this a different formulation than the traditional argument for 2/3? Very much so, it eliminates the FF case in a fairly different way. But perhaps this highlights some of the disconnect between a more symbolic-based 2/3 response and the generative-based 1/2 response. It's a difference between just saying "is it possible for a male to croak from this set" and "how can a male croak from this set". From a generation perspective, getting to 2/3 requires silencing female frogs, so that a pair of female frogs can never be discovered. (Yes, the argument is a bit of a stretch since the code does require generating one croak, but hopefully you can understand the kinds of arguments and assumptions that could get to that conclusion.)

• Options
Registered User regular
This is the information, it's 50/50. QEteD is wrong for the problem stated.

• Options
Registered User regular
Larlar
Here is a situation in which the 2/3rds probability applies:

You work in a fungi research lab, and you have just accidentally ingested a fatally poisonous mushroom for which licking the female frog of a particular species will cure you. You run to the amphibian research wing because they are doing frog pair behavior studies on this species. There are four terrariums for each pair of interest: a pair of a big male and small male, a pair of big female and small male, a pair of big male and small female, and a pair of big female and small female. The frogs are all identical in appearance, and you cannot tell their sex by sight. You arrive and to your horror, you realize Kevin was the last person working here because all the labels have been replaced by drawings of penises. One terrarium is empty, and you know it is the Ff pair because you heard the senior researchers complain about how Kevin lost track of them during cleaning and their replacements have not yet arrived. It kind of seems like Kevin should be fired, but you were just eating mushrooms out of your lab so maybe you shouldn't be criticizing folks in other research departments. Anyway, only one terrarium can be opened at a time, and you're getting light-headed. Time is short and you can only lick one pair of frogs, what is your chance of surviving?

• Options
Registered User, Moderator mod
They’re both 50%. Flip a coin, lol
the logic there doesn't seem confusing at all, you have 3 choices and 2 of the 3 choices you can make mean you survive

• Options
Registered User regular
Larlar
MrBlarney wrote: »
At the risk guarantee of introducing more confusion and arguing, you can try to generalize the "have one of them croak" by introducing a parameter for how likely any given male is to croak, compared to any given female:
import random

### parameters
# num_frogs: number of frogs in the sample
# p_male: probability any frog is male. Probability of female is 1-p_male.
# male_croak_weight: likelihood a male will croak compared to females.
#  If weight=1, all frogs are equally likely to croak.
#  If weight=2, individual males are twice as likely to croak as females.
#  If weight=0.5, individual females are twice as likely to croak as males.
num_frogs = 2
p_male = 0.5
male_croak_weight = 1

# initialize tally variables
total_samples = 1000000
sample = 0

while (sample < total_samples):
# Generate set of frogs
frogs = random.choices(['M','F'], [p_male, 1-p_male], k=num_frogs)

# Have one of them croak
croak_weights = [male_croak_weight if frog == 'M' else 1/male_croak_weight
for frog in frogs]
croak = random.choices(frogs, croak_weights)

# Throw out sample and try again if the croak was female since we heard a male
if (croak[0] == 'F'):
continue

# Are there any lady frogs?
if (any(frog == "F" for frog in frogs)):

sample += 1



If the croak likelihood ratio is 1 (that is, in a pair, a male is just as likely to croak as a female), then you get the 1/2 answer out. But if the croak likelihood ratio is some large number like 1,000,000 (such that a male will almost certainly croak when paired with a female) then you get the 2/3 answer out.

Is this a different formulation than the traditional argument for 2/3? Very much so, it eliminates the FF case in a fairly different way. But perhaps this highlights some of the disconnect between a more symbolic-based 2/3 response and the generative-based 1/2 response. It's a difference between just saying "is it possible for a male to croak from this set" and "how can a male croak from this set". From a generation perspective, getting to 2/3 requires silencing female frogs, so that a pair of female frogs can never be discovered. (Yes, the argument is a bit of a stretch since the code does require generating one croak, but hopefully you can understand the kinds of arguments and assumptions that could get to that conclusion.)

And if the croak likelihood is 0.00000001, it is most likely that you would have heard a lady frog croak first.
So if a male is croaking, then the two frogs in the clearing are both male.

• Options
No face Registered User regular
They’re both 50%. Flip a coin, lol
asofyeun wrote: »
Here is a situation in which the 2/3rds probability applies:

You work in a fungi research lab, and you have just accidentally ingested a fatally poisonous mushroom for which licking the female frog of a particular species will cure you. You run to the amphibian research wing because they are doing frog pair behavior studies on this species. There are four terrariums for each pair of interest: a pair of a big male and small male, a pair of big female and small male, a pair of big male and small female, and a pair of big female and small female. The frogs are all identical in appearance, and you cannot tell their sex by sight. You arrive and to your horror, you realize Kevin was the last person working here because all the labels have been replaced by drawings of penises. One terrarium is empty, and you know it is the Ff pair because you heard the senior researchers complain about how Kevin lost track of them during cleaning and their replacements have not yet arrived. It kind of seems like Kevin should be fired, but you were just eating mushrooms out of your lab so maybe you shouldn't be criticizing folks in other research departments. Anyway, only one terrarium can be opened at a time, and you're getting light-headed. Time is short and you can only lick one pair of frogs, what is your chance of surviving?

With my last breath I engineer a scene that upon discovery of my body will result in the firing of Kevin and a lifetime ban from him getting within 200 feet of any amphibian

• Options
In the scuppers with the staggers and jagsRegistered User regular
None of this is Kevin's fault, Enlong is the one who did this to us.

• Options
Yeah ZestRegistered User regular
They’re both 50%. Flip a coin, lol
Jedoc wrote: »
None of this is Kevin's fault, Enlong is the one who did this to us.

It wasn't Enlong at all, it was their evil twin, Gnolne!

• Options
Registered User regular
They’re both 50%. Flip a coin, lol
Damn you, Christopher Gnolne!