nlcpy.random.Generator.logistic
- Generator.logistic(self, loc=0.0, scale=1.0, size=None)
- Draws samples from a logistic distribution. - Samples are drawn from a logistic distribution with specified parameters, loc (location or mean, also median), and scale (>0). - Parameters
- locfloat, optional
- Parameter of the distribution. Default is 0. 
- scalefloat, optional
- Parameter of the distribution. Must be non-negative. Default is 1. 
- sizeint or tuple of ints, optional
- Output shape. If the given shape is, e.g., - (m, n, k), then- m * n * ksamples are drawn.
 
- Returns
- outndarray
- Drawn samples from the parameterized logistic distribution. 
 
 - Note - The probability density for the Logistic distribution is - where - = location and - = scale. - Restriction - If loc is neither a scalar nor None : NotImplementedError occurs. 
- If scale is neither a scalar nor None : NotImplementedError occurs. 
 - Examples - Draw samples from the distribution: - >>> import nlcpy as vp >>> loc, scale = 10, 1 >>> s = vp.random.default_rng().logistic(loc, scale, 10000) >>> import matplotlib.pyplot as plt >>> count, bins, ignored = plt.hist(s.get(), bins=50) - Plot against distribution - >>> def logist(x, loc, scale): ... return vp.exp((loc-x)/scale)/(scale*(1+vp.exp((loc-x)/scale))**2) >>> lgst_val = logist(bins, loc, scale) >>> plt.plot(bins, lgst_val * count.max() / lgst_val.max()) ... >>> plt.show() 