Newer
Older
Lecture_repo / Lectures_my / EMPP / Lecture2 / mchrzasz.tex
@mchrzasz mchrzasz on 15 Nov 2015 17 KB updated second lecture
\documentclass[11 pt,xcolor={dvipsnames,svgnames,x11names,table}]{beamer}

\usepackage[english]{babel} 
\usepackage{polski}         
\usepackage[skins,theorems]{tcolorbox}
\tcbset{highlight math style={enhanced,
  colframe=red,colback=white,arc=0pt,boxrule=1pt}}

\usetheme[
	bullet=circle,		% Other option: square
	bigpagenumber,		% circled page number on lower right
	topline=true,			% colored bar at the top of the frame 
	shadow=false,			% Shading for beamer blocks
	watermark=BG_lower,	% png file for the watermark
	]{Flip}

%\logo{\kern+1.em\includegraphics[height=1cm]{SHiP-3_LightCharcoal}}
                            

\usepackage[lf]{berenis}
\usepackage[LY1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{emerald}
\usefonttheme{professionalfonts}
\usepackage[no-math]{fontspec}		
\defaultfontfeatures{Mapping=tex-text}	% This seems to be important for mapping glyphs properly

\setmainfont{Gillius ADF}			% Beamer ignores "main font" in favor of sans font
\setsansfont{Gillius ADF}			% This is the font that beamer will use by default
% \setmainfont{Gill Sans Light}		% Prettier, but harder to read

\setbeamerfont{title}{family=\fontspec{Gillius ADF}}

\input t1augie.fd

%\newcommand{\handwriting}{\fontspec{augie}} % From Emerald City, free font
%\newcommand{\handwriting}{\usefont{T1}{fau}{m}{n}} % From Emerald City, free font
% \newcommand{\handwriting}{}	% If you prefer no special handwriting font or don't have augie

%% Gill Sans doesn't look very nice when boldfaced
%% This is a hack to use Helvetica instead
%% Usage: \textbf{\forbold some stuff}
%\newcommand{\forbold}{\fontspec{Arial}}

\usepackage{graphicx}
\usepackage[export]{adjustbox}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{colortbl}
\usepackage{mathrsfs} 			% For Weinberg-esque letters
\usepackage{cancel}				% For "SUSY-breaking" symbol
\usepackage{slashed}            % for slashed characters in math mode
\usepackage{bbm}                % for \mathbbm{1} (unit matrix)
\usepackage{amsthm}				% For theorem environment
\usepackage{multirow}			% For multi row cells in table
\usepackage{arydshln} 			% For dashed lines in arrays and tables
\usepackage{siunitx}
\usepackage{xhfill}
\usepackage{grffile}
\usepackage{textpos}
\usepackage{subfigure}
\usepackage{tikz}
\usepackage{hyperref}
%\usepackage{hepparticles}    
\usepackage[italic]{hepparticles}     

\usepackage{hepnicenames} 

% Drawing a line
\tikzstyle{lw} = [line width=20pt]
\newcommand{\topline}{%
  \tikz[remember picture,overlay] {%
    \draw[crimsonred] ([yshift=-23.5pt]current page.north west)
             -- ([yshift=-23.5pt,xshift=\paperwidth]current page.north west);}}



% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\usepackage{tikzfeynman}		% For Feynman diagrams
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{trees}
\usetikzlibrary{matrix,arrows} 				% For commutative diagram
% http://www.felixl.de/commu.pdf
\usetikzlibrary{positioning}				% For "above of=" commands
\usetikzlibrary{calc,through}				% For coordinates
\usetikzlibrary{decorations.pathreplacing}  % For curly braces
% http://www.math.ucla.edu/~getreuer/tikz.html
\usepackage{pgffor}							% For repeating patterns

\usetikzlibrary{decorations.pathmorphing}	% For Feynman Diagrams
\usetikzlibrary{decorations.markings}
\tikzset{
	% >=stealth', %%  Uncomment for more conventional arrows
	vector/.style={decorate, decoration={snake}, draw},
	provector/.style={decorate, decoration={snake,amplitude=2.5pt}, draw},
	antivector/.style={decorate, decoration={snake,amplitude=-2.5pt}, draw},
	fermion/.style={draw=gray, postaction={decorate},
		decoration={markings,mark=at position .55 with {\arrow[draw=gray]{>}}}},
	fermionbar/.style={draw=gray, postaction={decorate},
		decoration={markings,mark=at position .55 with {\arrow[draw=gray]{<}}}},
	fermionnoarrow/.style={draw=gray},
	gluon/.style={decorate, draw=black,
		decoration={coil,amplitude=4pt, segment length=5pt}},
	scalar/.style={dashed,draw=black, postaction={decorate},
		decoration={markings,mark=at position .55 with {\arrow[draw=black]{>}}}},
	scalarbar/.style={dashed,draw=black, postaction={decorate},
		decoration={markings,mark=at position .55 with {\arrow[draw=black]{<}}}},
	scalarnoarrow/.style={dashed,draw=black},
	electron/.style={draw=black, postaction={decorate},
		decoration={markings,mark=at position .55 with {\arrow[draw=black]{>}}}},
	bigvector/.style={decorate, decoration={snake,amplitude=4pt}, draw},
}

% TIKZ - for block diagrams, 
% from http://www.texample.net/tikz/examples/control-system-principles/
% \usetikzlibrary{shapes,arrows}
\tikzstyle{block} = [draw, rectangle, 
minimum height=3em, minimum width=6em]




\usetikzlibrary{backgrounds}
\usetikzlibrary{mindmap,trees}	% For mind map
\newcommand{\degree}{\ensuremath{^\circ}}
\newcommand{\E}{\mathrm{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand\Ts{\rule{0pt}{2.6ex}}       % Top strut
\newcommand\Bs{\rule[-1.2ex]{0pt}{0pt}} % Bottom strut

\graphicspath{{images/}}	% Put all images in this directory. Avoids clutter.

% SOME COMMANDS THAT I FIND HANDY
% \renewcommand{\tilde}{\widetilde} % dinky tildes look silly, dosn't work with fontspec
%\newcommand{\comment}[1]{\textcolor{comment}{\footnotesize{#1}\normalsize}} % comment mild
%\newcommand{\Comment}[1]{\textcolor{Comment}{\footnotesize{#1}\normalsize}} % comment bold
%\newcommand{\COMMENT}[1]{\textcolor{COMMENT}{\footnotesize{#1}\normalsize}} % comment crazy bold
\newcommand{\Alert}[1]{\textcolor{Alert}{#1}} % louder alert
\newcommand{\ALERT}[1]{\textcolor{ALERT}{#1}} % loudest alert
%% "\alert" is already a beamer pre-defined
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%

\def\Put(#1,#2)#3{\leavevmode\makebox(0,0){\put(#1,#2){#3}}}

\usepackage{gmp}
\usepackage[final]{feynmp-auto}

\usepackage[backend=bibtex,style=numeric-comp,firstinits=true]{biblatex}
\bibliography{bib}
\setbeamertemplate{bibliography item}[text]

\makeatletter\let\frametextheight\beamer@frametextheight\makeatother

% suppress frame numbering for backup slides
% you always need the appendix for this!
\newcommand{\backupbegin}{
	\newcounter{framenumberappendix}
	\setcounter{framenumberappendix}{\value{framenumber}}
}
\newcommand{\backupend}{
	\addtocounter{framenumberappendix}{-\value{framenumber}}
	\addtocounter{framenumber}{\value{framenumberappendix}} 
}


\definecolor{links}{HTML}{2A1B81}
%\hypersetup{colorlinks,linkcolor=,urlcolor=links}

% For shapo's formulas:
\def\lsi{\raise0.3ex\hbox{$<$\kern-0.75em\raise-1.1ex\hbox{$\sim$}}}
\def\gsi{\raise0.3ex\hbox{$>$\kern-0.75em\raise-1.1ex\hbox{$\sim$}}}
\newcommand{\lsim}{\mathop{\lsi}}
\newcommand{\gsim}{\mathop{\gsi}}
\newcommand{\wt}{\widetilde}
%\newcommand{\ol}{\overline}
\newcommand{\Tr}{\rm{Tr}}
\newcommand{\tr}{\rm{tr}}
\newcommand{\eqn}[1]{&\hspace{-0.7em}#1\hspace{-0.7em}&}
\newcommand{\vev}[1]{\rm{$\langle #1 \rangle$}}
\newcommand{\abs}[1]{\rm{$\left| #1 \right|$}}
\newcommand{\eV}{\rm{eV}}
\newcommand{\keV}{\rm{keV}}
\newcommand{\GeV}{\rm{GeV}}
\newcommand{\im}{\rm{Im}}
\newcommand{\disp}{\displaystyle}
\def\be{\begin{equation}}
\def\ee{\end{equation}}
\def\ba{\begin{eqnarray}}
\def\ea{\end{eqnarray}}
\def\d{\partial}
\def\l{\left(}
\def\r{\right)}
\def\la{\langle}
\def\ra{\rangle}
\def\e{{\rm e}}
\def\Br{{\rm Br}}
\def\fixme{{\color{red} FIXME!}}
\def\mc{{\color{Magenta}{MC}}}
\def\pdf{{\rm p.d.f.}}

\author{ {\fontspec{Trebuchet MS}Marcin Chrz\k{a}szcz} (Universit\"{a}t Z\"{u}rich)}
\institute{UZH}
\title[Random number generators and application]{Random number generators and application}
\date{\fixme}


\begin{document}
\tikzstyle{every picture}+=[remember picture]

{
\setbeamertemplate{sidebar right}{\llap{\includegraphics[width=\paperwidth,height=\paperheight]{bubble2}}}
\begin{frame}[c]%{\phantom{title page}} 
\begin{center}
\begin{center}
	\begin{columns}
		\begin{column}{0.9\textwidth}
			\flushright\fontspec{Trebuchet MS}\bfseries \Huge {Random number generators and application}
		\end{column}
		\begin{column}{0.2\textwidth}
		  %\includegraphics[width=\textwidth]{SHiP-2}
		\end{column}
	\end{columns}
\end{center}
	\quad
	\vspace{3em}
\begin{columns}
\begin{column}{0.44\textwidth}
\flushright \vspace{-1.8em} {\fontspec{Trebuchet MS} \Large Marcin Chrząszcz\\\vspace{-0.1em}\small \href{mailto:mchrzasz@cern.ch}{mchrzasz@cern.ch}}

\end{column}
\begin{column}{0.53\textwidth}
\includegraphics[height=1.3cm]{uzh-transp}
\end{column}
\end{columns}

\vspace{1em}
%		\footnotesize\textcolor{gray}{With N. Serra, B. Storaci\\Thanks to the theory support from M. Shaposhnikov, D. Gorbunov}\normalsize\\
\vspace{0.5em}
	\textcolor{normal text.fg!50!Comment}{Experimental Methods in Particle Physics, \\ 19 November, 2015}
\end{center}
\end{frame}
}


\begin{frame}\frametitle{Random and pseudorandom numbers}
  \begin{exampleblock}{John von Neumann:}                                                                                                                                                                                                                                                                                                
''Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin. For, as has been pointed out several times, there is no such thing as a random number — there are only methods to produce random numbers, and a strict arithmetic procedure of course is not such a method.''
        \end{exampleblock} 

$\color{PineGreen}\Rrightarrow$ Random number: a given value that is taken by a random variable $ \twoheadrightarrow$ by definition cannot be predicted.\\
%$\color{PineGreen}\Rrightarrow$ Sequence of random numbers $\twoheadrightarrow$ 
$\color{PineGreen}\Rrightarrow$ Sources of truly random numbers:
\begin{itemize}
\item Mechanical
\item Physical
\end{itemize}
$\color{PineGreen}\Rrightarrow$ Disadvantages of physical generators:
\begin{itemize}
\item To slow for typical applications, especially the mechanical ones!
\item Not stable; small changes in boundary conditions might lead to completely different results!
\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Random numbers - history remark}
$\color{PineGreen}\Rrightarrow$ In the past there were books with random numbers:
\begin{center}
\includegraphics[width=0.55\textwidth]{images/million-random-digits-open.jpg}
  \end{center}
$\color{PineGreen}\Rrightarrow$ It's obvious that they didn't become very popular ;)\\
$\color{PineGreen}\Rrightarrow$ This methods are comming back!\\
$\color{PineGreen}\twoheadrightarrow$ Storage device are getting more cheap and bigger (CD, DVD).\\
$\color{PineGreen}\twoheadrightarrow$ 1995: G. Marsaglia, $650\rm MB$ of random numbers, ''White and Black Noise''.


\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Pseudorandom numbers}
$\color{PineGreen}\Rrightarrow$ Pseudorandom numbers are numbers that are generated accordingly to strict mathematical formula. \\
$\color{PineGreen}\looparrowright$ Strictly speaking they are non random numbers, how ever they have all the statistical properties of random numbers.\\
$\color{PineGreen}\looparrowright$  Discussing those properties is a wide topic so let's just say that without knowing the formula they are generated by one cannot say if those numbers are random or not.\\
$\color{PineGreen}\Rrightarrow$  Mathematical methods of producing pseudorandom numbers:
\begin{itemize}
\item Good statistical properties of generated numbers.
\item Easy to use and fast!
\item Reproducible!
\end{itemize}
$\color{PineGreen}\Rrightarrow$ Since mathematical pseudorandom genrators are dominantly:  pseudorandom $\rightarrowtail$ random.


\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Middle square generator; von Neumann}
$\color{PineGreen}\Rrightarrow$  The first mathematical generator (middle square) was proposed by von Neumann (1964).\\{~}\\
$\color{PineGreen}\looparrowright$ Formula: $
\tcbhighmath[fuzzy halo=0.5mm with PineGreen!50!white,arc=0.1pt,
  boxrule=0pt,frame hidden]{ X_n= \lfloor X_{n-1}^2\cdot 10 ^{-m} \rfloor - \lfloor X_{n-1}^2\cdot 10^{-3m} \rfloor}
$

$\color{PineGreen}\looparrowright$ where $X_0$ is a constant (seed), $\lfloor\cdot\rfloor$ is the cut-off of a number to integer.\\
$\color{PineGreen}\Rrightarrow$  Example:\\
{~}{~}Let's put $m=2$ and $X_0=2045$:\\
\begin{columns}
\column{0.1\textwidth}
{~}
\column{0.4\textwidth}
$\color{PineGreen}\looparrowright$ $X_0^2=\underbrace{04}_{\rm rej}1820\underbrace{25}_{\rm rej}$
\column{0.3\textwidth}
 $\Rightarrow X_1=1820$
\end{columns}
\begin{columns}
\column{0.1\textwidth}
{~}
\column{0.4\textwidth}
$\color{PineGreen}\looparrowright$ $X_1^2=\underbrace{03}_{\rm rej}3124\underbrace{00}_{\rm rej}$
\column{0.3\textwidth}
 $\Rightarrow X_1=3124$
\end{columns}
$\color{PineGreen}\looparrowright$ Simple generator but unfortunately quite bad generator. Firstly the sequences are very short and strongly dependent on the $X_0$ number.



\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Linear generators}

$\color{PineGreen}\Rrightarrow$ General equation:
\begin{equation}
\tcbhighmath[fuzzy halo=0.5mm with PineGreen!50!white,arc=0.1pt,
  boxrule=0pt,frame hidden]{X_n=(a_1X_{n-1} + a_2X_{n-2}+...+a_kX_{n-k}+c)~{\rm mod}~m    ,} \nonumber
\end{equation}
$\color{PineGreen}\looparrowright$ where $a_i,c,m$ are parameters of a generator(integer numbers).\\
$\color{PineGreen}\looparrowright$  Generator initialization $\color{PineGreen} \rightleftarrows$ setting those parameters.\\
$\color{PineGreen}\Rrightarrow$ Very old generators. (often used in Pascal, or first C versions):
\begin{columns}
\column{0.1\textwidth}
{~}
\column{0.8\textwidth}
$k=1:~X_n=(aX_{n-1} +c )~{\rm mod} m,$
$c=
\begin{cases}
=0, {\rm multiplicative geneator}\\
\neq 0, {\rm mix geneator}
\end{cases}
$
\column{0.1\textwidth}
{~}


\end{columns}
$\color{PineGreen}\Rrightarrow$ The period can be achieved by tuning the seed parameters:\\
$P_{{\rm max}}=
\begin{cases}
2^{L-2};~{\rm for~} m=2^L\\
m-1;~{\rm for~} m= {\rm prime~number}
\end{cases}
$
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Linear generators; examples}

$\color{PineGreen}\Rrightarrow$ General equation:
\begin{equation}
\tcbhighmath[fuzzy halo=0.5mm with PineGreen!50!white,arc=0.1pt,
  boxrule=0pt,frame hidden]{X_n=(a_1X_{n-1} + a_2X_{n-2}+...+a_kX_{n-k}+c)~{\rm mod}~m    ,} \nonumber
\end{equation}
$\color{PineGreen}\looparrowright$ where $a_i,c,m$ are parameters of a generator(integer numbers).\\
$\color{PineGreen}\looparrowright$  Generator initialization $\color{PineGreen} \rightleftarrows$ setting those parameters.\\
$\color{PineGreen}\Rrightarrow$ Very old generators. (often used in Pascal, or first C versions):
\begin{columns}
\column{0.1\textwidth}
{~}
\column{0.8\textwidth}
$k=1:~X_n=(aX_{n-1} +c )~{\rm mod} m,$
$c=
\begin{cases}
=0, {\rm multiplicative~geneator}\\
\neq 0, {\rm mix~geneator}
\end{cases}
$
\column{0.1\textwidth}
{~}


\end{columns}
$\color{PineGreen}\Rrightarrow$ The period can be achieved by tuning the seed parameters:\\
$P_{{\rm max}}=
\begin{cases}
2^{L-2};~{\rm for~} m=2^L\\
m-1;~{\rm for~} m= {\rm prime~number}
\end{cases}
$
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Shift register generator}
\begin{small}
$\color{PineGreen}\Rrightarrow$ General equation:
\begin{equation}
\tcbhighmath[fuzzy halo=0.5mm with PineGreen!50!white,arc=0.1pt,
  boxrule=0pt,frame hidden]{b_n=(a_1X_{n-1} + a_2X_{n-2}+...+a_kX_{n-k}+c)~{\rm mod}~2    ,} \nonumber
\end{equation}
where $a_i \subset(\lbrace0,1\rbrace )$\\
$\color{PineGreen}\Rrightarrow$ Super fast and easy to implement due to: $(a+b) ~{\rm mod}~2 = a~{\rm xor}~b$
\begin{center}
\begin{tabular}{||c|c|c||}
\hline \hline a & b & a xor b\\ \hline
0 & 0 & 0\\
1 & 0 & 1\\
0 & 1 & 1\\
1 & 1 & 0\\ \hline \hline
\end{tabular}
\end{center}
$\color{PineGreen}\Rrightarrow$ Maximal period is $2^k-1$.\\
$\color{PineGreen}\Rrightarrow$ Example (Tausworths generator):\\
$a_p=a_q=1$, other $a_i=0$ and $p>q$. Then: $b_n=b_{n-p}~{\rm xor}~b_{n-q}$

$\color{PineGreen}\Rrightarrow$ How to get numbers from bits (for example):\\
$U_i = \sum_{j=1}^L 2^{-j} b_{is+j},~s<L$.

\end{small}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Fibonacci generator}
\begin{small}
$\color{PineGreen}\Rrightarrow$ In 1202 Fibonacci with Leonardo in Piza:
\begin{equation}
f_n=f_{n-2}+f_{n-1},~n\geqslant 2 \nonumber
\end{equation}
$\color{PineGreen}\Rrightarrow$ Based on this first generator was created (Taussky and Todd, 1956):
\begin{equation}
X_n=(X_{n-2}+X_{n-1})~{\rm mod}~m,~n\geqslant 2 \nonumber
\end{equation}
This generator isn't so good in terms of statistics tests.\\
$\color{PineGreen}\Rrightarrow$ Generalization:
\begin{equation}
X_n=(X_{n-r} \odot X_{n-s})~{\rm mod}~m,~n \geqslant r ,~s \geqslant 1 \nonumber
\end{equation}\begin{center}

\begin{tabular}{||c|c|c||}
\hline \hline $\bigodot$ & $P_{max}$ & Stat. properties \\ \hline
$+,-$ & $(2^r-1)2^{L-1}$ & good \\
$x$ & $(2^r-1)2^{L-13}$ & very good \\
$xor$ & $(2^r-1)$ & poor \\ \hline \hline 
\end{tabular}


\end{center}

\end{small}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Multiply with carry, generator}
\begin{small}


\end{small}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Subtract with borrow, generator}
\begin{small}


\end{small}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Non linear generators}
\begin{small}


\end{small}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}\frametitle{Non linear generators}
\begin{small}


\end{small}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%5
%% Stat tests$





\backupbegin   

\begin{frame}\frametitle{Backup}


\end{frame}

\backupend			

\end{document}