|
|
|
@@ -26,7 +26,7 @@ from ._utils.custom_ops import exp_generic, log_generic |
|
|
|
class Geometric(Distribution): |
|
|
|
""" |
|
|
|
Geometric Distribution. |
|
|
|
It represents that there are k failures before the first sucess, namely taht there are in total k+1 Bernoulli trails |
|
|
|
It represents that there are k failures before the first sucess, namely taht there are in total k+1 Bernoulli trials |
|
|
|
when the first success is achieved. |
|
|
|
|
|
|
|
Args: |
|
|
|
@@ -62,7 +62,7 @@ class Geometric(Distribution): |
|
|
|
>>> # `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival`, have the same arguments as follows. |
|
|
|
>>> # Args: |
|
|
|
>>> # value (Tensor): the value to be evaluated. |
|
|
|
>>> # probs1 (Tensor): the probability of success of a Bernoulli trail. Default: self.probs. |
|
|
|
>>> # probs1 (Tensor): the probability of success of a Bernoulli trial. Default: self.probs. |
|
|
|
>>> # Examples of `prob`. |
|
|
|
>>> # Similar calls can be made to other probability functions |
|
|
|
>>> # by replacing `prob` by the name of the function. |
|
|
|
@@ -79,7 +79,7 @@ class Geometric(Distribution): |
|
|
|
(3,) |
|
|
|
>>> # Functions `mean`, `sd`, `var`, and `entropy` have the same arguments. |
|
|
|
>>> # Args: |
|
|
|
>>> # probs1 (Tensor): the probability of success of a Bernoulli trail. Default: self.probs. |
|
|
|
>>> # probs1 (Tensor): the probability of success of a Bernoulli trial. Default: self.probs. |
|
|
|
>>> # Examples of `mean`. `sd`, `var`, and `entropy` are similar. |
|
|
|
>>> ans = g1.mean() # return 1.0 |
|
|
|
>>> print(ans.shape) |
|
|
|
@@ -94,8 +94,8 @@ class Geometric(Distribution): |
|
|
|
>>> # Interfaces of 'kl_loss' and 'cross_entropy' are the same. |
|
|
|
>>> # Args: |
|
|
|
>>> # dist (str): the name of the distribution. Only 'Geometric' is supported. |
|
|
|
>>> # probs1_b (Tensor): the probability of success of a Bernoulli trail of distribution b. |
|
|
|
>>> # probs1_a (Tensor): the probability of success of a Bernoulli trail of distribution a. Default: self.probs. |
|
|
|
>>> # probs1_b (Tensor): the probability of success of a Bernoulli trial of distribution b. |
|
|
|
>>> # probs1_a (Tensor): the probability of success of a Bernoulli trial of distribution a. Default: self.probs. |
|
|
|
>>> # Examples of `kl_loss`. `cross_entropy` is similar. |
|
|
|
>>> ans = g1.kl_loss('Geometric', probs_b) |
|
|
|
>>> print(ans.shape) |
|
|
|
@@ -110,7 +110,7 @@ class Geometric(Distribution): |
|
|
|
>>> # Examples of `sample`. |
|
|
|
>>> # Args: |
|
|
|
>>> # shape (tuple): the shape of the sample. Default: () |
|
|
|
>>> # probs1 (Tensor): the probability of success of a Bernoulli trail. Default: self.probs. |
|
|
|
>>> # probs1 (Tensor): the probability of success of a Bernoulli trial. Default: self.probs. |
|
|
|
>>> ans = g1.sample() |
|
|
|
>>> print(ans.shape) |
|
|
|
() |
|
|
|
@@ -172,7 +172,7 @@ class Geometric(Distribution): |
|
|
|
@property |
|
|
|
def probs(self): |
|
|
|
""" |
|
|
|
Return the probability of success of the Bernoulli trail, |
|
|
|
Return the probability of success of the Bernoulli trial, |
|
|
|
after casting to dtype. |
|
|
|
""" |
|
|
|
return self._probs |
|
|
|
|