% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2012_fall_practical_computing_for_scientists/hw05/hw05.tex"
% LAST MODIFICATION: "Mon, 01 Oct 2012 11:06:32 -0400 (evmik)"
% (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com>
% $Id:$
\documentclass[letter,12pt]{article}

%---------------------------------------------------------------
\usepackage{listings}
\usepackage{color}
\usepackage{fullpage}
%---------------------------------------------------------------

\begin{document}
\newcommand{\problem}[1]{%
	{\flushleft  \bf #1\\}
}
\newcommand{\hw}[1]{%
	\begin{center}
		\Large  \bf Homework #1%
	\end{center}%
}
\newcommand{\mat}[1]{% matlab code
{\color{blue}\texttt{#1}}%
}

%---------------------------------------------------------------
\hw{05}

General comments: 
\begin{itemize}
	\item Do not forget to run some test cases. 
\end{itemize}

\problem{Problem 1 (5 points)}
%---------------------------------------------------------------
Estimate the Euler's number $e=2.71\ldots$ via evaluation of
the following integral with the Monte-Carlo method
\begin{eqnarray*}
	e=\int_0^1 (e^x+1) dx
\end{eqnarray*}




\problem{Problem 2 (5 points)}
%---------------------------------------------------------------

For the  problem above. Plot  (in loglog  space) the deviation  of integral
from  its true  value  as a  function  of the  random  points number  ($N$)
spanning from  10 to $10^6$. For  each $N$ do  it at least 100  times, mark
such  points as  small dots  (matlab \mat{'.'}  marker specifier)  on your  plot,
calculate and plot the mean of  the integral value estimation at particular
$N$ with a circle marker (matlab \mat{'o'} marker specifier).

Does the $e$ estimate error drops as $1/\sqrt{N}$?

\problem{Problem 3 (5 points)}
%---------------------------------------------------------------
Consider the LCG random generator with $a=11$, $c=2$, $m=65535$, and
$r_1=1$. What is the best case scenario for the length/period of the random
sequence of a LC generator with $m=65535$? Estimate the actual length of the
non repeating sequence.

\problem{Problem 4 (5 points)}
%---------------------------------------------------------------
Modify the colony life script example to take in account helping neighbors.
Leave the probability to heal for a cell without alive neighbors as it is,
double healing probability for the cell with one alive neighbor, and triple it
if a cell with alive neighbors on both sides. We model that illness does not prevent a
helping/healing action, i.e. a neighbor must be alive to help
but it might have an illness.

{\bf Make sure that you are using matlab random generator i.e. \mat{rand}}.

Does the saying ``the best neighbor is the dead neighbor'' still applies?



%---------------------------------------------------------------
\end{document}
%---------------------------------------------------------------
