I.何をする?

次を参考にして確率分布にして学びます。

6 Useful Probability Distributions with Applications to Data Science Problems

Fun with the Binomial Distribution

II.Binomial distribution

You can answer the following question with binomial distribution.

Given 10 flips of a fair coin, what is the probability of getteing 6 head?

Let’s go through some python code that runs a simulation. The code below does the following:

  1. Gnerate a random number between 0 and 1. If that number is 0.5 or more, then count it as heads, otherwise tails.

  2. Repeat this a specified number of times (the amount of trials is specified by the input variable trials).

from scipy.stats import binom
import matplotlib.pyplot as plt
num_trials = 10
heads_probability = .5

probs = [binom.pmf(i, num_trials, heads_probability) for i in range(11)]
plt.stem(list(range(11)), probs)
## <StemContainer object of 3 artists>
plt.show()