How to Verify the Distribution of Data using Q-Q Plots? | by Satyam Kumar | Towards Data Science

A Q-Q plot, or Quantile-Quantile plot, is a graphical method to verify the distribution of any random variable such as normal, exponential, lognormal, etc. It is a statistical approach to observe the nature of any distribution.
For example, if given a distribution need to be verified if it is a normal distribution or not, we run statistical analysis and compare the unknown distribution with a known normal distribution. Then by observing the results of the Q-Q plot, we can confirm if the given distribution is normally distributed or not.
Given an unknown random variable.Find each integral percentile value or 100 z-values.Generate a known random distribution and follow steps 1–2 for this distribution too.Plotting Q-Q plot
Given an unknown random variable.
Find each integral percentile value or 100 z-values.
Generate a known random distribution and follow steps 1–2 for this distribution too.
Plotting Q-Q plot
Given a random distribution, that needs to be verified if it is a normal/gaussian distribution or not. For understanding, we will name this unknown distribution X, and known normal distribution as Y.
X = np.random.normal(loc=50, scale=25, size=1000)
we are generating a normal distribution having 1000 values with mean=50 and standard deviation=25.
X_100 = []for i in range(1,101):    X_100.append(np.percentile(X, i))
Compute each integral percentile (1%, 2%, 3%, . . . , 99%, 100%) value of X random distribution and store it in X_100.
Y = np.random.normal(loc=0, scale=1, size=1000)
Generating a normal distribution having 1000 values with mean=0 and standard deviation=1 which need to be compared with the unknown distribution X to verify if X distribution is distributed normally or not.
Y_100 = []for i in range(101):    Y_100.append(np.percentile(Y, i))
Compute each integral percentile (1%, 2%, 3%, . . . , 99%, 100%) value of Y random distributions and store it in Y_100.
Plot a scatter plot for the above obtained 100 percentile values of unknown distribution to the normal distribution.
Here X — is the unknown distribution that is compared to Y — normal distribution.
For a Q-Q Plot, if the scatter points in the plot lie in a straight line, then both the random variable have same distribution, else they have different distribution.
From the above Q-Q plot, it is observed that X is normally distributed.
If X is not normally distributed and it has some other distribution, then if the Q-Q plot is plotted between X and a normal distribution the scatter points will not lie in a straight line.
Here, X distributed is a log-normal distribution, which is compared to a normal distribution, hence the scatter points in the Q-Q plot are not in a straight line.
Here are 4 Q-Q plots for 4 different conditions of X and Y distribution.
Q-Q plot can be used to compare any two distribution and can be used to verify an unknown distribution by comparing it with a known distribution. There is a major limitation for this method that is the requirement of a large set of data points, as concluding fewer data would not be a wise decision. By observing the Q-Q plot one can predict if the two distributions are the same or not.
Thank You for Reading