What Is a Uniform Distribution?

Uniform distribution is a uniform base distribution where all the outcomes have the same probability, which means that each result has the same opportunity to occur.

Tossed coin uniform distribution graph

Explanation

The above illustration gives a graphical representation of a coin toss. In a coin toss, we have an equal probability of getting a tail or a head.

As we can see in the graph, both sides of the coin have a 50% chance. As both sides of the coin have the same probability, it is an excellent example of uniform distribution.

Example

Other than the graphical representation, we have a code implementation below in javascript which shows the number of tails and heads we get from randomly generating 0s and 1s.

let headCount = 0;
let tailCount = 0;
let tex = "";
for (var i = 0; i < 100; i++) {
let occ = Math.floor(Math.random() * 2);
if (occ == 0)
{
tex = tex + "head ";
headCount++;
}
else
{
tex = tex + "tail ";
tailCount++;
}
}
console.log(tex);
console.log("Total number of Tails = " + tailCount);
console.log("Total number of Heads = " + headCount);

Note: Every time we run the code, it will provide a different result, but both heads and tails have the same probability of occurring

  • Lines 5 - 15: We used a for loop to emulate tossing a coin one hundred times. For the result of the toss, we used Math.random to find a random number between 0,1. We treat 0 as the head and 1 as the tail.

Test your probability skills

Roll a die

Q

When you roll a die, what is the probability of getting 3?

A)

20%

B)

16.67%

C)

25%

D)

15%

Copyright ©2024 Educative, Inc. All rights reserved