This is regarding the pdf_binomial subsection of the week 1 programming assignment. When I run the test cells in my notebook, I get the expected answers, down to the last decimal point. However, when I submit my assignment, I only get a 4/10 for this subsection, and I see this message:
Failed test case: got an unexpected value for parameters x=1e-10, n=15, p=0.5.
Expected:
0.0,
but got:
3.051757813512642e-05.
Failed test case: got an unexpected value for parameters x=4.2, n=8, p=0.57.
Expected:
0.0,
but got:
0.2649150001048276.
Failed test case: using n=0.5 which should yield a np.nan value.
Expected:
nan,
but got:
0j.
Failed test case: got an unexpected value for parameters x=4.2, n=8, p=0.57.
Expected:
0.0,
but got:
0.2526220674236071.
Failed test case: got an unexpected value for parameters x=0, n=20, p=0.25.
Expected:
0.0031712119389339932,
but got:
0.
Failed test case: using n=0.5 which should yield a np.nan value.
Expected:
nan,
but got:
0.
I tried implementing the function with different combinations of
**
np.power
math.factorial
scipy.special.comb
np.math.factorial
They all return the same unexpected values.
Interestingly enough, pdf_binomial that fails here is used later in prob_of_X_given_C and passes all tests before and after submission. Which means there are errors in the grading tests for pdf_binomial. Please fix them and reset the number of submissions to 3.
Unfortunately, it’s still not working, @a-zarta ; and now I’ve run out of submissions.
Please fix the tests and reset the remaining number of submissions to 3 again.
Thanks!
Hi @Janos, are you getting the exact same error message? The grader was updated yesterday and those test cases should no longer exist so if you got the same error message it is probably due to coursera’s servers taking some time to propagate the changes. If you encountered another error let me know. Also as Lucas mentioned you should have an unlimited number of submissions.
I wasn’t aware of that. I had the information that every graded assignment in Coursera could be attempted up to 3 times. I’m glad it’s no longer the case.
Yes, the last reported failing test case was one of the 3 posted above: x=0, n=20, p=0.25. The instructions explicitly state that 𝑥=1,2,…,𝑛. Hence the exclusion of a value of x=0 from the distribution. Did you want to write 𝑥=0,1,2,…,𝑛?
Please try using “comb(n, x)” function instead of those functions using factorials. I had a problem at first when I tried to calculate the combination part manually using the factorials, but when I used the built-in function “comb”, it worked.
Maybe, the online notebook environment is strugling with the huge numbers involved when calculating factorials. Usually, the built-in functions do the math in a very efficient way.
It worked with n allowed to take a value of 0.
Thanks, guys.
@Joao_Carlos_Lima_Sel ! Thanks, I had tried comb and you may be right that it’s more efficient. But I think we can narrow down this particular problem to a grading bug that’s been fixed now and to the question of whether x can take 0 in the pdf_binomial exercise.
Thanks, everyone!
@Janos, yes, you are right, there is an error in the mkdown since the pmf of the binomial is defined starting from 0. We’ll correct this shortly. Thanks for helping us realize this!