第22章付録:深層学習のための数学
22.8.5. Poisson22.8.5 ポアソン分布
Let’s now perform a thought experiment. We are standing at a bus stop and we want to know how many buses will arrive in the next minute. Let’s start by considering which is simply the probability that a bus arrives in the one minute window. For bus stops far from an urban center, this might be a pretty good approximation. We may never see more than one bus in a minute.
英語のヒント
では、思考実験をしよう。バス停に立っていて、次の1分間に何台のバスが来るかを知りたいとする。まず、1分間の窓の中にバスが来る確率にすぎないを考えることから始めよう。都市の中心から遠いバス停では、これはかなりよい近似かもしれない。1分間に2台以上のバスを見ることは決してないかもしれない。
However, if we are in a busy area, it is possible or even likely that two buses will arrive. We can model this by splitting our random variable into two parts for the first 30 seconds, or the second 30 seconds. In this case we can write
英語のヒント
しかし、にぎやかな地域にいるなら、2台のバスが来ることもありうるし、むしろありそうですらある。確率変数を最初の30秒と次の30秒の二つの部分に分けることで、これをモデル化できる。この場合、次のように書ける。
(22.8.11)
where is the total sum, and . The total distribution is then .
英語のヒント
ここでは全体の和であり、である。すると、全体の分布はである。
Why stop here? Let’s continue to split that minute into parts. By the same reasoning as above, we see that
英語のヒント
なぜここで止めるのか。その1分間を個の部分に分割し続けよう。上と同じ推論により、次がわかる。
(22.8.12)
Consider these random variables. By the previous section, we know that (22.8.12) has mean , and variance . If we take , we can see that these numbers stabilize to , and variance . This indicates that there could be some random variable we can define in this infinite subdivision limit.
英語のヒント
これらの確率変数を考えよう。前の節から、式(22.8.12)は平均と分散をもつことがわかっている。とすると、これらの数はと分散に落ち着くことがわかる。これは、この無限に細かく分割した極限で定義できる何らかの確率変数がありうることを示している。
This should not come as too much of a surprise, since in the real world we can just count the number of bus arrivals, however it is nice to see that our mathematical model is well defined. This discussion can be made formal as the law of rare events.
英語のヒント
現実世界ではバスの到着の数をただ数えられるので、これはそれほど驚くことではないはずだが、数学的なモデルがきちんと定義されているのを見るのはよいことである。この議論は、稀な事象の法則として形式化できる。
Following through this reasoning carefully, we can arrive at the following model. We will say that if it is a random variable which takes the values with probability
英語のヒント
この推論を注意深くたどると、次のモデルにたどり着ける。とは、値を次の確率でとる確率変数のことだとする。
(22.8.13)
The value is known as the rate (or the shape parameter), and denotes the average number of arrivals we expect in one unit of time.
英語のヒント
値は率(あるいは形状パラメータ)として知られ、単位時間あたりに期待される到着の平均の数を表す。
We may sum this probability mass function to get the cumulative distribution function.
英語のヒント
この確率質量関数の和をとると、累積分布関数が得られる。
(22.8.14)
lam = 5.0
xs = [i for i in range(20)]
pmf = torch.tensor([torch.exp(torch.tensor(-lam)) * lam**k
/ factorial(k) for k in xs])
d2l.plt.stem(xs, pmf, use_line_collection=True)
d2l.plt.xlabel('x')
d2l.plt.ylabel('p.m.f.')
d2l.plt.show()x = torch.arange(-1, 21, 0.01)
cmf = torch.cumsum(pmf, dim=0)
def F(x):
return 0 if x < 0 else 1 if x > n else cmf[int(x)]
d2l.plot(x, torch.tensor([F(y) for y in x.tolist()]), 'x', 'c.d.f.')As we saw above, the means and variances are particularly concise. If , then:
英語のヒント
上で見たように、平均と分散はとくに簡潔である。なら、次が成り立つ。
This can be sampled as follows.
英語のヒント
これは次のように抽出できる。
m = torch.distributions.poisson.Poisson(lam)
m.sample((10, 10))tensor([[ 1., 4., 6., 8., 4., 4., 4., 7., 6., 4.],
[ 3., 6., 7., 7., 5., 7., 7., 3., 5., 4.],
[ 4., 1., 3., 3., 10., 5., 5., 3., 7., 5.],
[ 4., 3., 4., 10., 8., 6., 4., 6., 5., 5.],
[ 5., 11., 1., 5., 7., 5., 2., 4., 3., 5.],
[ 6., 6., 4., 4., 3., 1., 5., 8., 4., 5.],
[ 2., 9., 7., 2., 6., 5., 2., 8., 6., 10.],
[ 1., 4., 3., 7., 3., 1., 7., 5., 3., 6.],
[ 5., 4., 6., 4., 9., 8., 3., 3., 1., 8.],
[ 3., 12., 9., 13., 2., 14., 3., 2., 0., 3.]])