Draw samples from a logistic distribution.
Samples are drawn from a logistic distribution with specified parameters, loc (location or mean, also median), and scale (>0).
Note
New code should use the logistic method of a Generator instance instead; please see the Quick start.
Parameter of the distribution. Default is 0.
Parameter of the distribution. Must be non-negative. Default is 1.
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.
Drawn samples from the parameterized logistic distribution.
See also
scipy.stats.logisticprobability density function, distribution or cumulative density function, etc.
random.Generator.logisticwhich should be used for new code.
The probability density for the Logistic distribution is
where \(\mu\) = location and \(s\) = 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.
Reiss, R.-D. and Thomas M. (2001), “Statistical Analysis of Extreme Values, from Insurance, Finance, Hydrology and Other Fields,” Birkhauser Verlag, Basel, pp 132-133.
Weisstein, Eric W. “Logistic Distribution.” From MathWorld–A Wolfram Web Resource. https://mathworld.wolfram.com/LogisticDistribution.html
Wikipedia, “Logistic-distribution”, https://en.wikipedia.org/wiki/Logistic_distribution
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()
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/random/generated/numpy.random.logistic.html