dask 2021.10.0

NotesParametersReturns
standard_gamma(self, shape, size=None, chunks='auto', **kwargs)

This docstring was copied from numpy.random.mtrand.RandomState.standard_gamma.

Some inconsistencies with the Dask version may exist.

Samples are drawn from a Gamma distribution with specified parameters, shape (sometimes designated "k") and scale=1.

note

New code should use the standard_gamma method of a default_rng() instance instead; please see the :None:ref:`random-quick-start`.

Notes

The probability density for the Gamma distribution is

$$p(x) = x^{k-1}\frac{e^{-x/\theta}}{\theta^k\Gamma(k)},$$

where $k$ is the shape and $\theta$ the scale, and $\Gamma$ is the Gamma function.

The Gamma distribution is often used to model the times to failure of electronic components, and arises naturally in processes for which the waiting times between Poisson distributed events are relevant.

Parameters

shape : float or array_like of floats

Parameter, must be non-negative.

size : int or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k) , then m * n * k samples are drawn. If size is None (default), a single value is returned if shape is a scalar. Otherwise, np.array(shape).size samples are drawn.

Returns

out : ndarray or scalar

Drawn samples from the parameterized standard gamma distribution.

Draw samples from a standard Gamma distribution.

See Also

Generator.standard_gamma

which should be used for new code.

scipy.stats.gamma

probability density function, distribution or cumulative density function, etc.

Examples

Draw samples from the distribution:

This example is valid syntax, but we were not able to check execution
>>> shape, scale = 2., 1. # mean and width  # doctest: +SKIP
... s = np.random.standard_gamma(shape, 1000000) # doctest: +SKIP

Display the histogram of the samples, along with the probability density function:

This example is valid syntax, but we were not able to check execution
>>> import matplotlib.pyplot as plt  # doctest: +SKIP
... import scipy.special as sps # doctest: +SKIP
... count, bins, ignored = plt.hist(s, 50, density=True) # doctest: +SKIP
... y = bins**(shape-1) * ((np.exp(-bins/scale))/ # doctest: +SKIP
...  (sps.gamma(shape) * scale**shape))
... plt.plot(bins, y, linewidth=2, color='r') # doctest: +SKIP
... plt.show() # doctest: +SKIP
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/random.py#407
type: <class 'function'>
Commit: