Nested sampling algorithm とは、ベイズ統計 におけるモデル比較、及び事後分布からのサンプル生成のための計算手法である。 2004年に物理学者 のジョン・スキリング(John Skilling)によって開発された。 [ 1]
背景
ベイズの定理 によれば、同時に真となることはない二つのモデルの組
(
M
1
,
M
2
)
{\displaystyle (M_{1},M_{2})}
に対し、データ
D
{\displaystyle D}
を観測した時のモデル
M
1
{\displaystyle M_{1}}
の事後確率は次のように計算できる:
P
(
M
1
∣
D
)
=
P
(
D
∣
M
1
)
P
(
M
1
)
P
(
D
)
=
P
(
D
∣
M
1
)
P
(
M
1
)
P
(
D
∣
M
1
)
P
(
M
1
)
+
P
(
D
∣
M
2
)
P
(
M
2
)
=
1
1
+
P
(
D
∣
M
2
)
P
(
D
∣
M
1
)
P
(
M
2
)
P
(
M
1
)
{\displaystyle {\begin{aligned}P(M_{1}\mid D)&={\frac {P(D\mid M_{1})P(M_{1})}{P(D)}}\\&={\frac {P(D\mid M_{1})P(M_{1})}{P(D\mid M_{1})P(M_{1})+P(D\mid M_{2})P(M_{2})}}\\&={\frac {1}{1+{\frac {P(D\mid M_{2})}{P(D\mid M_{1})}}{\frac {P(M_{2})}{P(M_{1})}}}}\end{aligned}}}
ここで
M
1
{\displaystyle M_{1}}
と
M
2
{\displaystyle M_{2}}
に対する事前確率は既知であるとする。事後確率を求めるには残りのベイズ因子
P
(
D
∣
M
2
)
/
P
(
D
∣
M
1
)
{\displaystyle P(D\mid M_{2})/P(D\mid M_{1})}
を求める必要があるが、一般にNuisance paramterを周辺化(積分)する必要があるため、評価はそれほど簡単ではない。一般にモデル
M
{\displaystyle M}
がパラメータ
θ
{\displaystyle \theta }
(多次元であってもよく、モデルにより異なっても良い)を持つとき、
M
{\displaystyle M}
の周辺化は次のようになる:
P
(
D
∣
M
)
=
∫
d
θ
P
(
D
∣
θ
,
M
)
P
(
θ
∣
M
)
{\displaystyle P(D\mid M)=\int d\theta \,P(D\mid \theta ,M)P(\theta \mid M)}
この積分はしばしば解析的に扱いにくいものであり、数値アルゴリズムを用い近似値を求める必要があります。Nested sampling algorithmは、特にこういった周縁化積分の近似計算のためにJohn Skillingによって開発され、積分計算と同時に事後分布
P
(
θ
∣
D
,
M
)
{\displaystyle P(\theta \mid D,M)}
からのサンプルが生成できるという追加の利点がある [ 2] 。これはベイズ推定の観点からはブリッジサンプリングや防御的重要度サンプリングなどの[ 3] 方法に代わるものである。
Nested sampling algorithmの単純なバージョンは次のようになる。周辺確率密度
Z
=
P
(
D
∣
M
)
{\displaystyle Z=P(D\mid M)}
は以下のように計算される:
Start with
N
{\displaystyle N}
points
θ
1
,
…
,
θ
N
{\displaystyle \theta _{1},\ldots ,\theta _{N}}
sampled from prior.
for
i
=
1
{\displaystyle i=1}
to
j
{\displaystyle j}
do % The number of iterations j is chosen by guesswork.
L
i
:=
min
(
{\displaystyle L_{i}:=\min(}
current likelihood values of the points
)
{\displaystyle )}
;
X
i
:=
exp
(
−
i
/
N
)
;
{\displaystyle X_{i}:=\exp(-i/N);}
w
i
:=
X
i
−
1
−
X
i
{\displaystyle w_{i}:=X_{i-1}-X_{i}}
Z
:=
Z
+
L
i
⋅
w
i
;
{\displaystyle Z:=Z+L_{i}\cdot w_{i};}
Save the point with least likelihood as a sample point with weight
w
i
{\displaystyle w_{i}}
.
Update the point with least likelihood with some Markov chain Monte Carlo steps according to the prior, accepting only steps that
keep the likelihood above
L
i
{\displaystyle L_{i}}
.
end
return
Z
{\displaystyle Z}
;
各繰り返しステップにおいて
X
i
{\displaystyle X_{i}}
は、
θ
i
{\displaystyle \theta _{i}}
における値より大きい尤度をもつようなパラメータ空間の体積の推定値である。重み
w
i
{\displaystyle w_{i}}
は2つの超曲面
{
θ
∣
P
(
D
∣
θ
,
M
)
=
P
(
D
∣
θ
i
−
1
,
M
)
}
{\displaystyle \{\theta \mid P(D\mid \theta ,M)=P(D\mid \theta _{i-1},M)\}}
及び
{
θ
∣
P
(
D
∣
θ
,
M
)
=
P
(
D
∣
θ
i
,
M
)
}
{\displaystyle \{\theta \mid P(D\mid \theta ,M)=P(D\mid \theta _{i},M)\}}
の間の体積の推定値である。更新手順
Z
:=
Z
+
L
i
w
i
{\displaystyle Z:=Z+L_{i}w_{i}}
により、
L
i
w
i
{\displaystyle L_{i}w_{i}}
の
i
{\displaystyle i}
による合計を計算することで、以下の積分を数値的に近似する:
P
(
D
∣
M
)
=
∫
P
(
D
∣
θ
,
M
)
P
(
θ
∣
M
)
d
θ
=
∫
P
(
D
∣
θ
,
M
)
d
P
(
θ
∣
M
)
{\displaystyle {\begin{aligned}P(D\mid M)&=\int P(D\mid \theta ,M)P(\theta \mid M)\,d\theta \\&=\int P(D\mid \theta ,M)\,dP(\theta \mid M)\end{aligned}}}
j
→
∞
{\displaystyle j\to \infty }
の極限でこの推定量には
1
/
N
{\displaystyle 1/N}
の正のバイアスがあるが [ 4] 、
(
1
−
1
/
N
)
{\displaystyle (1-1/N)}
の代わりに
exp
(
−
1
/
N
)
{\displaystyle \exp(-1/N)}
を上記のアルゴリズムで用いることでこの誤差を取り除くことができる。
この計算手法の発想は、
f
(
θ
)
=
P
(
D
∣
θ
,
M
)
{\displaystyle f(\theta )=P(D\mid \theta ,M)}
の範囲を細分化し、各間隔
[
f
(
θ
i
−
1
)
,
f
(
θ
i
)
]
{\displaystyle [f(\theta _{i-1}),f(\theta _{i})]}
ごとに、ランダムに選択された点
θ
{\displaystyle \theta }
がこの区間内に存在する確率を推定する、ということである。これはルベーグ積分 を数値的に実装するベイズ流の方法と考えることができる。 [ 5]
実装
Nested sampling algorhithmの各プログラミング言語 ごとの公開済み実装例は以下の通り。
C 、 R 、またはPythonの 簡単な例は、JohnSkillingのWebサイトにある。 [ 6]
上記の単純なコードのHaskell 実装例はHackageにある。 [ 7]
スペクトル をフィッティング するために設計されたR の例は出典[ 8] で説明されており、GitHub上にも存在する。 [ 9]
DiamondsというC ++ の例は、GitHubにある。
統計物理学と物性物理学 で使用する高度にモジュール化されたPython の例は、GitHubにあります。
pymatnestは、さまざまな材料のエネルギー地形 を探索し、任意の温度での熱力学的変数を計算し、相転移 を特定するために設計されたPython パッケージである。
MultiNestは、多峰性事後分布のNested sampling algorithmによるサンプリングを実行できる。 [ 10] C ++、Fortran、Python入力用のインターフェースがあり、GitHubで入手できる。
PolyChordは、GitHubで利用できるもう1つのNested sampling algorithmソフトウェアパッケージである。 PolyChordの計算効率は、パラメーターの数が増えるとMultiNestより適切にスケーリングされる。つまり、PolyChordは、高次元の問題に対してより効率的になる場合がある。 [ 11]
NestedSamplers.jl:単一および複数の楕円体のネストされたサンプリングアルゴリズムを実装するためのJulia パッケージがGitHub上にある。
応用
Nested sampling algorithm は2004年に提案されて以来、天文学 の分野の多くの側面で使用されており、宇宙論的 モデルの選択と物体検出にも使用された。これは、「精度、一般的な適用性、および計算の実現可能性を併せ持っている」ためである。 [ 12] 多峰性事後確率を処理するためのアルゴリズムの改良が、現存するデータセット内の天体を検出する手段として提案されている。 [ 10] Nested sampling algorithmの他の応用は、アルゴリズムを使用して最適な有限要素 モデルを選択する有限要素更新の分野にあり、これは構造ダイナミクスに適用された。 [ 13] このサンプリング方法は、材料モデリングの分野でも使用されている。統計力学 から分配関数 を学習し、熱力学的 特性を導き出すためにも使用できる。 [ 14]
動的 Nested sampling
動的 Nested samplingは、Nested sampling algorithmの一般化であり、計算の精度が最大になるようにパラメータ空間のさまざまな領域で取得されるサンプルの数が動的に調整される。 [ 15] これにより、サンプルの割り当てを変更できず、計算精度にほとんど影響を与えない領域で多くのサンプルが取得される、元のNested sampling algorithm と比較して、精度と計算効率が大幅に向上する場合がある。
公開されている動的Nested samplingのソフトウェアパッケージには、次のものがある。
dynesty -GitHubからダウンロードできる動的なネストされたサンプリングのPython実装。 [ 16] [ 17]
dyPolyChord:Python、C ++、Fortranの尤度および事前分布で使用できるソフトウェアパッケージ。 [ 18] dyPolyChordはGitHubで入手できる。 [ 19]
動的Nested samplingは色々な科学分野で使用され、重力波検出[ 20] 、空間内の距離のマッピング[ 21] 、太陽系外惑星の検出など、さまざまな科学的問題に適用されてきた。 [ 22]
関連項目
参考文献
^ Skilling, John (2004). “Nested Sampling”. AIP Conference Proceedings 735 : 395–405. Bibcode : 2004AIPC..735..395S . doi :10.1063/1.1835238 .
^ Skilling, John (2006). “Nested Sampling for General Bayesian Computation”. Bayesian Analysis 1 (4): 833–860. doi :10.1214/06-BA127 .
^ Chen, Ming-Hui, Shao, Qi-Man, and Ibrahim, Joseph George (2000). Monte Carlo methods in Bayesian computation . Springer. ISBN 978-0-387-98935-8 . https://books.google.com/books?id=R3GeFfshc7wC
^ Walter, Clement (2017). “Point-process based Monte Carlo estimation”. Statistics and Computing 27 : 219–236. arXiv :1412.6368 . doi :10.1007/s11222-015-9617-y .
^ Jasa, Tomislav; Xiang, Ning (2012). “Nested sampling applied in Bayesian room-acoustics decay analysis” . Journal of the Acoustical Society of America 132 (5): 3251–3262. Bibcode : 2012ASAJ..132.3251J . doi :10.1121/1.4754550 . PMID 23145609 . https://semanticscholar.org/paper/8225853110831e251aff26fc9b6431d0f2cc6e6c .
^ John Skilling website
^ Nested sampling algorithm in Haskell at Hackage
^ Nested sampling algorithm in R on Bojan Nikolic website
^ Nested sampling algorithm in R on GitHub
^ a b Feroz, F.; Hobson, M.P. (2008). “Multimodal nested sampling: an efficient and robust alternative to Markov Chain Monte Carlo methods for astronomical data analyses” . MNRAS 384 (2): 449–463. arXiv :0704.3704 . Bibcode : 2008MNRAS.384..449F . doi :10.1111/j.1365-2966.2007.12353.x . http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:0704.3704 .
^ Handley, Will; Mike, Hobson; Anthony, Lasenby (2015). “polychord: next-generation nested sampling”. Monthly Notices of the Royal Astronomical Society 453 (4): 4384–4398. arXiv :1506.00171 . Bibcode : 2015MNRAS.453.4384H . doi :10.1093/mnras/stv1911 .
^ Mukherjee, P.; Parkinson, D.; Liddle, A.R. (2006). “A Nested Sampling Algorithm for Cosmological Model Selection”. Astrophysical Journal 638 (2): 51–54. arXiv :astro-ph/0508461 . Bibcode : 2006ApJ...638L..51M . doi :10.1086/501068 .
^ Mthembu, L.; Marwala, T.; Friswell, M.I.; Adhikari, S. (2011). “Model selection in finite element model updating using the Bayesian evidence statistic”. Mechanical Systems and Signal Processing 25 (7): 2399–2412. Bibcode : 2011MSSP...25.2399M . doi :10.1016/j.ymssp.2011.04.001 .
^ Partay, Livia B. (2010). “Efficient Sampling of Atomic Configurational Spaces”. The Journal of Physical Chemistry B 114 (32): 10502–10512. arXiv :0906.3544 . doi :10.1021/jp1012973 . PMID 20701382 .
^ Higson, Edward; Handley, Will; Hobson, Michael; Lasenby, Anthony (2019). “Dynamic nested sampling: an improved algorithm for parameter estimation and evidence calculation”. Statistics and Computing 29 (5): 891–913. arXiv :1704.03459 . Bibcode : 2019S&C....29..891H . doi :10.1007/s11222-018-9844-0 .
^ The dynesty nested sampling software package on GitHub
^ Speagle, Joshua (2020). “dynesty: A Dynamic Nested Sampling Package for Estimating Bayesian Posteriors and Evidences”. Monthly Notices of the Royal Astronomical Society 493 (3): 3132–3158. arXiv :1904.02180 . doi :10.1093/mnras/staa278 .
^ Higson, Edward (2018). “dyPolyChord: dynamic nested sampling with PolyChord”. Journal of Open Source Software 3 (29): 965. doi :10.21105/joss.00965 .
^ The dyPolyChord dynamic nested sampling software package on GitHub
^ Ashton, Gregory (2019). “Bilby: A User-friendly Bayesian Inference Library for Gravitational-wave Astronomy”. The Astrophysical Journal Supplement Series 241 (2): 13. arXiv :1811.02042 . Bibcode : 2019ApJS..241...27A . doi :10.3847/1538-4365/ab06fc etal
^ Zucker, Catherine (2018). “Mapping Distances across the Perseus Molecular Cloud Using {CO} Observations, Stellar Photometry, and Gaia {DR}2 Parallax Measurements”. The Astrophysical Journal 869 (1): 83. arXiv :1803.08931 . doi :10.3847/1538-4357/aae97c etal
^ Günther, Maximilian (2019). “A super-Earth and two sub-Neptunes transiting the nearby and quiet M dwarf TOI-270”. Nature Astronomy 3 (12): 1099–1108. arXiv :1903.06107 . Bibcode : 2019NatAs...3.1099G . doi :10.1038/s41550-019-0845-5 etal