flopscope.numpy.random.Generator.logistic
fnp.random.Generator.logistic(self, loc=0.0, scale=1.0, size=None)
Draw samples from a logistic distribution.
Adapted from NumPy docs np.random.Generator.logistic
Logistic distribution; cost = numel(output).
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), thenm * n * ksamples are drawn. If size isNone(default), a single value is returned iflocandscaleare both scalars. Otherwise,flops.broadcast(loc, scale).sizesamples are drawn.
Returns
- out:ndarray or scalar
Drawn samples from the parameterized logistic distribution.
See also
- scipy.stats.logistic probability density function, distribution or cumulative density function, etc.
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.
References
1
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.2
Weisstein, Eric W. "Logistic Distribution." From
MathWorld--A Wolfram Web Resource.
https://mathworld.wolfram.com/LogisticDistribution.html3
Wikipedia, "Logistic-distribution",
https://en.wikipedia.org/wiki/Logistic_distributionExamples
Draw samples from the distribution:
>>> loc, scale = 10, 1
>>> rng = flops.random.default_rng()
>>> s = rng.logistic(loc, scale, 10000)
>>> import matplotlib.pyplot as plt
>>> count, bins, _ = plt.hist(s, bins=50, label='Sampled data')# plot sampled data against the exact distribution
>>> def logistic(x, loc, scale):
... return flops.exp((loc-x)/scale)/(scale*(1+flops.exp((loc-x)/scale))**2)
>>> logistic_values = logistic(bins, loc, scale)
>>> bin_spacing = flops.mean(flops.diff(bins))
>>> plt.plot(bins, logistic_values * bin_spacing * s.size, label='Logistic PDF')
>>> plt.legend()
>>> plt.show()