Skip to content

Commit

Permalink
For L2-2-
Browse files Browse the repository at this point in the history
  • Loading branch information
wistaria committed Oct 25, 2018
1 parent 97f81c4 commit 278fd84
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 65 deletions.
4 changes: 2 additions & 2 deletions lecture/6_monte_carlo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

\input{6_monte_carlo/randomized.tex}
\input{6_monte_carlo/process.tex}
\input{6_monte_carlo/integration.tex}
\input{6_monte_carlo/rng.tex}
\input{6_monte_carlo/mcmc.tex}
\input{6_monte_carlo/histogram.tex}
\input{6_monte_carlo/integration.tex}
\input{6_monte_carlo/mcmc.tex}
\input{6_monte_carlo/exercise.tex}

\end{document}
40 changes: 37 additions & 3 deletions lecture/6_monte_carlo/process.tex
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
\section{物理過程のシミュレーション}

\begin{frame}[t,fragile]{物質中の中性子輸送}
\begin{center}
\resizebox{0.45\textwidth}{!}{\includegraphics{image/scattering.pdf}}
\end{center}
\end{frame}

\begin{frame}[t,fragile]{物質中の中性子輸送}
\begin{itemize}
\setlength{\itemsep}{1em}
\item 物理過程
\resizebox{0.4\textwidth}{!}{\includegraphics{image/scattering.pdf}}
%\setlength{\itemsep}{1em}
\item ある板状の物質(厚さ$D$)に垂直に中性子が入射したときの吸収率・透過率・反射率
\item 中性子はある確率で物質の原子核に衝突し、確率$p_{\rm c}$で吸収、$p_{\rm s}=1-p_{\rm c}$で散乱される
\begin{itemize}
\item 衝突は確率的に起きるので、次の衝突までの距離$\ell$は指数分布にしたがう($\ell$: 平均自由行程)
\[
p(\ell) = \lambda e^{-\lambda\ell}
\]
\item 衝突時、ランダムな方向に散乱されるとすると
\[
p(\theta,\phi) \, d\theta \, d\phi = \frac{d\Omega}{4\pi} = \frac{\sin \theta}{4\pi} \, d\theta \, d\phi
\]
\[
p(\theta) = \frac{\sin \theta}{2} \qquad p(\phi)=\frac{1}{2\pi}
\]
\end{itemize}
\end{itemize}
\end{frame}

\begin{frame}[t,fragile]{モンテカルロシミュレーション}
\begin{enumerate}
\setlength{\itemsep}{1em}
\item 初期条件 $z=0$, $\theta = 0$
\item {\color{red} 指数分布から$\ell$を選ぶ}
\item $z \leftarrow z + \ell \cos \theta$
\item $z<0$ → 反射(終了) \\
$z>D$ → 透過(終了) \\
$0 < z < D$ → 確率$p_{\rm c}$で吸収(終了)、$p_{\rm s}$で散乱
\item {\color{red} 散乱後の$\theta$を選び}、2に戻る
\end{enumerate}
\vspace*{-5cm}\hspace{8cm}\resizebox{0.25\textwidth}{!}{\includegraphics{image/scattering.pdf}}
\end{frame}

18 changes: 18 additions & 0 deletions lecture/6_monte_carlo/randomized-01.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\begin{frame}[t,fragile]{乱択アルゴリズム(randomized algorithm)}
\begin{itemize}
\setlength{\itemsep}{1em}
\item 実行中に乱数を参照してその値によって振る舞いをかえるアルゴリズム
\item ラスベガスアルゴリズム
\begin{itemize}
\item 乱数の出方によらず常に正しい結果を与えるアルゴリズム
\item 平均化効果を利用するアルゴリズム:クイックソート
\end{itemize}
\item モンテカルロアルゴリズム
\begin{itemize}
\item 乱数の出方によっては誤った結果を与えるアルゴリズム
\item 標本を利用するアルゴリズム:最大カット問題
\item くじ引き型のアルゴリズム:素数性判定、関数の同一性、行列積の検算
\item サンプリングアルゴリズム:モンテカルロ積分、マルコフ連鎖モンテカルロ
\end{itemize}
\end{itemize}
\end{frame}
13 changes: 13 additions & 0 deletions lecture/6_monte_carlo/randomized-02.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\begin{frame}[t,fragile]{乱択クイックソート}
\begin{itemize}
\setlength{\itemsep}{1em}
\item 分割統治法に基づく再帰的なソートアルゴリズム
\begin{itemize}
\item 配列の中から要素を一つ選び、それより小さい要素からのみなる集合と大きい要素のみからなる集合の2つに分ける
\item それぞれの集合をソートし、結合する
\end{itemize}
\item ほぼ同じ大きさの集合に分けることができる場合の実行ステップ数$\sim {\cal O}(n \log n)$
\item 最悪(選んだ要素が常に最大 or 最小値)の場合のステップ数$\sim {\cal O}(n^2)$
\item 分割に用いる要素を「ランダムに」選ぶ $\Rightarrow$ 平均ステップ数$\sim {\cal O}(n \log n)$
\end{itemize}
\end{frame}
3 changes: 3 additions & 0 deletions lecture/6_monte_carlo/randomized-03.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\begin{frame}[t,fragile]{クイックソート}
\resizebox{!}{.9\textheight}{\includegraphics{image/quicksort.pdf}}
\end{frame}
14 changes: 14 additions & 0 deletions lecture/6_monte_carlo/randomized-04.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\begin{frame}[t,fragile]{最小カット問題}
\begin{itemize}
\setlength{\itemsep}{1em}
\item 「最小カット (min-cut)」= 連結グラフを二つの部分に分けるために切らなければならない辺(エッジ)の集合のうち、もっとも小さいもの
\item ``Randomized Min-Cut Algorithm''
\begin{itemize}
\item ランダムに辺を一つ選ぶ
\item 辺の両端の頂点を一つにつぶす(自己ループは取り除く)
\item 残りの頂点が二つになるまで繰り返す
\end{itemize}
\item 上の試行を何回も繰り返して、得られたうちで最小なカットを結果とする
\item 頂点の数が $n$ のグラフに関して、正解が得られる確率:少なくとも $\frac{2}{n(n-1)}$
\end{itemize}
\end{frame}
3 changes: 3 additions & 0 deletions lecture/6_monte_carlo/randomized-05.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\begin{frame}[t,fragile]{最小カット問題}
\resizebox{!}{.6\textheight}{\includegraphics{image/min-cut.pdf}}
\end{frame}
62 changes: 7 additions & 55 deletions lecture/6_monte_carlo/randomized.tex
Original file line number Diff line number Diff line change
@@ -1,57 +1,9 @@
\section{乱択アルゴリズム}

\begin{frame}[t,fragile]{乱択アルゴリズム(randomized algorithm)}
\begin{itemize}
\setlength{\itemsep}{1em}
\item 実行中に乱数を参照してその値によって振る舞いをかえるアルゴリズム
\item ラスベガスアルゴリズム
\begin{itemize}
\item 乱数の出方によらず常に正しい結果を与えるアルゴリズム
\item 平均化効果を利用するアルゴリズム:クイックソート
\end{itemize}
\item モンテカルロアルゴリズム
\begin{itemize}
\item 乱数の出方によっては誤った結果を与えるアルゴリズム
\item 標本を利用するアルゴリズム:最大カット問題
\item くじ引き型のアルゴリズム:素数性判定、関数の同一性、行列積の検算
\item サンプリングアルゴリズム:モンテカルロ積分、マルコフ連鎖モンテカルロ
\end{itemize}
\end{itemize}
\end{frame}

\begin{frame}[t,fragile]{乱択クイックソート}
\begin{itemize}
\setlength{\itemsep}{1em}
\item 分割統治法に基づく再帰的なソートアルゴリズム
\begin{itemize}
\item 配列の中から要素を一つ選び、それより小さい要素からのみなる集合と大きい要素のみからなる集合の2つに分ける
\item それぞれの集合をソートし、結合する
\end{itemize}
\item ほぼ同じ大きさの集合に分けることができる場合の実行ステップ数$\sim {\cal O}(n \log n)$
\item 最悪(選んだ要素が常に最大 or 最小値)の場合のステップ数$\sim {\cal O}(n^2)$
\item 分割に用いる要素を「ランダムに」選ぶ $\Rightarrow$ 平均ステップ数$\sim {\cal O}(n \log n)$
\end{itemize}
\end{frame}
% -*- coding: utf-8 -*-

\begin{frame}[t,fragile]{クイックソート}
\resizebox{!}{.9\textheight}{\includegraphics{image/quicksort.pdf}}
\end{frame}

\begin{frame}[t,fragile]{最小カット問題}
\begin{itemize}
\setlength{\itemsep}{1em}
\item 「最小カット (min-cut)」= 連結グラフを二つの部分に分けるために切らなければならない辺(エッジ)の集合のうち、もっとも小さいもの
\item ``Randomized Min-Cut Algorithm''
\begin{itemize}
\item ランダムに辺を一つ選ぶ
\item 辺の両端の頂点を一つにつぶす(自己ループは取り除く)
\item 残りの頂点が二つになるまで繰り返す
\end{itemize}
\item 上の試行を何回も繰り返して、得られたうちで最小なカットを結果とする
\item 頂点の数が $n$ のグラフに関して、正解が得られる確率:少なくとも $\frac{2}{n(n-1)}$
\end{itemize}
\end{frame}
\section{乱択アルゴリズム}

\begin{frame}[t,fragile]{最小カット問題}
\resizebox{!}{.6\textheight}{\includegraphics{image/min-cut.pdf}}
\end{frame}
\input{randomized-01.tex}
\input{randomized-02.tex}
\input{randomized-03.tex}
\input{randomized-04.tex}
\input{randomized-05.tex}
2 changes: 1 addition & 1 deletion lecture/6_monte_carlo/rng.tex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ \section{擬似乱数}
\item 計算式に従って生成するため、必ず何らかの相関は残る
\item できる限り相関が少なく周期の長い、理想的な乱数の開発が続けられている
\begin{itemize}
\item 現時点で最も品質が高いと考えられている乱数発生器:メルセンヌ・ツイスター
\item 現時点で、標準的な乱数発生器:メルセンヌ・ツイスター
\item 周期 $2^{19937}-1$、高速、日本製! (例: \href{https://github.com/todo-group/computer-experiments/blob/master/exercise/monte_carlo/random.c}{example-2-L2/random.c})
\end{itemize}
\end{itemize}
Expand Down
11 changes: 7 additions & 4 deletions lecture/lecture-2-2.tex
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ \section{多体系の統計力学}
% \setlength{\itemsep}{1em}
\item 数え上げ
\begin{itemize}
\item 計算コスト (指数関数的)
\item 計算コスト × (指数関数的)
\item メモリコスト ○ (${\cal O}(1)$)
\end{itemize}
\item 転送行列法
Expand All @@ -97,11 +97,14 @@ \section{多体系の統計力学}
\end{itemize}
\end{frame}

\input{6_monte_carlo/randomized.tex}
\section{乱択アルゴリズム}
\input{6_monte_carlo/randomized-01.tex}
\input{6_monte_carlo/randomized-02.tex}
\input{6_monte_carlo/randomized-03.tex}

\input{6_monte_carlo/process.tex}
\input{6_monte_carlo/integration.tex}
\input{6_monte_carlo/rng.tex}
\input{6_monte_carlo/integration.tex}
\input{6_monte_carlo/mcmc.tex}
\input{6_monte_carlo/histogram.tex}

\end{document}

0 comments on commit 278fd84

Please sign in to comment.