1 / 8

Monte Carlo Simulation Part.2 Metropolis Algorithm

Monte Carlo Simulation Part.2 Metropolis Algorithm. Dept. Phys. Tunghai Univ. Numerical Methods C. T. Shih. Simple/Importance Sampling. 當我們用 MC 法計算積分時,若該函數為常數函數 f(x)=constant ,則取樣數不管多少,準確度皆為百分之百 相對的,如果 f(x) 為 delta 函數,則取樣數不管多少,準確度幾乎皆為零

svea
Télécharger la présentation

Monte Carlo Simulation Part.2 Metropolis Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Monte Carlo SimulationPart.2 Metropolis Algorithm Dept. Phys. Tunghai Univ. Numerical Methods C. T. Shih

  2. Simple/Importance Sampling • 當我們用 MC 法計算積分時,若該函數為常數函數 f(x)=constant,則取樣數不管多少,準確度皆為百分之百 • 相對的,如果 f(x) 為 delta 函數,則取樣數不管多少,準確度幾乎皆為零 • 也就是說,如果在積分區間內,f(x) 為一平滑函數,則 MC 法較準確,如果f(x)的變動很劇烈,則 MC 法的誤差會變大

  3. Weight Function: w(x) • 因此,在 f(x) 變化劇烈時,在以 MC 取樣時,最好依據 f(x) 的大小來決定取樣機率 • 亦即:|f(x)| 大的,對∫f(x)dx的貢獻較大,如果沒有被選中則結果的誤差極大 • 解決方式:改變 x 被選中的機率,讓 |f(x)| 大的被選中的機率增加 • Weight distribution function: w(x),決定每個x被選中的機率

  4. Weight Function: w(x) • w(x) 必須歸一化,即在積分區間內∫w(x)dx=1 • 由於 x 的選取已被 w(x) 扭曲,所以計算積分時要把這個部分「還」回去:若一共取樣了M個x,則其積分值為

  5. Metropolis 演算法 • 如何產生一連串的 x,使得 x 的分佈滿足 w(x)?步驟如下: • 由均勻亂數產生一任意 x,a<x<b • 再產生另外一個亂數 x’,a<x’<b • 兩者的機率權重比為 P(x→x’) w(x’)/w(x) • 若 P ≧ 1,則接受 x’ 為新的 x 值 • 若 P < 1,則產生一亂數 y,若 y<P,則接受 x’ 為新的 x,否則下一個被選取的仍然是舊的 x • 如此即可得到一連串的 x,重複此步驟 M 次,將每次所得到的 x 所對應的 f(x)/w(x) 求平均,即為所求之積分近似值

  6. f(x) 與 w(x) • 最好的 w(x) 當然就是 |f(x)| 本身,但是因為 w(x) 必須滿足 ∫w(x)dx=1,所以得先對 w(x) 做積分 → 回到問題的原點 • 但是如果 f(x) 是物理上的 probability distribution function(如波茲曼函數),我們經常要積分的是一些物理量的平均值: • 這類問題即可以 Metropolis algorithm 來產生根據 f(x) 所分佈的 M 個 x

More Related