Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Alpha distribution #356

Merged
merged 5 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/api_reference/distributions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Continuous support
:toctree: auto_generated/
:template: class.rst

Alpha
Beta
ChiSquared
Exponential
Expand Down
2 changes: 2 additions & 0 deletions skpro/distributions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# adapted from sktime

__all__ = [
"Alpha",
"Beta",
"ChiSquared",
"Delta",
Expand All @@ -27,6 +28,7 @@
"Weibull",
]

from skpro.distributions.alpha import Alpha
from skpro.distributions.beta import Beta
from skpro.distributions.chi_squared import ChiSquared
from skpro.distributions.compose import IID
Expand Down
61 changes: 61 additions & 0 deletions skpro/distributions/alpha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# copyright: skpro developers, BSD-3-Clause License (see LICENSE file)
"""Alpha probability distribution."""

__author__ = ["SaiReavanth25"]

import pandas as pd
from scipy.stats import alpha, rv_continuous

from skpro.distributions.adapters.scipy import _ScipyAdapter


class Alpha(_ScipyAdapter):
"""Alpha distribution.

Parameters
----------
a : float or array of float (1D or 2D), must be positive
shape parameter of the distribution
index : pd.Index, optional, default = RangeIndex
columns : pd.Index, optional, default = RangeIndex

Example
-------
>>> from skpro.distributions import Alpha

>>> distr = Alpha(a=[[1, 2], [3, 4]])
"""

_tags = {
"capabilities:approx": ["pdfnorm"],
"capabilities:exact": ["mean", "var", "pdf", "log_pdf", "cdf", "ppf"],
"distr:measuretype": "continuous",
"distr:paramtype": "parametric",
"broadcast_init": "on",
}

def __init__(self, a, index=None, columns=None):
self.a = a

super().__init__(index=index, columns=columns)

def _get_scipy_object(self) -> rv_continuous:
return alpha

def _get_scipy_param(self) -> dict:
SaiRevanth25 marked this conversation as resolved.
Show resolved Hide resolved
a = self._bc_params["a"]

return [a], {}

@classmethod
def get_test_params(cls, parameter_set="default"):
"""Return testing parameter settings for the estimator."""
params1 = {"a": [[2, 3], [4, 5]]}
params2 = {
"a": 3,
"index": pd.Index([1, 2, 3]),
"columns": pd.Index(["a", "b"]),
}
params3 = {"a": 2.5}

return [params1, params2, params3]
Loading