Skip to content

Conversation

@arnavk23
Copy link
Contributor

@arnavk23 arnavk23 commented Jan 28, 2026

Reference Issues/PRs

Fixes #416. See also #415.

What does this implement/fix? Explain your changes.

Fixes incorrect PMF plotting for discrete distributions. Previously, discrete distributions like Binomial were plotted as continuous curves. Now they correctly display as discrete probability mass functions using stem plots at integer support points.

Changes:

  • Modified _plot_single() in BaseDistribution to detect discrete distributions
  • Extract support ranges from scipy distributions and evaluate PMF at integer points
  • Use stem plots for discrete PMF, maintain line plots for continuous distributions
  • Handle infinite support bounds (e.g., Poisson)

Does your contribution introduce a new dependency? If yes, which one?

No.

What should a reviewer concentrate their feedback on?

  • Logic for discrete vs continuous distribution detection and plot type selection
  • Support extraction and integer point evaluation
  • Backward compatibility

Did you add any tests for the change?

Yes, added test_discrete_pmf_plotting() in test_proba_basic.py to verify stem plots are used for discrete PMF.

Any other comments?

Maintains full backward compatibility with existing continuous distribution plotting.

PR checklist

For all contributions

  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
    For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

- Modified _plot_single() in BaseDistribution to handle discrete distributions
- For discrete PMF plots, extract support from scipy distribution and evaluate at integer points
- Use stem plots instead of line plots for discrete PMF visualization
- Handle infinite support bounds (e.g., Poisson) with reasonable limits
- Maintain backward compatibility for continuous distributions

This resolves the issue where Binomial and other discrete distribution PMFs
were plotted as continuous curves instead of proper discrete mass functions.
- Added test_discrete_pmf_plotting() to verify that discrete distributions
  use stem plots for PMF visualization
- Ensures the fix for issue sktime#416 doesn't regress
- Replace bare except Exception with specific exception types
- Shorten long docstring line to comply with flake8 E501
- Maintain black formatting
@arnavk23 arnavk23 changed the title [ENH] Add _support method to BaseDistribution [ENH] Fix incorrect PMF plotting Jan 28, 2026
@fkiraly fkiraly added enhancement module:probability&simulation probability distributions and simulators labels Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement module:probability&simulation probability distributions and simulators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] plot method of the Binomial distribution shows incorrect pmf.

2 participants