Skip to content

Commit

Permalink
Updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
themathgeek13 committed Nov 18, 2017
1 parent 74eb960 commit bb9cc6e
Show file tree
Hide file tree
Showing 21 changed files with 1,761 additions and 209 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
848 changes: 848 additions & 0 deletions week5,6_ChebyshevFit&UnstableSeriesSum/error_clenshaw2.xhtml

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified week7_ProbabilityDistbn/3dSurfacePlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified week7_ProbabilityDistbn/RoI_contour.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
212 changes: 212 additions & 0 deletions week7_ProbabilityDistbn/prob_dist.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,218 @@ Finally, the region of interest (|f|<1) is marked below (lies within the
\end_inset


\end_layout

\begin_layout Subsubsection
Monte Carlo Integration
\end_layout

\begin_layout Standard
By using sampling-based integration for obtaining the area of the region
of interest, we can use the upper bound function |Z|=1 and the limits
\begin_inset Formula $-2<x,y<2$
\end_inset

.
The points x,y are chosen uniformly on their intervals, and then the value
of f(x,y) is computed.
If the value is below 1, it is considered to be inside the region of interest.
The total area under consideration is -2<x,y<2, or a total area of 16 units.
This is multiplied to obtain the area within the region of interest as
3.142 units.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

countin = 0
\end_layout

\begin_layout Plain Layout

countout = 0
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

for i in range(1000000):
\end_layout

\begin_layout Plain Layout

...: a,b=np.random.rand(2)*4-2
\end_layout

\begin_layout Plain Layout

...: c=f(a,b)
\end_layout

\begin_layout Plain Layout

...: if abs(c)<1:
\end_layout

\begin_layout Plain Layout

...: countin+=1
\end_layout

\begin_layout Plain Layout

...: else:
\end_layout

\begin_layout Plain Layout

...: countout+=1
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

In [78]: countin/float(countin+countout)
\end_layout

\begin_layout Plain Layout

Out[78]: 0.196376
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

In [79]: 16*countin/float(countin+countout)
\end_layout

\begin_layout Plain Layout

Out[79]: 3.142016
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Poisson Point Process
\end_layout

\begin_layout Standard
A Poisson point process is a stochastic process wherein the number of arrivals
per unit time is defined by the arrival rate
\begin_inset Formula $\lambda$
\end_inset

.
The inter-arrival times are exponentially distributed with mean
\begin_inset Formula $1/\lambda$
\end_inset

.
The PDF is
\begin_inset Formula $f(t)=\lambda\exp(-\lambda t)$
\end_inset

, and the CDF is
\begin_inset Formula $F(t)=1-\exp(-\lambda t)$
\end_inset

.
By using the inverse CDF method, we can obtain the required probability
distribution by using: [SOURCE: https://stackoverflow.com/questions/1155539/how-
do-i-generate-a-poisson-process]
\end_layout

\begin_layout Standard
\begin_inset Formula $-log(1-U)/\lambda=-log(U)/\lambda$
\end_inset

.
\end_layout

\begin_layout Standard
Python provides a function to generate exponentially distributed random
numbers using the above technique:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

import random
\end_layout

\begin_layout Plain Layout

for i in range(1,10):
\end_layout

\begin_layout Plain Layout

print random.expovariate(15)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
The arrival times can be obtained by summing to a moving time variable:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

import random
\end_layout

\begin_layout Plain Layout

t= 0
\end_layout

\begin_layout Plain Layout

for i in range(1,10):
\end_layout

\begin_layout Plain Layout

t+= random.expovariate(15)
\end_layout

\begin_layout Plain Layout

print t
\end_layout

\end_inset


\end_layout

\end_body
Expand Down
Loading

0 comments on commit bb9cc6e

Please sign in to comment.