- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Show Power Log-Normal Distribution in Statistics using Python
In this article we will learn about Power Log-Normal Distribution, its application and uses. We will learn to analyze the distribution by the help of different methods including PDF and CDF. Before that let's see what Power Normal Distribution is.
Power Log-Normal Distribution
Power Log-Normal Distribution is variation of log-normal distribution. The only difference is, we obtain power log-normal distribution by applying power transformation into the log-normal distribution. Difference between the power normal distribution and the power log-normal distribution is the power normal distribution is the variation of normal distribution whereas power log-normal distribution is a variation of log-normal distribution. Both of them have power parameters which can define the shape of distribution.
Let’s see the power Log-normal distribution using various methods −
Method 1: Random Number Generation
Here In this method, we will generate random numbers from the power Log-normal distribution. For generating the random number we use scipy.stats module.
Example
from scipy.stats import powerlognorm import numpy as np import matplotlib.pyplot as plt c, s = 2.14, 0.446 x = 0.5 random_numbers = powerlognorm.rvs(c, s, size=1000) plt.hist(random_numbers, bins=30, density=True, alpha=0.5) plt.xlabel('Values') plt.ylabel('Probability') plt.title('Power Log-Normal Distribution') plt.show()
Output
Explanation
Here in this method, we imported the powerlognorm class from scipy.stats. Here we have parameters as c, s which is location parameter and shape parameter. Using powerlognorm.rvs() we generated 1000 random values from power log-normal distribution and plotted the histogram for those random values.
In the function we imported the powerlognorm class from scipy.stats module for working with power log-normal distribution. here c is location and s is a shape parameter. For calculating the PDF at any given point we use pdf() function.
Method 2: Probability Density Function (PDF)
Power Log-Normal Distribution PDF observes probability of a particular value. It is used to define the probability of any random variable. To analyze the PDF of any specific point we will use the pdf() method.
Example
from scipy.stats import powerlognorm import numpy as np import matplotlib.pyplot as plt c, s = 2.14, 0.446 x = 1.5 pdf_ = powerlognorm.pdf(x, c, s) print(pdf_)
Output
0.12076527710927452
Explanation
Here in the function we import the powerlognorm class form the scipy.stats module. We calculate the PDF using the pdf() function and we passed parameter as location and shape into pdf function.
Method 3: Cumulative Distribution Function (CDF)
In this method we will use PDF of Cumulative Distribution Function to describe value of random variable which is less than or equal to value x. We can calculate CDF using cdf() function.
Example
from scipy.stats import powerlognorm import numpy as np import matplotlib.pyplot as plt c, s = 2.14, 0.446 x = 1.5 cdf_ = powerlognorm.cdf(x, c, s) print(cdf_)
Output
0.9740141301157031
Explanation
In this function we imported the powernorm class from scipy.stats module for working with the power log-normal distribution.
Method 3:Visualize Power Log-Normal Distribution
Let’s visualize the power Log-normal distribution.
Example
from scipy.stats import powerlognorm import numpy as np import matplotlib.pyplot as plt c, s = 2.14, 0.446 r = powerlognorm.rvs(c,s, size=1000) plt.hist(r, bins=30, density=True, alpha=0.5) plt.title('Power Log-Normal Distribution') plt.xlabel('Values') plt.ylabel('Probab') plt.show()
Output
Explanation
We imported the libraries for working with power log-normal distribution and for plotting graphs. As always we use powerlognorm.rvs() method to generate 1000 random values from power log-normal distribution. Using hist() function from histogram we plotted the graph.
So, in this article we get to know Power Log-Normal Distribution. We saw various methods to work with the PDF which includes generating random variables, calculating the PDF, CDF, and visualizing the distribution using histogram. Moreover, we also saw how we can fit our data in the (Probability Density Function) PDF.