|
55 | 55 | from pytensor.tensor.random.op import RandomVariable
|
56 | 56 | from pytensor.tensor.variable import TensorConstant
|
57 | 57 |
|
58 |
| -from pymc.distributions.distribution import CustomDist |
59 | 58 | from pymc.logprob.abstract import _logprob_helper
|
60 | 59 | from pymc.logprob.basic import icdf
|
61 | 60 |
|
@@ -2378,12 +2377,17 @@ class ChiSquared:
|
2378 | 2377 | r"""
|
2379 | 2378 | :math:`\chi^2` log-likelihood.
|
2380 | 2379 |
|
| 2380 | + This is the distribution from the sum of the squares of :math:`\nu` independent standard normal random variables or a special |
| 2381 | + case of the gamma distribution. |
| 2382 | +
|
2381 | 2383 | The pdf of this distribution is
|
2382 | 2384 |
|
2383 | 2385 | .. math::
|
2384 | 2386 |
|
2385 | 2387 | f(x \mid \nu) = \frac{x^{(\nu-2)/2}e^{-x/2}}{2^{\nu/2}\Gamma(\nu/2)}
|
2386 | 2388 |
|
| 2389 | + Read more about the :math:`\chi^2` distribution at https://en.wikipedia.org/wiki/Chi-squared_distribution |
| 2390 | +
|
2387 | 2391 | .. plot::
|
2388 | 2392 | :context: close-figs
|
2389 | 2393 |
|
@@ -2414,26 +2418,12 @@ class ChiSquared:
|
2414 | 2418 | Degrees of freedom (nu > 0).
|
2415 | 2419 | """
|
2416 | 2420 |
|
2417 |
| - def chisquared_dist(nu, size): |
2418 |
| - return Gamma.dist(alpha=nu / 2, beta=1 / 2, size=size) |
2419 |
| - |
2420 | 2421 | def __new__(cls, name, nu, **kwargs):
|
2421 |
| - return CustomDist( |
2422 |
| - name, |
2423 |
| - nu, |
2424 |
| - dist=cls.chisquared_dist, |
2425 |
| - class_name="ChiSquared", |
2426 |
| - **kwargs, |
2427 |
| - ) |
| 2422 | + return Gamma(name, alpha=nu / 2, beta=1 / 2, **kwargs) |
2428 | 2423 |
|
2429 | 2424 | @classmethod
|
2430 | 2425 | def dist(cls, nu, **kwargs):
|
2431 |
| - return CustomDist.dist( |
2432 |
| - nu, |
2433 |
| - dist=cls.chisquared_dist, |
2434 |
| - class_name="ChiSquared", |
2435 |
| - **kwargs, |
2436 |
| - ) |
| 2426 | + return Gamma.dist(alpha=nu / 2, beta=1 / 2, **kwargs) |
2437 | 2427 |
|
2438 | 2428 |
|
2439 | 2429 | # TODO: Remove this once logp for multiplication is working!
|
|
0 commit comments