0

How to prove the probability with code?

Suppose one couple have two children. Question: under the circumstance of one of their children being a girl, what is the probability of another being a girl too?? There’re two most likely answer: 1/2 and 1/3 Our teacher has told us that the answer is 1/3, a little confusing right? How to prove that ?

17th Aug 2018, 4:25 AM
Ś≥∂ŚÖČHikari
Ś≥∂ŚÖČHikari - avatar
8 Respuestas
+ 1
Ś≥∂ŚÖČHikari if it is one child case, a child can be girl or boy...so, probability is 1 out of 2 and hence it is 1/2.. now, two children case possible scenarios are bg,gb,bb,gg.... as one child is girl is given, bb is not to be considered... now, you have three options gg,gb or bg... so, it's 1/3....
17th Aug 2018, 5:02 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Ś≥∂ŚÖČHikari it's independent event but once condition is that one child is girl child, it's not pure probability... take a look on conditional probability... and don't expect people to code for you entirely... try to implement your learning into code for better understanding... show us your efforts and let people know where you are stuck so that they can help you with next steps... hint : use rand function with 1 and 2 as outcome and consider 1 or 2 as boy child
17th Aug 2018, 5:28 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
That maybe right, but how about this: since the sexes are independent event, right? How can they influence each other? Besides, all I want is proof with code , not logical answer
17th Aug 2018, 5:23 AM
Ś≥∂ŚÖČHikari
Ś≥∂ŚÖČHikari - avatar
0
Sorry maybe I should post my code at the beginning. Unfortunately,my code just never get the right 1/3 answer https://code.sololearn.com/cI4b93AkIA75/?ref=app
17th Aug 2018, 6:05 AM
Ś≥∂ŚÖČHikari
Ś≥∂ŚÖČHikari - avatar
0
Ketan Lalcheta...don’t know how to @
17th Aug 2018, 6:30 AM
Ś≥∂ŚÖČHikari
Ś≥∂ŚÖČHikari - avatar
0
Ś≥∂ŚÖČHikari I am not into Python... below is the full dynamic code of probability for two children in c++... https://code.sololearn.com/c60To116gskg/?ref=app
17th Aug 2018, 6:46 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Ketan Lalcheta but you code ends up with 25%, That’s not what we want
17th Aug 2018, 6:50 AM
Ś≥∂ŚÖČHikari
Ś≥∂ŚÖČHikari - avatar
0
Ś≥∂ŚÖČHikari updated now and I guess how it should be...still will wait for others to comment on this.. if you just want to verify perfectly 1/3, it's to be hard coded... check for cases as 1,1: 1,2 : 2,1 :2,2 as 4 values and check for 2,2 count which will be 1 and 1,1 count will be 1..so, 1 /(4-1) as 1/3...
17th Aug 2018, 7:01 AM
Ketan Lalcheta
Ketan Lalcheta - avatar