logseries#
- class brainstate.random.logseries(p, size=None, key=None, dtype=None)#
Draw samples from a logarithmic series distribution.
Samples are drawn from a log series distribution with specified shape parameter, 0 <=
p< 1.- Parameters:
p (float or array_like of floats) – Shape parameter for the distribution. Must be in the range [0, 1).
size (
int|Sequence[int] |integer|Sequence[integer] |None) – 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 ifpis a scalar. Otherwise,np.array(p).sizesamples are drawn.key (
int|Array|ndarray|None) – The key for the random number generator. If not given, the default random number generator is used.
- Returns:
out – Drawn samples from the parameterized logarithmic series distribution.
- Return type:
ndarray or scalar
See also
scipy.stats.logserprobability density function, distribution or cumulative density function, etc.
Notes
The probability density for the Log Series distribution is
\[P(k) = \frac{-p^k}{k \ln(1-p)},\]where p = probability.
The log series distribution is frequently used to represent species richness and occurrence, first proposed by Fisher, Corbet, and Williams in 1943 [2]. It may also be used to model the numbers of occupants seen in cars [3].
References
Examples
Draw samples from the distribution:
>>> import brainstate >>> a = .6 >>> s = brainstate.random.logseries(a, 10000) >>> import matplotlib.pyplot as plt # noqa >>> count, bins, ignored = plt.hist(s)
# plot against distribution
>>> def logseries(k, p): ... return -p**k/(k*np.log(1-p)) >>> plt.plot(bins, logseries(bins, a)*count.max()/ ... logseries(bins, a).max(), 'r') >>> plt.show()