lognormal(self, mean=0.0, sigma=1.0, size=None, chunks='auto', **kwargs)
This docstring was copied from numpy.random.mtrand.RandomState.lognormal.
Some inconsistencies with the Dask version may exist.
Draw samples from a log-normal distribution with specified mean, standard deviation, and array shape. Note that the mean and standard deviation are not the values for the distribution itself, but of the underlying normal distribution it is derived from.
New code should use the lognormal
method of a default_rng()
instance instead; please see the :None:ref:`random-quick-start`
.
A variable :None:None:`x`
has a log-normal distribution if :None:None:`log(x)`
is normally distributed. The probability density function for the log-normal distribution is:
where $\mu$ is the mean and $\sigma$ is the standard deviation of the normally distributed logarithm of the variable. A log-normal distribution results if a random variable is the product of a large number of independent, identically-distributed variables in the same way that a normal distribution results if the variable is the sum of a large number of independent, identically-distributed variables.
Mean value of the underlying normal distribution. Default is 0.
Standard deviation of the underlying normal 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 mean
and sigma
are both scalars. Otherwise, np.broadcast(mean, sigma).size
samples are drawn.
Drawn samples from the parameterized log-normal distribution.
Draw samples from a log-normal distribution.
Generator.lognormal
which should be used for new code.
scipy.stats.lognorm
probability density function, distribution, cumulative density function, etc.
Draw samples from the distribution:
This example is valid syntax, but we were not able to check execution>>> mu, sigma = 3., 1. # mean and standard deviation # doctest: +SKIP
... s = np.random.lognormal(mu, sigma, 1000) # doctest: +SKIP
Display the histogram of the samples, along with the probability density function:
This example is valid syntax, but we were not able to check execution>>> import matplotlib.pyplot as plt # doctest: +SKIPThis example is valid syntax, but we were not able to check execution
... count, bins, ignored = plt.hist(s, 100, density=True, align='mid') # doctest: +SKIP
>>> x = np.linspace(min(bins), max(bins), 10000) # doctest: +SKIPThis example is valid syntax, but we were not able to check execution
... pdf = (np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2)) # doctest: +SKIP
... / (x * sigma * np.sqrt(2 * np.pi)))
>>> plt.plot(x, pdf, linewidth=2, color='r') # doctest: +SKIP
... plt.axis('tight') # doctest: +SKIP
... plt.show() # doctest: +SKIP
Demonstrate that taking the products of random samples from a uniform distribution can be fit well by a log-normal probability density function.
This example is valid syntax, but we were not able to check execution>>> # Generate a thousand samples: each is the product of 100 randomThis example is valid syntax, but we were not able to check execution
... # values, drawn from a normal distribution.
... b = [] # doctest: +SKIP
... for i in range(1000): # doctest: +SKIP
... a = 10. + np.random.standard_normal(100)
... b.append(np.product(a))
>>> b = np.array(b) / np.min(b) # scale values to be positive # doctest: +SKIPThis example is valid syntax, but we were not able to check execution
... count, bins, ignored = plt.hist(b, 100, density=True, align='mid') # doctest: +SKIP
... sigma = np.std(np.log(b)) # doctest: +SKIP
... mu = np.mean(np.log(b)) # doctest: +SKIP
>>> x = np.linspace(min(bins), max(bins), 10000) # doctest: +SKIPThis example is valid syntax, but we were not able to check execution
... pdf = (np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2)) # doctest: +SKIP
... / (x * sigma * np.sqrt(2 * np.pi)))
>>> plt.plot(x, pdf, color='r', linewidth=2) # doctest: +SKIPSee :
... plt.show() # doctest: +SKIP
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them