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

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
主站蜘蛛池模板: 杂多县| 和龙市| 沅江市| 玉山县| 望都县| 延安市| 泗水县| 容城县| 华蓥市| 宿州市| 呼伦贝尔市| 大化| 湘乡市| 乐东| 灯塔市| 安宁市| 德州市| 印江| 衡水市| 渭南市| 承德市| 武平县| 双桥区| 东乡| 乌兰浩特市| 汽车| 全南县| 射洪县| 长宁县| 津市市| 禄丰县| 吴旗县| 威信县| 临洮县| 修水县| 三明市| 乾安县| 临夏市| 岳阳县| 连城县| 怀柔区|