- Machine Learning for Developers
- Rodolfo Bonnin
- 180字
- 2021-07-02 15:46:47
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:

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:

- Flask Web全棧開發實戰
- Python數據分析入門與實戰
- Building a Game with Unity and Blender
- Python高級機器學習
- Eclipse Plug-in Development:Beginner's Guide(Second Edition)
- Java 9模塊化開發:核心原則與實踐
- bbPress Complete
- Python 3 數據分析與機器學習實戰
- Android智能手機APP界面設計實戰教程
- Python編程入門(第3版)
- SQL Server 2008實用教程(第3版)
- Puppet 5 Beginner's Guide(Third Edition)
- 從零開始學UI設計·基礎篇
- Mastering Unity Scripting
- Learning QGIS(Second Edition)