diff --git a/docs/examples/gallery/chisquared.md b/docs/examples/gallery/chisquared.md index 567f89ca..406e5753 100644 --- a/docs/examples/gallery/chisquared.md +++ b/docs/examples/gallery/chisquared.md @@ -54,7 +54,7 @@ for nu in nus: ```{eval-rst} ======== ========================================== -Support :math:`x \in (0, \infty)` +Support :math:`x \in [0, \infty)` Mean :math:`\nu` Variance :math:`2\nu` ======== ========================================== diff --git a/docs/examples/gallery/exponential.md b/docs/examples/gallery/exponential.md index 8c2302aa..01046341 100644 --- a/docs/examples/gallery/exponential.md +++ b/docs/examples/gallery/exponential.md @@ -91,7 +91,7 @@ for beta in betas: ```{eval-rst} ======== ========================================== -Support :math:`x \in (0, \infty)` +Support :math:`x \in [0, \infty)` Mean :math:`\frac{1}{\lambda}` Variance :math:`\frac{1}{\lambda^2}` ======== ========================================== diff --git a/preliz/distributions/beta.py b/preliz/distributions/beta.py index 65b24a58..5db3d39c 100644 --- a/preliz/distributions/beta.py +++ b/preliz/distributions/beta.py @@ -252,7 +252,7 @@ def nb_entropy(alpha, beta): @nb.vectorize(nopython=True, cache=True) def nb_logpdf(x, alpha, beta): - if x < 0 or x > 1: + if x <= 0 or x >= 1: return -np.inf else: beta_ = gammaln(alpha) + gammaln(beta) - gammaln(alpha + beta) diff --git a/preliz/distributions/gamma.py b/preliz/distributions/gamma.py index 8de9c823..adb2451b 100644 --- a/preliz/distributions/gamma.py +++ b/preliz/distributions/gamma.py @@ -191,7 +191,7 @@ def nb_ppf(q, alpha, beta, lower, upper): @nb.vectorize(nopython=True, cache=True) def nb_logpdf(x, alpha, beta): - if x < 0: + if x <= 0: return -np.inf else: x = x / (1 / beta) diff --git a/preliz/distributions/hurdle.py b/preliz/distributions/hurdle.py index 030166fb..0a9af722 100644 --- a/preliz/distributions/hurdle.py +++ b/preliz/distributions/hurdle.py @@ -47,13 +47,12 @@ class Hurdle(DistributionTransformer): Expected proportion of the base distribution (0 < psi < 1) """ - def __init__(self, dist, psi, **kwargs): + def __init__(self, dist, psi=None, **kwargs): self.dist = dist - self.psi = psi super().__init__() - self._parametrization(**kwargs) + self._parametrization(psi, **kwargs) - def _parametrization(self, **kwargs): + def _parametrization(self, psi=None, **kwargs): dist_params = [] if not kwargs: if hasattr(self.dist, "params"): @@ -65,6 +64,7 @@ def _parametrization(self, **kwargs): dist_params.append(value) setattr(self, key, value) + self.psi = psi self.params = (*dist_params, self.psi) self.param_names = (*self.dist.param_names, "psi") if all_not_none(*dist_params): diff --git a/preliz/distributions/kumaraswamy.py b/preliz/distributions/kumaraswamy.py index 8cb20355..4faafa2e 100644 --- a/preliz/distributions/kumaraswamy.py +++ b/preliz/distributions/kumaraswamy.py @@ -173,7 +173,7 @@ def nb_entropy(a, b): @nb.vectorize(nopython=True, cache=True) def nb_logpdf(x, a, b): - if x < 0 or x > 1: + if x <= 0 or x >= 1: return -np.inf else: return np.log(a * b) + xlogy((a - 1), x) + xlog1py((b - 1), -(x**a)) diff --git a/preliz/tests/test_scipy.py b/preliz/tests/test_scipy.py index 208f4501..b136a3e9 100644 --- a/preliz/tests/test_scipy.py +++ b/preliz/tests/test_scipy.py @@ -87,7 +87,12 @@ {"loc": 0, "scale": 2}, ), # not in scipy (InverseGamma, stats.invgamma, {"alpha": 5, "beta": 2}, {"a": 5, "scale": 2}), - (Kumaraswamy, stats.beta, {"a": 1, "b": 5}, {"a": 1, "b": 5}), # not in scipy + ( + Kumaraswamy, + stats.beta, + {"a": 1.00000001, "b": 5}, + {"a": 1.00000001, "b": 5}, + ), # not in scipy (Laplace, stats.laplace, {"mu": 2.5, "b": 4}, {"loc": 2.5, "scale": 4}), (LogLogistic, stats.fisk, {"alpha": 1, "beta": 8}, {"c": 8}), (Logistic, stats.logistic, {"mu": 2.5, "s": 4}, {"loc": 2.5, "scale": 4}),