% This is a simple LaTex sample document that gives a submission format
%   for IEEE PAMI-TC conference submissions.  Use at your own risk.

% Make two column format for LaTex 2e.\
\documentclass[12pt,twocolumn]{article} %,twocolumn

%\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
%\documentstyle[times,twocolumn]{article}
\usepackage[dvips]{graphicx,graphics}
% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{9.2in} \setlength{\textwidth}{6.875in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.1875in}  % Centers text.
\setlength{\evensidemargin}{-.1875in}

% Add the period after section numbers.  Adjust spacing.
\newcommand{\Section}[1]{\vspace{-8pt}\section{\hskip -1em.~~#1}\vspace{-3pt}}
\newcommand{\SubSection}[1]{\vspace{-3pt}\subsection{\hskip -1em.~~#1}
        \vspace{-3pt}}
\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand {\diff}[1] {\frac{\partial}{\partial #1}}
\newcommand{\jacob}[3]{\frac{\partial^2 #3}{\partial #1 \partial #2}}
\newcommand{\der}[2]{\frac{\partial #2}{\partial #1}}
\begin{document}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 471: Lecture 2\\
Integral Transform Method}
% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
% For two authors (default example)
\maketitle \thispagestyle{empty}
\begin{enumerate}

\item Uniform random numbers $U \sim Unif(0,1)$. Using $U$,
generate 1000 uniform random numbers $X \sim Unif(-1,5)$.

\begin{verbatim}
>> u = rand(1000,1);
>> size(u)
ans =
        1000           1
>> x = 4*u-1;
>> rand
ans =
    0.4048
>> rand
ans =
    0.6271
>> s=rand('state')
s =
    0.8598
    0.1398
    ......
>> rand('state',s)
>> rand
ans =
    0.4048
\end{verbatim}

\item Theorem (Integral transform method). For an increasing
function $g$ with inverse function $g^{-1}$, if  $U \sim
Unif(0,1)$, $g^{-1}(U) \sim g$. {\em Proof.} See lecture note.

\item Generate 1000 random numbers whose probability density
function is $f(x) = x$ for $(0,\sqrt{2})$ and $0$ otherwise.\\
{\em Solution.} We need to generate a random variable whose
cumulative distribution function (c.d.f.) is $F(x)=x^2/2$. The
inverse is given by $F^{-1}(x) = \sqrt{2x}$.
\begin{verbatim}
>>sqrt(2*rand(1000,1))
\end{verbatim}

\item Theoretically you can generate any random variables from the
uniform distribution but the disadvantage of the integral
transform method is that it is practical only if the c.d.f. are
explicitly available. For instance the c.d.f. of a normal r.v. can
not be expressed explicitly. If $X \sim N(0,1)$, the c.d.f. of $X$
is given by
$$\Phi(x) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^x
\exp \Big(\frac{z^2}{2}\Big) \;dz.$$ It can be shown that
$$\Phi^{-1}(x) \approx t - \frac{a_0 + a_1 t}{1 + b_1 t + b_2
t^2}$$ for some constants $a_i$ and $b_i$ $(t^2= -2 \log x)$.


\item Generate 1000 random numbers from exponential distribution
with parameter $\lambda$.\\
 {\em Solution.} $f(x)=e^{-\lambda
x}/\lambda$. $F(x) = 1 - e^{-\lambda x}$. $F^{-1}(x) =
-\frac{1}{\lambda}\ln(1 -x)$. Then $-\frac{1}{\lambda} \ln (1 - U)
\sim exp (\lambda)$. Since $ 1-U \sim Unif(0,1)$ as well,
$-\frac{1}{\lambda} \ln U \sim exp (\lambda)$. In the case
$\lambda =2$,
\begin{verbatim}
>> U=rand(1000,1);
>> X=-log(U)/2;
\end{verbatim}

\item Read Chapter 4 and 5.

\end{enumerate}
\end{document}
