📄 random number generation.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0066)http://www-stat.stanford.edu/~susan/courses/b494/index/node47.html -->
<!--Converted with LaTeX2HTML 2K.1beta (1.57)original version by: Nikos Drakos, CBLU, University of Leeds* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>Random Number Generation</TITLE>
<META content="Random Number Generation" name=description>
<META content=t name=keywords>
<META content=document name=resource-type>
<META content=global name=distribution>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2523" name=GENERATOR>
<META http-equiv=Content-Style-Type content=text/css><LINK
href="Random Number Generation.files/t.css" rel=STYLESHEET><LINK
href="node44.html" rel=previous><LINK href="node22.html" rel=up><LINK
href="node48.html" rel=next></HEAD>
<BODY><!--Navigation Panel--><A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node48.html"
name=tex2html771><IMG height=24 alt=next
src="Random Number Generation.files/next.png" width=37 align=bottom
border=0></A> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node22.html"
name=tex2html767><IMG height=24 alt=up
src="Random Number Generation.files/up.png" width=26 align=bottom border=0></A>
<A href="http://www-stat.stanford.edu/~susan/courses/b494/index/node46.html"
name=tex2html763><IMG height=24 alt=previous
src="Random Number Generation.files/prev.png" width=63 align=bottom
border=0></A> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node124.html"
name=tex2html769><IMG height=24 alt=index
src="Random Number Generation.files/index.png" width=43 align=bottom
border=0></A> <BR><B>Next:</B> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node48.html"
name=tex2html772>Congruential Methods</A> <B>Up:</B> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node22.html"
name=tex2html768>Numerical Analysis for Statisticians</A> <B>Previous:</B> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node46.html"
name=tex2html764>Examples</A> <B><A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node124.html"
name=tex2html770>Index</A></B> <BR><BR><!--End of Navigation Panel-->
<H1><A name=SECTION002100000000000000000>Random Number Generation</A> </H1>Read
the following web site pages: <A
href="http://www.maa.org/mathland/mathland_4_22.html"
name=tex2html4>http://www.maa.org/mathland/mathland_4_22.html</A>
<P><A href="http://stat.fsu.edu/~geo/diehard.html"
name=tex2html5>http://stat.fsu.edu/<IMG height=52 alt=$\~$
src="Random Number Generation.files/img268.png" width=337 align=bottom
border=0>geo/diehard.html</A>
<P>And read chapter 7 of Numerical Recipes.
<P><B>Motivation</B>: <BR>Random numbers are used: <BR>1- To solve problems that
are too complex (stochastic algorithms for NP complete problems)
<P>2- For optimization (simulated annealing, genetic algorithms).
<P>3- System Simulation (physics and biology, econometrics...)
<P>4- Non-parametric tests, bootstrap, permutation tests.
<P>5- Quadrature methods using Monte Carlo.
<P>Solving a deterministic problem by rewriting it as equivalent to a problem
with a stochastic component.
<P>Little Example as a reminder of what Monte-Carlo is: <BR>
<P></P>
<DIV align=center><!-- MATH \begin{displaymath}\theta=\int_0^1 f(t)dt\end{displaymath} --><IMG
height=37 alt="\begin{displaymath}\theta=\int_0^1 f(t)dt\end{displaymath}"
src="Random Number Generation.files/img269.png" width=71 border=0> </DIV><BR
clear=all>
<P></P>
<P>If this exists it can be seen as <IMG height=37 alt=$E(f(X))$
src="Random Number Generation.files/img270.png" width=42 align=middle border=0>
where <IMG height=17 alt=$X$ src="Random Number Generation.files/img12.png"
width=22 align=bottom border=0> has a uniform distribution on <IMG height=65
alt=$[0,1]$ src="Random Number Generation.files/img271.png" width=347
align=middle border=0>. So we approximate it with <BR>
<P></P>
<DIV align=center><!-- MATH \begin{displaymath}\hat{\theta}= \frac{1}{N}\sum_{i=1}^N f(X_i)\end{displaymath} --><IMG
height=18
alt="\begin{displaymath}\hat{\theta}= \frac{1}{N}\sum_{i=1}^N f(X_i)\end{displaymath}"
src="Random Number Generation.files/img272.png" width=48 border=0> </DIV><BR
clear=all>
<P></P>for a sample of size <IMG height=17 alt=$N$
src="Random Number Generation.files/img76.png" width=22 align=bottom border=0>
of uniform random variables.
<P>Most methods, even if they need non-uniform random variates, as in
simulation, still use uniform random variables as their starting points.
<P>So we will spend some time explaining the basics of random numbers.
<P>The machine being deterministic, there is definitely a problem, we will never
get purely random numbers, they will only look so.
<P>(We already saw that there are some pretty bad ones, when we did the
multidimensional visualization of the <B>IBM randu</B> generated numbers with
xgobi).
<P>Also beware of <IMG height=31 alt=$srand$
src="Random Number Generation.files/img273.png" width=383 align=bottom
border=0>, the basic unix one is bad.
<P>Every time I reconnect to matlab, it provides the same random number the
first time I ask for one: <PRE>>> rand
ans = 0.9501
</PRE>
<P>So it is quite predictable, and I could prove I am psychic.
<P><BR>
<HR>
<!--Table of Child-Links--><A name=CHILD_LINKS><STRONG>Subsections</STRONG></A>
<UL>
<LI><A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node48.html"
name=tex2html773>Congruential Methods</A>
<LI><A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node49.html"
name=tex2html774>Other `Better?' Methods</A> </LI></UL><!--End of Table of Child-Links-->
<HR>
<!--Navigation Panel--><A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node48.html"
name=tex2html771><IMG height=24 alt=next
src="Random Number Generation.files/next.png" width=37 align=bottom
border=0></A> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node22.html"
name=tex2html767><IMG height=24 alt=up
src="Random Number Generation.files/up.png" width=26 align=bottom border=0></A>
<A href="http://www-stat.stanford.edu/~susan/courses/b494/index/node46.html"
name=tex2html763><IMG height=24 alt=previous
src="Random Number Generation.files/prev.png" width=63 align=bottom
border=0></A> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node124.html"
name=tex2html769><IMG height=24 alt=index
src="Random Number Generation.files/index.png" width=43 align=bottom
border=0></A> <BR><B>Next:</B> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node48.html"
name=tex2html772>Congruential Methods</A> <B>Up:</B> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node22.html"
name=tex2html768>Numerical Analysis for Statisticians</A> <B>Previous:</B> <A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node46.html"
name=tex2html764>Examples</A> <B><A
href="http://www-stat.stanford.edu/~susan/courses/b494/index/node124.html"
name=tex2html770>Index</A></B> <!--End of Navigation Panel-->
<ADDRESS>Susan Holmes 2002-01-12 </ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -