Javatpoint Logo
Javatpoint Logo

Uniform Discrete Distribution in Statistics using Python

Introduction:

In this tutorial, we are learning Uniform Discrete Distribution in Statistics using Python. Here we use a uniform discrete random variable: scipy.stats.randint(). This variable is inherited from the generic method. It is an example of the rv_discrete class. This method contains specific details for any distribution.

The discrete uniform distribution is an equal probability of a finite number of events. A simple example of a random distribution is rolling a dice. The possible events are 1 to 6, and the probability of getting the given number each time the dice is rolled is 1/6.

Parameters of Uniform Discrete Distribution in Statistics:

Here we discuss the parameters of the uniform discrete distribution in Python. There are mainly four parameters which are discussed below -

Returns value of Uniform Discrete Distribution in Statistics:

Here we discuss the returns value of the uniform discrete distribution in Python. It mainly returns the result as a uniform discrete random variable.

Give some examples of Uniform Discrete Distribution in Python:

Now we give some examples of uniform discrete distribution in Python. The examples are given in below -

Examples 1:

Here we give an example of creating a uniform discrete random variable in Python. Basically, here we find the rv value by using randint library. The code is written below -

Output:

Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below -

The value of RV is: 
 

Examples 2:

Now we give an example of uniform discrete variable and probability distribution in Python. Here we need to import numpy and randint library. The code is written below -

Output:

Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below -

The Random Variates are: 
 [ 2  1  0 6  0  1  3  2  0  1]

The Probability Distribution is: 
 [1. 1. 1. 1. 1.]

Examples 3:

Now we give an example of a graphical representation of uniform discrete distribution in Python. Here we mainly represent the distribution in a plot. Here need to import matplotlob.pyplot for plotting the distribution. The code is given below -

Output:

Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below -

The graphical distribution is: 
The graphical distribution is: [0. 0.02040816 0.04081633 0.06122449 0.08163265 0.10204082 0.12244898 0.14285714 0.16326531 0.18367347 0.20408163 0.2244898 0.24489796 0.26530612 0.28571429 0.30612245 0.32653061 0.34693878 0.36734694 0.3877551 0.40816327 0.42857143 0.44897959 0.46938776 0.48979592 0.51020408 0.53061224 0.55102041 0.57142857 0.59183673 0.6122449 0.63265306 0.65306122 0.67346939 0.69387755 0.71428571 0.73469388 0.75510204 0.7755102 0.79591837 0.81632653 0.83673469 0.85714286 0.87755102 0.89795918 0.91836735 0.93877551 0.95918367 0.97959184 1. ]

Uniform Discrete Distribution in Statistics using Python

Example 4:

Now we give an example of creating an array between 1 to 10 using uniform discrete distribution in Python. Mainly here we take two values x and y. Then we used np.arange() function for find the value of array. The code is given below -

Output:

Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below -

The value of array is: [1 2 3 4 5 6 7 8 9 10]

Conclusion:

So, in this tutorial, we learn Python - Uniform Discrete Distribution in Statistics. Here we talk about the parameters and returns value of the uniform discrete distribution in Python. We also share some examples of it.







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