ビュフォンの針 (ビュフォンのはり、英 : Buffon's needle problem )は18世紀 の博物学者 ジョルジュ=ルイ・ルクレール、コント・ド・ビュフォン が提起した数学 上の問題 である。
もし床に多数の平行線を引き、そこに針を落すならば、どれかの線と針が交差する確率はどのようになるかという問題である。
積分と幾何学 を使ってこの問題は解け、またこの方法を使って、モンテカルロ法 で円周率 の近似値を求められる。
解法 a は線と交差する場合、 b は交差しない場合 この問題を数学的に表現すると以下のようになる: 長さ l {\displaystyle l} の針を、間隔 t {\displaystyle t} で平行線が描かれた床に落としたときに、線と針が交差する確率はどれくらいか?
針の中心から近いほうの線までの距離を x {\displaystyle x} とし、針と線がなす角の小さい方を θ {\displaystyle \theta } とする。
0 {\displaystyle 0} から t / 2 {\displaystyle t/2} における x {\displaystyle x} の確率密度関数 は
{ 2 t : 0 ≤ x ≤ t 2 0 : elsewhere. {\displaystyle {\begin{cases}{\frac {2}{t}}&:\ 0\leq x\leq {\frac {t}{2}}\\0&:{\text{elsewhere.}}\end{cases}}} である。
また、 0 {\displaystyle 0} から π / 2 {\displaystyle \pi /2} における θ {\displaystyle \theta } の確率密度関数は
{ 2 π : 0 ≤ θ ≤ π 2 0 : elsewhere. {\displaystyle {\begin{cases}{\frac {2}{\pi }}&:\ 0\leq \theta \leq {\frac {\pi }{2}}\\0&:{\text{elsewhere.}}\end{cases}}} である。
2つの確率変数 x {\displaystyle x} と θ {\displaystyle \theta } は独立なので、同時確率密度関数は積をとって
{ 4 t π : 0 ≤ x ≤ t 2 , 0 ≤ θ ≤ π 2 0 : elsewhere. {\displaystyle {\begin{cases}{\frac {4}{t\pi }}&:\ 0\leq x\leq {\frac {t}{2}},\ 0\leq \theta \leq {\frac {\pi }{2}}\\0&:{\text{elsewhere.}}\end{cases}}} となる。
針と線が交差するのは
x ≤ l 2 sin θ . {\displaystyle x\leq {\frac {l}{2}}\sin \theta .} のときである。
針の長さに応じて2つの場合に分けて考える。
場合分け1: 針が短い場合 t ≥ l {\displaystyle t\geq l} の場合、針と線が交差する確率は
P = ∫ θ = 0 π 2 ∫ x = 0 ( l / 2 ) sin θ 4 t π d x d θ = 2 l t π . {\displaystyle P=\int _{\theta =0}^{\frac {\pi }{2}}\int _{x=0}^{(l/2)\sin \theta }{\frac {4}{t\pi }}\,dx\,d\theta ={\frac {2l}{t\pi }}.} となる。
この式を用いてシミュレーションによって円周率の近似値を求めることができる(モンテカルロ法 )。 針を n {\displaystyle n} 回落としたときに針と線が h {\displaystyle h} 回交差したとすると
h n ∼ 2 l t π , {\displaystyle {\frac {h}{n}}\sim {\frac {2l}{t\pi }},} であったということなので π {\displaystyle \pi } の値は
π ∼ 2 l n t h . {\displaystyle \pi \sim {\frac {2{l}n}{th}}.} で近似できる。
場合分け2: 針が長い場合 t < l {\displaystyle t<l} の場合、針と線が交差する確率は
∫ θ = 0 π 2 ∫ x = 0 m ( θ ) 4 t π d x d θ {\displaystyle \int _{\theta =0}^{\frac {\pi }{2}}\int _{x=0}^{m(\theta )}{\frac {4}{t\pi }}\,dx\,d\theta } となる。ここで m ( θ ) {\displaystyle m(\theta )} は ( l / 2 ) sin θ {\displaystyle (l/2)\sin \theta } と t / 2 {\displaystyle t/2} の最小値である。
上の積分を行うと t < l {\displaystyle t<l} のとき、針と線が交差する確率は、
2 l t π − 2 t π { l 2 − t 2 + t sin − 1 ( t l ) } + 1 {\displaystyle {\frac {2l}{t\pi }}-{\frac {2}{t\pi }}\left\{{\sqrt {l^{2}-t^{2}}}+t\sin ^{-1}\left({\frac {t}{l}}\right)\right\}+1} または
2 π cos − 1 t l + 2 π l t { 1 − 1 − ( t l ) 2 } . {\displaystyle {\frac {2}{\pi }}\cos ^{-1}{\frac {t}{l}}+{\frac {2}{\pi }}{\frac {l}{t}}\left\{1-{\sqrt {1-\left({\frac {t}{l}}\right)^{2}}}\right\}.} となる。
2つ目の式において、1番目の項は針が常に少なくとも1つの線と交差するような角度で落ちる確率を表す。2番目の項は位置によっては交差しない可能性のある角度で落ちたときに針と線が交差する確率を表す。
ラザリニの実験 1901年にイタリア の数学者 マリオ・ラザリニはビュフォンの針の実験を行った。3408回針を投げて、よく知られた円周率の近似値 355 / 113 を得た。この近似値と π との差は 3 × 10−7 以下である。印象的な結果ではあるが、以下の理由でフェアな実験でなかったとされている。
ラザリニは線の巾の 5 / 6 の長さの針を選んだがその場合、針が直線と交差する確率は 5 / 3π である。n 回落下させて x 回交差したことから求められる π の値は
π ≈ 5 / 3 · n / x π は 355 / 113 に近いので(5桁以下の整数を使った分数の近似値でこれより近い分数はない)、n と x は下式のように書かれる:
355 / 113 = 5 / 3 · n / x または
x = 113 / 213 n である。π の近似値を求めるのであるが、355 / 113 は正しい値に近いので、n を 213 の整数倍の数字を選ぶことによって、113 の整数倍の数になる結果を得れば実験は成功する。
213 回の実験で 113 が得られれば π の小数点以下 6 桁の近似値が求まったことになり、そうでなければ実験を続ければよい。ラザリニは 3408 = 213 × 16 回の実験で、希望の近似値を得たことになった。
シミュレーションにおける依存の循環 この実験をコンピュータでシミュレーション して円周率の近似値を求める際に、 0 {\displaystyle 0} から π / 2 {\displaystyle \pi /2} までの一様分布を用いて θ {\displaystyle \theta } を決めてしまうと(求めようとしている値であるはずの)円周率の値への依存が発生してしまう。依存を回避するには、以下の擬似コードのように単位円の内側の点をランダムに選ぶことで円周率を使わずに sin θ {\displaystyle \sin \theta } の値を求めればよい[ 1] 。
function simulation(l, t, n)
h = 0
for (iter = 0; iter < n; iter++)
x = Uniform(0, t/2)
repeat
dx = Uniform(0, 1)
dy = Uniform(0, 1)
radius = sqrt(dx*dx + dy*dy)
until radius <= 1
if x <= (l/2) * (dy/radius)
h = h + 1
return 2*l*n / (t*h)
ここで Uniform(a, b) はaからbまでの一様乱数を表す。なお擬似コードでは簡単のため例外処理は省略している。
関連項目
脚注 ^ “Lecture 10: The Alpha and the Omega of Monte Carlo”. 2017年12月13日 閲覧。