Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.random.RandomState.gumbel

RandomState.gumbel(loc=0.0,scale=1.0,size=None)

Draw samples from a Gumbel distribution.

Draw samples from a Gumbel distribution with specified location andscale. For more information on the Gumbel distribution, seeNotes and References below.

Parameters:

loc : float or array_like of floats, optional

The location of the mode of the distribution. Default is 0.

scale : float or array_like of floats, optional

The scale parameter of the distribution. Default is 1.

size : int or tuple of ints, optional

Output shape. If the given shape is, e.g.,(m,n,k), thenm*n*k samples are drawn. If size isNone (default),a single value is returned ifloc andscale are both scalars.Otherwise,np.broadcast(loc,scale).size samples are drawn.

Returns:

out : ndarray or scalar

Drawn samples from the parameterized Gumbel distribution.

Notes

The Gumbel (or Smallest Extreme Value (SEV) or the Smallest ExtremeValue Type I) distribution is one of a class of Generalized ExtremeValue (GEV) distributions used in modeling extreme value problems.The Gumbel is a special case of the Extreme Value Type I distributionfor maximums from distributions with “exponential-like” tails.

The probability density for the Gumbel distribution is

p(x) = \frac{e^{-(x - \mu)/ \beta}}{\beta} e^{ -e^{-(x - \mu)/\beta}},

where\mu is the mode, a location parameter, and\beta is the scale parameter.

The Gumbel (named for German mathematician Emil Julius Gumbel) was usedvery early in the hydrology literature, for modeling the occurrence offlood events. It is also used for modeling maximum wind speed andrainfall rates. It is a “fat-tailed” distribution - the probability ofan event in the tail of the distribution is larger than if one used aGaussian, hence the surprisingly frequent occurrence of 100-yearfloods. Floods were initially modeled as a Gaussian process, whichunderestimated the frequency of extreme events.

It is one of a class of extreme value distributions, the GeneralizedExtreme Value (GEV) distributions, which also includes the Weibull andFrechet.

The function has a mean of\mu + 0.57721\beta and a varianceof\frac{\pi^2}{6}\beta^2.

References

[R157]Gumbel, E. J., “Statistics of Extremes,”New York: Columbia University Press, 1958.
[R158]Reiss, R.-D. and Thomas, M., “Statistical Analysis of ExtremeValues from Insurance, Finance, Hydrology and Other Fields,”Basel: Birkhauser Verlag, 2001.

Examples

Draw samples from the distribution:

>>>mu,beta=0,0.1# location and scale>>>s=np.random.gumbel(mu,beta,1000)

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

>>>importmatplotlib.pyplotasplt>>>count,bins,ignored=plt.hist(s,30,normed=True)>>>plt.plot(bins,(1/beta)*np.exp(-(bins-mu)/beta)...*np.exp(-np.exp(-(bins-mu)/beta)),...linewidth=2,color='r')>>>plt.show()

(Source code,png,pdf)

../../_images/numpy-random-RandomState-gumbel-1_00_00.png

Show how an extreme value distribution can arise from a Gaussian processand compare to a Gaussian:

>>>means=[]>>>maxima=[]>>>foriinrange(0,1000):...a=np.random.normal(mu,beta,1000)...means.append(a.mean())...maxima.append(a.max())>>>count,bins,ignored=plt.hist(maxima,30,normed=True)>>>beta=np.std(maxima)*np.sqrt(6)/np.pi>>>mu=np.mean(maxima)-0.57721*beta>>>plt.plot(bins,(1/beta)*np.exp(-(bins-mu)/beta)...*np.exp(-np.exp(-(bins-mu)/beta)),...linewidth=2,color='r')>>>plt.plot(bins,1/(beta*np.sqrt(2*np.pi))...*np.exp(-(bins-mu)**2/(2*beta**2)),...linewidth=2,color='g')>>>plt.show()

(png,pdf)

../../_images/numpy-random-RandomState-gumbel-1_01_00.png

Previous topic

numpy.random.RandomState.get_state

Next topic

numpy.random.RandomState.hypergeometric

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp