 Search Introduction to Numpy Multinomial Distribution

Numpy Multinomial Distribution – Before moving ahead, let’s know a bit of Python Logistic Distribution

It shows the random result (mostly numbers) of possible outcomes of one or more events.

E.g., Dice roll, Survey of population of people below age of 48, Coin toss etc.

It includes three parameters –

```n - number of possible outcomes (e.g. 2 for coin toss).

pvals - list of probabilities of outcomes (e.g. In every single possible outcomes there’s a probability of coming a random result [H/T, T/H] for coin toss).

size - Returned array of the shape.```

### Example – Checking the probability of random outcomes at every roll of dice.

`from numpy import randomrandom_outcomes = random.multinomial(n=6, pvals=[1/6, 1/6, 1/6, 1/6, 1/6, 1/6])print(random_outcomes)`
```Output -

[2 0 0 2 1 1]```

As shown above, it returned an array containing random outcomes of rolling a dice 6 times.

Note: Later you will learn more in our Python Multinomial Distribution Tutorial.

### Example – Checking the probability of random outcomes at every flip of coin.

`from numpy import randomx = random.multinomial(n=2, pvals=[1/2, 1/2])print(x)`

As a result, it returned an array containing random outcomes of flipping a coin 2 times.

Note: Number 1 denotes both Head and Tail in coin toss.

Notice: Multinomial samples won’t produce one value! Each will get one value pval.

If you find anything incorrect in the above-discussed topic and have any further questions, please comment below.

Like us on

Share on