A continuous probability distribution of a random variable whose logarithm is usually distributed is known as a log-normal (or lognormal) distribution in probability theory.
A variable x is said to follow a log-normal distribution if and only if the log(x) follows a normal distribution. The PDF is defined as follows.
Where mu is the population mean & sigma is the standard deviation of the log-normal distribution of a variable. Just like normal distribution which is a manifestation of summation of a large number of Independent and identically distributed random variables, lognormal is the result of multiplying a large number of Independent and identically distributed random variables. Generating a random number from a log-normal distribution is very easy with help of the NumPy library.
numpy.random.lognormal(mean=0.0, sigma=1.0, size=None)
- mean: It takes the mean value for the underlying normal distribution.
- sigma: It takes only non-negative values for the standard deviation for the underlying normal distribution
- size : It takes either a int or a tuple of given shape. If a single value is passed it returns a single integer as result. If a tuple then it returns a 2D matrix of values from log-normal distribution.
Returns: Drawn samples from the parameterized log-normal distribution(nd Array or a scalar).
The below example depicts how to generate random numbers from a log-normal distribution:
Let’s prove that log-Normal is a product of independent and identical distributions of a random variable using python. In the program below we are generating 1000 points randomly from a normal distribution and then taking the product of them and finally plotting it to get a log-normal distribution.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course