A generic continuous random variable class meant for subclassing.
rv_continuous is a base class to construct specific distribution classes and instances from for continuous random variables. It cannot be used directly as a distribution.
Parameters :  momtype : int, optional
a : float, optional
b : float, optional
xa : float, optional
xb : float, optional
xtol : float, optional
badvalue : object, optional
name : str, optional
longname : str, optional
shapes : str, optional
extradoc : str, optional


Notes
Frozen Distribution
Alternatively, the object may be called (as a function) to fix the shape, location, and scale parameters returning a “frozen” continuous RV object:
Subclassing
New random variables can be defined by subclassing rv_continuous class and redefining at least the
_pdf or the cdf method which will be given clean arguments (in between a and b) and passing the argument check method
If postive argument checking is not correct for your RV then you will also need to redefine
_argcheck
Correct, but potentially slow defaults exist for the remaining methods but for speed and/or accuracy you can override
_cdf, _ppf, _rvs, _isf, _sf
Rarely would you override _isf and _sf but you could.
Statistics are computed using numerical integration by default. For speed you can redefine this using
OR
You can override
Examples
To create a new Gaussian distribution, we would do the following:
class gaussian_gen(rv_continuous):
"Gaussian distribution"
def _pdf:
...
...
Methods
rvs(<shape(s)>, loc=0, scale=1, size=1)  random variates  
pdf(x, <shape(s)>, loc=0, scale=1)  probability density function  
cdf(x, <shape(s)>, loc=0, scale=1)  cumulative density function  
sf(x, <shape(s)>, loc=0, scale=1)  survival function (1cdf — sometimes more accurate)  
ppf(q, <shape(s)>, loc=0, scale=1)  percent point function (inverse of cdf — quantiles)  
isf(q, <shape(s)>, loc=0, scale=1)  inverse survival function (inverse of sf)  
moments(n, <shape(s)>)  noncentral nth moment of the standard distribution (oc=0, scale=1)  
stats(<shape(s)>, loc=0, scale=1, moments=’mv’)  mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’)  
entropy(<shape(s)>, loc=0, scale=1)  (differential) entropy of the RV.  
fit(data, <shape(s)>, loc=0, scale=1)  Parameter estimates for generic data  
__call__(<shape(s)>, loc=0, scale=1)  calling a distribution instance creates a frozen RV object with the same methods but holding the given shape, location, and scale fixed. see Notes section  
Parameters for Methods  
x  arraylike  quantiles 
q  arraylike  lower or upper tail probability 
<shape(s)>  arraylike  shape parameters 
loc  arraylike, optional  location parameter (default=0) 
scale  arraylike, optional  scale parameter (default=1) 
size  int or tuple of ints, optional  shape of random variates (default computed from input arguments ) 
moments  string, optional  composed of letters [‘mvsk’] specifying which moments to compute where ‘m’ = mean, ‘v’ = variance, ‘s’ = (Fisher’s) skew and ‘k’ = (Fisher’s) kurtosis. (default=’mv’) 
n  int  order of moment to calculate in method moments 
Methods that can be overwritten by subclasses  
_rvs _pdf _cdf _sf _ppf _isf _stats _munp _entropy _argcheck  
There are additional (internal and private) generic methods that can  
be useful for crosschecking and for debugging, but might work in all  
cases when directly called. 