Javatpoint Logo
Javatpoint Logo

Moyal Distribution in Statistics using Python

The scipy.stats.moyal describes the Moyal continuous random variable. It is an instance of the rv_continuous class inherited from the generic methods. It completes the techniques by adding details specific to this distribution.

The Probability Density Function, which gives the Moyal Distribution, is given by:

Moyal Distribution in Statistics using Python

for any real number x.

The probability density function for moyal distribution defined is the standardized form. We use the loc and scale parameters to shift and scale the distribution. The shifting of the location does not make it a noncentral distribution. moyal.pdf(x, loc, scale) is exactly equal to moyal.pdf(y) / scale with y = (x - loc) / scale.

Parameters including in the Moyal Distribution

  • q: it is referred to as the probability of the lower and upper tail.
  • x: it refers to the quantiles.
  • loc: it is used to refer to the location parameter. This parameter is optional.
  • scale: it refers to the scale parameter. This parameter is optional.
  • moments: It is composed of different letters ['msvk']:
    • 'm': mean
    • 'v': variance
    • 's': Fisher's skew
    • 'k': Fisher's kurtosis

By default, it is 'mv' (mean and variance)

  • Size: It defines the shape or random variates. It is a tuple of integer data type. It is an optional parameter.
  • Results: It returns the Moyal continuous random variable.

Python provides the moyal module under the scipy.stats library, which is used to find the moyal Distribution.

Importing the moyal() library in Python

Let's understand the concept of Moyal Distribution in Statistics with the help of different programs with different cases.

Program 1: A program to create Moyal Distribution Random Variable

Code:

Output:

Random Variable : 
 

Explanation:

We have made a random variable for the Moyal Distribution using the moyal() function. We first imported the module, assigned two variables, and printed the random variable using the moyal() function.

Program 2: A program to create Moyal continuous variates and the Probability distribution.

Code:

Output:

Random Variates : 
 5.433057489802547
The Probability Distribution : 
 [0.00000000e+000 0.00000000e+000 0.00000000e+000 0.00000000e+000
 0.00000000e+000 0.00000000e+000 0.00000000e+000 0.00000000e+000
 0.00000000e+000 1.71574983e-257 6.45284818e-149 4.82438362e-093
 7.66841150e-062 3.16667935e-043 1.69312620e-031 9.11678236e-024
 1.79604652e-018 9.98985023e-015 5.29128092e-012 5.66170389e-010
 1.98046197e-008 3.11086502e-007 2.72050184e-006 1.53744531e-005
 6.23980859e-005 1.96266675e-004 5.05959515e-004 1.11453385e-003
 2.16511397e-003 3.79994588e-003 6.13937970e-003 9.26625611e-003
 1.32181547e-002 1.79872053e-002 2.35255454e-002 2.97540234e-002
 3.65720193e-002 4.38668423e-002 5.15217984e-002 5.94225337e-002
 6.74616140e-002 7.55415155e-002 8.35762953e-002 9.14922397e-002
 9.92277665e-002 1.06732820e-001 1.13967946e-001 1.20903201e-001
 1.27516990e-001 1.33794916e-001 1.39728688e-001 1.45315106e-001
 1.50555158e-001 1.55453209e-001 1.60016308e-001 1.64253578e-001
 1.68175711e-001 1.71794536e-001 1.75122659e-001 1.78173171e-001
 1.80959406e-001 1.83494751e-001 1.85792486e-001 1.87865668e-001
 1.89727039e-001 1.91388951e-001 1.92863320e-001 1.94161592e-001
 1.95294716e-001 1.96273137e-001 1.97106788e-001 1.97805096e-001
 1.98376988e-001 1.98830903e-001 1.99174806e-001 1.99416207e-001
 1.99562173e-001 1.99619354e-001 1.99593998e-001 1.99491972e-001
 1.99318779e-001 1.99079582e-001 1.98779220e-001 1.98422224e-001
 1.98012838e-001 1.97555036e-001 1.97052534e-001 1.96508810e-001
 1.95927118e-001 1.95310497e-001 1.94661790e-001 1.93983655e-001
 1.93278575e-001 1.92548869e-001 1.91796703e-001 1.91024102e-001
 1.90232956e-001]

Explanation:

We have printed the random continuous variates and the probability distribution using the .pdf method using the numpy array assigned.

Program 3: A program to graphically represent the Moyal Probability distribution.

Code:

Output:

Distribution : 
 [0.         0.04081633 0.08163265 0.12244898 0.16326531 0.20408163
 0.24489796 0.28571429 0.32653061 0.36734694 0.40816327 0.44897959
 0.48979592 0.53061224 0.57142857 0.6122449  0.65306122 0.69387755
 0.73469388 0.7755102  0.81632653 0.85714286 0.89795918 0.93877551
 0.97959184 1.02040816 1.06122449 1.10204082 1.14285714 1.18367347
 1.2244898  1.26530612 1.30612245 1.34693878 1.3877551  1.42857143
 1.46938776 1.51020408 1.55102041 1.59183673 1.63265306 1.67346939
 1.71428571 1.75510204 1.79591837 1.83673469 1.87755102 1.91836735
 1.95918367 2.        ]

Moyal Distribution in Statistics using Python

Explanation:

We have printed the distribution using the numpy array, and then using matplotlib, we have printed a graph of the Moyal Distribution using the Probability Density function.

Program 4: A program to graphically represent varying positional arguments in the Moyal Probability Distribution Function.

Code:

Output:

[,
 ]

Moyal Distribution in Statistics using Python

Explanation:

We made a numpy array with linear, equal spaces, then plotted a graph with two different Moyal distributions using the Probability Density Functions.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA