第22章付録:深層学習のための数学
22.8.3. Continuous Uniform22.8.3 連続一様分布
Next, let’s discuss the continuous uniform distribution. The idea behind this random variable is that if we increase the in the discrete uniform distribution, and then scale it to fit within the interval , we will approach a continuous random variable that just picks an arbitrary value in all with equal probability. We will denote this distribution as
英語のヒント
次に、連続一様分布を論じよう。この確率変数の背後にある考えは、離散一様分布のを増やし、それを区間に収まるように尺度を変えると、の中の任意の値をすべて等しい確率で選ぶだけの連続確率変数に近づくというものである。この分布を次のように表す。
(22.8.5)
The probability density function is
英語のヒント
確率密度関数は次のとおりである。
(22.8.6)
The cumulative distribution function is
英語のヒント
累積分布関数は次のとおりである。
(22.8.7)
a, b = 1, 3
x = torch.arange(0, 4, 0.01)
p = (x > a).type(torch.float32)*(x < b).type(torch.float32)/(b-a)
d2l.plot(x, p, 'x', 'p.d.f.')def F(x):
return 0 if x < a else 1 if x > b else (x - a) / (b - a)
d2l.plot(x, torch.tensor([F(y) for y in x]), 'x', 'c.d.f.')If , then:
英語のヒント
なら、次が成り立つ。
We can sample an array of arbitrary shape from a uniform random variable as follows. Note that it by default samples from a , so if we want a different range we need to scale it.
英語のヒント
一様分布の確率変数から、任意の形の配列を次のように抽出できる。既定ではから抽出するので、別の範囲が欲しいなら尺度を変える必要があることに注意しよう。
(b - a) * torch.rand(10, 10) + atensor([[2.4857, 2.2461, 1.6809, 2.7434, 2.7072, 2.6190, 1.4883, 1.2517, 1.3454,
2.4754],
[1.0974, 1.5680, 1.8788, 2.8231, 2.1695, 2.6461, 1.4914, 1.4887, 1.3860,
1.9090],
[1.3746, 1.7773, 1.2412, 1.1950, 2.7281, 2.8356, 1.2266, 2.4724, 2.4641,
2.8991],
[2.4018, 2.6727, 1.0308, 1.1951, 1.9390, 1.6486, 2.8314, 1.1025, 1.3354,
1.0130],
[1.1281, 1.8000, 2.3788, 2.6580, 1.6750, 2.2081, 1.2705, 1.0757, 2.3311,
2.6557],
[2.9912, 1.2263, 1.8115, 1.5940, 1.9321, 1.6469, 2.2990, 2.1473, 1.8165,
1.2806],
[1.1672, 1.1536, 1.9649, 2.1655, 1.7170, 1.0284, 1.3305, 2.1904, 1.4036,
2.1958],
[2.5891, 2.5840, 2.2679, 2.0687, 2.9249, 1.6741, 1.2238, 2.4463, 2.2235,
2.7038],
[1.8697, 2.4965, 1.5785, 2.7890, 2.3319, 2.1434, 2.3333, 1.0286, 1.9245,
1.7640],
[1.2504, 1.7558, 1.4322, 1.5226, 1.3380, 1.1388, 1.8707, 2.2330, 2.3818,
2.2087]])