Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

Add `pdf(_, missing)` and `logpdf(_, missing)`

Open ArunS-tack opened this issue 2 years ago • 3 comments

closes #1392.

ArunS-tack avatar Mar 01 '23 17:03 ArunS-tack

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (eecfd3c) 85.81% compared to head (9af9c09) 85.82%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1688   +/-   ##
=======================================
  Coverage   85.81%   85.82%           
=======================================
  Files         131      137    +6     
  Lines        8314     8318    +4     
=======================================
+ Hits         7135     7139    +4     
  Misses       1179     1179           
Impacted Files Coverage Δ
src/common.jl 81.18% <100.00%> (+0.38%) :arrow_up:
src/univariates.jl 74.66% <100.00%> (+0.11%) :arrow_up:
src/eachvariate.jl 85.71% <0.00%> (-4.77%) :arrow_down:
src/multivariate/dirichlet.jl 73.30% <0.00%> (-4.62%) :arrow_down:
src/univariate/discrete/negativebinomial.jl 90.74% <0.00%> (-2.69%) :arrow_down:
src/univariate/continuous/uniform.jl 95.00% <0.00%> (-1.00%) :arrow_down:
src/univariate/discrete/poissonbinomial.jl 93.07% <0.00%> (-0.63%) :arrow_down:
src/utils.jl 95.58% <0.00%> (ø)
src/density_interface.jl
...ulesCoreExt/univariate/discrete/poissonbinomial.jl 100.00% <0.00%> (ø)
... and 6 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Mar 01 '23 17:03 codecov-commenter

Thank you for the PR!

Unfortunately, in my opinion it should not be merged in its current form.

More generally, I think #1392 needs more thought and discussion. In my opinion, it is a design problem of Missing that somehow people now expect every method to support missing (just check how many open issues there are in Statistics stdlib about handling missing values). So I'm not excited about it, but I would be fine with adding pdf(d::Distribution, x::Missing) = missing irrespective of these deficiencies, given how widespread implementations with missing have become.

However, I don't see a compelling reason to add pdf(d::Missing, x::Real) or similar. x::Missing corresponds to missing data but in what situations would one encounter a missing distribution?

Another point is: Why should one only handle pdf? What about logpdf? cdf? etc.

In addition to these general concerns, I think there are some other problems with this PR:

  • .DS_Store should not be added
  • x::Any is too generic, IMO a method for x::Missing is sufficient
  • The definition creates a stackoverflow if neither d nor x are missing
  • More tests should be added

Thank you for the review however for the second point, pdf(missing, x) was requested as well. If we just use x::Missing, it will again give a method error. But I agree that there's a very minimal chance of it happening. I will look into points 4 and 5.

ArunS-tack avatar Mar 02 '23 04:03 ArunS-tack

however for the second point, pdf(missing, x) was requested as well.

Not every feature request is uncontroversial and should be implemented :slightly_smiling_face:

devmotion avatar Mar 02 '23 08:03 devmotion