Show Power Normal Distribution in Statistics using Python


In this article we will get to know Power 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 Normal Distribution

Power Normal Distribution is same as normal distribution only difference is, this distribution includes the power parameter which is used to control the shape of the distribution. It provides us easy way for modeling the data which will show the characteristics of non-normal distribution.

Let’s see the power normal distribution using various methods −

Method 1: Random Number Generation

Here In this method, we will generate random numbers from the power normal distribution. For generating the random number we use scipy.stats module.

Example

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import powernorm

mean = 0  
sigma = 1
alpha = 2  

random_numbers = powernorm.rvs(alpha, loc=mean, scale=sigma, size=20)
print(random_numbers)

Output

[-1.13156225 -1.87837294  0.43238318 -2.01395963 -0.78067048 -0.09210662
 -0.90814025  0.64637169  0.3459799  -1.11370548 -0.40993553  0.933623
 -0.31985786 -0.35511113 -0.04098083 -0.44625217  0.44481325 -0.71633978
 -1.00779006  1.30530909]

Explanation

Here in the function we import the powernorm class from scipy.stats for working with power normal distribution. Here we have parameter as mean, sigma which is standard deviation and alpha for power parameter. Using powernorm.rvs() we generated 20 random values from power normal distribution.

Method 2: Probability Density Function (PDF)

The PDF of a Power Normal Distribution says that some outcome will happen. It is used to define the probability of any random variable. To analyze the PDF of any specific point we will use pdf() method.

Example

from scipy.stats import powernorm

mean = 0
sigma = 1
alpha = 2

x = 0.5
pdf_value = powernorm.pdf(x, alpha, loc=mean , scale=sigma)

print(pdf_value)

Output

0.21725073878123458

Explanation

Here also in the function we import the powernorm class from scipy.stats to work with power normal distribution. For calculating the PDF at any given point we use pdf() function.

Method 3:Cumulative Distribution Function (CDF)

We use the PDF of Cumulative Distribution Function for describing the value of random variable which is less than or equal to any value x. This comes under cumulative function as it evaluate the sum of total likelihood until that point.

Example

from scipy.stats import powernorm

sigma = 1
alpha = 2
mean = 0

x = 0.5
cdf_value = powernorm.cdf(x, alpha, loc=mean, scale=sigma)

print(cdf_value)

Output

0.9048045871969101

Explanation

Here in the function we import the powernorm class from scipy.stats to work with power normal distribution. For calculating the CDF at any given point x we use cdf() function.

Method 4:Fit Data to Power Normal Distribution

For fitting the values we can use fit() method. We can estimate the parameter of Power Normal Distribution after fitting the value to PDF.

Example

from scipy.stats import powernorm
import numpy as np

data = np.array([0.5, 0.6, 0.7, 0.8, 0.9])

alpha, loc, scale = powernorm.fit(data)

print("A:", alpha)
print("S:", scale)
print("L:", loc)

Output

A: 3.0842243722735286e-05 
S: 0.0011910055743893453 
L: 0.4320397942139688

Explanation

Here in the function we import the powernorm class from scipy.stats for working with the Power Normal Distribution. We used the fit() method for estimating the Power Normal Distribution parameters, here the parameters are A, S, L which are Alpha, Scale and Location respectively.

So, in this article we explored Power Normal Distribution. We see various method 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.

Updated on: 13-Oct-2023

60 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements