@@ -487,56 +487,37 @@ def gamma(shape, rate=None, scale=None, **kwargs):
487
487
return _gamma (shape , scale , ** kwargs )
488
488
489
489
490
- class ChiSquareRV ( RandomVariable ):
491
- r"""A chi square continuous random variable .
490
+ def chisquare ( df , size = None , ** kwargs ):
491
+ r"""Draw samples from a chisquare distribution .
492
492
493
493
The probability density function for `chisquare` in terms of the number of degrees of
494
494
freedom :math:`k` is:
495
495
496
496
.. math::
497
-
498
497
f(x; k) = \frac{(1/2)^{k/2}}{\Gamma(k/2)} x^{k/2-1} e^{-x/2}
499
-
500
498
for :math:`k > 2`. :math:`\Gamma` is the gamma function:
501
499
502
500
.. math::
503
-
504
501
\Gamma(x) = \int_0^{\infty} t^{x-1} e^{-t} \mathrm{d}t
505
502
506
-
507
503
This variable is obtained by summing the squares :math:`k` independent, standard normally
508
504
distributed random variables.
509
505
510
- """
511
- name = "chisquare"
512
- ndim_supp = 0
513
- ndims_params = [0 ]
514
- dtype = "floatX"
515
- _print_name = ("ChiSquare" , "\\ operatorname{ChiSquare}" )
516
-
517
- def __call__ (self , df , size = None , ** kwargs ):
518
- r"""Draw samples from a chisquare distribution.
519
-
520
- Signature
521
- ---------
522
-
523
- `() -> ()`
524
-
525
- Parameters
526
- ----------
527
- df
528
- The number :math:`k` of degrees of freedom. Must be positive.
529
- size
530
- Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
531
- independent, identically distributed random variables are
532
- returned. Default is `None` in which case a single random variable
533
- is returned.
534
-
535
- """
536
- return super ().__call__ (df , size = size , ** kwargs )
537
-
506
+ Signature
507
+ ---------
508
+ `() -> ()`
538
509
539
- chisquare = ChiSquareRV ()
510
+ Parameters
511
+ ----------
512
+ df
513
+ The number :math:`k` of degrees of freedom. Must be positive.
514
+ size
515
+ Sample shape. If the given size is, e.g. `(m, n, k)` then `m * n * k`
516
+ independent, identically distributed random variables are
517
+ returned. Default is `None` in which case a single random variable
518
+ is returned.
519
+ """
520
+ return gamma (shape = df / 2.0 , scale = 2.0 , size = size , ** kwargs )
540
521
541
522
542
523
class ParetoRV (ScipyRandomVariable ):
0 commit comments