'Returns a random number generator for the predictive distribution.
Parameters
params : array-like
The model parameters.
scale : scalar
The scale parameter.
exog : array-like
The predictor variable matrix.
Returns
gen
Frozen random number generator object.  Use the ``rvs`` method to
generate random values.
Notes
Due to the behavior of ``scipy.stats.distributions objects``, the
returned random number generator must be called with ``gen.rvs(n)``
where ``n`` is the number of observations in the data set used
to fit the model.  If any other value is used for ``n``, misleading
results will be produced.'

def get_distribution(self, params, scale=1, exog=None, exposure=None, offset=None):

    fit = self.predict(params, exog, exposure, offset, linear=False)
    import scipy.stats.distributions as dist
    if isinstance(self.family, families.Gaussian):
        return dist.norm(loc=fit, scale=np.sqrt(scale))
    elif isinstance(self.family, families.Binomial):
        return dist.binom(n=1, p=fit)
    elif isinstance(self.family, families.Poisson):
        return dist.poisson(mu=fit)
    elif isinstance(self.family, families.Gamma):
        alpha = (fit / float(scale))
        return dist.gamma(alpha, scale=scale)
    else:
        raise ValueError(('get_distribution    not    implemented    for    %s' % self.family.name))
