官术网_书友最值得收藏!

Bernoulli distributions

Let's begin with a simple distribution: one that has a binary outcome, and is very much like tossing a (fair) coin.

This distribution represents a single event that takes the value 1 (let's call this heads) with a probability of p, and 0 (lets call this tails), with probability 1-p.

In order to visualize this, let's generate a large number of events of a Bernoulli distribution using np and graph the tendency of this distribution, with the following only two possible outcomes:

    plt.figure() 
distro = np.random.binomial(1, .6, 10000)/0.5
plt.hist(distro, 2 , normed=1)

The following graph shows the binomial distribution, through an histogram, showing the complementary nature of the outcomes' probabilities:

Binomial distribution

So, here we see the very clear tendency of the complementing probabilities of the possible outcomes. Now let's complement the model with a larger number of possible outcomes. When their number is greater than 2, we are talking about a multinomial distribution:

    plt.figure()
distro = np.random.binomial(100, .6, 10000)/0.01
plt.hist(distro, 100 , normed=1)
plt.show()

Take a look at the following graph:

Multinomial distribution with 100 possible outcomes
主站蜘蛛池模板: 新干县| 衡水市| 那坡县| 咸宁市| 府谷县| 焉耆| 浠水县| 普安县| 蒙城县| 邹城市| 丰顺县| 昂仁县| 漯河市| 阳山县| 兴安盟| 兰州市| 岳阳市| 浮梁县| 永宁县| 和平县| 永顺县| 屏东市| 寿光市| 项城市| 固始县| 花莲县| 宁河县| 大宁县| 江阴市| 洛宁县| 涞源县| 英吉沙县| 呼和浩特市| 获嘉县| 广宁县| 舟山市| 兖州市| 通化县| 金沙县| 乌拉特后旗| 休宁县|