This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / random / RandomState / logistic

cython_function_or_method

numpy.random:RandomState.logistic

Signature

def   logistic ( loc = 0.0 scale = 1.0 size = None )

Summary

Draw samples from a logistic distribution.

Extended Summary

Samples are drawn from a logistic distribution with specified parameters, loc (location or mean, also median), and scale (>0).

Parameters

loc : float or array_like of floats, optional

Parameter of the distribution. Default is 0.

scale : float or array_like of floats, optional

Parameter of the distribution. Must be non-negative. Default is 1.

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 loc and scale are both scalars. Otherwise, np.broadcast(loc, scale).size samples are drawn.

Returns

out : ndarray or scalar

Drawn samples from the parameterized logistic distribution.

Notes

The probability density for the Logistic distribution is

where = location and = scale.

The Logistic distribution is used in Extreme Value problems where it can act as a mixture of Gumbel distributions, in Epidemiology, and by the World Chess Federation (FIDE) where it is used in the Elo ranking system, assuming the performance of each player is a logistically distributed random variable.

Examples

Draw samples from the distribution:
loc, scale = 10, 1
s = np.random.logistic(loc, scale, 10000)
import matplotlib.pyplot as plt
count, bins, ignored = plt.hist(s, bins=50)
# plot against distribution
def logist(x, loc, scale):
    return np.exp((loc-x)/scale)/(scale*(1+np.exp((loc-x)/scale))**2)
lgst_val = logist(bins, loc, scale)
plt.plot(bins, lgst_val * count.max() / lgst_val.max())
plt.show()
fig-860ed4848e16820d.png

See also

random.Generator.logistic

which should be used for new code.

scipy.stats.logistic

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

Aliases

  • numpy.random.logistic
  • numpy.random.RandomState.logistic