Grading issue on week 1 programming assignment (C3_W1_Assignment)

Hello!

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.

Can someone help me figure out why this is?

2 Likes

Hi @Vikram_Mark_Radhakri, can you send me your notebook via DM and I will take a look?

1 Like

Hi. I have sent you a DM with the notebook attached. Please let me know if you haven’t received it.

1 Like

I’ve got similar errors for pdf_binomial:

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.

Thank you !

Hi @Vikram_Mark_Radhakri, your implementation was correct. There was a bug in the grader which has been fixed.

Thanks for looking into it @Janos, the bug has now been fixed.

Let me know if your submissions are now working for that grader function.

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!

1 Like

Hi @Janos, you should have an unlimited number of submissions for any assignment. Could you please trying refreshing your workspace?

If this does not solve your problem, let me know.

Thanks
Lucas

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.

Hi @lucas.coutinho ,
Hi @a-zarta ,

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,…,𝑛?

Thank you very much.

János

Hi @Vikram_Mark_Radhakri and @Janos.

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!

1 Like

Thanks for your input @Joao_Carlos_Lima_Sel!

@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!

2 Likes