Skip to content

Commit 6e886e5

Browse files
committed
Update exponential
1 parent 11f4bf7 commit 6e886e5

File tree

4 files changed

+123
-102
lines changed

4 files changed

+123
-102
lines changed

bayesml/bernoulli/_bernoulli.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import warnings
66
import numpy as np
77
from scipy.stats import beta as ss_beta
8-
# from scipy.stats import betabino as ss_betabinom
8+
# from scipy.stats import betabinom as ss_betabinom
99
import matplotlib.pyplot as plt
1010

1111
from .. import base
@@ -18,14 +18,14 @@ class GenModel(base.Generative):
1818
Parameters
1919
----------
2020
theta : float, optional
21-
a real number in :math:`[0, 1]`, by default 0.5
21+
a real number in :math:`[0, 1]`, 0.5 by default.
2222
h_alpha : float, optional
23-
a positive real number, by default 0.5
23+
a positive real number, 0.5 by default.
2424
h_beta : float, optional
25-
a positibe real number, by default 0.5
25+
a positibe real number, 0.5 by default.
2626
seed : {None, int}, optional
2727
A seed to initialize numpy.random.default_rng(),
28-
by default None
28+
None by default.
2929
"""
3030
def __init__(self,*,theta=0.5,h_alpha=0.5,h_beta=0.5,seed=None):
3131
self.rng = np.random.default_rng(seed)
@@ -58,9 +58,9 @@ def set_h_params(self,h_alpha=None,h_beta=None):
5858
Parameters
5959
----------
6060
h_alpha : float, optional
61-
a positive real number, bydefault None
61+
a positive real number, None by default.
6262
h_beta : float, optional
63-
a positibe real number, bydefault None
63+
a positibe real number, None by default.
6464
"""
6565
if h_alpha is not None:
6666
self.h_alpha = _check.pos_float(h_alpha,'h_alpha',ParameterFormatError)
@@ -93,7 +93,7 @@ def set_params(self,theta=None):
9393
Parameters
9494
----------
9595
theta : float, optional
96-
a real number :math:`\theta \in [0, 1]`, by default None.
96+
a real number :math:`\theta \in [0, 1]`, None by default.
9797
"""
9898
if theta is not None:
9999
self.theta = _check.float_in_closed01(theta,'theta',ParameterFormatError)
@@ -150,9 +150,9 @@ def visualize_model(self,sample_size=20,sample_num=5):
150150
Parameters
151151
----------
152152
sample_size : int, optional
153-
A positive integer, by default 20
153+
A positive integer, 20 by default.
154154
sample_num : int, optional
155-
A positive integer, by default 5
155+
A positive integer, 5 by default.
156156
157157
Examples
158158
--------
@@ -195,9 +195,9 @@ class LearnModel(base.Posterior,base.PredictiveMixin):
195195
Parameters
196196
----------
197197
h0_alpha : float, optional
198-
a positive real number, by default 0.5
198+
a positive real number, 0.5 by default.
199199
h0_beta : float, optional
200-
a positibe real number, by default 0.5
200+
a positibe real number, 0.5 by default.
201201
202202
Attributes
203203
----------
@@ -240,9 +240,9 @@ def set_h0_params(self,h0_alpha=None,h0_beta=None):
240240
Parameters
241241
----------
242242
h0_alpha : float, optional
243-
a positive real number, by default None
243+
a positive real number, None by default.
244244
h0_beta : float, optionanl
245-
a positibe real number, by default None
245+
a positibe real number, None by default.
246246
"""
247247
if h0_alpha is not None:
248248
self.h0_alpha = _check.pos_float(h0_alpha,'h0_alpha',ParameterFormatError)
@@ -268,9 +268,9 @@ def set_hn_params(self,hn_alpha,hn_beta):
268268
Parameters
269269
----------
270270
hn_alpha : float, optional
271-
a positive real number, by default None
271+
a positive real number, None by default.
272272
hn_beta : float, optional
273-
a positibe real number, by default None
273+
a positibe real number, None by default.
274274
"""
275275
if hn_alpha is not None:
276276
self.hn_alpha = _check.pos_float(hn_alpha,'hn_alpha',ParameterFormatError)
@@ -315,10 +315,10 @@ def estimate_params(self,loss="squared",dict_out=False):
315315
Parameters
316316
----------
317317
loss : str, optional
318-
Loss function underlying the Bayes risk function, by default \"squared\".
318+
Loss function underlying the Bayes risk function, \"squared\" by default.
319319
This function supports \"squared\", \"0-1\", \"abs\", and \"KL\".
320320
dict_out : bool, optional
321-
If ``True``, output will be a dict, by default ``False``.
321+
If ``True``, output will be a dict, by ``False`` default.
322322
323323
Returns
324324
-------
@@ -376,7 +376,7 @@ def estimate_interval(self,credibility=0.95):
376376
Parameters
377377
----------
378378
credibility : float, optional
379-
A posterior probability that the interval conitans the paramter, by default 0.95
379+
A posterior probability that the interval conitans the paramter, 0.95 by default.
380380
381381
Returns
382382
-------
@@ -430,7 +430,7 @@ def make_prediction(self,loss="squared"):
430430
Parameters
431431
----------
432432
loss : str, optional
433-
Loss function underlying the Bayes risk function, by default \"squared\".
433+
Loss function underlying the Bayes risk function, \"squared\" by default.
434434
This function supports \"squared\", \"0-1\", \"abs\", and \"KL\".
435435
436436
Returns
@@ -462,7 +462,7 @@ def pred_and_update(self,x,loss="squared"):
462462
x : int
463463
It must be 0 or 1
464464
loss : str, optional
465-
Loss function underlying the Bayes risk function, by default \"squared\".
465+
Loss function underlying the Bayes risk function, \"squared\" by default.
466466
This function supports \"squared\", \"0-1\", \"abs\", and \"KL\".
467467
468468
Returns

bayesml/exponential/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,30 @@
5454
The predictive distribution is as follows:
5555
5656
* :math:`x_{n+1} \in \mathbb{R}_{\geq 0}`: a new data point
57-
* :math:`\alpha_\mathrm{p} \in \mathbb{R}_{>0}`: the hyperparameter of the posterior
58-
* :math:`\eta_\mathrm{p} \in \mathbb{R}_{>0}`: the hyperparameter of the posterior
57+
* :math:`\kappa_\mathrm{p} \in \mathbb{R}_{>0}`: the hyperparameter of the posterior
58+
* :math:`\lambda_\mathrm{p} \in \mathbb{R}_{>0}`: the hyperparameter of the posterior
5959
6060
.. math::
61-
p(x_{n+1}|x^n)=\mathrm{Lomax}(x_{n+1}|\alpha_\mathrm{p},\eta_\mathrm{p}) = \frac{\alpha_\mathrm{p}}{\eta_\mathrm{p}}\left(1+\frac{x_{n+1}}{\eta_\mathrm{p}}\right)^{-(\alpha_\mathrm{p}+1)},
61+
p(x_{n+1}|x^n)=\mathrm{Lomax}(x_{n+1}|\kappa_\mathrm{p},\lambda_\mathrm{p}) = \frac{\kappa_\mathrm{p}}{\lambda_\mathrm{p}}\left(1+\frac{x_{n+1}}{\lambda_\mathrm{p}}\right)^{-(\kappa_\mathrm{p}+1)},
6262
6363
.. math::
6464
\mathbb{E}[x_{n+1} | x^n] &=
6565
\begin{cases}
66-
\frac{\eta_\mathrm{p}}{\alpha_\mathrm{p}-1}, & \alpha_\mathrm{p}>1,\\
66+
\frac{\lambda_\mathrm{p}}{\kappa_\mathrm{p}-1}, & \kappa_\mathrm{p}>1,\\
6767
\mathrm{undefined}, & \text{otherwise},
6868
\end{cases}\\
6969
\mathbb{V}[x_{n+1} | x^n] &=
7070
\begin{cases}
71-
\frac{\eta_\mathrm{p}^2 \alpha_\mathrm{p}}{(\alpha_\mathrm{p}-1)^2(\alpha_\mathrm{p}-2)}, & \alpha_\mathrm{p}>2,\\
72-
\infty, & 1<\alpha_\mathrm{p}\leq 2,\\
71+
\frac{\lambda_\mathrm{p}^2 \kappa_\mathrm{p}}{(\kappa_\mathrm{p}-1)^2(\kappa_\mathrm{p}-2)}, & \kappa_\mathrm{p}>2,\\
72+
\infty, & 1<\kappa_\mathrm{p}\leq 2,\\
7373
\mathrm{undefined}, & \text{otherwise},
7474
\end{cases}
7575
7676
where the parameters are obtained from the hyperparameters of the posterior distribution as follows:
7777
7878
.. math::
79-
&\alpha_\mathrm{p} = \alpha_n, \\
80-
&\eta_\mathrm{p} = \beta_n.
79+
&\kappa_\mathrm{p} = \alpha_n, \\
80+
&\lambda_\mathrm{p} = \beta_n.
8181
"""
8282
from ._exponential import GenModel
8383
from ._exponential import LearnModel

0 commit comments

Comments
 (0)