Describe the bug
Normal and Laplace accept non-positive values for their required scale parameters and can return mathematically invalid pdf values instead of rejecting the input.
For example:
-
Normal(mu=0, sigma=-1).pdf(0) returns -0.3989422804014327
-
Laplace(mu=0, scale=-1).pdf(0) returns -0.5
A probability density function should never be negative, so this is a silent correctness issue.
To Reproduce
from skpro.distributions.normal import Normal
from skpro.distributions.laplace import Laplace
print(Normal(mu=0, sigma=-1).pdf(0))
print(Laplace(mu=0, scale=-1).pdf(0))
Observed output in skpro:
-0.3989422804014327
-0.5
SciPy comparison:
from scipy.stats import norm, laplace
print(norm.pdf(0, loc=0, scale=-1))
print(laplace.pdf(0, loc=0, scale=-1))
Expected behavior
These distributions document sigma and scale as positive parameters. Passing non-positive values should raise a clear ValueError, ideally at construction time, instead of allowing invalid parameters through to pdf evaluation.
Environment
OS: Windows
Python: 3.9.13
skpro: current main branch (local clone)
Additional context
This appears to be missing parameter validation in the distribution constructors. I checked a few related distributions as well; the strongest confirmed cases from direct reproduction are Normal and Laplace.
I'd be happy to open a PR for this.