6 kyu

Statistics in Kata 2: AND case - Ball bags

54 of 190powderham
Description
Loading description...
Statistics
Probability
Arrays
Fundamentals
  • Please sign in or sign up to leave a comment.
  • Blind4Basics Avatar

    x(

    Who's the jerk who put a link into the description that leads directly to the EDIT PANEL of the other kata...?

    x(

    happened again.... x/

  • monadius Avatar

    The description uses an incorrect terminology: "mutually exclusive events" should be replaced with "independent events" everywhere. The joint probability of mutually exclusive events is always 0. But the joint probability of independent events is the product of probabilities.

  • ejini战神 Avatar
    • Python new test framework should be used (Refer this & this for more detail)

    • test.assert_approx_equals should be used instead

  • ejini战神 Avatar
    • Node 12 should be enabled (Refer this and this for more info)

    • assert.approxEquals should be used instead

  • user9644768 Avatar

    Ruby 3.0 should be enabled, see this to learn how to do it

  • Blind4Basics Avatar

    x(

    Who's the jerk who put a link into the description that leads directly to the EDIT PANEL of the other kata...?

    x(

  • john9631 Avatar

    This is now faulty for python without replacement

  • bsiverly Avatar

    I did the math longhand and it worked fine, but failed the third random case. The expected value was not the correct value based on doing the math long form.

    Any idea why that might be?

    problem was: (ball_probability([['yellow', 'green', 'yellow', 'yellow', 'yellow', 'yellow', 'green', 'green', 'blue', 'green', 'green', 'blue', 'red'], ['green', 'blue'], False]))

  • sdewitt Avatar

    I have a feeling I am missing something in the explantion. All the test cases work fine, but when I run on random inputs I sometimes get failures when replace is False. So let me talk you through my understanding of one test case (w/o showing the code) (... and as you will see I am not a mathematician so I need dummies guide as explantions!)

    The input is [['red', 'yellow', 'red', 'yellow', 'yellow', 'blue', 'red', 'yellow', 'green', 'blue', 'blue', 'green', 'red', 'yellow', 'yellow', 'green', 'yellow', 'blue'], ['blue', 'red'], False]

    So I have 18 balls, 4 of which are blue, so P(b) = 4/18 = 0.222.... Since I don't replace the blue that I drew on the first round, I now have only 17 balls, 4 of which are red, so P(r) = 4/17 = 0.235...

    So P(b,r,False) = 0.222x0.235 = 0.052, but according to the test, the probablity should be 0.037

    Now - where is the flaw? I was hoping writing this would lead me to enightenment, but not the case this time...

  • docgunthrop Avatar

    My solution failed one of the random test cases; the kata "expected -0 but got 0". It went through fine when I hit submit a second time.

  • GiacomoSorbi Avatar

    Translations published :)

    I tried to keep your original spirit intact, so same data structure as an input and not too many edge test cases (no balls with less than 2 elements); let me know if everything is ok for you!