確率分布:直感的なガイド
この記事では、データサイエンスでよく用いられる確率分布の直感的な理解を解説します。
これらの分布はパラメータによって形状が定義され、Bernoulli試行を基盤としています。
Bernoulli試行は成功または失敗の2つの結果のみを持つ試行であり、独立したBernoulli試行を繰り返すことで、二項分布(成功回数の確率)や幾何分布(初回の成功までの試行回数)といった分布が導き出されます。
二項分布はn choose kという組み合わせの演算子を用いて計算され、大量の試行では正規分布による近似が用いられます。
データサイエンスにおいて頻繁に登場する「確率分布」は、現象の不確実性を数学的にモデル化するための重要なツールです。本記事では、これらの確率分布の基礎となる考え方や、具体的な利用シーンを解説します。特に、コイン投げのような単純な試行から派生する二項分布や幾何分布といった概念を掘り下げます。
確率分布の基礎となるベルヌーイ試行
確率分布を理解する上でまず重要なのが「ベルヌーイ試行」という概念です。これは、結果が「成功」か「失敗」のどちらか二択で決まる試行を指します。例えば、コイン投げで表が出るか裏が出るか、ユーザーがサービスに登録するかどうかなどが該当します。この試行は、成功確率pを持つと定義されます。ベルヌーイ試行自体は単純ですが、これを独立した試行を連続して行うことで、より複雑な現象をモデル化できるようになります。
試行回数に基づく二項分布と幾何分布
独立したベルヌーイ試行をn回行ったとき、「k回成功する確率」を求めるのが二項分布です。例えば、5回試行して2回成功する確率を計算する際、成功の組み合わせの総数を考慮する必要があります。一方、「初めて成功するまでに必要な試行回数」を問うのが幾何分布です。これは、成功確率pを持つ試行を繰り返した際に、何回目で初めて成功するかをモデル化する際に利用されます。
正規分布への近似と応用分野
二項分布は試行回数nが大きくなると、組み合わせの計算が非常に煩雑になります。このような場合、統計学では「正規分布」を用いて近似的に処理することが一般的です。この正規分布への近似は、仮説検定などの統計的テストを行う際に、二項分布の指標を扱う上で非常に重要な手法となっています。これらの分布は、データサイエンスにおける統計的推論の基盤を形成しています。
まとめ
本記事で解説した二項分布や幾何分布は、より複雑な連続的な時間モデル(ポアソン過程や指数分布など)へと発展していきます。これらの確率分布を深く理解することは、データから意味のある洞察を引き出すための必須スキルとなります。
原文の冒頭を表示(英語・3段落のみ)
In this series, I’ll break down the intuition behind the most common probability distributions in Data Science - their structural similarities, use cases and examples.All the distributions we’ll cover are parametric. This just means the entire “shape” of the distribution can be described by a few specific numbers: the parameters. For example, a Normal distribution is defined entirely by just two: its mean and its variance.The underlying event for both of these distributions is a Bernoulli trial. A Bernoulli trial is an event which has one of two outcomes - one is usually labelled success which has the probability, p, and is the event we are interested in, while the other is a failure. Note that the outcome space here is discrete. For example, head in a coin toss, user signing up and etc. A Bernoulli trial on its own isn’t that interesting. It becomes interesting when we do a series of independent Bernoulli trials each with probability of success p. Because then we can ask two questions:What is the probability of getting k successes in n trials? This is modeled by Binomial distribution.What is the probability of getting the first success in k trials? This is modeled by Geometric distribution.Let’s say n = 5 and k = 2. And the probability of success in each independent Bernoulli trial is p.For us to get k = 2 successes, we precisely need 2 successes and 3 failures in 5 trials,\(p ^ 2 (1-p) ^ 3.\)However, note that the 2 successes can come from any 2 of the 5 trials. So for example, in the case of Success, Failure, Failure, Failure, Success, we have, \(P(1-P)(1-P)(1-P)P = p ^ 2 (1-p) ^ 3.\)All of these combinations are captured by the n choose k operator which returns the number of ways we can pick n (=2) successes out of n (=5). So the final probability is, \(\binom{5}{2} p ^ 2 (1-p) ^ 3\)And the generalized form is,\(\binom{n}{k} p ^ k (1-p) ^ {(n-k)}\)We will come back to the binomial distribution later in the series. But as a spoiler, for large values of n the (n choose k) is tedious to calculate, and we will get around that by using the Normal distribution. This approximation is used for running statistical tests on binomial metrics in hypothesis testing.Again, assume that the probability of success in each independent Bernoulli trial is p.So if k = 1, then P is the probability of success in the first trial. Then it is just,\(P(k=1) = p\)For k = 2, the first trial must be a failure and the second one must be a success. And we have,\(P(k=2) = (1-p)p\)For k = 3, \(P(k=3) = (1-p)(1-p)p\)And so on.So this can be generalized for any k, \(P(k) = (1-p)^{(k-1)} p\)Therefore, to compute the probability P of k successes in n independent Bernoulli trials, we use,\(P(k) = \binom{n}{k} p ^ k (1-p) ^ {(n-k)}.\)And to get the probability P of getting the first success in k independent Bernoulli trials, we use,\(P(k) = (1 - p)^{(k-1)}p\)In the next series, we’ll move from discrete counts to time-based continuous models, introducing Poisson processes and the Exponential distribution.
※ 著作権に配慮し、引用は冒頭3段落までです。続きは元記事をご覧ください。