@@ -487,56 +487,37 @@ def gamma(shape, rate=None, scale=None, **kwargs):
487487 return _gamma (shape , scale , ** kwargs )
488488
489489
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 .
492492
493493 The probability density function for `chisquare` in terms of the number of degrees of
494494 freedom :math:`k` is:
495495
496496 .. math::
497-
498497 f(x; k) = \frac{(1/2)^{k/2}}{\Gamma(k/2)} x^{k/2-1} e^{-x/2}
499-
500498 for :math:`k > 2`. :math:`\Gamma` is the gamma function:
501499
502500 .. math::
503-
504501 \Gamma(x) = \int_0^{\infty} t^{x-1} e^{-t} \mathrm{d}t
505502
506-
507503 This variable is obtained by summing the squares :math:`k` independent, standard normally
508504 distributed random variables.
509505
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+ `() -> ()`
538509
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 )
540521
541522
542523class ParetoRV (ScipyRandomVariable ):
0 commit comments