power(a, size=None, device=None, out=None)

Draw samples in [0, 1] from a power distribution with given parameter a.

  • a (float or array_like of floats) – Shape of the distribution. Must be > 0.

  • 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 a is a scalar. Otherwise, np.array(a).size samples are drawn.


out – Drawn samples from the power distribution.

Return type

ndarray or scalar


>>> np.random.power(a=5)
>>> np.random.power(a=5, size=[2,3])
array([[0.988391  , 0.5153122 , 0.9383134 ],
       [0.9078098 , 0.87819266, 0.730635]])
>>> np.random.power(a=np.array([2,3])
array([0.7499419 , 0.88894516])
The probability density function is f(x; a) = ax^{a-1}, 0 \le x \le 1, a>0.
The power distribution is just the inverse of the Pareto distribution and
a special case of the Beta distribution.