Multinomial Distribution in R, when each result has a given probability of occurring, the multinomial distribution describes the likelihood of obtaining a specific number of counts for k different outcomes.

A statistical experiment with n repeated trials is known as a multinomial experiment. There are a finite number of possible outcomes in each trial. The likelihood of a particular outcome occurring on any given trial remains constant.

If a random variable X has a multinomial distribution, the probability that outcome 1 will occur exactly x1 times, outcome 2 will occur exactly x2 times, and so on can be calculated using the formula:

Probability = n! * (p1x1 * p2x2 * … * pkxk) / (x1! * x2! … * xk!)

where:

n: total number of events

x1: the number of times the first outcome happens

p1: In a given trial, what are the probability that outcome 1 will occur?

In R, we may use the dmultinom() function to calculate a multinomial probability, which has the following syntax.

dmultinom(x=c(1, 6, 8), prob=c(0.4, 0.5, 0.1))

where:

x: The frequency of each outcome is represented by a vector.

prob: The probability of each outcome is represented by a vector (the sum must be 1)

The examples below demonstrate how to utilize this function in practice.

## Example 1:

Candidate A receives 20% of the vote, Candidate B receives 30% of the vote, and Candidate C earns 50% of the vote in a three-way election for mayor.

What is the probability that 5 voters voted for candidate A, 5 for candidate B, and 3 for candidate C in a random sample of ten voters?

To address this question, we can use the R code below:

make a multinomial probability calculation

dmultinom(x=c(5, 5, 3), prob=c(0.2, 0.3, 0.5))

[1] 0.007005398

The probability that exactly 5 people voted for A, 5 voted for B, and 3 voted for C is 0.007.

## Example 2

Assume there are six yellow balls, two red balls, and two pink balls in an urn.

What is the probability that all four balls in the urn are yellow if we pick four balls at random from the urn and replace them?

To address this question, we can use the R code below:

Multinomial Probability Calculator

dmultinom(x=c(4, 0, 0), prob=c(0.6, 0.2, 0.2))

[1] 0.1296

The chance of all four balls being yellow is 0.1296.

## Example 3

Assume two boys are playing cards against one another. Student A has a 0.6 chance of winning a game, Student B has a 0.3 chance of winning a game, and they have a 0.1 chance of tying in a game.

What is the probability that player A will win 5 times, player B will win 4 times, and they will tie one time if they play ten games?

To address this question, we can use the R code below:

make a multinomial probability calculation

dmultinom(x=c(5, 4, 1), prob=c(0.6, 0.3, 0.1))

[1] 0.07936186

About 0.08 percent of the time, player A wins 5 times, player B wins 4 times, and they tie 1 time.

Can’t rename columns that don’t exist – Data Science Tutorial

## Example 4

A series of matches are played by three card players. Player A has a 20% chance of winning any game, player B has a 30% chance of winning, and player C has a 50% chance of winning.

What is the probability that player A will win one game, player B will win two games, and player C will win three games if they play six games?

Given:

n = 12 people (6 games total)

n1=1 (Player A wins)

n2 =2 (Player B wins)

n3 = 3 (Player C wins)

P1 = 0.20 (probability that Player A wins)

P2 = 0.30 (probability that Player B wins)

P3 = 0.50 (probability that Player C wins)

dmultinom(x=c(1, 2, 3), prob=c(0.20, 0.30, 0.50)) 0.135

Ndewo, achọrọ m ịmara ọnụahịa gị.