SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
Replica exchange MCMC
with Stan and R
Kentaro Matsuura
June 4, 2016
Tokyo.Stan
Example data
• N = 50 # number of data points
2
Model (Assumptions)
• 𝑌 𝑛 ~ Normal sin 𝛽 𝑋 𝑛 , 𝜎 𝑌
• angular rate: 𝛽 ~ Normal+ 0, 50
• noise scale: 𝜎 𝑌 ~ Student_t+ 4, 0, 5
3
𝑛 = 1, … , 𝑁
Stan Code 4
R Code 5
Result | trace plot 6
This chain seems good.
Should I set initial values
around (b, s_y)=(24, 0.3) ?
By the way
A contour map of log-posterior can be visualized.
Because the number of parameters is just two in this model.
7
For later explanation, I visualized
𝐸
𝑇
(≈ − log-posterior )
𝐸: Energy, 𝑇: Temperature
higher log-posterior  lower
𝐸
𝑇
previous model is correspond to 𝑇 = 1
Contour map of 𝐸/𝑇 (at 𝑇 = 1) 8
Contour map of 𝐸/𝑇 (at 𝑇 = 1) 9
around (24, 0.3)
𝐸 ≈ 33
around (0.5, 0.3)
𝐸 ≈ 28
10
Replica exchange MCMC
(also known as parallel tempering)
Setting initial values is generally difficult.
References
• Y. Iba, "Extended Ensemble Monte Carlo," Int. J. Mod.
Phys. C, 12, pp.623-652, 2001.
• Movie by Y. Iba (in Japanese):
レプリカ交換MCMC講義 (伊庭幸人) 難易度★★
https://www.youtube.com/watch?v=1c7mQIhEqmQ
• Books (in Japanese)
– 福島孝治 (2006) サイコロふって積分する方法 確率的情報処理と統
計力学(SGCライブラリ 50) p.60-66.
– 伊庭ほか (2005) 計算統計II (統計科学のフロンティア 12) p.74-78
11
Overview 12
Monte Carlo Step
𝑇5
𝑇4
𝑇3
𝑇2
𝑇1 = 1
>>>>
𝑁𝑟𝑒𝑝𝑙𝑖𝑐𝑎 = 5
Annealing and Heating 13
𝑇ℎ𝑖𝑔ℎ
𝑇 𝑚𝑖𝑑𝑑𝑙𝑒
𝑇1 = 1
Sampling from joint distribution
• Theoretically, Replica exchange MCMC
does sampling from the following joint
distribution:
𝑝 𝜽1, … , 𝜽 𝑇 𝑁_𝑟𝑒𝑝𝑙𝑖𝑐𝑎
=
𝑟=1
𝑁_𝑟𝑒𝑝𝑙𝑖𝑐𝑎
𝑝 𝜽 𝑟|𝑇 = 𝑇𝑟
where 𝑝 𝜽 𝑟|𝑇 = 𝑇𝑟 ∝ exp −
𝐸 𝜽 𝑟
𝑇𝑟
14
Exchange probability of replicas
𝑝 = min 1,
exp −
𝐸 𝑟′
𝑇𝑟
−
𝐸𝑟
𝑇 𝑟′
exp −
𝐸𝑟
𝑇𝑟
−
𝐸 𝑟′
𝑇 𝑟′
= min 1, exp 𝐸𝑟 − 𝐸 𝑟′ ×
1
𝑇𝑟
−
1
𝑇 𝑟′
15
Pseudo Code 16
set T of replicas: T = (1, T2, T3, ..., TN_replica)
set initial values: x = (x0, x0, ..., x0)
for e in 1, ..., N_exchange
for r in 1, ..., N_replica
short sampling started from x[r] at each T[r]
end
save MCMC samples at T = 1
exchange replicas if p < unif(0,1)
for r in 1, ..., N_replica
update x[r]
end
end
Stan Code 17
R Code and Settings
• R Code:
• 𝑁𝑟𝑒𝑝𝑙𝑖𝑐𝑎 = 10
• 𝑁𝑒𝑥𝑐ℎ𝑎𝑛𝑔𝑒 = 100
• 𝑇 = 1, 1.54, … , 32.37, 50
• 𝑥0 = 𝑏, 𝜎 𝑦 0
= 24. 2, 0.4
• iter=70 and warmup=50 each short sampling
(i.e. 20 MCMC samples)
18
𝑁𝑟𝑒𝑝𝑙𝑖𝑐𝑎 needs ≈ 𝑁
geometric progression
deep local minimum ☠
https://gist.github.com/MatsuuraKentaro/bccf13af3ba5
2c9d6c379c0032725b91
Result | Exchanges of replicas 19
Result | 𝐸 (Energy) 20
Result | 𝐸 (Energy) 21
Result | trace plot (at 𝑇 = 1) 22
Discussion
• Can I re-use warmup result in Stan?
i.e. step size &
diagonal elements of inverse mass matrix
• How to set iter and warmup of each short
sampling?
warmup=50 is usually too short as total sampling.
But, total warmup is 50*100 in this case.
Does it make sense?
23

Weitere ähnliche Inhalte

Was ist angesagt?

「統計的学習理論」第1章
「統計的学習理論」第1章「統計的学習理論」第1章
「統計的学習理論」第1章Kota Matsui
 
KDD'17読み会:Anomaly Detection with Robust Deep Autoencoders
KDD'17読み会:Anomaly Detection with Robust Deep AutoencodersKDD'17読み会:Anomaly Detection with Robust Deep Autoencoders
KDD'17読み会:Anomaly Detection with Robust Deep AutoencodersSatoshi Hara
 
PRML第6章「カーネル法」
PRML第6章「カーネル法」PRML第6章「カーネル法」
PRML第6章「カーネル法」Keisuke Sugawara
 
クラシックな機械学習の入門 6. 最適化と学習アルゴリズム
クラシックな機械学習の入門  6. 最適化と学習アルゴリズムクラシックな機械学習の入門  6. 最適化と学習アルゴリズム
クラシックな機械学習の入門 6. 最適化と学習アルゴリズムHiroshi Nakagawa
 
PRML輪読#7
PRML輪読#7PRML輪読#7
PRML輪読#7matsuolab
 
数式を(ちょっとしか)使わずに隠れマルコフモデル
数式を(ちょっとしか)使わずに隠れマルコフモデル数式を(ちょっとしか)使わずに隠れマルコフモデル
数式を(ちょっとしか)使わずに隠れマルコフモデルYuya Takashina
 
統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)Kota Mori
 
レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成Nagi Teramo
 
サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会
サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会
サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会Shotaro Sano
 
階層ベイズと自由エネルギー
階層ベイズと自由エネルギー階層ベイズと自由エネルギー
階層ベイズと自由エネルギーHiroshi Shimizu
 
PRML輪読#11
PRML輪読#11PRML輪読#11
PRML輪読#11matsuolab
 
PRML輪読#3
PRML輪読#3PRML輪読#3
PRML輪読#3matsuolab
 
リスクベースポートフォリオの高次モーメントへの拡張
リスクベースポートフォリオの高次モーメントへの拡張リスクベースポートフォリオの高次モーメントへの拡張
リスクベースポートフォリオの高次モーメントへの拡張Kei Nakagawa
 
混合ガウスモデルとEMアルゴリスム
混合ガウスモデルとEMアルゴリスム混合ガウスモデルとEMアルゴリスム
混合ガウスモデルとEMアルゴリスム貴之 八木
 
関数データ解析の概要とその方法
関数データ解析の概要とその方法関数データ解析の概要とその方法
関数データ解析の概要とその方法Hidetoshi Matsui
 
PRML第9章「混合モデルとEM」
PRML第9章「混合モデルとEM」PRML第9章「混合モデルとEM」
PRML第9章「混合モデルとEM」Keisuke Sugawara
 
最適輸送の計算アルゴリズムの研究動向
最適輸送の計算アルゴリズムの研究動向最適輸送の計算アルゴリズムの研究動向
最適輸送の計算アルゴリズムの研究動向ohken
 
PRML輪読#2
PRML輪読#2PRML輪読#2
PRML輪読#2matsuolab
 
PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6
PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6
PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6Hiroyuki Kato
 

Was ist angesagt? (20)

「統計的学習理論」第1章
「統計的学習理論」第1章「統計的学習理論」第1章
「統計的学習理論」第1章
 
KDD'17読み会:Anomaly Detection with Robust Deep Autoencoders
KDD'17読み会:Anomaly Detection with Robust Deep AutoencodersKDD'17読み会:Anomaly Detection with Robust Deep Autoencoders
KDD'17読み会:Anomaly Detection with Robust Deep Autoencoders
 
PRML第6章「カーネル法」
PRML第6章「カーネル法」PRML第6章「カーネル法」
PRML第6章「カーネル法」
 
クラシックな機械学習の入門 6. 最適化と学習アルゴリズム
クラシックな機械学習の入門  6. 最適化と学習アルゴリズムクラシックな機械学習の入門  6. 最適化と学習アルゴリズム
クラシックな機械学習の入門 6. 最適化と学習アルゴリズム
 
Rの高速化
Rの高速化Rの高速化
Rの高速化
 
PRML輪読#7
PRML輪読#7PRML輪読#7
PRML輪読#7
 
数式を(ちょっとしか)使わずに隠れマルコフモデル
数式を(ちょっとしか)使わずに隠れマルコフモデル数式を(ちょっとしか)使わずに隠れマルコフモデル
数式を(ちょっとしか)使わずに隠れマルコフモデル
 
統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)
 
レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成レプリカ交換モンテカルロ法で乱数の生成
レプリカ交換モンテカルロ法で乱数の生成
 
サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会
サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会
サポートベクトルデータ記述法による異常検知 in 機械学習プロフェッショナルシリーズ輪読会
 
階層ベイズと自由エネルギー
階層ベイズと自由エネルギー階層ベイズと自由エネルギー
階層ベイズと自由エネルギー
 
PRML輪読#11
PRML輪読#11PRML輪読#11
PRML輪読#11
 
PRML輪読#3
PRML輪読#3PRML輪読#3
PRML輪読#3
 
リスクベースポートフォリオの高次モーメントへの拡張
リスクベースポートフォリオの高次モーメントへの拡張リスクベースポートフォリオの高次モーメントへの拡張
リスクベースポートフォリオの高次モーメントへの拡張
 
混合ガウスモデルとEMアルゴリスム
混合ガウスモデルとEMアルゴリスム混合ガウスモデルとEMアルゴリスム
混合ガウスモデルとEMアルゴリスム
 
関数データ解析の概要とその方法
関数データ解析の概要とその方法関数データ解析の概要とその方法
関数データ解析の概要とその方法
 
PRML第9章「混合モデルとEM」
PRML第9章「混合モデルとEM」PRML第9章「混合モデルとEM」
PRML第9章「混合モデルとEM」
 
最適輸送の計算アルゴリズムの研究動向
最適輸送の計算アルゴリズムの研究動向最適輸送の計算アルゴリズムの研究動向
最適輸送の計算アルゴリズムの研究動向
 
PRML輪読#2
PRML輪読#2PRML輪読#2
PRML輪読#2
 
PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6
PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6
PRML上巻勉強会 at 東京大学 資料 第2章2.3.3 〜 2.3.6
 

Ähnlich wie Replica exchange MCMC

DSP_FOEHU - MATLAB 02 - The Discrete-time Fourier Analysis
DSP_FOEHU - MATLAB 02 - The Discrete-time Fourier AnalysisDSP_FOEHU - MATLAB 02 - The Discrete-time Fourier Analysis
DSP_FOEHU - MATLAB 02 - The Discrete-time Fourier AnalysisAmr E. Mohamed
 
Applied Algorithms and Structures week999
Applied Algorithms and Structures week999Applied Algorithms and Structures week999
Applied Algorithms and Structures week999fashiontrendzz20
 
Markov chain Monte Carlo methods and some attempts at parallelizing them
Markov chain Monte Carlo methods and some attempts at parallelizing themMarkov chain Monte Carlo methods and some attempts at parallelizing them
Markov chain Monte Carlo methods and some attempts at parallelizing themPierre Jacob
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Alexander Litvinenko
 
Lecture: Monte Carlo Methods
Lecture: Monte Carlo MethodsLecture: Monte Carlo Methods
Lecture: Monte Carlo MethodsFrank Kienle
 
Molecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based ComputingMolecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based Computingijcsit
 
Response Surface in Tensor Train format for Uncertainty Quantification
Response Surface in Tensor Train format for Uncertainty QuantificationResponse Surface in Tensor Train format for Uncertainty Quantification
Response Surface in Tensor Train format for Uncertainty QuantificationAlexander Litvinenko
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical MethodsTeja Ande
 
K-adaptive partitioning for survival data
K-adaptive partitioning for survival dataK-adaptive partitioning for survival data
K-adaptive partitioning for survival data수행 어
 
Phase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle SystemsPhase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle SystemsStefan Eng
 
Approximating Value of pi(Π) using Monte Carlo Iterative Method
Approximating Value of pi(Π) using Monte Carlo Iterative MethodApproximating Value of pi(Π) using Monte Carlo Iterative Method
Approximating Value of pi(Π) using Monte Carlo Iterative MethodNischal Lal Shrestha
 
Digital Signal Processing[ECEG-3171]-Ch1_L05
Digital Signal Processing[ECEG-3171]-Ch1_L05Digital Signal Processing[ECEG-3171]-Ch1_L05
Digital Signal Processing[ECEG-3171]-Ch1_L05Rediet Moges
 
Common Fixed Theorems Using Random Implicit Iterative Schemes
Common Fixed Theorems Using Random Implicit Iterative SchemesCommon Fixed Theorems Using Random Implicit Iterative Schemes
Common Fixed Theorems Using Random Implicit Iterative Schemesinventy
 
PART VII.3 - Quantum Electrodynamics
PART VII.3 - Quantum ElectrodynamicsPART VII.3 - Quantum Electrodynamics
PART VII.3 - Quantum ElectrodynamicsMaurice R. TREMBLAY
 
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...Shu Tanaka
 

Ähnlich wie Replica exchange MCMC (20)

DSP_FOEHU - MATLAB 02 - The Discrete-time Fourier Analysis
DSP_FOEHU - MATLAB 02 - The Discrete-time Fourier AnalysisDSP_FOEHU - MATLAB 02 - The Discrete-time Fourier Analysis
DSP_FOEHU - MATLAB 02 - The Discrete-time Fourier Analysis
 
Applied Algorithms and Structures week999
Applied Algorithms and Structures week999Applied Algorithms and Structures week999
Applied Algorithms and Structures week999
 
Markov chain Monte Carlo methods and some attempts at parallelizing them
Markov chain Monte Carlo methods and some attempts at parallelizing themMarkov chain Monte Carlo methods and some attempts at parallelizing them
Markov chain Monte Carlo methods and some attempts at parallelizing them
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...
 
numerical.ppt
numerical.pptnumerical.ppt
numerical.ppt
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
Lecture: Monte Carlo Methods
Lecture: Monte Carlo MethodsLecture: Monte Carlo Methods
Lecture: Monte Carlo Methods
 
Molecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based ComputingMolecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based Computing
 
Response Surface in Tensor Train format for Uncertainty Quantification
Response Surface in Tensor Train format for Uncertainty QuantificationResponse Surface in Tensor Train format for Uncertainty Quantification
Response Surface in Tensor Train format for Uncertainty Quantification
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
 
K-adaptive partitioning for survival data
K-adaptive partitioning for survival dataK-adaptive partitioning for survival data
K-adaptive partitioning for survival data
 
Phase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle SystemsPhase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle Systems
 
Approximating Value of pi(Π) using Monte Carlo Iterative Method
Approximating Value of pi(Π) using Monte Carlo Iterative MethodApproximating Value of pi(Π) using Monte Carlo Iterative Method
Approximating Value of pi(Π) using Monte Carlo Iterative Method
 
Digital Signal Processing[ECEG-3171]-Ch1_L05
Digital Signal Processing[ECEG-3171]-Ch1_L05Digital Signal Processing[ECEG-3171]-Ch1_L05
Digital Signal Processing[ECEG-3171]-Ch1_L05
 
legendre.pptx
legendre.pptxlegendre.pptx
legendre.pptx
 
Conference ppt
Conference pptConference ppt
Conference ppt
 
Common Fixed Theorems Using Random Implicit Iterative Schemes
Common Fixed Theorems Using Random Implicit Iterative SchemesCommon Fixed Theorems Using Random Implicit Iterative Schemes
Common Fixed Theorems Using Random Implicit Iterative Schemes
 
PART VII.3 - Quantum Electrodynamics
PART VII.3 - Quantum ElectrodynamicsPART VII.3 - Quantum Electrodynamics
PART VII.3 - Quantum Electrodynamics
 
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
Quantum Annealing for Dirichlet Process Mixture Models with Applications to N...
 

Mehr von . .

TensorFlowで統計モデリング
TensorFlowで統計モデリングTensorFlowで統計モデリング
TensorFlowで統計モデリング. .
 
統計モデリングで癌の5年生存率データから良い病院を探す
統計モデリングで癌の5年生存率データから良い病院を探す統計モデリングで癌の5年生存率データから良い病院を探す
統計モデリングで癌の5年生存率データから良い病院を探す. .
 
Stanの紹介と応用事例(age heapingの統計モデル)
Stanの紹介と応用事例(age heapingの統計モデル)Stanの紹介と応用事例(age heapingの統計モデル)
Stanの紹介と応用事例(age heapingの統計モデル). .
 
MCMCサンプルの使い方 ~見る・決める・探す・発生させる~
MCMCサンプルの使い方 ~見る・決める・探す・発生させる~MCMCサンプルの使い方 ~見る・決める・探す・発生させる~
MCMCサンプルの使い方 ~見る・決める・探す・発生させる~. .
 
階層ベイズモデルで割安mobile PCを探す
階層ベイズモデルで割安mobile PCを探す階層ベイズモデルで割安mobile PCを探す
階層ベイズモデルで割安mobile PCを探す. .
 
順序データでもベイズモデリング
順序データでもベイズモデリング順序データでもベイズモデリング
順序データでもベイズモデリング. .
 
データ解析で割安賃貸物件を探せ!(山手線沿線編) LT
データ解析で割安賃貸物件を探せ!(山手線沿線編) LTデータ解析で割安賃貸物件を探せ!(山手線沿線編) LT
データ解析で割安賃貸物件を探せ!(山手線沿線編) LT. .
 
分布から見た線形モデル・GLM・GLMM
分布から見た線形モデル・GLM・GLMM分布から見た線形モデル・GLM・GLMM
分布から見た線形モデル・GLM・GLMM. .
 
100人のための統計解析 和食レストラン編
100人のための統計解析   和食レストラン編100人のための統計解析   和食レストラン編
100人のための統計解析 和食レストラン編. .
 
とある病んだ院生の体内時計(サーカディアンリズム)
とある病んだ院生の体内時計(サーカディアンリズム)とある病んだ院生の体内時計(サーカディアンリズム)
とある病んだ院生の体内時計(サーカディアンリズム). .
 
『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた
『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた
『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた. .
 
BUGSを使うメリット
BUGSを使うメリットBUGSを使うメリット
BUGSを使うメリット. .
 

Mehr von . . (12)

TensorFlowで統計モデリング
TensorFlowで統計モデリングTensorFlowで統計モデリング
TensorFlowで統計モデリング
 
統計モデリングで癌の5年生存率データから良い病院を探す
統計モデリングで癌の5年生存率データから良い病院を探す統計モデリングで癌の5年生存率データから良い病院を探す
統計モデリングで癌の5年生存率データから良い病院を探す
 
Stanの紹介と応用事例(age heapingの統計モデル)
Stanの紹介と応用事例(age heapingの統計モデル)Stanの紹介と応用事例(age heapingの統計モデル)
Stanの紹介と応用事例(age heapingの統計モデル)
 
MCMCサンプルの使い方 ~見る・決める・探す・発生させる~
MCMCサンプルの使い方 ~見る・決める・探す・発生させる~MCMCサンプルの使い方 ~見る・決める・探す・発生させる~
MCMCサンプルの使い方 ~見る・決める・探す・発生させる~
 
階層ベイズモデルで割安mobile PCを探す
階層ベイズモデルで割安mobile PCを探す階層ベイズモデルで割安mobile PCを探す
階層ベイズモデルで割安mobile PCを探す
 
順序データでもベイズモデリング
順序データでもベイズモデリング順序データでもベイズモデリング
順序データでもベイズモデリング
 
データ解析で割安賃貸物件を探せ!(山手線沿線編) LT
データ解析で割安賃貸物件を探せ!(山手線沿線編) LTデータ解析で割安賃貸物件を探せ!(山手線沿線編) LT
データ解析で割安賃貸物件を探せ!(山手線沿線編) LT
 
分布から見た線形モデル・GLM・GLMM
分布から見た線形モデル・GLM・GLMM分布から見た線形モデル・GLM・GLMM
分布から見た線形モデル・GLM・GLMM
 
100人のための統計解析 和食レストラン編
100人のための統計解析   和食レストラン編100人のための統計解析   和食レストラン編
100人のための統計解析 和食レストラン編
 
とある病んだ院生の体内時計(サーカディアンリズム)
とある病んだ院生の体内時計(サーカディアンリズム)とある病んだ院生の体内時計(サーカディアンリズム)
とある病んだ院生の体内時計(サーカディアンリズム)
 
『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた
『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた
『予測にいかす統計モデリングの基本』の売上データの分析をトレースしてみた
 
BUGSを使うメリット
BUGSを使うメリットBUGSを使うメリット
BUGSを使うメリット
 

Kürzlich hochgeladen

Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 

Kürzlich hochgeladen (20)

Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 

Replica exchange MCMC

  • 1. Replica exchange MCMC with Stan and R Kentaro Matsuura June 4, 2016 Tokyo.Stan
  • 2. Example data • N = 50 # number of data points 2
  • 3. Model (Assumptions) • 𝑌 𝑛 ~ Normal sin 𝛽 𝑋 𝑛 , 𝜎 𝑌 • angular rate: 𝛽 ~ Normal+ 0, 50 • noise scale: 𝜎 𝑌 ~ Student_t+ 4, 0, 5 3 𝑛 = 1, … , 𝑁
  • 6. Result | trace plot 6 This chain seems good. Should I set initial values around (b, s_y)=(24, 0.3) ?
  • 7. By the way A contour map of log-posterior can be visualized. Because the number of parameters is just two in this model. 7 For later explanation, I visualized 𝐸 𝑇 (≈ − log-posterior ) 𝐸: Energy, 𝑇: Temperature higher log-posterior  lower 𝐸 𝑇 previous model is correspond to 𝑇 = 1
  • 8. Contour map of 𝐸/𝑇 (at 𝑇 = 1) 8
  • 9. Contour map of 𝐸/𝑇 (at 𝑇 = 1) 9 around (24, 0.3) 𝐸 ≈ 33 around (0.5, 0.3) 𝐸 ≈ 28
  • 10. 10 Replica exchange MCMC (also known as parallel tempering) Setting initial values is generally difficult.
  • 11. References • Y. Iba, "Extended Ensemble Monte Carlo," Int. J. Mod. Phys. C, 12, pp.623-652, 2001. • Movie by Y. Iba (in Japanese): レプリカ交換MCMC講義 (伊庭幸人) 難易度★★ https://www.youtube.com/watch?v=1c7mQIhEqmQ • Books (in Japanese) – 福島孝治 (2006) サイコロふって積分する方法 確率的情報処理と統 計力学(SGCライブラリ 50) p.60-66. – 伊庭ほか (2005) 計算統計II (統計科学のフロンティア 12) p.74-78 11
  • 12. Overview 12 Monte Carlo Step 𝑇5 𝑇4 𝑇3 𝑇2 𝑇1 = 1 >>>> 𝑁𝑟𝑒𝑝𝑙𝑖𝑐𝑎 = 5
  • 13. Annealing and Heating 13 𝑇ℎ𝑖𝑔ℎ 𝑇 𝑚𝑖𝑑𝑑𝑙𝑒 𝑇1 = 1
  • 14. Sampling from joint distribution • Theoretically, Replica exchange MCMC does sampling from the following joint distribution: 𝑝 𝜽1, … , 𝜽 𝑇 𝑁_𝑟𝑒𝑝𝑙𝑖𝑐𝑎 = 𝑟=1 𝑁_𝑟𝑒𝑝𝑙𝑖𝑐𝑎 𝑝 𝜽 𝑟|𝑇 = 𝑇𝑟 where 𝑝 𝜽 𝑟|𝑇 = 𝑇𝑟 ∝ exp − 𝐸 𝜽 𝑟 𝑇𝑟 14
  • 15. Exchange probability of replicas 𝑝 = min 1, exp − 𝐸 𝑟′ 𝑇𝑟 − 𝐸𝑟 𝑇 𝑟′ exp − 𝐸𝑟 𝑇𝑟 − 𝐸 𝑟′ 𝑇 𝑟′ = min 1, exp 𝐸𝑟 − 𝐸 𝑟′ × 1 𝑇𝑟 − 1 𝑇 𝑟′ 15
  • 16. Pseudo Code 16 set T of replicas: T = (1, T2, T3, ..., TN_replica) set initial values: x = (x0, x0, ..., x0) for e in 1, ..., N_exchange for r in 1, ..., N_replica short sampling started from x[r] at each T[r] end save MCMC samples at T = 1 exchange replicas if p < unif(0,1) for r in 1, ..., N_replica update x[r] end end
  • 18. R Code and Settings • R Code: • 𝑁𝑟𝑒𝑝𝑙𝑖𝑐𝑎 = 10 • 𝑁𝑒𝑥𝑐ℎ𝑎𝑛𝑔𝑒 = 100 • 𝑇 = 1, 1.54, … , 32.37, 50 • 𝑥0 = 𝑏, 𝜎 𝑦 0 = 24. 2, 0.4 • iter=70 and warmup=50 each short sampling (i.e. 20 MCMC samples) 18 𝑁𝑟𝑒𝑝𝑙𝑖𝑐𝑎 needs ≈ 𝑁 geometric progression deep local minimum ☠ https://gist.github.com/MatsuuraKentaro/bccf13af3ba5 2c9d6c379c0032725b91
  • 19. Result | Exchanges of replicas 19
  • 20. Result | 𝐸 (Energy) 20
  • 21. Result | 𝐸 (Energy) 21
  • 22. Result | trace plot (at 𝑇 = 1) 22
  • 23. Discussion • Can I re-use warmup result in Stan? i.e. step size & diagonal elements of inverse mass matrix • How to set iter and warmup of each short sampling? warmup=50 is usually too short as total sampling. But, total warmup is 50*100 in this case. Does it make sense? 23