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

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
主站蜘蛛池模板: 泰兴市| 孟津县| 象州县| 平湖市| 临海市| 清苑县| 平安县| 湾仔区| 永川市| 柳江县| 洪洞县| 色达县| 芦溪县| 平阳县| 丰顺县| 东丽区| 南皮县| 潢川县| 夏河县| 邵武市| 绥宁县| 乌苏市| 阜南县| 华宁县| 沈阳市| 桃江县| 江川县| 大方县| 平陆县| 平阴县| 射阳县| 西安市| 肥乡县| 志丹县| 遵化市| 紫阳县| 肇庆市| 丹棱县| 习水县| 长泰县| 台湾省|