Stats are really not my cup of tea. I have a problem with “4-Ultimate test” (and also test 5 but I would at least understand what is wrong with this one)
I tried to stick as much as possible to the concept of taking balls out of the bag.
I think I got a decent algorithm but I might be totally wrong.
Test 4-Ultimate test
n=30 total nb of balls
w=10 nb of white balls
s=10 total nb of balls extracted
k=5 nb of white balls to be extracted
I get the following result
P(A)= 10 / 30 (white ball)
x 9 / 29 (white ball)
x 8 / 28 (white ball)
x 7 / 27 (white ball)
x 6 / 26 (white ball)
x 20 / 25 (black ball)
x 19 / 24 (black ball)
x 18 / 23 (black ball)
x 17 / 22 (black ball)
x 16 / 21 (black ball)
P(A)= 5168 / 10015005
P(!A)= 10009837 / 10015005
I don’t see what is wrong: is it my fraction simplification or the way I compute the stats ?
Any help will be greatly appreciated !
It’s also possible to draw the black balls before the white (or in any other order like WBBBWB…), you only count one.
Ok I got it.
Thanks a lot eulerscheZahl !
Hello this post makes me understood my error for the ultimate test 1
now i have 80 % and the ultimate test 2 that failed…
I can’t undestand my error since the result a nearly similary
50 balls taken
35 proba 35 whites… ?
2250829575120 * (C 50 35)
40/60* (white balls)
20/25* (blacks balls)
1235750079647531:7896812518143536 => 0.15648719996
134976:862537 => 0.15648719997
i can’t undestand why those result are so closed if i m wrong
any clue will be very lovely !
I use Window’s Calculator to do this division, got
So the last few digits are 9997 when simplified to the same number of digits as yours.
yes but i can’t undestand the ratio found (134976:862537) compared to mine, how the result could be so much factorized
There could be a loss of precision in the middle of your calculation.
What language are you using?
What data type are you using to do the calculation?
I only do the multiply on the numerator and denominator;
Then i m looking for the largest common divider and divide all…
I m not sure to lose precision using multiply… but you may be right
You could try using BigInt to verify the result. The correct fraction should be able to be reduced to two smaller integers.
Thx you @java_coffee_cup !
I have success on all test cases – so efficiency is now OK. I fail on validator 2.
As far as I can tell, I’ve dealt with all divide by zero cases so I don’t think I’m generating an error.
Would appreciate some guidance on where to look/what to improve.