-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathskellam.py
More file actions
54 lines (41 loc) · 1.63 KB
/
skellam.py
File metadata and controls
54 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Skellam probability distribution for skpro."""
from scipy.stats import rv_discrete, skellam
from skpro.distributions.adapters.scipy import _ScipyAdapter
class Skellam(_ScipyAdapter):
r"""Skellam probability distribution.
The Skellam distribution is a discrete probability distribution that describes
the difference between two independent Poisson-distributed random variables
with means $\mu_1$ and $\mu_2$. Its probability mass function (PMF) is:
.. math::
P(k; \mu_1, \mu_2) = e^{-(\mu_1 + \mu_2)}
\left( \frac{\mu_1}{\mu_2} \right)^{k/2} I_{|k|}(2 \sqrt{\mu_1 \mu_2})
where $I_{|k|}$ is the modified Bessel function of the first kind.
Parameters
----------
mu1 : float
Mean of the first Poisson distribution
mu2 : float
Mean of the second Poisson distribution
"""
_tags = {
"authors": ["arnavk23"],
"distr:measuretype": "discrete",
"capabilities:exact": ["mean", "var", "pmf", "log_pmf", "cdf", "ppf"],
"broadcast_init": "on",
}
def __init__(self, mu1, mu2, index=None, columns=None):
self.mu1 = mu1
self.mu2 = mu2
super().__init__(index=index, columns=columns)
def _get_scipy_object(self) -> rv_discrete:
return skellam
def _get_scipy_param(self):
mu1 = self._bc_params["mu1"]
mu2 = self._bc_params["mu2"]
return [mu1, mu2], {}
@classmethod
def get_test_params(cls, parameter_set="default"):
"""Return test parameters for Skellam."""
params1 = {"mu1": 3.0, "mu2": 2.0}
params2 = {"mu1": 5.0, "mu2": 1.0}
return [params1, params2]