home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-06 | 86.1 KB | 1,303 lines |
- Newsgroups: comp.sources.unix
- From: cthombor@theory.lcs.mit.edu (Clark D. Thomborson)
- Subject: v28i031: mrandom-3.0 - random number generator with persistent state, Part05/06
- References: <1.768285901.18944@gw.home.vix.com>
- Sender: unix-sources-moderator@gw.home.vix.com
- Approved: vixie@gw.home.vix.com
-
- Submitted-By: cthombor@theory.lcs.mit.edu (Clark D. Thomborson)
- Posting-Number: Volume 28, Issue 31
- Archive-Name: mrandom-3.0/part05
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 5 (of 6)."
- # Contents: doc/mrandom.ps.2
- # Wrapped by vixie@gw.home.vix.com on Fri May 6 21:42:56 1994
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'doc/mrandom.ps.2' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/mrandom.ps.2'\"
- else
- echo shar: Extracting \"'doc/mrandom.ps.2'\" \(85170 characters\)
- sed "s/^X//" >'doc/mrandom.ps.2' <<'END_OF_FILE'
- X%%Page: 2 5
- Xbop 262 162 a Fi(2)41 b(FILES)14 b(IN)g(THE)g(DISTRIBUTION)g(DIRECTOR)m(Y)468
- Xb Fl(2)262 307 y Fk(2)69 b(Files)21 b(in)h(the)g(Distribution)f(Directory)262
- X398 y Fl(The)14 b(mrandom)d(source)k(co)q(de)g(distribution)e(includes)h(the)
- Xh(follo)o(wing)c(\014les:)262 489 y Fh(mak)o(e\014le)19 b Fl(The)g(mak)o
- X(e\014le)d(for)j(creating)f(the)h Ff(mrtest)e Fl(program)g(and)h(the)i
- XFf(mrandom.a)365 539 y Fl(library)m(.)262 622 y Fh(README)h
- XFl(General)9 b(information)d(ab)q(out)k(the)g(mrandom)c(pac)o(k)n(age,)j
- X(including)f(c)o(hanges)365 672 y(to)14 b(the)h(last)e(v)o(ersion.)262
- X755 y Fh(mrandom.c)h(mrandom.h)19 b Fl(The)14 b(source)i(and)d(header)i
- X(\014les)g(for)e(the)i(main)d(mrandom)365 805 y(mo)q(dule.)262
- X888 y Fh(b)q(en)o(tley)l(.c)i(b)q(en)o(tley)l(.h)k Fl(The)f(source)h(and)e
- X(header)h(\014les)g(for)f(Ben)o(tley's)h(v)o(ersion)f(of)g(the)365
- X938 y(generator)f(describ)q(ed)h(in)d(Kn)o(uth)h(V)m(ol)f(2,)g(Section)i
- X(3.6.)262 1021 y Fh(p)q(crand.c)g(p)q(crand.h)k Fl(The)g(source)h(and)e
- X(header)h(\014les)f(for)g(the)h(P)o(ortable)f(Com)o(bined)365
- X1071 y(RNG.)262 1154 y Fh(ran0.c)d(ran0.h)g(ran1.c)h(ran1.h)f(ran2.c)g
- X(ran2.h)20 b Fl(The)12 b(source)h(and)f(header)h(\014les)f(for)365
- X1203 y(Press)k(and)e(T)m(euk)o(olsky's)f(ran0,)g(ran1,)g(and)h(ran2.)262
- X1286 y Fh(ultra.c)g(ultra.h)19 b Fl(The)14 b(source)h(and)f(header)h(\014les)
- Xf(for)g(Marsaglia's)e(Ultra)i(generator.)262 1369 y Fh(mrtest.c)19
- Xb Fl(The)14 b(mrtest)g(source)h(\014le.)262 1452 y Fh(xsq.c)h(xsq.h)21
- Xb Fl(Co)q(de)14 b(used)h(b)o(y)f(mrtest.)262 1536 y Fh(rngs.h)19
- Xb Fl(The)14 b(header)h(\014le)f(for)g(the)g(UNIX)g(RNGs)g(and)f(the)i
- X(trivial)d(RNG.)262 1619 y Fh(newrng.c)j(newrng.h)k Fl(Source)c(and)f(header)
- Xh(\014le)f(templates)f(for)h(a)f(new)h(RNG.)262 1702 y Fh(mrandom.3)19
- Xb Fl(The)14 b(man)e(pages)j(for)e(mrandom.)262 1785 y Fh(mrtest.1)19
- Xb Fl(The)14 b(man)e(pages)i(for)g(mrtest.)262 1868 y Fh(script)k
- XFl(A)c(test)h(script)g(for)e(mrtest.)262 1951 y Fh(mrandom.tex)19
- Xb Fl(The)14 b(latex)f(source)j(for)d(this)h(man)o(ual.)262
- X2034 y Fh(latexinfo.st)n(y)k Fl(The)c(st)o(yle)h(\014le)e(needed)j(to)e
- X(latex)f(this)h(man)o(ual.)262 2117 y Fh(mrandom.txt)k Fl(Plain)13
- Xb(ASCI)q(I)h(text)h(v)o(ersion)f(of)f(this)h(man)o(ual.)262
- X2200 y Fh(mrandom.ps)k Fl(P)o(ostScript)d(v)o(ersion)f(of)f(this)h(man)o
- X(ual.)p eop
- X%%Page: 3 6
- Xbop 262 162 a Fi(3)41 b(INST)m(ALLING)13 b(MRANDOM)845 b Fl(3)262
- X307 y Fk(3)69 b(Installing)21 b(mrandom)262 398 y Fl(Preparing)16
- Xb(the)h(mrandom)c(pac)o(k)n(age)j(for)g(use)h(b)o(y)f(other)h(programs)e(is)h
- X(simple.)24 b(Merely)262 448 y(p)q(osition)13 b(y)o(ourself)g(in)h(the)g
- X(directory)h(whic)o(h)f(con)o(tains)g(the)g(mrandom)d(\014les)j(and)g(t)o(yp)
- Xq(e:)324 548 y Ff(make)21 b(all)324 647 y Fl(This)12 b(will)e(compile)g(all)h
- X(necessary)j(source)f(\014les)g(and)e(create)j(the)e Ff(mrandom.a)e
- XFl(library)m(,)262 697 y(as)j(w)o(ell)h(as)g(the)g Ff(mrtest)f
- XFl(binary)g(executable.)324 747 y(Y)m(ou)i(can)i(also)e(mak)o(e)g(either)i
- X(the)g Ff(mrandom.a)d Fl(library)i(or)g(the)g Ff(mrtest)f Fl(executable)262
- X797 y(b)o(y)e(t)o(yping:)324 896 y Ff(make)21 b(mrandom.a)324
- X996 y Fl(or)324 1095 y Ff(make)g(mrtest)262 1195 y Fl(resp)q(ectiv)o(ely)m(.)
- X324 1245 y(T)m(o)13 b(sa)o(v)o(e)h(disk)g(space,)g(v)n(arious)f(in)o
- X(termediate)g(ob)r(ject)i(\014les)f(can)g(b)q(e)h(remo)o(v)o(ed)e(with:)324
- X1345 y Ff(make)21 b(clean)324 1444 y Fl(The)14 b(system)g(can)g(b)q(e)g
- X(restored)i(to)e(its)g(original)e(state)i(with:)324 1544 y
- XFf(make)21 b(realclean)324 1643 y Fl(The)14 b(mrandom)e(pac)o(k)n(age)h(is)h
- X(written)h(in)f(ANSI)g(C,)g(and)g(should)g(b)q(e)h(easily)e(p)q(ortable)262
- X1693 y(to)h(an)o(y)g(UNIX-based)i(system)e(supp)q(orting)h(a)f(C)h(language)e
- X(compiler.)19 b(Ho)o(w)o(ev)o(er,)c(when)262 1743 y(compiling)8
- Xb(on)j(a)g(new)h(system,)f(con\014rm)g(that)g(the)h Ff(long)f
- XFl(t)o(yp)q(e)h(is)f(represen)o(ted)j(in)d(32)g(bits.)262 1880
- Xy Fk(4)69 b(What)23 b(is)f(an)i(RNG?)262 1971 y Fl(Within)9
- Xb(the)j(mrandom)7 b(pac)o(k)n(age,)k(an)g(RNG)f(is)g(represen)o(ted)k(b)o(y)c
- X(the)i Ff(RNGdata)d Fl(structure.)262 2021 y(An)i(RNG)g(has)h(sev)o(eral)g
- X(abstract)g(c)o(haracteristics)i(whic)o(h)d(are)h(describ)q(ed)i(in)d(this)g
- X(section.)262 2071 y(F)m(or)j(a)g(more)g(detailed)h(description)g(of)g(the)g
- X(represen)o(tation)h(of)f(the)g Ff(RNGdata)e Fl(structure)262
- X2121 y(in)g(C,)g(see)i(App)q(endix)g(A.)324 2171 y(Asso)q(ciated)g(with)e(ev)
- Xo(ery)i(RNG)e(is:)324 2254 y Fe(\017)20 b Fl(an)d(algorithm)d(n)o(um)o(b)q
- X(er,)j(whic)o(h)f(determines)i(whic)o(h)f(algorithm)d(the)j(RNG)f(uses)365
- X2303 y(to)h(pro)q(duce)h(pseudorandom)e(generates.)29 b(F)m(or)16
- Xb(descriptions)i(of)e(the)i(algorithms)365 2353 y(whic)o(h)c(are)g(curren)o
- X(tly)h(installed)e(in)h(the)g(pac)o(k)n(age,)f(see)j(App)q(endix)e(B.)p
- Xeop
- X%%Page: 4 7
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)645
- Xb Fl(4)324 307 y Fe(\017)20 b Fl(an)13 b(\\mrandom)e(algorithm)f(n)o(um)o(b)q
- X(er,")i(whic)o(h)h(determines)h(whic)o(h)f(algorithm)e(the)365
- X357 y Ff(mrandomrv)d Fl(routine)h(will)f(use)i(to)f(pro)q(duce)i
- X(restricted-range)g(in)o(tegers)f(when)g(called)365 407 y(with)h(the)h(RNG.)d
- X(\(See)j(the)g(description)f(of)g Ff(mrandomrv)e Fl(in)h(Section)i(5.4.2)d
- X(for)i(more)365 457 y(information.\))324 533 y Fe(\017)20 b
- XFl(a)14 b(state)h(v)o(ector,)f(whic)o(h)g(con)o(tains)f(the)i(curren)o(t)g
- X(state)g(of)e(the)i(RNG.)324 609 y Fe(\017)20 b Fl(the)15 b(size)f(of)g(the)g
- X(state)h(v)o(ector.)324 685 y Fe(\017)20 b Fl(a)12 b(seed)i(v)o(ector,)f
- X(whic)o(h)f(con)o(tains)g(the)h(seeds)h(whic)o(h)f(w)o(ere)g(used)g(to)f
- X(seed)i(the)f(RNG.)324 762 y Fe(\017)20 b Fl(the)15 b(size)f(of)g(the)g(seed)
- Xh(v)o(ector.)324 838 y Fe(\017)20 b Fl(a)f(coun)o(t)g(of)g(the)h(n)o(um)o(b)q
- X(er)e(of)h(times)f(the)h(RNG)g(has)g(b)q(een)h(called)f(since)h(it)f(w)o(as)
- X365 888 y(initialized.)324 964 y Fe(\017)h Fl(t)o(w)o(o)14
- Xb(bu\013ers)412 1040 y Fh({)21 b Fl(a)13 b(bit)h(bu\013er)h(for)e(bit)h
- X(generates)412 1100 y Fh({)21 b Fl(a)13 b(main)f(bu\013er)j(for)e(all)g
- X(other)i(generates.)365 1176 y(See)g(Section)f(5.4.2)f(for)g(a)h(description)
- Xg(of)f(ho)o(w)h(the)g(t)o(w)o(o)g(bu\013ers)h(w)o(ork.)324
- X1252 y Fe(\017)20 b Fl(a)11 b(split)f(v)n(alue,)g(whic)o(h)g(determines)h(ho)
- Xo(w)f(man)o(y)f(generates)j(to)f(skip)f(b)q(et)o(w)o(een)i(v)n(alues)365
- X1302 y(whic)o(h)j(are)f(returned)j(from)12 b(the)j(RNG.)f(F)m(or)g(a)g
- X(detailed)g(description)h(of)f(the)h(split)365 1352 y(v)n(alue,)e(see)i
- X(Section)f(5.4.7.)324 1428 y Fe(\017)20 b Fl(a)14 b(string)g(con)o(taining)f
- X(the)h(h)o(uman-readable)f(name)f(of)h(the)i(RNG.)324 1504
- Xy Fe(\017)20 b Fl(the)12 b(range)g(of)f(the)h(RNG,)e(suc)o(h)i(that)g(the)g
- X(RNG)f(is)g(capable)g(of)g(pro)q(ducing)h(in)o(tegers)365 1554
- Xy(with)i(a)f(maxim)o(um)c(v)n(alue)k(of)h(range-1.)262 1689
- Xy Fk(5)69 b(Using)22 b(the)h(mrandom)g(pac)n(k)l(age)262 1788
- Xy Fd(5.1)55 b(Ov)n(erview)18 b(of)g(the)h(Library)262 1864
- Xy Fl(This)14 b(section)i(describ)q(es)g(the)g(mrandom)11 b(library)m(.)20
- Xb(The)15 b(pro)q(cedures)i(in)d(the)h(library)f(are)262 1914
- Xy(gathered)g(in)o(to)f(the)i(follo)o(wing)c(groups:)324 1984
- Xy Fe(\017)20 b Fl(functions)14 b(for)g(initializing)d(and)j(de-initializing)d
- X(\(killing\))h(RNGs)324 2060 y Fe(\017)20 b Fl(functions)14
- Xb(for)g(returning)g(generates)i(from)c(RNGs)324 2136 y Fe(\017)20
- Xb Fl(functions)14 b(for)g(sa)o(ving)f(and)h(restarting)g(RNGs)324
- X2212 y Fe(\017)20 b Fl(a)14 b(function)f(for)h(seeding)h(RNGs)324
- X2289 y Fe(\017)20 b Fl(a)14 b(function)f(for)h(c)o(hec)o(king)g(the)h(in)o
- X(tegrit)o(y)e(of)g(RNG)g(state)i(v)o(ectors)324 2365 y Fe(\017)20
- Xb Fl(a)13 b(function)g(for)g(pro)q(ducing)h(a)f(h)o(uman-readable)e(ASCI)q(I)
- Xj(description)g(of)e(an)h(RNG)324 2441 y Fe(\017)20 b Fl(functions)14
- Xb(for)g(examining)d(and)j(mo)q(difying)d(c)o(haracteristics)16
- Xb(of)d(RNGs)p eop
- X%%Page: 5 8
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)645
- Xb Fl(5)262 307 y Fd(5.2)55 b(Return)18 b(co)r(des)g(from)g(mrandom)e
- X(routines)262 384 y Fl(Most)e(mrandom)d(routines)j(follo)o(w)e(one)i(of)f(t)o
- X(w)o(o)h(con)o(v)o(en)o(tions)g(for)f(return)i(v)n(alues.)262
- X434 y(F)m(or)e(those)i(routines)f(whic)o(h)g(return)h(p)q(oin)o(ters)f(to)g
- X(an)g Ff(RNGdata)e Fl(structure:)324 516 y Fe(\017)20 b Fl(A)14
- Xb(v)n(alid)f(p)q(oin)o(ter)h(to)f(an)h Ff(RNGdata)e Fl(structure)k(is)e
- X(returned)i(up)q(on)e(success.)324 599 y Fe(\017)20 b Fl(A)14
- Xb(n)o(ull)f(p)q(oin)o(ter)h(is)g(returned)i(up)q(on)d(failure.)262
- X681 y(F)m(or)g(routines)h(whic)o(h)g(pro)q(duce)h(v)o(ectors)g(of)f
- X(pseudorandom)f(generates:)324 763 y Fe(\017)20 b Fl(The)15
- Xb(\014rst)f(cell)g(of)f(the)i(v)o(ector)g(is)e(returned)j(up)q(on)e(success.)
- X324 846 y Fe(\017)20 b Fl(The)15 b(program)d(ab)q(orts)i(up)q(on)g(error.)262
- X928 y(F)m(or)f(all)g(other)h(routines:)324 1010 y Fe(\017)20
- Xb Fl(A)14 b(0)g(or)g(-1)f(is)h(returned)h(up)q(on)f(failure.)262
- X1093 y(Details)f(are)h(pro)o(vided)g(in)f(the)i(description)f(of)g(the)g
- X(mrandom)d(library)i(in)h(Section)g(5.4.)262 1209 y Fd(5.3)55
- Xb(Linking)262 1285 y Fl(In)13 b(order)i(to)f(use)g(the)h(mrandom)c(library)i
- X(of)g(routines)i(in)e(y)o(our)h(programs)f(y)o(ou)g(m)o(ust:)324
- X1368 y Fe(\017)20 b Fl(Link)11 b(the)h Ff(mrandom.a)d Fl(library)i(with)g(y)o
- X(our)g(program.)k(This)c(will)f(t)o(ypically)g(in)o(v)o(olv)o(e)365
- X1417 y(merely)j(including)g(the)i(library)e(on)g(y)o(our)h(compiler's)f
- X(command)e(line,)i(suc)o(h)h(as:)428 1533 y Ff(cc)21 b(myprog.c)f(mrandom.a)
- X365 1649 y Fl(Since)e(mrandom)c(uses)k(some)f(UNIX)g(mathematical)d
- X(functions,)j(y)o(ou)g(ma)o(y)e(also)365 1699 y(need)g(to)f(link)f(a)g(math)g
- X(library)g(with)g(y)o(our)h(program,)e(as)i(in)f(the)i(follo)o(wing:)428
- X1815 y Ff(cc)21 b(myprog.c)f(mrandom.a)g(-lm)365 1931 y Fl(Chec)o(k)15
- Xb(the)f(do)q(cumen)o(tation)f(for)h(y)o(our)f(C)h(compiler)e(for)i(details.)
- X324 2014 y Fe(\017)20 b Fl(Include)15 b(the)f(follo)o(wing)d(line)j(at)g(the)
- Xg(top)g(of)f(y)o(our)h(source)h(\014le:)428 2080 y Ff(#include)20
- Xb("mrandom.h")262 2196 y Fd(5.4)55 b(The)19 b(mrandom)d(library)262
- X2273 y Fh(5.4.1)47 b(Initializati)o(on)12 b(and)k(De-Initial)o(i)o(zatio)o(n)
- X262 2350 y Fl(In)10 b(order)i(to)f(use)h(an)e(RNG,)g(it)h(m)o(ust)f(\014rst)h
- X(b)q(e)h(initialized.)j(This)c(is)g(accomplished)f(b)o(y)h(\014rst)262
- X2399 y(declaring)i(a)h(p)q(oin)o(ter)g(to)g(an)g Ff(RNGdata)e
- XFl(structure,)k(and)e(then)g(calling)f Ff(init_rng)p Fl(,)f(whic)o(h)262
- X2449 y(allo)q(cates)j(memory)f(for)i(the)h(RNG)e(and)h(readies)h(it)e(for)h
- X(use)h(b)o(y)f(the)h(other)f(routines)h(in)p eop
- X%%Page: 6 9
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)645
- Xb Fl(6)262 307 y(the)14 b(pac)o(k)n(age.)324 407 y Ff(RNGdata)20
- Xb(*init_rng\(alg,mran)o(dom_a)o(lg,se)o(ed,co)o(unt1)o(,coun)o(t2,bu)o(fsize)
- Xo(\))324 457 y(long)h(alg;)324 506 y(long)g(mrandom_alg;)324
- X556 y(long)g(*seed;)324 606 y(long)g(count1,)f(count2;)324
- X656 y(long)h(bufsize;)324 756 y(int)g(kill_rng\(rng\))324 805
- Xy(RNGdata)f(*rng;)324 905 y(init_rng)c Fl(returns)j(a)e(p)q(oin)o(ter)h(to)f
- X(an)h(initialized)e(RNG.)g(A)i(p)q(oin)o(ter)g(returned)h(b)o(y)262
- X955 y Ff(init_rng)12 b Fl(is)h(v)n(alid)g(for)g(use)i(b)o(y)f(all)e(other)j
- X(mrandom)c(routines.)324 1005 y Ff(alg)i Fl(is)h(the)g(n)o(um)o(b)q(er)g(of)f
- X(the)i(algorithm)c(to)j(b)q(e)g(used)h(b)o(y)f(the)g(RNG.)f(\(See)i(App)q
- X(endix)262 1054 y(B.\))324 1104 y Ff(mrandom_alg)g Fl(is)i(the)h(algorithm)c
- X(to)k(b)q(e)f(used)i(b)o(y)e Ff(mrandomrv)e Fl(when)j(called)f(with)262
- X1154 y(the)d(RNG.)f(\(See)i(Section)f(5.4.2.\))324 1204 y Ff(seed)e
- XFl(is)i(a)f(p)q(oin)o(ter)h(to)f(a)g(seed)i(v)o(ector)f(to)g(b)q(e)g(used)g
- X(to)g(seed)g(the)g(RNG.)f(\(See)h(Section)262 1254 y(5.4.4.\))324
- X1303 y Ff(count1)f Fl(and)i Ff(count2)e Fl(determine)i(the)h(n)o(um)o(b)q(er)
- Xe(of)g(initial)f(v)n(alues)h(to)h(b)q(e)g(generated)262 1353
- Xy(b)o(y)e(the)i(RNG)e(and)g(then)i(discarded,)f(according)g(to)g(the)h(form)o
- X(ula:)324 1453 y(n)o(um)o(b)q(er)e(to)h(discard)g(=)g Ff(count1)21
- Xb(+)g(BILLION*count2)p Fl(,)324 1553 y(where)10 b Ff(BILLION)e
- XFl(is)i(de\014ned)g(in)f(`)p Ff(mrandom.h)p Fl(')e(as)j(the)g(decimal)e
- X(constan)o(t)i(1000000000.)324 1602 y Ff(bufsize)19 b Fl(is)i(the)g(size)h
- X(of)e(the)i(RNG's)e(main)f(bu\013er.)40 b(A)21 b(non-p)q(ositiv)o(e)f(v)n
- X(alue)g(of)262 1652 y Ff(bufsize)d Fl(will)g(b)q(e)i(in)o(terpreted)h(as)f(a)
- Xg(v)n(alue)f(of)g(1.)32 b(\(See)19 b(Section)g(5.4.2)e(for)i(more)e(in-)262
- X1702 y(formation)11 b(on)j(bu\013ering.\))324 1752 y Ff(kill_rng)f
- XFl(destro)o(ys)j(the)f(RNG,)f(making)e(it)j(in)o(v)n(alid)e(for)h(use.)22
- Xb(This)15 b(pro)q(cedure)h(de-)262 1802 y(allo)q(cates)11 b(the)h(space)h
- X(used)f(b)o(y)f(the)h(RNG,)f(and)g(should)g(therefore)i(b)q(e)f(used)h(to)e
- X(kill)f(RNGs)262 1851 y(whic)o(h)j(will)g(no)g(longer)h(b)q(e)h(used.)324
- X1901 y(Do)e Fc(not)i Fl(use)f(an)g Ff(RNGdata)f Fl(p)q(oin)o(ter)h(whic)o(h)g
- X(p)q(oin)o(ts)g(to)g(an)g(activ)o(e)g(RNG)f(to)h(store)h(the)262
- X1951 y(return)g(v)n(alue)e(of)g Ff(init_rng)p Fl(.)j(In)e(order)h(to)f
- X(initialize)e(an)i(RNG,)e(y)o(ou)i(should)f(either:)324 2034
- Xy Fe(\017)20 b Fl(Declare)15 b(a)f(new)h Ff(RNGdata)e Fl(p)q(oin)o(ter,)h
- X(and)g(then)h(use)g(it)f(to)g(store)h(the)g(return)g(v)n(alue)365
- X2084 y(of)f Ff(init_rng)p Fl(,)d(as)j(sho)o(wn)g(in)g(Figure)g(1.)324
- X2167 y Fe(\017)20 b Fl(Use)12 b Ff(kill_rng)c Fl(to)i(de-initialize)f(an)i
- XFf(RNGdata)d Fl(p)q(oin)o(ter)j(whic)o(h)f(p)q(oin)o(ts)g(to)g(an)h(activ)o
- X(e)365 2217 y(RNG,)h(and)h(then)g(use)h(that)f(p)q(oin)o(ter)g(to)f(store)i
- X(to)f(the)g(return)h(v)n(alue)f(of)f Ff(init_rng)p Fl(,)365
- X2267 y(as)19 b(sho)o(wn)g(in)f(Figure)g(2.)32 b(Figure)19 b(3)f(sho)o(ws)h
- X(ho)o(w)f(an)h(RNG)f(should)g Fc(not)h Fl(b)q(e)g(re-)365 2316
- Xy(initialized.)p eop
- X%%Page: 7 10
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)645
- Xb Fl(7)324 465 y Ff(RNGdata)20 b(*rng;)324 515 y(long)h(seed[1];)324
- X615 y(rng=init_rng\(2,)d(0,)k(seed,)f(10000,)f(0,)i(8192\);)597
- X706 y Fl(Figure)14 b(1:)k(Prop)q(er)d(initialization)c(of)i(an)h(RNG)324
- X1121 y Ff(RNGdata)20 b(*myrng;)324 1171 y(long)h(seed[1];)324
- X1271 y(seed[0]=12345;)324 1320 y(myrng=init_rng\(2)o(,)e(0,)i(seed,)g(10000,)
- Xg(0,)g(8192\);)324 1370 y(kill_rng\(myrng\);)324 1420 y(myrng=init_rng\(3)o
- X(,)e(0,)i(seed,)g(5000,)g(0,)g(2048\);)573 1511 y Fl(Figure)14
- Xb(2:)j(Prop)q(er)f(re-initialization)11 b(of)i(an)h(RNG)324
- X1926 y Ff(RNGdata)20 b(*myrng;)324 1976 y(long)h(seed[1];)324
- X2076 y(seed[0]=12345;)324 2126 y(myrng=init_rng\(2)o(,)e(0,)i(seed,)g(10000,)
- Xg(0,)g(8192\);)324 2176 y(myrng=init_rng\(3)o(,)e(0,)i(seed,)g(5000,)g(0,)g
- X(2048\);)551 2267 y Fl(Figure)14 b(3:)j(Improp)q(er)d(re-initialization)d(of)
- Xj(an)f(RNG)p eop
- X%%Page: 8 11
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)645
- Xb Fl(8)262 307 y Fh(5.4.2)47 b(Pro)q(cedures)14 b(for)h(Generating)e
- X(Pseudorandom)g(Num)o(b)q(ers)262 384 y Fl(An)g(initialized)e(RNG)h(can)h(b)q
- X(e)h(used)g(to)f(generate)h(pseudorandom)e(n)o(um)o(b)q(ers)h(b)o(y)f(using)h
- X(a)262 434 y(v)n(ariet)o(y)g(of)g(routines)i(describ)q(ed)g(in)f(this)g
- X(section.)324 483 y(Routines)g(are)g(pro)o(vided)g(for)f(pro)q(ducing)h
- X(generates)i(of)d(four)h(t)o(yp)q(es:)324 572 y Fe(\017)20
- Xb Fl(double)14 b(precision)g(\015oating)f(p)q(oin)o(t)h(generates)h(in)f(the)
- Xg(range)g([0,1\))324 653 y Fe(\017)20 b Fl(single)14 b(precision)g
- X(\015oating)f(p)q(oin)o(t)g(generates)j(in)d(the)i(range)f([0,1\))324
- X735 y Fe(\017)20 b Fl(long)c(in)o(teger)i(generates)g(in)e(the)i(range)f(0)p
- XFg(::r)11 b Fe(\000)g Fl(1,)17 b(where)h(r)f(is)g(the)h(range)f(of)f(the)365
- X785 y(RNG)d(b)q(eing)h(used)h(to)f(pro)q(duce)h(generates)324
- X867 y Fe(\017)20 b Fl(long)9 b(in)o(teger)g(generates)i(in)e(the)h(range)f(0)
- Xp Fg(::)p Ff(m)p Fe(\000)p Fl(1,)g(for)g(an)o(y)g(1)i Fe(\024)h
- XFf(m)f Fg(<)h Ff(range)p 1520 867 14 2 v 14 w(rng)p Fl(\()p
- XFf(rng)p Fl(\))324 955 y(Note)e(that)g(although)e(b)q(oth)i(single)f(and)h
- X(double)g(precision)g(\015oats)f(can)h(b)q(e)g(returned)i(b)o(y)262
- X1005 y(the)h(generate-pro)q(ducing)h(routines,)f(the)h(actual)e(precision)h
- X(of)f(the)i(generates)g(pro)q(duced)262 1054 y(is)f(determined)g(b)o(y)g(the)
- Xg(precision)h(of)e(the)i(underlying)f(generator)h(b)q(eing)f(used.)19
- Xb(In)13 b(other)262 1104 y(w)o(ords,)j(the)h(di\013erence)h(b)q(et)o(w)o(een)
- Xg(routines)f(whic)o(h)f(return)h(generates)h(of)e(t)o(yp)q(e)h
- XFf(double)262 1154 y Fl(and)f(those)i(whic)o(h)e(return)i(generates)h(of)d(t)
- Xo(yp)q(e)h Ff(float)f Fl(is)h(merely)f(in)g(the)i(\\pac)o(k)n(aging")262
- X1204 y(of)i(the)h(generates,)i(not)e(in)f(the)i(precision)f(they)g(pro)o
- X(vide.)38 b(Information)18 b(ab)q(out)j(the)262 1254 y(precision)12
- Xb(of)g(the)h(RNGs)f(curren)o(tly)i(installed)e(in)g(the)h(pac)o(k)n(age)f(is)
- Xg(in)g(App)q(endix)h(B;)g(suc)o(h)262 1303 y(information)h(can)j(also)f(b)q
- X(e)i(obtained)f(at)g(run-time)f(through)h(the)g Ff(range_rng)e
- XFl(routine)262 1353 y(\(see)k(Section)g(5.4.7\).)29 b(The)19
- Xb(curren)o(t)h(v)o(ersion)e(of)g(the)g(pac)o(k)n(age)g(only)g(supp)q(orts)h
- X(RNGs)262 1403 y(with)13 b(precisions)i(of)e(no)h(more)f(than)g(32)h(bits.)
- X324 1453 y(Both)c(bu\013ered)i(and)e(un)o(bu\013ered)i(routines)f(are)f(pro)o
- X(vided.)17 b(Un)o(bu\013ered)12 b(routines)e(call)262 1503
- Xy(the)i(underlying)f(RNG)f(only)h(as)h(man)o(y)d(times)i(as)g(are)h(needed)h
- X(to)f(pro)q(duce)g(the)g(requested)262 1553 y(n)o(um)o(b)q(er)j(of)g
- X(generates,)j(while)e(bu\013ered)i(routines)e(main)o(tain)e(bu\013ers)j(of)f
- X(generates,)i(so)262 1602 y(that)13 b(generates)i(ma)o(y)d(b)q(e)i(pro)q
- X(duced)h(e\016cien)o(tly)f(ev)o(en)g(when)g(requested)i(in)d(small)e(quan-)
- X262 1652 y(tities.)24 b(Roughly)m(,)14 b(bu\013ered)k(routines)e(are)h
- X(preferable)g(when)f(generates)i(are)e(requested)262 1702 y(one)h(at)g(a)h
- X(time)e(or)h(in)g(small)e(quan)o(tities,)j(while)f(un)o(bu\013ered)i
- X(routines)f(are)g(preferable)262 1752 y(when)g(generates)i(are)e(requested)i
- X(in)e(large)g(quan)o(tities.)30 b(Some)17 b(other)i(di\013erences)h(b)q(e-)
- X262 1802 y(t)o(w)o(een)15 b(bu\013ered)g(and)g(un)o(bu\013ered)g(routines)g
- X(are)g(discussed)h(later)f(in)f(this)g(section.)20 b(The)262
- X1851 y(size)g(of)e(the)i(bu\013er)g(used)h(b)o(y)e(an)g(RNG)f(is)i
- X(determined)f(at)g(the)h(time)e(of)h(the)g(RNG's)262 1901 y(initialization;)
- X10 b(e\013ectiv)o(e)15 b(bu\013er)g(sizes)g(will)e(v)n(ary)g(from)f
- X(application)h(to)g(application.)324 1951 y(The)d(name)f(of)g(a)h(routine)g
- X(denotes)h(the)g(t)o(yp)q(e)f(of)g(the)g(v)n(alue)f(whic)o(h)h(the)h(routine)
- Xf(returns)262 2001 y(and)k(whether)i(the)f(routine)g(is)f(bu\013ered)i(or)f
- X(un)o(bu\013ered.)21 b(The)15 b(\014rst)h(letter)f(of)f(a)g(routine)262
- X2051 y(denotes)g(the)g(t)o(yp)q(e)g(of)e(v)n(alue)h(whic)o(h)g(it)g(returns:)
- X19 b(\\d")13 b(for)g(double)g(precision)h(and)f(\\f)s(")g(for)262
- X2100 y(single)e(precision)h(\015oating)e(p)q(oin)o(t)i(in)f(the)h(range)g
- X([0,1\);)e(\\l")h(for)g(long)g(in)o(teger)h(in)f(the)h(range)262
- X2150 y(0..\()p Ff(range_rng\()o(rng\))p Fl(-)o(1\),)f(and)j(\\b")g(for)f(bit)
- Xh(\(either)h(a)f(0)g(or)g(a)g(1\).)19 b(If)14 b(the)g(second)i(letter)262
- X2200 y(of)d(the)i(routine's)f(name)f(is)i(an)f(\\x",)f(then)i(the)g(routine)f
- X(is)g(un)o(bu\013ered.)21 b(Otherwise,)15 b(the)262 2250 y(routine)f(is)f
- X(bu\013ered.)324 2300 y(F)m(or)h(con)o(v)o(enience)j(in)d(user)i(programming)
- Xo(,)c(w)o(e)j(also)g(pro)o(vide)f(a)h(n)o(um)o(b)q(er)f(of)g(macros)262
- X2350 y(that)c(supply)g(default)f(parameter)h(v)n(alues.)17
- Xb(The)10 b(last)g(t)o(w)o(o)g(letters)h(of)f(all)f(our)h(fundamen)o(tal)262
- X2399 y(routines)i(is)h(\\rv".)k(This)12 b(means)f(that)i(they)g(m)o(ust)e(b)q
- X(e)i(pro)o(vided)f(with)g(b)q(oth)g(a)g(p)q(oin)o(ter)h(to)262
- X2449 y(an)f Ff(RNGdata)f Fl(structure)k(and)d(a)g(v)o(ector)h(to)g(\014ll)e
- X(with)i(generates)h(from)d(the)i(RNG.)e(Macros)p eop
- X%%Page: 9 12
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)645
- Xb Fl(9)262 307 y(whose)19 b(names)f(do)h(not)f(con)o(tain)h(an)g(\\r")f(ha)o
- X(v)o(e)h(the)g Ff(RNGdata)f Fl(p)q(oin)o(ter)h(omitted)e(from)262
- X357 y(their)c(parameter)g(list;)g(they)h(use)g(the)g(most-recen)o(tly)f
- X(initialized)f(or)i(restarted)h(RNG)e(to)262 407 y(pro)q(duce)j(generates.)22
- Xb(Macros)16 b(whose)f(names)f(do)h(not)f(con)o(tain)h(a)f(\\v")h(ha)o(v)o(e)f
- X(the)i(v)o(ector)262 457 y(and)f(n)o(um)o(b)q(er)g(of)g(generates)i(omitted)e
- X(from)f(their)i(parameter)f(list;)h(they)g(pro)q(duce)h(and)262
- X506 y(return)e(a)e(single)h(generate.)324 556 y(All)j(generating)h(routines)h
- X(ab)q(ort)f(with)f(a)h(message)g(to)g Ff(stderr)e Fl(if)h(called)h(with)g(an)
- X262 606 y(in)o(v)n(alid)11 b Ff(RNGdata)i Fl(p)q(oin)o(ter.)262
- X706 y Fh(Bu\013ering)324 805 y Fl(The)18 b(op)q(eration)g(of)g(the)g
- X(bu\013ered)i(routines)e(and)g(their)g(in)o(teraction)g(with)g(the)h(un-)262
- X855 y(bu\013ered)13 b(routines)g(requires)h(some)e(elab)q(oration.)k(Eac)o(h)
- Xd(RNG)f(main)o(tains)d(t)o(w)o(o)j(separate)262 905 y(bu\013ers:)28
- Xb(one)18 b(for)g(bu\013ering)h(bit)e(v)n(alues)h(\(the)h(\\bit)f
- X(bu\013er"\),)i(and)e(one)g(for)g(bu\013ering)262 955 y(all)e(other)h(v)n
- X(alues)g(\(the)h(\\main)d(bu\013er"\).)29 b(The)18 b(size)g(of)f(the)g(main)f
- X(bu\013er)i(of)e(an)h(RNG)262 1005 y(is)e(determined)g(at)g(the)h(time)e(of)h
- X(the)h(RNG's)e(initialization,)f(while)h(the)i(size)g(of)f(the)h(bit)262
- X1054 y(bu\013er)e(is)g(curren)o(tly)h(\014xed)f(at)g(32)f(bits.)324
- X1104 y(Consider)e(a)f(freshly-initialized)f(RNG)h(with)g(a)g(main)f(bu\013er)
- Xi(size)h(of)e(1000.)15 b(A)c(request)262 1154 y(is)k(made)g(for)h(a)g(single)
- Xf(generate)j(of)d(t)o(yp)q(e)h Ff(long)p Fl(.)24 b(The)16 b(RNG's)g(bu\013er)
- Xh(gets)f(\014lled)g(with)262 1204 y(1000)i(generates,)23 b(and)d(the)g
- X(\014rst)h(suc)o(h)f(generate)i(is)d(returned)j(to)e(the)g(user.)37
- Xb(So)20 b(the)262 1254 y(bu\013er)d(no)o(w)f(con)o(tains)g(999)g(generates.)
- X27 b(If)16 b(another)h(generate)h(of)e(t)o(yp)q(e)h Ff(long)p
- XFl(,)e Ff(double)p Fl(,)262 1303 y(or)g Ff(float)p Fl(,)g(is)g(requested,)j
- X(a)d(generate)i(will)d(b)q(e)i(pulled)g(from)e(the)i(bu\013er)g(and)g
- X(returned)262 1353 y(to)g(the)h(user)g(after)g(b)q(eing)f(con)o(v)o(erted)h
- X(to)g(the)f(prop)q(er)i(t)o(yp)q(e.)26 b(If)16 b(the)g(user)i(con)o(tin)o
- X(ues)f(to)262 1403 y(request)f(generates)g(in)f(this)f(w)o(a)o(y)g(and)h(the)
- Xg(main)e(bu\013er)j(b)q(ecomes)f(depleted,)g(it)g(will)e(b)q(e)262
- X1453 y(\014lled)g(again)g(with)g(1000)g(generates,)i(and)f(so)g(on.)324
- X1503 y(The)i(un)o(bu\013ered)i(routines)f(do)e(not)h(in)o(terfere)i(with)d
- X(either)i(of)f(the)g(RNG's)g(bu\013ers.)262 1553 y(Again,)e(consider)i(our)g
- X(RNG,)e(with)h(its)g(bu\013er)i(\014lled)e(with)g(1000)f(generates.)25
- Xb(The)16 b(user)262 1602 y(no)o(w)h(mak)o(es)g(a)h(request)i(for)d(a)h
- X(single)g(un)o(bu\013ered)h(generate.)32 b(The)19 b(underlying)e(RNG)262
- X1652 y(will)12 b(then)j(b)q(e)g(called)f(once,)h(returning)f(a)g(single)g
- X(generate,)h(lea)o(ving)e(our)i(bu\013er)g(of)f(1000)262 1702
- Xy(generates)g(un)o(touc)o(hed,)f(and)f(still)g(ready)h(to)f(b)q(e)i(accessed)
- Xh(b)o(y)d(the)h(bu\013ered)h(routines.)k(If,)262 1752 y(in)d(a)g(particular)h
- X(application,)e(it)h(is)h(necessary)i(to)d(alw)o(a)o(ys)g(use)i(consecutiv)o
- X(e)g(generates)262 1802 y(from)c(an)i(RNG,)f(then)h(that)h(RNG)e(should)h
- X(alw)o(a)o(ys)f(b)q(e)i(called)f Fc(either)f Fl(with)h(bu\013ered)i(or)262
- X1851 y(un)o(bu\013ered)e(routines,)f(but)g(not)g(with)f(a)h(com)o(bination)d
- X(of)j(b)q(oth.)324 1901 y(The)e(bit)f(bu\013er)h(of)f(an)g(RNG)f(op)q(erates)
- Xj(similarly)8 b(to)j(the)h(main)e(bu\013er,)i(with)f(one)h(k)o(ey)262
- X1951 y(di\013erence:)23 b(the)16 b(bit)f(bu\013er)i(is)e(\014lled)h(b)o(y)f
- X(sequen)o(tially)g(retrieving)h(generates)h(from)d(the)262
- X2001 y(main)9 b(bu\013er.)18 b(Once)13 b(again,)d(consider)i(our)f(RNG,)f
- X(with)i(its)f(bu\013er)h(\014lled)f(with)g(1000)g(gen-)262
- X2051 y(erates,)i(and)g(with)f(its)g(bit)h(bu\013er)g(empt)o(y)m(.)j(A)d
- X(single)f(bit)g(is)h(then)g(requested.)20 b(Thirt)o(y-t)o(w)o(o)262
- X2100 y(generates)15 b(will)d(b)q(e)i(pulled)g(from)e(the)i(main)d(bu\013er,)k
- X(transformed)e(in)o(to)g(thirt)o(y-t)o(w)o(o)g(one-)262 2150
- Xy(bit)f(0-1)h(v)n(alues,)f(then)i(stored)g(in)e(the)i(bit)e(bu\013er.)19
- Xb(\(F)m(or)13 b(users)h(who)f(are)h(more)e(concerned)262 2200
- Xy(with)k(sp)q(eed)i(than)f(accuracy)m(,)h(w)o(e)f(also)f(pro)o(vide)h(a)f
- X(\\fast")g(bit-bu\013er)i(call,)e(in)g(whic)o(h)h(a)262 2250
- Xy(single)f(32-bit)f(generate)j(from)d(the)i(main)d(bu\013er)k(is)e
- X(transformed)g(in)o(to)g(thirt)o(y-t)o(w)o(o)f(0-1)262 2300
- Xy(v)n(ariates.)i(See)e(the)g(descriptions)g(of)e Ff(bxrandom_f)f
- XFl(and)h Ff(brandom_f)p Fl(,)f(b)q(elo)o(w.\))p eop
- X%%Page: 10 13
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)624
- Xb Fl(10)262 307 y Fh(Un)o(bu\013ered)12 b(and)j(bu\013ered)f(calling)g(pro)q
- X(cedures)324 407 y Ff(double)20 b(dxrandomrv\(rng,)f(n,)i(v\))324
- X457 y(double)f(drandomrv\(rng,)f(n,)j(v\))324 506 y(RNGdata)e(*rng;)324
- X556 y(long)h(n;)324 606 y(double)f(v[];)324 706 y(float)h(fxrandomrv\(rng,)d
- X(n,)k(v\))324 756 y(float)f(frandomrv\(rng,)d(n,)k(v\))324
- X805 y(RNGdata)e(*rng;)324 855 y(long)h(n;)324 905 y(float)g(v[];)324
- X1005 y(long)g(lxrandomrv\(rng,)d(n,)k(v\))324 1054 y(long)f(lrandomrv\(rng,)e
- X(n,)i(v\))324 1104 y(RNGdata)f(*rng;)324 1154 y(long)h(n;)324
- X1204 y(long)g(v[];)324 1303 y(int)g(bxrandomrv\(rng,)e(n,)i(v\))324
- X1353 y(int)g(brandomrv\(rng,)e(n,)i(v\))324 1403 y(RNGdata)f(*rng;)324
- X1453 y(long)h(n;)324 1503 y(int)g(v[];)324 1602 y(int)g(bxrandomrv_f\(rng,)d
- X(n,)k(v\))324 1652 y(int)f(brandomrv_f\(rng,)d(n,)k(v\))324
- X1702 y(RNGdata)e(*rng;)324 1752 y(long)h(n;)324 1802 y(double)f(v[];)324
- X1901 y Fl(These)d(routines)g(\014ll)e(the)i(v)o(ector)g Ff(v)f
- XFl(with)g Ff(n)g Fl(generates)i(from)d Ff(rng)p Fl(,)g(and)i(return)g(the)262
- X1951 y(\014rst)d(generate)h(pro)q(duced)h(\(i.e.)h Ff(v[0])p
- XFl(\).)324 2001 y(If)10 b Ff(rng)g Fl(is)g(a)h(n)o(ull)e(p)q(oin)o(ter,)i
- X(then)g(the)h(most-recen)o(tly)e(initialized)f(or)i(restarted)h(RNG)e(is)262
- X2051 y(used)i(to)g(pro)q(duce)h(generates.)18 b(If)12 b Ff(n)f
- XFl(is)h(0,)f(then)i(the)f Ff(v)f Fl(parameter)h(need)g(not)g(b)q(e)g(pro)o
- X(vided,)262 2100 y(and)h(a)h(single)f(generate)j(is)d(pro)q(duced)i(and)f
- X(returned.)324 2150 y Ff(bxrandomrv)f Fl(uses)j(one)f(generate)i(from)c
- XFf(rng)h Fl(to)h(generate)i(eac)o(h)e(bit.)21 b(This)15 b(routine)262
- X2200 y(is)e(slo)o(w)o(er)h(than)g Ff(bxrandomrv_f)p Fl(,)d(but)j(returns)h
- X(bits)f(of)g(higher)g(qualit)o(y)m(.)324 2250 y Ff(bxrandomrv)p
- X547 2250 14 2 v 13 w(f)i Fl(uses)i(eac)o(h)f(generate)g(from)e
- XFf(rng)g Fl(to)h(pro)q(duce)i(32)e(bits.)25 b(Therefore,)262
- X2300 y(requests)14 b(for)e(bits)g(in)g(other)h(than)f(m)o(ultiples)e(of)i(32)
- Xg(will)e(result)k(in)d(bits)i(from)d(the)j(stream)262 2350
- Xy(b)q(eing)i(\\lost")g(b)q(et)o(w)o(een)i(calls.)22 b(The)16
- Xb(routine)g(returns)h(-1)e(if)f(it)h(is)h(called)f(with)g(an)g(RNG)262
- X2399 y(whose)f(range)h(is)f(not)g(2)635 2384 y Fb(32)670 2399
- Xy Fl(.)19 b(This)14 b(routine)h(is)f(faster)h(than)f Ff(bxrandomrv)p
- XFl(,)e(but)i(w)o(e)h(do)f(not)262 2449 y(recommend)9 b(its)j(use,)g(since)g
- X(w)o(e)f(kno)o(w)g(of)g(no)g(one)g(who)g(has)h(rigorously)e(tested)j(suc)o(h)
- Xf(a)f(bit)p eop
- X%%Page: 11 14
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)624
- Xb Fl(11)262 307 y(stream.)16 b(W)m(e)9 b(gain)g(con\014dence)j(in)e(our)g
- X(slo)o(w)o(er)g Ff(bxrandomrv)e Fl(bit)h(stream,)h(in)g(comparison,)262
- X357 y(ev)o(ery)i(time)f(the)h(underlying)g(generator)h(passes)g(a)f(test)h
- X(sensitiv)o(e)f(to)g(correlations)g(in)g(the)262 407 y(leading)k(digit)h(of)g
- X(its)g(\015oating)g(p)q(oin)o(t)g(output,)h(or)g(to)f(the)i(most)d
- X(signi\014can)o(t)h(bit)h(of)f(its)262 457 y(\014xed)d(p)q(oin)o(t)f(output.)
- X324 506 y Ff(brandomrv_f)p Fl(,)i(the)j(bu\013ered)h(v)o(ersion)f(of)e
- XFf(bxrandomrv_f)p Fl(,)g(do)q(es)i(not)f(exhibit)g(the)262
- X556 y(same)c(prop)q(ert)o(y)j(of)e(\\losing)f(bits")h(as)h(do)q(es)g
- XFf(bxrandomrv_f)p Fl(,)d(since)k(bits)e(whic)o(h)h(are)g(not)262
- X606 y(used)h(in)g(one)g(call)f(to)h Ff(brandomrv_f)d Fl(are)k(stored)f(in)g
- X(the)g(bit)g(bu\013er)h(and)f(are)g(a)o(v)n(ailable)262 656
- Xy(for)d(use)i(up)q(on)f(future)g(calls.)324 756 y Ff(int)21
- Xb(flush_rng\(rng\))324 805 y(RNGdata)f(*rng;)324 905 y Fl(Flushes)15
- Xb(b)q(oth)f(of)f(the)h(RNG's)f(bu\013ers.)262 1005 y Fh(Pro)q(cedure)h(for)h
- X(generating)e(in)o(tegers)g(in)i(a)h(restricted)d(range)324
- X1104 y Ff(long)21 b(mrandomrv\(rng,)e(m,)i(n,)g(v\))324 1154
- Xy(RNGdata)f(*rng;)324 1204 y(long)h(m,n,v[];)324 1303 y(mrandomrv)10
- Xb Fl(\014lls)i(the)g(v)o(ector)h Ff(v)f Fl(with)g Ff(n)g Fl(generates)h(in)f
- X(the)h(range)f(0)p Fg(::)p Ff(m)6 b Fe(\000)g Fl(1)k(using)i
- XFf(rng)p Fl(,)262 1353 y(where)18 b(1)e Fe(\024)h Ff(m)g Fe(\024)g
- XFf(range)p 672 1353 14 2 v 14 w(rng)p Fl(\()p Ff(rng)p Fl(\).)27
- Xb(If)17 b Ff(range)p 1044 1353 V 14 w(rng)p Fl(\()p Ff(rng)p
- XFl(\))f Fg(<)h Ff(m)p Fl(,)g(the)h(program)d(ab)q(orts)262
- X1403 y(with)e(an)h(error.)324 1453 y(The)c(algorithm)c(used)k(b)o(y)f
- XFf(mrandomrv)f Fl(to)h(\014ll)f Ff(v)h Fl(is)g(set)h(b)o(y)g
- XFf(init_rng)d Fl(or)i(b)o(y)g Ff(mralg_rng)p Fl(.)262 1503
- Xy(\(See)14 b(Section)h(5.4.1)d(and)i(Section)g(5.4.7.\))324
- X1553 y(Algorithm)i(0)i(is)g(Thom)o(b)q(orson's)f(un)o(biased)i(metho)q(d,)f
- X(whic)o(h)g(pro)q(duces)i(un)o(biased)262 1602 y(long)13 b(in)o(tegers)i(in)e
- X(the)i(range)f([0..)p Ff(m)p Fl(\).)k(The)c(algorithm)e(discards)j(an)o(y)e
- X(outputs)i(from)d Ff(rng)262 1652 y Fl(whic)o(h)j(are)i(larger)f(than)f
- XFg(r)d Fe(\000)f Fl(\()p Fg(r)h Fl(mo)q(d)e Ff(m)p Fl(\),)16
- Xb(where)h(r)f(is)g(equal)g(to)f Ff(range)p 1425 1652 V 15 w(rng\(rng\))p
- XFl(.)23 b(A)o(t)262 1702 y(w)o(orst,)15 b(this)g(co)q(de)h(will)e(discard)i
- X(\(on)f(long-term)e(a)o(v)o(erage\))j(at)f(most)f(one)h(v)n(alue)g(of)g(r)g
- X(for)262 1752 y(ev)o(ery)d(one)h(that)f(is)g(useful.)17 b(This)12
- Xb(w)o(orst)g(case)h(is)f(only)g(encoun)o(tered)i(for)d(extremely)h(large)262
- X1802 y Ff(m)p Fl(;)h(for)h(\014xed)g(and)g(mo)q(derate)g Ff(m)p
- XFl(,)f(this)h(co)q(de)h(will)d(rarely)j(discard)f(a)g(v)n(alue,)f(and)h(th)o
- X(us)g(will)262 1851 y(run)f(essen)o(tially)g(as)g(fast)f(as)h(algorithm)e(1.)
- X17 b(When)c(the)h(v)n(alue)e(of)g Ff(m)h Fl(c)o(hanges)g(on)g(eac)o(h)g(call)
- X262 1901 y(to)g Ff(mrandom)p Fl(,)f(ho)o(w)o(ev)o(er,)h(this)h(co)q(de)g(is)g
- X(slo)o(w)o(er)g(than)f(algorithm)e(1,)i(due)h(to)g(the)g(necessit)o(y)262
- X1951 y(of)f(recomputing)g Fg(r)d Fe(\000)f Fl(\()p Fg(r)k Fl(mo)q(d)d
- XFf(m)p Fl(\).)324 2001 y(The)15 b(program)e(ab)q(orts)i(with)f(an)g(error)i
- X(message)e(to)g Ff(stderr)f Fl(if)h Ff(rng)g Fl(is)g(b)q(eha)o(ving)h(so)262
- X2051 y(non-randomly)10 b(that)j(Algorithm)e(0)i(m)o(ust)f(mak)o(e)g(an)h
- X(excessiv)o(e)i(n)o(um)o(b)q(er)d(of)h(calls)f(to)h Ff(rng)262
- X2100 y Fl(in)g(order)i(to)e(pro)q(duce)i(the)g(requested)h(n)o(um)o(b)q(er)d
- X(of)g(generates.)324 2150 y(The)j(program)f(ab)q(orts)h(with)g(an)g(error)h
- X(to)f Ff(stderr)f Fl(if)g Ff(mrandomrv)f Fl(is)i(ask)o(ed)h(to)f(use)262
- X2200 y(Algorithm)11 b(0)j(with)f(a)h(v)n(alue)f(of)g Ff(m)h
- XFl(for)g(whic)o(h)f Ff(m)f Fg(>)f Ff(range)p 1187 2200 V 15
- Xw(rng)p Fl(\()p Ff(rng)p Fl(\))o(.)324 2300 y(Algorithm)j(1)j(is)f(the)i
- X(standard)f Ff(\(long\)\(m*dxrandom)o(r\(rng)o(\)\))p Fl(.)24
- Xb(This)16 b(algorithm)262 2350 y(ma)o(y)9 b(b)q(e)j(biased:)17
- Xb(for)12 b(large)f Ff(m)p Fl(,)g(some)g(results)i(ma)o(y)c(b)q(e)j(b)q(e)h
- X(more)d(lik)o(ely)g(than)i(others.)18 b(The)262 2399 y(bias)d(is)397
- X2383 y Fa(r)s Fb(mo)q(d)s Ff(m)p 397 2390 105 2 v 439 2414
- Xa(m)507 2399 y Fl(,)h(whic)o(h)g(is)f(upp)q(er-b)q(ounded)i(b)o(y)f(0.1\045)e
- X(if)h Ff(m)h Fl(is)f(less)h(than)g(a)g(milli)o(on)d(and)262
- X2449 y(the)h(range)g(r)g(of)g Ff(rng)f Fl(is)g(at)h(least)g(a)g(billion.)p
- Xeop
- X%%Page: 12 15
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)624
- Xb Fl(12)324 307 y(W)m(e)10 b(do)h(not)g(supp)q(ort,)h(and)f(indeed)g(w)o(e)h
- X(activ)o(ely)e(discourage,)i(generating)f(restricted-)262 357
- Xy(range)j(in)o(tegers)i(with)e Ff(lrandomr\(rng\)\045m)p Fl(.)i(Man)o(y)f
- X(RNGs)f(ha)o(v)o(e)g(p)q(o)q(or)h(b)q(eha)o(vior)f(under)262
- X407 y(this)h(transformation,)e(most)h(noticeably)h(when)h Ff(m)e
- XFl(is)i(a)e(p)q(o)o(w)o(er)i(of)f(2.)21 b(When)16 b Ff(m)f
- XFl(is)g(not)g(a)262 457 y(p)q(o)o(w)o(er)d(of)g(2,)h(\014xed-p)q(oin)o(t)f
- X(division)f(required)j(b)o(y)e(an)h(\\)p Ff(\045)p Fl(")e(op)q(eration)i(is)f
- X(time-consuming)262 506 y(on)h(man)o(y)f(w)o(orkstations.)262
- X606 y Fh(NOTES)324 656 y Fl(The)k Ff(mrandomrv)d Fl(pro)q(cedure)18
- Xb(is)d(capable)g(of)g(generating)h(long)e(in)o(tegers)j(in)e(the)h(full)262
- X706 y(range)c(of)g(an)o(y)g(RNG)g(for)h(whic)o(h)f(1)f Fe(\024)h
- XFf(range)p 972 706 14 2 v 15 w(rng)p Fl(\()p Ff(rng)p Fl(\))e
- XFe(\024)i Fl(2)1223 691 y Fb(32)1258 706 y Fl(.)18 b(In)12
- Xb(order)i(to)e(accomplish)262 756 y(this,)g(with)h(the)g(parameter)g
- XFf(m)f Fl(a)h(signed)g(long)f(in)o(teger,)h(the)h(follo)o(wing)c(mapping)g
- X(is)j(used:)262 847 y(Range\()p Ff(mrandom\(m\))p Fl(\))e(=)j(0)p
- XFg(::)p Ff(m)8 b Fe(\000)i Fl(1)177 b(if)13 b(1)e Fe(\024)h
- XFf(m)g Fg(<)f Fl(2)1212 832 y Fb(31)685 897 y Fl(0)p Fg(::)p
- XFl(2)751 882 y Fb(32)794 897 y Fe(\000)f Fl(1)143 b(if)13 b
- XFf(m)e Fl(=)h(0)685 946 y(0)p Fg(::)p Fl(\(2)767 931 y Fb(31)810
- X946 y Fe(\000)e Ff(m)f Fe(\000)g Fl(1\))39 b(if)13 b Fe(\000)p
- XFl(2)1091 931 y Fb(31)1138 946 y Fe(\024)f Ff(m)f Fg(<)h Fl(0)324
- X1038 y(Macros)18 b(are)f(de\014ned)h(for)f(easy)h(calling)d(of)i
- XFf(mrandomrv)e Fl(with)i(v)n(arious)f(default)h(pa-)262 1088
- Xy(rameters.)h(See)c(Section)f(5.4.2)e(for)i(the)h(naming)d(con)o(v)o(en)o
- X(tions)i(follo)o(w)o(ed)e(b)o(y)i(the)h(macros.)262 1195 y
- XFh(5.4.3)47 b(Sa)o(ving)15 b(and)g(restarting)e(RNGs)262 1272
- Xy Fl(RNGs)h(ma)o(y)f(b)q(e)j(sa)o(v)o(ed)f(to)g(disk)f(\014les)i(in)e(a)h(h)o
- X(uman-readable)e(ASCI)q(I)j(format)d(and)i(later)262 1322 y(restarted.)27
- Xb(RNG)16 b(bu\013ers)i(are)f(not)g(sa)o(v)o(ed,)f(and)h(therefore)h(all)d
- X(restarted)k(RNGs)d(ha)o(v)o(e)262 1372 y(empt)o(y)f(bu\013ers,)k(and)d(an)o
- X(y)h(data)f(remaining)f(in)h(an)h(RNG's)f(bu\013er)i(at)e(the)i(time)d(of)i
- X(its)262 1422 y(state-sa)o(v)o(e)d(will)f Fc(not)h Fl(b)q(e)g(reconstructed.)
- X324 1521 y Ff(int)21 b(save_rng\(rng,)e(filename\))324 1571
- Xy(RNGdata)h(*rng;)324 1621 y(char)h(*filename;)324 1720 y(RNGdata)f
- X(*restart_rng\(filen)o(ame\))324 1770 y(char)h(*filename;)324
- X1870 y(save_rng)12 b Fl(sa)o(v)o(es)i Ff(rng)g Fl(to)f(the)i(ASCI)q(I)f
- X(\014le)g(named)f Ff(filename)p Fl(.)324 1920 y Ff(restart_rng)7
- Xb Fl(restarts)k(an)e(RNG)f(from)g(a)h(previously)g(sa)o(v)o(ed)g
- X(state\014le.)18 b(The)9 b(restarted)262 1969 y(RNG)g(will)f(b)q(egin)i
- X(where)i(the)e(sa)o(v)o(ed)g(RNG)g(\\left)f(o\013.")17 b(As)10
- Xb(with)g Ff(init_rng)p Fl(,)e(the)j Ff(RNGdata)262 2019 y Fl(p)q(oin)o(ter)f
- X(used)h(to)e(store)i(the)g(restarted)h(RNG)d Fc(must)h Fl(b)q(e)h(either)f(a)
- Xg(freshly)g(declared)h(p)q(oin)o(ter)262 2069 y(or)i(a)h(p)q(oin)o(ter)g(to)g
- X(a)f(freshly)h(killed)f(RNG)g(\(see)j(Section)e(5.4.1\).)324
- X2119 y(RNGs)e(ma)o(y)f(store)j(their)f(state)g(and)g(seed)h(v)o(ectors)g(in)e
- X(an)o(y)h(of)f(a)g(n)o(um)o(b)q(er)g(of)h(formats,)262 2169
- Xy(and)e(this)g(is)g(re\015ected)i(in)e(the)h(format)d(of)i(the)g(state)h
- X(\014le.)17 b(Figure)12 b(4)f(sho)o(ws)g(a)g(sample)f(state)262
- X2219 y(\014le)g(of)g(an)g(RNG)g(using)h(the)g(Kn)o(uth/Ben)o(tley)g
- X(lagged-Fib)q(onnacci)f(generator)h(prand)g(\(see)262 2268
- Xy(App)q(endix)17 b(B\),)h(whic)o(h)e(stores)j(its)e(state)g(and)g(seeds)i(as)
- Xe(32-bit)f Ff(long)21 b(int)p Fl(s.)27 b(Figure)17 b(5)262
- X2318 y(sho)o(ws)11 b(a)f(sample)g(state)i(\014le)f(of)f(an)h(RNG)f(using)h
- X(4.3bsd)f Ff(nrand48)p Fl(,)g(whic)o(h)h(stores)h(its)f(state)262
- X2368 y(and)i(seeds)j(as)e(16-bit)f Ff(int)p Fl(s.)324 2418
- Xy(A)g(few)h(examples)f(of)g(ho)o(w)g(to)g(sa)o(v)o(e)h(and)f(restart)i(RNGs)f
- X(are)g(displa)o(y)o(ed)f(in)g(Figure)g(6.)p eop
- X%%Page: 13 16
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)624
- Xb Fl(13)324 307 y Ff(RNG)21 b(statefile)f(for)h(algorithm)f(2,)h
- X(\(Knuth/Bentley)e(prand:)i(lagged)324 356 y(Fibbonacci\))324
- X406 y(Buffer)f(size)h(=)h(1024)f(bytes)324 456 y(Initial)f(seed)h(table)g(=)
- X389 506 y(00000927)324 556 y(Number)f(of)i(calls)e(to)i(underlying)e(RNG)h
- X(after)g(seeding)f(=)h(0)h(billion)324 605 y(+)f(2000)324 655
- Xy(Next)g(value)g(in)g(this)g(pseudorandom)e(sequence)h(=)i(0b64d0ea)324
- X705 y(This)f(RNG)g(returns)f(every)h(1)h(generates)324 755
- Xy(This)f(RNG)g(uses)g(mrandom)f(algorithm)g(0)324 805 y(RNG)h(state)g(table)f
- X(=)389 855 y(0911c27a)g(10641ca0)g(2ba00807)h(1aabed0a)389
- X904 y(273ff367)f(1ab88564)g(2ae76a9e)h(2a7e6bc0)389 954 y(35c7568e)f
- X(201b6b04)g(3ad90695)h(303208b2)389 1004 y(1e718896)f(054c9886)g(00e8c93f)h
- X(130a41cb)389 1054 y(11de97bf)f(0da54e15)g(2f4fcca0)h(0ebb1f70)389
- X1104 y(01c195c3)f(3283980e)g(37dee108)h(0893a89b)389 1153 y(326849b0)f
- X(167bb45e)g(19cc9765)h(33d97b51)389 1203 y(36b425d1)f(35704e34)g(29a638ca)h
- X(280a086f)389 1253 y(11dfa5d6)f(14dcbcc4)g(2610bdf4)h(02534109)389
- X1303 y(2817daf4)f(0bcf76ab)g(19b0a07d)h(0eebf7f6)389 1353 y(113c003e)f
- X(31b996b0)g(12bab234)h(05eddb36)389 1402 y(1ed71381)f(377742a3)g(3878e079)h
- X(2668c922)389 1452 y(22cc8033)f(22368c85)g(18e960ea)h(2002b06f)389
- X1502 y(22ff23e8)f(251187dc)g(340c3dcd)h(00000023)389 1552 y(00000004)370
- X1643 y Fl(Figure)14 b(4:)j(A)d(sample)f(RNG)g(state)i(\014le)f(for)f(the)i
- X(Kn)o(uth/Ben)o(tley)g(prand\(\).)324 1740 y Ff(RNG)21 b(statefile)f(for)h
- X(algorithm)f(4,)h(\(4.3bsd)g(nrand48.c:)e(48-bit)324 1790 y(multiplicative\))
- X324 1840 y(Buffer)h(size)h(=)h(8192)f(bytes)324 1889 y(Initial)f(seed)h
- X(table)g(=)389 1939 y(0096)65 b(b43f)f(0034)h(bf15)324 2039
- Xy(Number)20 b(of)i(calls)e(to)i(underlying)e(RNG)h(after)g(seeding)f(=)h(0)h
- X(billion)324 2089 y(+)f(11000)324 2138 y(Next)g(value)g(in)g(this)g
- X(pseudorandom)e(sequence)h(=)i(04a3689e)324 2188 y(This)f(RNG)g(returns)f
- X(every)h(1)h(generates)324 2238 y(This)f(RNG)g(uses)g(mrandom)f(algorithm)g
- X(0)324 2288 y(RNG)h(state)g(table)f(=)389 2338 y(07c5)65 b(8f2d)f(0000)h
- X(a7d6)530 2429 y Fl(Figure)14 b(5:)k(A)c(sample)e(RNG)i(state)g(table)g(for)g
- XFf(nrand48)p eop
- X%%Page: 14 17
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)624
- Xb Fl(14)324 294 y Ff(/*)21 b(Proper)g(way)g(to)g(re-initialize)e(an)j(active)
- Xe(RNG)h(*/)324 344 y(mrandom\(rng,10,n)o(,v\);)324 394 y(kill_rng\(rng\);)324
- X444 y(rng=restart_rng\()o("myst)o(atefi)o(le"\);)324 544 y(/*)g(Proper)g(way)
- Xg(to)g(restart)g(an)g(inactive)f(RNG)h(*/)324 593 y(RNGdata)f(*rng;)324
- X643 y(rng=restart_rng\()o("myst)o(atefi)o(le"\);)324 743 y(/*)h(Improper)f
- X(way)h(to)h(restart)e(an)i(active)e(RNG)h(*/)324 793 y(mrandom\(rng,10,n)o
- X(,v\);)324 842 y(rng=restart_rng\()o("myst)o(atefi)o(le"\);)515
- X934 y Fl(Figure)14 b(6:)j(Examples)c(of)g(sa)o(ving)h(and)f(restarting)i
- X(RNGs)262 1066 y Fh(5.4.4)47 b(Seeding)262 1143 y Fl(Eac)o(h)14
- Xb(RNG)g(is)g(initially)e(seeded)k(during)e(initialization)e(b)o(y)i
- XFf(init_rng)p Fl(.)j(An)e(RNG)f(ma)o(y)262 1193 y(also)f(b)q(e)h(reseeded)j
- X(at)c(an)o(y)h(time)e(after)i(initialization.)324 1292 y Ff(void)21
- Xb(seed_rng\(rng,see)o(d\))324 1342 y(RNGdata)f(*rng;)324 1392
- Xy(long)h(*seed;)324 1492 y(seed_rng)16 b Fl(seeds)j Ff(rng)e
- XFl(with)g(the)i(seed)g(table)e(p)q(oin)o(ted)h(to)f(b)o(y)h
- XFf(seed)p Fl(.)28 b(The)18 b(RNG's)262 1541 y(coun)o(ter)c(is)g(reset)i(to)d
- X(0)h(and)g(its)g(bu\013ers)h(are)f(\015ushed.)262 1649 y Fh(5.4.5)47
- Xb(Chec)o(king)15 b(RNG)h(in)o(tegri)o(t)n(y)262 1726 y Fl(An)f(RNG)g(can)h(b)
- Xq(e)g(c)o(hec)o(k)o(ed)h(to)e(see)i(if)e(it)g(has)h(b)q(een)g(corrupted)h(or)
- Xf(is)f(otherwise)i(not)e(in)262 1776 y(prop)q(er)f(condition)g(for)f(use.)324
- X1875 y Ff(int)21 b(check_rng\(rng\);)324 1925 y(RNGdata)f(*rng;)324
- X2025 y(check_rng)12 b Fl(c)o(hec)o(ks)k(the)g(in)o(tegrit)o(y)d(of)h(the)i
- X(RNG,)d(in)h(order)h(to)g(determine)f(whether)262 2075 y(it)f(can)h(b)q(e)h
- X(used)f(b)o(y)g(the)h(other)f(mrandom)d(library)i(routines.)262
- X2183 y Fh(5.4.6)47 b(Obtaining)13 b(a)j(h)o(uman-readabl)o(e)d(description)f
- X(of)k(the)e(RNG)324 2259 y Ff(char)21 b(*describe_rng\(rn)o(g,rng)o(id\))324
- X2309 y(RNGdata)f(*rng;)324 2359 y(char)h(rngid[RNGIDSTRLE)o(N];)p
- Xeop
- X%%Page: 15 18
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)624
- Xb Fl(15)324 307 y Ff(describe_rng)19 b Fl(places)j(a)g(h)o(uman-readable)e
- X(description)j(of)e Ff(rng)g Fl(in)g(the)i(string)262 357 y
- XFf(rngid)p Fl(.)16 b(The)f(string)f(has)g(the)g(follo)o(wing)e(format:)324
- X457 y Ff(RNG)21 b(state)g(identifier)e(is)j(\(alg,)f(mralg:)f(seed1,)h
- X(seed2;)f(count1,count2;)324 506 y(bufsize,)g(split\))324 606
- Xy Fl(where)324 697 y Fe(\017)g Ff(alg)11 b Fl(is)f(the)i(n)o(um)o(b)q(er)e
- X(of)h(the)g(algorithm)d(used)k(b)o(y)f Ff(rng)f Fl(to)h(generate)h
- X(pseudorandom)365 747 y(n)o(um)o(b)q(ers.)18 b(\(See)d(App)q(endix)f(B.\))324
- X830 y Fe(\017)20 b Ff(mralg)10 b Fl(is)h(the)g(n)o(um)o(b)q(er)g(of)f(the)h
- X(algorithm)e(used)i(b)o(y)g Ff(mrandomrv)e Fl(when)i(called)g(with)365
- X880 y Ff(rng)p Fl(.)18 b(\(See)d(Section)f(5.4.2.\))324 963
- Xy Fe(\017)20 b Ff(seed1)14 b Fl(and)h Ff(seed2)f Fl(are)i(the)g(\014rst)f
- X(and)g(second)i(en)o(tries)f(in)e(t)p Ff(rng)p Fl('s)h(seed)h(table.)22
- Xb(If)365 1013 y Ff(rng)p Fl('s)12 b(seed)i(table)e(has)h(more)e(than)h(t)o(w)
- Xo(o)g(en)o(tries,)i(only)d(the)i(\014rst)h(t)o(w)o(o)e(are)g(included)365
- X1063 y(in)i(its)g(description.)k(\(See)d(Section)f(5.4.4.\))324
- X1146 y Fe(\017)20 b Ff(count1)13 b Fl(and)h Ff(count2)e Fl(represen)o(t)k
- XFf(rng)p Fl('s)e(coun)o(ter.)19 b(\(See)14 b(Section)h(5.4.1.\))324
- X1229 y Fe(\017)20 b Ff(bufsize)13 b Fl(is)g(the)i(n)o(um)o(b)q(er)e(of)g(en)o
- X(tries)i(in)f Ff(rng)p Fl('s)f(bu\013er.)19 b(\(See)c(Section)f(5.4.2.\))324
- X1312 y Fe(\017)20 b Ff(split)13 b Fl(is)h Ff(rng)p Fl('s)f(curren)o(t)i
- X(split)f(v)n(alue.)j(\(See)e(Section)f(5.4.7.\))324 1403 y
- XFf(describe_rng)19 b Fl(exits)j(with)f(a)g(message)g(to)h Ff(stderr)e
- XFl(if)h(called)g(with)g(an)h(in)o(v)n(alid)262 1453 y Ff(RNGdata)12
- Xb Fl(p)q(oin)o(ter.)262 1561 y Fh(5.4.7)47 b(Pro)q(cedures)14
- Xb(for)h(examining)f(and)h(mo)q(difying)e(RNG)j(parameters)262
- X1637 y Fl(Pro)q(cedures)21 b(are)e(a)o(v)n(ailable)e(for)h(examining)f(and)h
- X(mo)q(difying)e(an)j(RNG's)f(parameters)262 1687 y(once)c(it)g(has)g(b)q(een)
- Xh(initialized.)324 1787 y Ff(int)21 b(mralg_rng\(rng,)e(new_value\))324
- X1837 y(RNGdata)h(*rng;)324 1886 y(long)h(new_value;)324 1986
- Xy(int)g(split_rng\(rng,)e(new_value\))324 2036 y(RNGdata)h(*rng;)324
- X2086 y(long)h(new_value;)324 2185 y(double)f(range_rng\(rng\))324
- X2235 y(RNGdata)g(*rng;)324 2335 y(mralg_rng)e Fl(sets)k Ff(rng)p
- XFl('s)e(mrandom)e(algorithm)g(n)o(um)o(b)q(er)h(\(See)j(Section)f(5.4.2)e
- X(for)262 2385 y(information)12 b(on)j(mrandom)d(algorithm)g(n)o(um)o(b)q
- X(ers\).)22 b(It)16 b(returns)g(0)f(if)g Ff(new_value)e Fl(is)i(an)262
- X2434 y(in)o(v)n(alid)c(v)n(alue.)p eop
- X%%Page: 16 19
- Xbop 262 162 a Fi(5)41 b(USING)14 b(THE)g(MRANDOM)f(P)m(A)o(CKA)o(GE)624
- Xb Fl(16)324 294 y Ff(RNGdata)20 b(*rngs[10];)324 344 y(long)h(seed;)324
- X394 y(int)g(i;)324 494 y(seed=12345;)324 544 y(for)g(\(i=0;)g(i<10;)f(i++\))h
- X({)367 593 y(/*)h(RNG)f(#i)g(gets)g(cycled)g(i)g(times)g(*/)367
- X643 y(rng[i]=init_rng\(2,0)o(,&see)o(d,i,0)o(,1024)o(\);)367
- X693 y(split\(rng[i],9\);)324 743 y(})615 834 y Fl(Figure)14
- Xb(7:)k(Creating)c(\\leapfrogged")e(RNGs)324 967 y Ff(split_rng)20
- Xb Fl(sets)k(the)f(split)e(v)n(alue)h(of)g Ff(rng)p Fl(.)42
- Xb(It)23 b(returns)h(0)e(if)f Ff(new_value)f(<)i Fl(0.)262 1017
- Xy(An)c(RNG's)g(split)g(v)n(alue)g(is)g(set)i(to)e Ff(SPLIT_DEF)e
- XFl(up)q(on)j(initialization.)29 b Ff(SPLIT_DEF)17 b Fl(is)262
- X1066 y Ff(#define)p Fl(d)12 b(in)h(`)p Ff(mrandom.h)p Fl(',)e(and)j(curren)o
- X(tly)g(has)h(a)e(v)n(alue)g(of)h(0.)324 1116 y(The)j(function)g(of)f(the)h
- X(split)g(v)n(alue)f(is)g(to)h(sim)o(ulate)e(one)i(\\branc)o(h")g(of)f(a)h
- X(generator)262 1166 y(whic)o(h)11 b(has)g(b)q(een)i(\\split")d(in)o(to)g(t)o
- X(w)o(o)h(or)g(more)g(generators.)18 b(This)11 b(is)g(b)q(est)i(illustrated)e
- X(with)262 1216 y(an)g(example.)17 b(Consider)12 b(an)g(\(apparen)o(tly)g
- X(non-random\))f(RNG)g(whic)o(h)h(returns)i(the)f(ra)o(w)262
- X1266 y(sequence:)621 1349 y(0)h(1)f(2)h(3)g(4)f(5)h(6)f(7)h(8)g(9)f(10)h(11)f
- X(12)g(13)h(14)f(15)g(...)262 1432 y(The)j(split)g(v)n(alue)g(indicates)h(ho)o
- X(w)f(man)o(y)e(elemen)o(ts)i(of)g(the)h(sequence)i(to)d(skip)g(b)q(et)o(w)o
- X(een)262 1481 y(generates.)j(F)m(or)13 b(example,)f(if)g(our)h(sample)g(RNG)f
- X(w)o(ere)i(giv)o(en)f(a)g(split)g(v)n(alue)g(of)g(1)g(imm)o(e-)262
- X1531 y(diately)g(after)h(initialization,)d(it)i(w)o(ould)g(then)i(return)g
- X(the)f(follo)o(wing)e(sequence:)846 1614 y(0)i(2)f(4)h(6)g(8)f(10)g(...)262
- X1697 y(A)g(split)h(v)n(alue)f(of)g(2)h(after)g(initialization)d(w)o(ould)i
- X(pro)q(duce:)836 1780 y(0)g(3)h(6)g(9)f(12)g(15)h(...)262 1863
- Xy(An)19 b(RNG)g(ma)o(y)f(b)q(e)i(split)f(at)g(an)o(y)g(time)f(after)i(its)g
- X(initialization.)32 b(So,)20 b(for)f(example,)262 1913 y(our)14
- Xb(sample)g(RNG)f(migh)o(t)g(b)q(e)i(initialized)e(and)i(then)g(made)f(to)g
- X(generate)i(the)f(follo)o(wing)262 1963 y(v)n(alues:)881 2046
- Xy(0)e(1)h(2)g(3)f(4)h(5)262 2129 y(b)q(efore)g(b)q(eing)g(split)f(with)h(a)g
- X(split)f(v)n(alue)g(of)h(3,)f(pro)q(ducing)h(the)g(follo)o(wing)e(generates:)
- X832 2212 y(6)i(10)f(14)h(18)f(22)g(...)262 2295 y(Splitting)g(can)h(b)q(e)i
- X(used)f(to)f(create)i(sev)o(eral)f(\\leapfrogged")f(RNGs)g(from)f(one)h(RNG,)
- Xg(as)262 2345 y(sho)o(wn)f(in)h(Figure)g(7.)324 2395 y(This)c(op)q(eration)g
- X(ma)o(y)e(b)q(e)j(useful)f(in)g(parallel)f(co)q(des,)j(as)e(in)g(testing)g
- X(an)g(RNG)g(for)g(long-)262 2445 y(range)k(correlations.)21
- Xb(Unfortunately)m(,)14 b(our)g(curren)o(t)j(implem)o(en)o(tation)12
- Xb(is)i(ine\016cien)o(t)h(for)p eop
- X%%Page: 17 20
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(17)262 307 y(leapfrogging)11 b(large)h(n)o(um)o(b)q(ers)h(of)f
- X(RNGs.)17 b(A)c(more)f(e\016cien)o(t)h(metho)q(d)f(ma)o(y)f(b)q(e)i(included)
- X262 357 y(in)g(a)h(future)g(v)o(ersion)g(of)f(mrandom.)324
- X407 y(The)h(split)g(v)n(alue)g(a\013ects)h(all)e(of)h(the)h(pseudorandom)e(n)
- Xo(um)o(b)q(er)h(generating)g(routines)262 457 y(\(See)g(Section)h(5.4.2\).)
- X324 506 y Ff(range_rng)d Fl(returns)j(the)g(range)f(of)f Ff(rng)p
- XFl(.)262 606 y Fh(NOTES)324 656 y Fl(These)j(pro)q(cedures)h(exit)d(with)g(a)
- Xh(message)f(to)g Ff(stderr)g Fl(if)g Ff(rng)f Fl(do)q(es)j(not)e(p)q(oin)o(t)
- Xg(to)h(a)262 706 y(v)n(alid)d Ff(RNGdata)g Fl(structure.)262
- X843 y Fk(6)69 b(Adding)23 b(new)f(RNGs)g(to)h(the)g(P)n(ac)n(k)l(age)262
- X934 y Fl(This)c(section)i(is)f(designed)h(for)e(the)i(programmer)d(who)h
- X(wishes)i(to)f(add)g(new)g(RNGs)262 984 y(to)15 b(the)i(mrandom)c(pac)o(k)n
- X(age.)24 b(The)16 b(section)h(\014rst)g(describ)q(es)h(the)e(routines)h(whic)
- Xo(h)f(m)o(ust)262 1034 y(b)q(e)21 b(pro)o(vided)f(b)o(y)h(the)g(programmer)e
- X(to)h(serv)o(e)i(as)f(an)g(in)o(terface)g(b)q(et)o(w)o(een)h(the)f(RNG)262
- X1083 y(and)14 b(the)g(mrandom)d(pac)o(k)n(age.)19 b(It)14 b(then)h(describ)q
- X(es)h(the)f(RNG)e(parameters)i(whic)o(h)f(m)o(ust)262 1133
- Xy(b)q(e)j(de\014ned)h(in)e(a)h(header)g(\014le)g(for)f(the)i(RNG,)d(and)i(ho)
- Xo(w)f(these)i(parameters)f(are)g(to)g(b)q(e)262 1183 y(incorp)q(orated)j(in)o
- X(to)f(the)i(co)q(de)f(for)g(mrandom)d(itself.)35 b(Finally)m(,)19
- Xb(it)g(describ)q(es)j(ho)o(w)e(to)262 1233 y(remak)o(e)c(the)h(mrandom)d(pac)
- Xo(k)n(age)j(after)g(adding)f(or)h(mo)q(difying)c(RNGs.)27 b(App)q(endix)17
- Xb(B)262 1283 y(con)o(tains)g(descriptions)i(of)f(the)g(ten)h(RNGs)f
- X(installed)f(in)g(the)i(curren)o(t)g(v)o(ersion)g(of)e(the)262
- X1332 y(pac)o(k)n(age.)262 1449 y Fd(6.1)55 b(Routines)18 b(Pro)n(vided)g(b)n
- X(y)h(the)f(Programmer)262 1525 y Fh(6.1.1)47 b(In)o(tro)q(duction)262
- X1602 y Fl(This)17 b(section)i(describ)q(es)h(routines)e(whic)o(h)g(m)o(ust)f
- X(b)q(e)i(pro)o(vided)e(b)o(y)h(eac)o(h)g(RNG)g(in)f(the)262
- X1652 y(pac)o(k)n(age.)324 1701 y(The)k(routines)g(pro)o(vided)f(b)o(y)h(the)g
- X(programmer)d(m)o(ust)h(manipulate)g(an)h Ff(RNGdata)262 1751
- Xy Fl(structure.)j(In)16 b(order)f(to)g(facilitate)f(this,)h(t)o(w)o(o)g
- X(macros)f(are)i(a)o(v)n(ailable)d(for)i(accessing)h(an)262
- X1801 y(RNG's)d(state)h(and)g(seed)h(v)o(ectors:)324 1884 y
- XFe(\017)20 b Ff(RNGstate)12 b Fl(refers)k(to)e(the)g(RNG's)f(state)i(v)o
- X(ector.)324 1967 y Fe(\017)20 b Ff(RNGseed)13 b Fl(refers)i(to)f(the)g(RNG's)
- Xf(seed)i(v)o(ector.)262 2050 y(These)j(v)o(ectors)g(are)f(one-dimensional)e
- X(C)h(arra)o(ys,)i(e.g.)26 b Ff(RNGstate[0])15 b Fl(is)i(the)g(\014rst)h(el-)
- X262 2100 y(emen)o(t)d(in)g(the)i(RNG's)e(state)h(v)o(ector,)h
- XFf(RNGstate[1])c Fl(is)j(the)g(second)h(elemen)o(t,)f(etc.)25
- Xb(In)262 2150 y(order)17 b(to)g(mak)o(e)f(use)i(of)f(these)h(macros,)f(the)h
- X(name)e(of)g(the)i Ff(RNGdata)e Fl(p)q(oin)o(ter)h(in)g(y)o(our)262
- X2200 y(routines')c(parameter)f(lists)h Fc(must)g Fl(b)q(e)g
- XFf(rng)p Fl(,)f(as)h(sho)o(wn)g(in)g(the)g(examples)f(in)g(this)h(section.)
- X324 2249 y(The)j(names)g(used)h(as)f(examples)f(in)h(this)g(section)h(b)q
- X(egin)f(with)g(\\)p Ff(myrng)p Fl(";)f(ho)o(w)o(ev)o(er,)262
- X2299 y(there)g(are)f(no)g(restrictions)h(on)f(naming)e(of)h(routines)i(pro)o
- X(vided)e(b)o(y)h(an)g(RNG.)f(Ho)o(w)o(ev)o(er,)262 2349 y(for)f(ease)j(of)d
- X(readabilit)o(y)g(and)h(consistency)m(,)h(w)o(e)g(suggest)g(that)f(the)h
- X(naming)d(con)o(v)o(en)o(tions)262 2399 y(used)j(in)g(this)g(section)g(b)q(e)
- Xh(follo)o(w)o(ed.)p eop
- X%%Page: 18 21
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(18)324 307 y(The)10 b(routines)h(describ)q(ed)h(in)d(this)i(section)
- Xf(should)g(b)q(e)h(included)f(in)g(a)f(single)h Ff(.c)g Fl(\014le.)17
- Xb(A)262 357 y(template)11 b(for)h(suc)o(h)h(a)f(source)h(\014le,)f(called)g
- X(`)p Ff(newrng.c)p Fl(',)e(is)i(included)g(in)g(the)h(distribution)262
- X407 y(and)g(displa)o(y)o(ed)h(in)f(Figure)h(8.)324 457 y(Remem)o(b)q(er)8
- Xb(that)j(all)e(RNG)g(state)i(information)c(m)o(ust)j(b)q(e)g(included)h(in)e
- X(the)i Ff(RNGstate)262 506 y Fl(\014eld)f(of)g(the)i Ff(RNGdata)d
- XFl(structure.)19 b(In)11 b(particular,)f(do)h Fc(not)g Fl(use)h(global)d(or)h
- X(static)h(v)n(ariables)262 556 y(to)h(hold)g(RNG)g(state)i(information.)g
- X(Doing)e(so)h(will)e(mak)o(e)g(it)h(imp)q(ossible)f(to)i(run)g(sev)o(eral)262
- X606 y(instan)o(tiations)f(of)i(y)o(our)f(RNG)g(sim)o(ulataneously)m(.)262
- X714 y Fh(6.1.2)47 b(Seeding)14 b(Routine)324 791 y Ff(void)21
- Xb(myrng_seed\(rng,)d(seed\))324 840 y(RNGdata)i(*rng;)324 890
- Xy(long)h(*seed;)324 990 y Fl(This)13 b(pro)q(cedure)i(is)e(used)h(for)e
- X(seeding)i(the)g(RNG.)d(The)j(in)o(terpretation)f(of)g(the)g
- XFf(seed)262 1040 y Fl(parameter)18 b(is)g(left)h(en)o(tirely)g(to)f(the)h
- X(programmer.)30 b(It)19 b(ma)o(y)m(,)e(for)h(example,)h(p)q(oin)o(t)f(to)262
- X1089 y(a)f(single)g(in)o(teger)h(or)f(to)g(an)g(arra)o(y)h(of)e(5,000)g(in)o
- X(tegers.)30 b(One)18 b(of)f(the)h(RNGs)f(curren)o(tly)262 1139
- Xy(installed)c(in)h(the)h(pac)o(k)n(age)f(in)o(terprets)i(the)f
- XFf(seed)e Fl(parameter)h(as)g(p)q(oin)o(ting)g(to)g(three)h(16-)262
- X1189 y(bit)10 b(in)o(tegers.)18 b(Ob)o(viously)m(,)10 b(RNGs)h(whic)o(h)g
- X(are)h(capable)f(of)g(b)q(eing)g(seeded)i(with)e(a)g(v)n(ariable)262
- X1239 y(n)o(um)o(b)q(er)19 b(of)h(seeds)i(need)g(to)e(b)q(e)h(passed)h(a)e
- X(seed)i(p)q(oin)o(ter)e(whic)o(h)h(con)o(tains)f(adequate)262
- X1289 y(information)10 b(ab)q(out)k(the)h(n)o(um)o(b)q(er)e(of)g(seeds)j(to)d
- X(whic)o(h)h(it)g(p)q(oin)o(ts.)324 1339 y(Although)g(the)i(seeding)g(pro)q
- X(cedure)h(is)d(passed)j(an)d(en)o(tire)i Ff(RNGdata)e Fl(structure)j(as)e(a)
- X262 1388 y(parameter,)c(it)h(should)g(only)g(manipulate)e(the)j
- XFf(RNGstate)e Fl(\014eld)h(of)g(that)g(structure.)20 b(\(See)262
- X1438 y(App)q(endix)e(A)f(for)h(information)d(on)i(the)i Ff(RNGdata)d
- XFl(structure.\))32 b(Man)o(y)17 b(RNG)g(seeding)262 1488 y(pro)q(cedures)k
- X(will)d(simply)f(cop)o(y)i(the)h(seed)g(parameter)f(in)o(to)f
- XFf(RNGstate)p Fl(,)h(as)g(sho)o(wn)g(in)262 1538 y(Figure)14
- Xb(9.)324 1588 y(Other)j(seeding)f(pro)q(cedures)i(ma)o(y)c(\014ll)h
- XFf(RNGstate)f Fl(with)h(the)h(results)h(of)e(some)g(com-)262
- X1637 y(plicated)e(function)h(p)q(erformed)f(on)h(the)h(initial)d(seed)j
- X(table.)262 1745 y Fh(6.1.3)47 b(Pseudorandom)13 b(Num)o(b)q(er)i(Generating)
- Xe(Pro)q(cedure)324 1822 y Ff(long)21 b(myrng_lgen\(rng\))324
- X1872 y(RNGdata)f(*rng;)324 1971 y(double)g(myrng_dgen\(rng\))324
- X2021 y(RNGdata)g(*rng;)324 2121 y Fl(The)13 b(programmer)e(m)o(ust)g(pro)o
- X(vide)i Fc(one)g Fl(pro)q(cedure,)i(matc)o(hing)c(one)i(of)f(the)h(t)o(w)o(o)
- Xg(pro-)262 2171 y(tot)o(yp)q(es)e(giv)o(en)g(ab)q(o)o(v)o(e,)g(whic)o(h)f
- X(returns)j(a)e(single)f(generate)i(from)e(the)h(RNG.)f(The)h(routine)262
- X2220 y(ma)o(y)g(return)16 b(either:)324 2303 y Fe(\017)k Fl(a)14
- Xb(double)g(precision)g(\015oating)f(p)q(oin)o(t)g(n)o(um)o(b)q(er)g(in)h(the)
- Xg(range)g([0,1\),)f(or)324 2386 y Fe(\017)20 b Fl(a)14 b(long)f(\(32-bit\))g
- X(in)o(teger)h(in)g(the)g(range)g(0..)p Ff(range_rng\(rng\))o
- XFl(-1)p eop
- X%%Page: 19 22
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(19)324 401 y Ff(/*)21 b(newrng.c)f(*/)324 450 y(/*)h(RNG)g(source)g
- X(file)g(template)f(*/)324 500 y(/*)h(Robert)g(Plotkin)324 550
- Xy(/*)g(5/3/93)g(*/)324 650 y(#include)f("newrng.h")324 749
- Xy(/*)h(Generating)f(procedure)g(*/)324 799 y(/*)h(Only)g(one)g(of)h(the)f
- X(following)f(two)h(procedures)f(should)g(be)i(*/)324 849 y(/*)f(defined,)f
- X(depending)g(on)i(the)f(kind)g(of)g(value)g(that)g(*/)324 899
- Xy(/*)g(your)g(RNG)g(returns)g(*/)324 998 y(long)g(newrng_lgen\(rng\))324
- X1048 y(RNGdata)f(*rng;)324 1098 y({)324 1148 y(/*)h(Your)g(generating)f
- X(procedure)g(goes)h(here)g(*/)324 1198 y(})324 1297 y(double)f
- X(newrng_dgen\(rng\))324 1347 y(RNGdata)g(*rng;)324 1397 y({)324
- X1447 y(/*)h(Your)g(generating)f(procedure)g(goes)h(here)g(*/)324
- X1496 y(})324 1596 y(/*)g(Seeding)g(procedure)e(*/)324 1646
- Xy(void)i(newrng_seed\(rng,)o(seed\))324 1696 y(RNGdata)f(*rng;)324
- X1746 y(long)h(*seed;)324 1795 y({)324 1845 y(/*)g(Your)g(seeding)f(procedure)
- Xg(goes)h(here)g(*/)324 1895 y(})324 1995 y(/*)g(Checking)f(procedure)g(*/)324
- X2044 y(int)h(newrng_check\(rng\))324 2094 y(RNGdata)f(*rng;)324
- X2144 y({)324 2194 y(/*)h(Your)g(checking)f(procedure)g(goes)h(here)g(*/)324
- X2244 y(})656 2335 y Fl(Figure)14 b(8:)k(RNG)13 b(source)i(\014le)f(template)p
- Xeop
- X%%Page: 20 23
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(20)324 294 y Ff(void)21 b(myrng_seed\(rng,)d(seed\))324
- X344 y(RNGdata)i(*rng;)324 394 y(long)h(*seed;)324 444 y({)324
- X494 y(RNGstate[0]=seed)o([0];)324 544 y(RNGstate[1]=seed)o([1];)d(/*)k(This)f
- X(RNG)g(uses)g(two)g(long)g(seeds)g(*/)324 593 y(})633 685 y
- XFl(Figure)14 b(9:)j(A)d(sample)f(seeding)i(pro)q(cedure)324
- X771 y Ff(long)21 b(myrng_lgen\(rng\))324 821 y(RNGdata)f(*rng;)324
- X871 y({)324 921 y(RNGstate[0]*=123)o(45+67)o(89;)324 971 y(return\(RNGstate[)
- Xo(0]\);)324 1020 y(})594 1112 y Fl(Figure)14 b(10:)j(A)d(sample)f(generating)
- Xh(pro)q(cedure)262 1244 y(It)h(is)f(p)q(oin)o(tless)i(for)e(the)i(programmer)
- Xc(to)j(pro)o(vide)g(pro)q(cedures)i(of)e(b)q(oth)g(t)o(yp)q(es.)22
- Xb(If)15 b(this)262 1294 y(is)e(done,)g(only)f(one)i(of)e(them)h(will)f(b)q(e)
- Xi(accessible)g(b)o(y)f(an)o(y)g(user)h(co)q(de,)g(dep)q(ending)g(on)f(the)262
- X1344 y(v)n(alue)g(giv)o(en)g(to)h Ff(RNGreturns)p Fl(,)d Ff(RNGdgen)p
- XFl(,)h(and)i Ff(RNGlgen)e Fl(\(see)j(Section)g(6.2\).)324 1394
- Xy(Although)d(the)h(generating)g(pro)q(cedure)h(is)f(passed)h(an)e(en)o(tire)h
- XFf(RNGdata)e Fl(structure,)k(it)262 1444 y(should)9 b(only)g(manipulate)f
- X(the)i Ff(RNGstate)e Fl(\014eld)i(of)f(the)h(structure.)19
- Xb(A)10 b(sample)e(generating)262 1493 y(pro)q(cedure)15 b(is)f(displa)o(y)o
- X(ed)f(in)h(Figure)g(10.)262 1601 y Fh(6.1.4)47 b(RNG)16 b(Chec)o(king)f(Pro)q
- X(cedure)324 1678 y Ff(int)21 b(myrng_check\(rng\))324 1728
- Xy(RNGdata)f(*rng;)324 1827 y Fl(The)g(programmer)d(m)o(ust)i(pro)o(vide)h(a)f
- X(pro)q(cedure)j(to)e(c)o(hec)o(k)g(the)h(in)o(tegrit)o(y)e(of)g(the)262
- X1877 y Ff(RNGdata)d Fl(structure.)32 b(The)18 b(pro)q(cedure)i(returns)g(a)d
- X(v)n(alue)h(of)f(1)g(if)h(the)g(RNG)f(is)h(\014t)g(for)262
- X1927 y(use,)h(and)f(returns)i(0)d(otherwise.)32 b(The)18 b(co)q(ding)g(of)g
- X(the)g(pro)q(cedure)i(is)e(en)o(tirely)h(RNG-)262 1977 y(sp)q(eci\014c,)14
- Xb(and)g(ma)o(y)e(b)q(e)j(extremely)e(simple)g(or)h(extremely)f(complicated,)f
- X(dep)q(ending)j(on)262 2027 y(the)g(nature)h(of)f(the)g(RNG)g(and)g(the)g
- X(exten)o(t)i(of)d(in)o(tegrit)o(y)h(desired.)23 b(On)15 b(one)g(extreme)h(is)
- X262 2077 y(the)g(pro)q(cedure)j(whic)o(h)d(alw)o(a)o(ys)f(declares)j
- X(success,)h(and)d(on)g(the)h(other)g(extreme)g(is)f(the)262
- X2126 y(p)q(erfect)e(\(and)g(slo)o(w\))f(pro)q(cedure)i(whic)o(h)e(creates)i
- X(a)e(new)h(RNG,)e(seeds)j(it)e(with)g(the)h(seeds)262 2176
- Xy(of)c(the)i(RNG)e(to)i(b)q(e)f(c)o(hec)o(k)o(ed,)i(cycles)f(it)f(through)h
- X(the)f(n)o(um)o(b)q(er)g(of)g(generates)i(whic)o(h)e(w)o(ere)262
- X2226 y(pro)q(duced)k(b)o(y)f(the)g(RNG)g(to)g(b)q(e)g(c)o(hec)o(k)o(ed,)h
- X(and)f(compares)g(the)h(state)g(tables)f(of)f(the)i(t)o(w)o(o)262
- X2276 y(RNGs.)21 b(Clearly)m(,)14 b(the)h(pro)q(cedure)i(should)e(not)g(mo)q
- X(dify)e(the)i(RNG)g(in)f(an)o(y)h(w)o(a)o(y)m(.)20 b(When)262
- X2326 y(writing)c(a)g(c)o(hec)o(king)h(pro)q(cedure)i(it)e(migh)o(t)e(b)q(e)i
- X(useful)g(to)g(examine)e(those)j(included)f(in)262 2375 y(the)d(existing)g
- X(pac)o(k)n(age.)p eop
- X%%Page: 21 24
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(21)324 294 y Ff(/*)21 b(newrng.h)f(*/)324 344 y(/*)h(RNG)g(header)g
- X(file)g(template)f(*/)324 394 y(/*)h(Robert)g(Plotkin)324 444
- Xy(/*)g(5/3/93)g(*/)324 544 y(#include)f("mrandom.h")324 643
- Xy(/*)h(Information)f(for)h(mrandom)f(*/)324 693 y(#define)g(RNGstatesize_n)
- X324 743 y(#define)g(RNGseedsize_2)324 793 y(#define)g(RNGrange_2)324
- X842 y(#define)g(RNGname_2)324 892 y(#define)g(RNGreturns_2)324
- X942 y(#define)g(RNGstatetype_2)324 992 y(#define)g(RNGdgen_2)324
- X1042 y(#define)g(RNGlgen_2)324 1092 y(#define)g(RNGseed_2)324
- X1141 y(#define)g(RNGcheck_2)324 1241 y(/*)h(mrandom)g(interface)e(routines)i
- X(*/)324 1291 y(long)g(newrng_gen\(/*)e(RNGdata)h(*)i(*/\);)324
- X1341 y(void)f(newrng_seed\(/*)e(RNGdata)h(*,)h(long)g(*)h(*/\);)324
- X1390 y(int)f(newrng_check\(/*)e(RNGdata)h(*)i(*/\);)642 1482
- Xy Fl(Figure)14 b(11:)k(RNG)13 b(header)i(\014le)f(template)262
- X1614 y Fd(6.2)55 b(RNG)19 b(Header)e(Files)262 1691 y Fl(F)m(or)d(eac)o(h)i
- X(RNG)f(included)g(in)g(the)h(pac)o(k)n(age,)f(there)h(m)o(ust)f(b)q(e)g(a)g
- X(corresp)q(onding)i(header)262 1741 y(\014le.)i(The)c(header)g(\014le)f(con)o
- X(tains)g(information)e(ab)q(out)i(the)h(RNG)e(whic)o(h)i(is)f(used)h(b)o(y)f
- X(the)262 1791 y(mrandom)d(library)i(routines.)20 b(This)15
- Xb(section)g(describ)q(es)h(the)f(information)d(con)o(tained)i(in)262
- X1840 y(RNG)d(header)i(\014les,)f(and)g(describ)q(es)i(ho)o(w)d(to)h(use)h
- X(suc)o(h)g(header)f(\014les)h(to)f(incorp)q(orate)g(new)262
- X1890 y(RNGs)18 b(in)o(to)g(the)h(mrandom)d(pac)o(k)n(age.)32
- Xb(A)19 b(template)f(for)g(suc)o(h)h(a)g(header)g(\014le,)h(called)262
- X1940 y(`)p Ff(newrng.h)p Fl(',)10 b(is)k(included)g(in)g(the)g(distribution)f
- X(and)h(displa)o(y)o(ed)f(in)h(Figure)g(11.)262 2048 y Fh(6.2.1)47
- Xb(Information)13 b(in)i(Header)g(Files)262 2125 y Fl(Eac)o(h)f(header)h
- X(\014le)e(should)h(b)q(egin)g(with)g(the)g(follo)o(wing)d(directiv)o(es:)324
- X2224 y Ff(#ifndef)20 b(MRANDOM)324 2274 y(#include)g("mrandom.h")324
- X2324 y(#endif)p eop
- X%%Page: 22 25
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(22)262 307 y Fh(De\014niti)o(on)12 b(of)k(RNG)f(parameters)324
- X407 y Fl(The)i(next)h(set)g(of)f(lines)g(in)f(the)i(\014le)f(should)g(con)o
- X(tain)g Ff(#define)e Fl(statemen)o(ts)j(whic)o(h)262 457 y(assign)13
- Xb(v)n(alues)h(to)g(the)g(RNG's)g(parameters.)k(The)c(names)f(used)i(in)f(the)
- Xg Ff(#define)f Fl(state-)262 506 y(men)o(ts)d(m)o(ust)g(con)o(tain)h(the)h
- X(RNG's)e(n)o(um)o(b)q(er.)16 b(There)c(are)g(curren)o(tly)g(ten)g(RNGs)e
- X(included)262 556 y(in)16 b(the)i(pac)o(k)n(age,)f(lab)q(eled)g(0)g(through)g
- X(9.)27 b(The)18 b(next)f(RNG)f(included)i(in)e(the)i(pac)o(k)n(age)262
- X606 y(should)d(b)q(e)h(lab)q(eled)g(n)o(um)o(b)q(er)f(10,)g(and)h(so)g(on.)23
- Xb(The)16 b(\\)p Ff(n)p Fl(")f(in)h(eac)o(h)g(parameter)f(name)g(in)262
- X656 y(the)f(follo)o(wing)d(list)j(should)f(b)q(e)i(in)o(terpreted)g(as)f(the)
- Xh(RNG's)e(n)o(um)o(b)q(er.)262 729 y Ff(RNGname_n)18 b Fl(A)11
- Xb(string)g(constan)o(t)h(con)o(taining)d(the)j(name)d(of)i(the)g(RNG,)f
- X(terminated)g(with)365 779 y(a)k(newline)g(c)o(haracter.)262
- X855 y Ff(RNGstatesize_n)j Fl(The)f(n)o(um)o(b)q(er)e(of)h(en)o(tries)h(in)e
- X(the)i(RNG's)e(state)i(table.)22 b(Eac)o(h)15 b(en)o(try)365
- X905 y(is)g(a)f(\(32-bit\))g Ff(long)p Fl(.)19 b(If)14 b(the)h(RNG)f(is)h
- X(capable)f(of)g(using)h(state)g(tables)g(of)f(v)n(arying)365
- X955 y(sizes,)h Ff(RNGstatesize_n)c Fl(should)i(b)q(e)i(de\014ned)g(as)f(the)g
- X(maxim)o(um)9 b(p)q(ossible)14 b(size.)262 1030 y Ff(RNGseedsize_n)k
- XFl(The)11 b(n)o(um)o(b)q(er)g(of)g(en)o(tries)h(in)f(the)h(RNG's)e(seed)j
- X(table.)k(Eac)o(h)12 b(en)o(try)g(is)f(a)365 1080 y(\(32-bit\))i
- XFf(long)p Fl(.)k(If)c(the)h(RNG)e(is)h(capable)g(of)g(using)g(seed)i(tables)e
- X(of)g(v)n(arying)f(sizes,)365 1130 y Ff(RNGseedsize_n)f Fl(should)j(b)q(e)h
- X(de\014ned)g(as)f(the)g(maxim)n(um)c(p)q(ossible)k(size.)262
- X1206 y Ff(RNGrange_n)k Fl(The)h(range)f(of)f(the)i(RNG,)e(expressed)j(as)e(a)
- Xg(double)g(precision)h(\015oating)365 1256 y(p)q(oin)o(t)f(n)o(um)o(b)q(er.)
- X29 b(The)19 b(range)f(of)f(the)i(RNG)e(is)h(one)g(more)f(than)h(the)h(maxim)n
- X(um)365 1305 y(v)n(alue)12 b(the)i(RNG)e(is)g(capable)h(of)f(generating.)18
- Xb(F)m(or)12 b(RNGs)g(whic)o(h)h(pro)q(duce)h(double)365 1355
- Xy(precision)f(generates)h(with)e(a)h(precision)f(of)g(p)h(\(i.e.)k(in)12
- Xb(the)h(range)g([0)p Fg(;)7 b Fl(\()p Ff(RNGrange)s Fe(\000)365
- X1405 y Fl(1)p Fg(:)p Fl(0\))p Fg(=)p Fl(\(1)k Fg(<<)h(p)p Fl(\)\),)h
- XFf(RNGrange)e Fl(should)i(b)q(e)h(de\014ned)h(as)e(2)1246 1390
- Xy Fa(p)1265 1405 y Fl(.)18 b(F)m(or)13 b(example,)e(an)i(RNG)365
- X1455 y(whic)o(h)d(pro)q(duces)h(8-b)o(yte)f(IEEE)g(\015oating-p)q(oin)o(t)e
- X(generates)j(using)f(single-precision)365 1505 y(IEEE)15 b(arithmetic)e
- X(\(24-bit)g(man)o(tissas\))f(has)j(a)e(range)h(of)f(16777216.0.)262
- X1581 y Ff(RNGreturns_n)18 b Fl(A)f(n)o(um)o(b)q(er)g(signifying)e(the)j(t)o
- X(yp)q(e)f(of)g(the)h(generate)g(returned)h(b)o(y)e(the)365
- X1630 y(RNG.)c(An)h(RNG)f(can)h(return)h(a)f(v)n(alue)f(of)g(one)h(of)g(t)o(w)
- Xo(o)f(t)o(yp)q(es:)415 1706 y Fe(\017)21 b Fl(a)13 b Ff(long)g
- XFl(in)h(the)g(range)g(0..)p Ff(RNGrange)p Fl(-1)415 1765 y
- XFe(\017)21 b Fl(a)13 b Ff(double)g Fl(in)g(the)i(range)f([0,1\))365
- X1841 y(RNGs)c(whic)o(h)g(return)h(v)n(alues)e(of)h(t)o(yp)q(e)g
- XFf(long)f Fl(and)h Ff(double)e Fl(return)k(t)o(yp)q(es)e Ff(RET_LONG)365
- X1891 y Fl(and)k Ff(RET_DOUBLE)p Fl(,)d(resp)q(ectiv)o(ely)m(,)k(as)f
- X(de\014ned)h(in)e(`)p Ff(mrandom.h)p Fl('.)262 1967 y Ff(RNGstatetype)18
- Xb Fl(A)f(n)o(um)o(b)q(er)f(signifying)g(the)h(in)o(terpretation)h(of)e(the)i
- X(v)n(alues)f(stored)h(in)365 2017 y(the)c(RNG's)e(state)i(and)e(seed)i(v)o
- X(ectors.)19 b(This)13 b(v)n(alue)f(is)h(used)h(b)o(y)f(the)g(routines)h(that)
- X365 2067 y(read)g(and)g(write)g(the)g(ASCI)q(I)g(state)h(\014les,)e(thereb)o
- X(y)i(allo)o(wing)c(p)q(ortabilit)o(y)i(of)g(state)365 2116
- Xy(\014les)f(across)h(mac)o(hines)e(with)h(di\013eren)o(t)g(b)o(yte)h
- X(orderings)f(\(see)h(Section)f(5.4.3\).)k(The)365 2166 y(follo)o(wing)c(v)n
- X(alues)h(are)h(curren)o(tly)h(supp)q(orted:)732 2250 y(V)m(alue)160
- Xb(T)o(yp)q(e)p 707 2267 645 2 v 732 2351 a Ff(STATE)p 845 2351
- X14 2 v 15 w(CHAR)49 b Fl(8-bit)13 b(c)o(haracter)732 2401 y
- XFf(STATE)p 845 2401 V 15 w(INT)71 b Fl(16-bit)13 b(in)o(teger)732
- X2451 y Ff(STATE)p 845 2451 V 15 w(LONG)49 b Fl(32-bit)13 b(long)f(in)o(teger)
- Xp eop
- X%%Page: 23 26
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(23)365 307 y(The)10 b(v)n(alues)f(of)g Ff(STATE)p
- X721 307 14 2 v 14 w(FLOAT)g Fl(\(IEEE-standard)h(32-bit)e(\015oat\))h(and)g
- XFf(STATE)p 1559 307 V 15 w(DOUBLE)365 357 y Fl(\(IEEE-standard)k(64-bit)e
- X(\015oat\))g(are)i(not)e(curren)o(tly)i(supp)q(orted)g(and)e(are)i(reserv)o
- X(ed)365 407 y(for)h(future)g(use.)262 490 y Ff(RNGdgen_n)g
- XFh(and)h Ff(RNGlgen_n)k Fl(The)14 b(lab)q(el)f(of)h(the)g(pro)q(cedure)i(to)e
- X(b)q(e)g(used)h(for)f(generat-)365 540 y(ing)f(pseudorandom)f(n)o(um)o(b)q
- X(ers.)17 b(If)c(the)g(RNG)f(returns)j Ff(double)p Fl(s,)d(then)h
- XFf(RNG_dgen)365 589 y Fl(should)20 b(b)q(e)i(de\014ned)f(as)f(the)h(lab)q(el)
- Xf(of)g(the)h(RNG)f(generating)g(pro)q(cedure,)k(and)365 639
- Xy Ff(RNG_lgen)8 b Fl(should)h(b)q(e)h(de\014ned)g(as)g(0.)16
- Xb(If)9 b(the)h(RNG)e(returns)j Ff(long)p Fl(s,)e(then)h Ff(RNG_lgen)365
- X689 y Fl(should)20 b(b)q(e)i(de\014ned)f(as)f(the)h(lab)q(el)f(of)g(the)h
- X(RNG)f(generating)g(pro)q(cedure,)k(and)365 739 y Ff(RNG_dgen)12
- Xb Fl(should)i(b)q(e)h(de\014ned)g(as)f(0.)262 822 y Ff(RNGseed_n)k
- XFl(The)d(lab)q(el)e(of)g(the)i(pro)q(cedure)h(to)d(b)q(e)i(used)g(for)e
- X(seeding)i(the)f(RNG.)262 905 y Ff(RNGcheck_n)k Fl(The)c(lab)q(el)e(of)h(the)
- Xh(pro)q(cedure)h(to)e(b)q(e)h(used)g(for)e(c)o(hec)o(king)i(the)g(in)o
- X(tegrit)o(y)e(of)365 955 y(the)j(RNG.)262 1046 y Fh(Pro)q(cedure)f(protot)o
- X(yp)q(es)324 1146 y Fl(Finally)m(,)f(the)j(header)g(\014le)f(m)o(ust)f(con)o
- X(tain)h(function)g(protot)o(yp)q(es)h(for)e(the)i(three)h(pro-)262
- X1196 y(cedures)h(pro)o(vided)e(b)o(y)g(the)h(RNG,)e(so)h(that)h(the)f(pro)q
- X(cedures)j(can)d(b)q(e)h(accessed)i(b)o(y)d(the)262 1245 y(main)11
- Xb(mrandom)g(co)q(de.)19 b(F)m(or)14 b(example:)324 1345 y Ff(long)21
- Xb(myrng_gen\(\);)324 1395 y(void)g(myrng_seed\(\);)324 1445
- Xy(int)g(myrng_check\(\);)262 1561 y Fd(6.3)55 b(Mo)r(difying)18
- Xb(the)g(mrandom)e(co)r(de)262 1637 y Fl(Only)i(a)h(few)g(lines)g(of)g(`)p
- XFf(mrandom.h)p Fl(')d(and)j(`)p Ff(mrandom.c)p Fl(')e(need)j(to)f(b)q(e)g(mo)
- Xq(di\014ed)f(when)262 1687 y(adding)13 b(a)g(new)i(RNG)e(to)g(the)i(pac)o(k)n
- X(age.)324 1779 y Fe(\017)20 b Fl(The)i(n)o(um)o(b)q(er)e(of)h(RNGs)g(curren)o
- X(tly)h(installed)e(in)h(the)h(pac)o(k)n(age)e(is)h(de\014ned)i(as)365
- X1828 y Ff(NUM_RNGS)18 b Fl(in)g(`)p Ff(mrandom.h)p Fl('.)31
- Xb(The)20 b(curren)o(t)g(v)n(alue)e(is)h(10.)33 b(This)19 b(v)n(alue)g(should)
- X365 1878 y(b)q(e)c(incremen)o(ted)f(when)g(a)g(new)g(RNG)f(is)h(added)g(to)g
- X(the)h(pac)o(k)n(age.)324 1961 y Fe(\017)20 b Fl(The)15 b(header)g(\014le)f
- X(for)g(the)h(new)f(RNG)g(needs)h(to)f(b)q(e)h Ff(#include)p
- XFl(d)d(in)i(`)p Ff(mrandom.c)p Fl('.)365 2011 y(The)i Ff(#include)d
- XFl(directiv)o(e)i(should)g(b)q(e)g(included)g(in)g(the)g(section)h(mark)o(ed)
- Xd(b)o(y)i(the)365 2061 y(commen)o(t)7 b(\\)p Ff(Header)21 b(files)f(for)i
- X(RNGs)f(currently)f(included)g(in)h(package.)p Fl(")324 2144
- Xy Fe(\017)f Fl(Sev)o(eral)11 b(additions)f(need)h(to)f(b)q(e)h(made)f(in)g(`)
- Xp Ff(mrandom.c)p Fl(')d(in)j(the)h(section)h(mark)o(ed)d(b)o(y)365
- X2194 y(the)23 b(commen)o(t)d(\\)p Ff(Arrays)g(to)i(hold)f(information)e
- X(about)i(RNGs.)p Fl(")g(This)h(sec-)365 2243 y(tion)17 b(of)f(the)i(co)q(de)g
- X(declares)g(and)f(initializes)f(sev)o(eral)i(arra)o(ys)f(whic)o(h)g(hold)g
- X(infor-)365 2293 y(mation)c(ab)q(out)h(the)h(RNGs)f(included)h(in)f(the)i
- X(pac)o(k)n(age.)j(When)c(installing)e(a)h(new)p eop
- X%%Page: 24 27
- Xbop 262 162 a Fi(6)41 b(ADDING)13 b(NEW)h(RNGS)f(TO)h(THE)g(P)m(A)o(CKA)o(GE)
- X507 b Fl(24)324 291 y Ff(INCS)21 b(=)g(mrandom.h)f(bentley.h)g(pcrand.h)g
- X(ran0.h)h(ran1.h)f(ran2.h)324 341 y(ultra.h)g(xsq.h)h(myrng.h)324
- X391 y(SRCS)g(=)g(mrtest.c)f(mrandom.c)g(bentley.c)g(pcrand.c)g(ran0.c)h
- X(ran1.c)324 440 y(ran2.c)f(ultra.c)h(xsq.c)f(myrng.c)324 490
- Xy(OBJS)h(=)g(mrandom.o)f(bentley.o)g(pcrand.o)g(ran0.o)h(ran1.o)f(ran2.o)324
- X540 y(ultra.o)g(xsq.o)h(myrng.o)592 631 y Fl(Figure)14 b(12:)j(Addition)c(of)
- Xh Ff(myrng)e Fl(to)i Ff(makefile)365 765 y Fl(RNG,)f(the)i(appropriate)g
- XFf(#define)p Fl(d)d(v)n(alues)i(need)i(to)e(b)q(e)h(inserted)g(at)f(the)h
- X(end)g(of)365 814 y(eac)o(h)k(initialization)d(list.)31 b(F)m(or)17
- Xb(example,)h(the)h(declaration)f(of)g Ff(RNGname)p 1571 814
- X14 2 v 14 w(a)g Fl(cur-)365 864 y(ren)o(tly)c(reads:)428 980
- Xy Ff(char)21 b(RNGname)p 694 980 V 14 w(a[NUM)p 818 980 V 14
- Xw(RNGS][RNGIDSTRLEN]=)o({RNGn)o(ame)p 1423 980 V 13 w(0,)g(RNGname)p
- X1656 980 V 14 w(1,)455 1030 y(RNGname)p 612 1030 V 14 w(2,)g(RNGname)p
- X845 1030 V 14 w(3,)h(RNGname)p 1079 1030 V 14 w(4,)f(RNGname)p
- X1312 1030 V 15 w(5,)g(RNGname)p 1546 1030 V 14 w(6,)455 1080
- Xy(RNGname)p 612 1080 V 14 w(7,)g(RNGname)p 845 1080 V 14 w(8,)h(RNGname)p
- X1079 1080 V 14 w(9};)365 1196 y Fl(After)15 b(adding)e(a)g(new)i(RNG)e(to)h
- X(the)g(pac)o(k)n(age,)f(this)h(declaration)g(w)o(ould)f(read:)428
- X1312 y Ff(char)21 b(RNGname)p 694 1312 V 14 w(a[NUM_RNGS][RNGI)o(DSTRL)o
- X(EN]={)o(RNGna)o(me)p 1430 1312 V 13 w(0,)g(RNGname)p 1662
- X1312 V 14 w(1,)455 1362 y(RNGname)p 612 1362 V 14 w(2,)g(RNGname)p
- X845 1362 V 14 w(3,)h(RNGname)p 1079 1362 V 14 w(4,)f(RNGname)p
- X1312 1362 V 15 w(5,)g(RNGname)p 1546 1362 V 14 w(6,)455 1412
- Xy(RNGname)p 612 1412 V 14 w(7,)g(RNGname)p 845 1412 V 14 w(8,)h(RNGname)p
- X1079 1412 V 14 w(9,)455 1461 y(/*)f(RNG)g(#10)g(added)g(->)g(*/)h(RNGname)p
- X1113 1461 V 14 w(10};)365 1578 y Fl(The)13 b(arra)o(ys)f Ff(statesize)p
- X773 1578 V 13 w(a)p Fl(,)g Ff(seedsize)p 1008 1578 V 14 w(a)p
- XFl(,)g Ff(range)p 1178 1578 V 14 w(a)p Fl(,)g Ff(returns)p
- X1392 1578 V 14 w(a)p Fl(,)f Ff(statetype)p 1649 1578 V 14 w(a)p
- XFl(,)365 1627 y Ff(seed)p 456 1627 V 15 w(a)p Fl(,)i Ff(dgen)p
- X606 1627 V 15 w(a)p Fl(,)g Ff(lgen)p 756 1627 V 15 w(a)p Fl(,)g(and)h
- XFf(check)p 1009 1627 V 15 w(a)f Fl(need)i(to)f(b)q(e)g(similarly)d(mo)q
- X(di\014ed.)262 1743 y Fd(6.4)55 b(Remaking)16 b(the)j(mrandom)d(P)n(ac)n(k)m
- X(age)262 1820 y Fl(Once)21 b(y)o(ou)f(ha)o(v)o(e)f(added)i(an)f(RNG)f(to)h
- X(the)h(pac)o(k)n(age)f(as)g(describ)q(ed)i(in)e(the)g(previous)262
- X1870 y(sections,)14 b(y)o(ou)f(will)g(need)i(to)e(remak)o(e)h(the)g(mrandom)d
- X(pac)o(k)n(age.)18 b(T)m(o)13 b(do)g(this:)324 1952 y Fe(\017)20
- Xb Fl(Mak)o(e)11 b(sure)h(that)f(all)f(of)h(the)g(\014les)h(for)e(the)i
- X(mrandom)c(pac)o(k)n(age,)j(include)g(the)g(source)365 2002
- Xy(and)j(header)h(\014les)f(for)g(y)o(our)f(new)i(RNG,)d(are)j(in)e(the)i
- X(same)e(directory)m(.)324 2085 y Fe(\017)20 b Fl(Include)d(the)f(names)f(of)g
- X(y)o(our)h(header,)g(source,)i(and)d(ob)r(ject)i(\014les)f(in)f(`)p
- XFf(makefile)p Fl(')365 2135 y(on)e(the)h(lines)f(lab)q(eled)g
- XFf(INCS)p Fl(,)e Ff(SRCS)p Fl(,)h(and)h Ff(OBJS)p Fl(,)f(resp)q(ectiv)o(ely)m
- X(,)i(as)f(sho)o(w)g(in)f(Figure)365 2184 y(12.)324 2267 y Fe(\017)20
- Xb Fl(F)m(ollo)o(w)12 b(the)i(instructions)g(for)f(making)e(the)j(mrandom)d
- X(pac)o(k)n(age,)h(as)i(describ)q(ed)h(in)365 2317 y(Section)g(3.)262
- X2399 y(Once)d(the)g(pac)o(k)n(age)f(has)h(b)q(een)h(remade)e(it)g(will)f(b)q
- X(e)i(ready)g(for)f(use,)h(with)g(y)o(our)f(new)h(RNG,)262 2449
- Xy(b)o(y)h(other)i(programs.)p eop
- X%%Page: 25 28
- Xbop 262 162 a Fi(A)41 b(THE)14 b(RNGD)o(A)m(T)m(A)e(STR)o(UCTURE)727
- Xb Fl(25)262 307 y Fk(A)68 b(The)23 b(RNGdata)g(Structure)262
- X406 y Fd(A.1)55 b(In)n(tro)r(duction)262 483 y Fl(This)15 b(section)h
- X(describ)q(es)i(the)e(represen)o(tation)h(in)e(C)h(of)f(the)h
- XFf(RNGdata)e Fl(structure)k(whic)o(h)262 533 y(is)12 b(used)i(b)o(y)e(the)i
- X(mrandom)c(pac)o(k)n(age)i(to)h(represen)o(t)i(RNGs.)i(This)c(structure)i
- X(need)f(nev)o(er)262 583 y(b)q(e)j(manipulated)d(b)o(y)j(the)g(programmer,)e
- X(except)j(as)f(describ)q(ed)h(in)e(Section)h(6.1.)26 b(This)262
- X632 y(section,)17 b(therefore,)i(is)e(in)o(tended)g(for)g(those)g(who)g(are)g
- X(in)o(terested)i(in)d(learning)h(a)f(little)262 682 y(more)c(ab)q(out)i(the)h
- X(inner)f(w)o(orkings)f(of)g(the)i(mrandom)c(pac)o(k)n(age.)324
- X732 y(In)j(order)i(to)e(generate)i(random)d(n)o(um)o(b)q(ers,)h(the)h(user)h
- X(m)o(ust)d(\014rst)j(declare)f(a)f(p)q(oin)o(ter)262 782 y(to)f(an)h
- XFf(RNGdata)f Fl(structure,)j(and)d(use)i Ff(init_rng)e Fl(to)h(allo)q(cate)f
- X(space)i(for)f(the)h(RNG)e(and)262 832 y(p)q(erform)8 b(v)n(arious)i
- X(initialization)d(functions.)16 b(The)10 b(user)h(uses)g(the)g(RNG)e(en)o
- X(tirely)h(through)262 882 y(calls)i(pro)o(vided)i(b)o(y)f(the)h(in)o(terface)
- Xf(describ)q(ed)i(in)e(Section)h(5.4;)e(i.e.)17 b(the)d(user)h(should)e(not)
- X262 931 y(directly)h(manipulate)d(the)k Ff(RNGdata)d Fl(structure.)262
- X1048 y Fd(A.2)55 b(Inside)19 b(the)f(Structure)262 1124 y Fl(The)c
- X(de\014nition)f(of)h(the)g Ff(RNGdata)e Fl(structure)17 b(is)c(displa)o(y)o
- X(ed)h(in)f(Figure)h(13.)324 1174 y(Descriptions)g(of)g(its)f(\014elds)i(are)f
- X(as)g(follo)o(ws:)262 1265 y Ff(rngalg)19 b Fl(A)f(n)o(um)o(b)q(er)g(iden)o
- X(tifying)f(the)i(algorithm)d(to)i(b)q(e)h(used)g(b)o(y)f(the)h(RNG)f(to)g
- X(pro-)365 1315 y(duce)f(pseudorandom)e(generates.)25 b(Algorithms)13
- Xb(in)i(the)i(pac)o(k)n(age)e(are)h(n)o(um)o(b)q(ered)365 1365
- Xy(sequen)o(tially)h(starting)f(with)h(0;)g(curren)o(tly)h(there)g(are)f(10)f
- X(algorithms)f(installed,)365 1415 y(n)o(um)o(b)q(ered)f(0)g(through)h(9.)k(A)
- X14 b(table)h(of)e(RNGs)h(whic)o(h)g(are)h(curren)o(tly)g(installed)f(in)365
- X1465 y(the)h(mrandom)10 b(pac)o(k)n(age,)j(with)h(their)g(corresp)q(onding)g
- X(algorithm)e(n)o(um)o(b)q(ers,)g(is)i(in)365 1514 y(App)q(endix)h(B.)262
- X1597 y Ff(mrandom_alg)j Fl(The)12 b(algorithm)d(use)j(b)o(y)g
- XFf(mrandomrv)d Fl(when)j(called)g(with)f(this)g(RNG.)g(See)365
- X1647 y(Section)k(5.4.2)d(for)h(more)g(on)h Ff(mrandomrv)p Fl(.)262
- X1730 y Ff(rngstate)19 b Fl(A)14 b(p)q(oin)o(ter)g(to)g(the)g(RNG's)g(state)g
- X(v)o(ector,)h(used)g(to)f(store)h(the)f(curren)o(t)i(state)365
- X1780 y(of)i(the)g(RNG.)f(See)h(Sections)h(5.4.3,)d(6.1,)i(and)f(6.2.1)g(for)g
- X(more)g(information)e(on)365 1830 y(RNG)e(state)i(v)o(ectors.)262
- X1913 y Ff(rngseed)k Fl(A)14 b(p)q(oin)o(ter)f(to)h(the)g(RNG's)f(seed)i(v)o
- X(ector.)k(See)14 b(Section)h(5.4.4)c(for)j(more)f(infor-)365
- X1963 y(mation)f(on)i(RNG)f(seed)i(v)o(ectors.)262 2046 y Ff(rngcount1)p
- XFh(,)f Ff(rngcount2)19 b Fl(These)12 b(t)o(w)o(o)f(v)n(alues)g(represen)o(t)i
- X(the)f(n)o(um)o(b)q(er)f(of)f(generates)j(the)365 2096 y(RNG)g(has)h(pro)q
- X(duced)i(since)e(initialization,)d(according)j(to)g(the)g(form)o(ula:)428
- X2212 y Ff(rngcount1+rngco)o(unt2*)o(BILLI)o(ON)365 2328 y Fl(where)21
- Xb(BILLION)e(is)g(de\014ned)h(in)f(`)p Ff(mrandom.h)p Fl('.)31
- Xb(Please)20 b(note)f(that)h(the)f(v)n(alue)365 2378 y(represen)o(ted)14
- Xb(b)o(y)e Ff(rngcount1)d Fl(and)i Ff(rngcount2)f Fl(is)h(the)h
- XFc(total)f Fl(n)o(um)o(b)q(er)f(of)h(generates)365 2428 y(pro)q(duced)17
- Xb(b)o(y)f(the)g(RNG)f(since)h(initialization,)d(including)i(those)h
- X(discarded)h(due)p eop
- X%%Page: 26 29
- Xbop 262 162 a Fi(A)41 b(THE)14 b(RNGD)o(A)m(T)m(A)e(STR)o(UCTURE)727
- Xb Fl(26)262 702 y Ff(struct)42 b(rngdata)20 b({)414 752 y(long)h(rngalg;)414
- X802 y(long)g(mrandom_alg;)414 852 y(long)g(*rngstate;)414 902
- Xy(long)g(*rngseed;)414 952 y(long)g(rngcount1;)414 1001 y(long)g(rngcount2;)
- X414 1051 y(struct)g({)610 1101 y(long)g(size;)610 1151 y(long)g(nleft;)610
- X1201 y(long)g(nbleft;)610 1250 y(double)g(*dbuf,*dbufp;)610
- X1300 y(long)g(*lbuf,*lbufp;)610 1350 y(int)g(*bbuf,*bbufp;)610
- X1400 y(})h(buffer;)414 1450 y(long)f(rngnextval;)414 1499 y(long)g(rngsplit;)
- X414 1549 y(char)g(rngname[];)414 1599 y(long)g(rngstatesize;)414
- X1649 y(long)g(rngseedsize;)414 1699 y(long)g(rngrangem1;)414
- X1749 y(double)g(rngrange;)414 1798 y(signed)g(int)g(rngreturns;)262
- X1848 y(};)262 1898 y(typedef)f(struct)g(rngdata)h(RNGdata;)668
- X2081 y Fl(Figure)14 b(13:)k(The)c Ff(RNGdata)f Fl(structure)p
- Xeop
- X%%Page: 27 30
- Xbop 262 162 a Fi(B)41 b(RNGS)14 b(CURRENTL)m(Y)f(INST)m(ALLED)g(IN)h(THE)g(P)
- Xm(A)o(CKA)o(GE)286 b Fl(27)365 307 y(to)18 b(splitting)f(of)g(the)i(RNG.)d
- X(\(See)j(Section)f(5.4.7)e(for)i(more)f(information)e(ab)q(out)365
- X357 y(splitting)e(RNGs.\))262 440 y Ff(rngnextval)18 b Fl(The)h(next)f(v)n
- X(alue)g(to)g(b)q(e)g(output)h(from)d(the)j(RNG.)d(This)i(v)n(alue)g(is)g
- X(used)365 490 y(in)o(ternally)13 b(b)o(y)h(the)g(mrandom)d(library)i(and)h
- X(is)g(not)g(guaran)o(teed)g(to)g(b)q(e)g(accurate.)262 573
- Xy Ff(rngsplit)19 b Fl(Ev)o(ery)10 b(\()p Ff(split)p Fl(+1\)-th)g(generate)h
- X(of)f(the)h(underlying)f(RNG)f(will)g(b)q(e)i(returned)365
- X623 y(b)o(y)k(the)h(RNG)e(calling)f(pro)q(cedures.)24 b Ff(rngsplit)13
- Xb Fl(is)i(set)h(to)f Ff(DEF_SPLIT)e Fl(up)q(on)i(ini-)365 672
- Xy(tialization)g(of)h(the)h(RNG,)e(as)i(de\014ned)h(in)e(`)p
- XFf(mrandom.h)p Fl('.)23 b(See)17 b(Section)g(5.4.7)e(for)365
- X722 y(more)e(information)e(ab)q(out)j(splitting)f(RNGs.)262
- X805 y Ff(buffer)19 b Fl(This)g(structure)j(con)o(tains)d(information)e(ab)q
- X(out)i(the)h(RNG's)f(bu\013er)h(and)g(its)365 855 y(bit)c(bu\013er.)27
- Xb(\(See)17 b(Section)g(5.4.2)e(for)h(more)f(information)f(on)i(RNG)f
- X(bu\013ers.\))28 b(It)365 905 y(con)o(tains)14 b(sev)o(eral)h(\014elds:)365
- X988 y Ff(size)20 b Fl(The)15 b(n)o(um)o(b)q(er)e(of)g(en)o(tries)i(in)e(the)i
- X(RNG's)e(bu\013er.)365 1054 y Ff(nleft)20 b Fl(The)14 b(n)o(um)o(b)q(er)g(of)
- Xf(v)n(alues)g(left)h(in)f(the)i(RNG's)e(bu\013er.)365 1121
- Xy Ff(nbleft)20 b Fl(The)14 b(n)o(um)o(b)q(er)f(of)h(v)n(alues)f(left)h(in)f
- X(the)i(RNG's)e(bit)g(bu\013er.)365 1187 y Ff(dbuf)p Fh(,)j
- XFf(dbufp)j Fl(A)10 b(p)q(oin)o(ter)g(to)f(the)h(\014rst)h(en)o(try)f(in)f
- X(the)h(double)g(bu\013er,)h(and)e(a)g(p)q(oin)o(ter)457 1237
- Xy(to)k(the)i(next)f(en)o(try)h(to)e(b)q(e)i(retriev)o(ed)g(from)d(the)j
- X(double)f(bu\013er.)365 1303 y Ff(lbuf)p Fh(,)i Ff(lbufp)j
- XFl(Same)13 b(for)h(the)g(long)f(bu\013er.)365 1370 y Ff(bbuf)p
- XFh(,)j Ff(bbufp)j Fl(Same)13 b(for)h(the)g(bit)g(bu\013er.)324
- X1461 y(The)e(remaining)d(v)n(alues)i(in)g(the)i(RNGdata)d(structure)k(are)e
- X(deriv)o(ed)g(from)d(the)j(RNG's)262 1511 y(header)e(\014le)g(up)q(on)g
- X(initialization.)k(F)m(or)c(more)e(information)f(on)j(the)g(v)n(alues)g(of)f
- X(these)j(\014elds,)262 1561 y(see)j(Section)f(6.2.1.)262 1698
- Xy Fk(B)68 b(RNGs)23 b(Curren)n(tly)f(Installed)f(in)h(the)h(P)n(ac)n(k)l(age)
- X262 1789 y Fl(There)11 b(are)g(curren)o(tly)g(ten)g(RNGs)f(installed)g(in)g
- X(the)h(mrandom)d(pac)o(k)n(age.)16 b(This)11 b(app)q(endix)262
- X1839 y(pro)o(vides)16 b(brief)g(descriptions)h(of)f(eac)o(h)g(of)g(them.)24
- Xb(References)18 b(are)f(pro)o(vided)f(for)g(those)262 1889
- Xy(who)d(are)h(in)o(terested)i(in)d(\014nding)h(out)g(ab)q(out)f(the)i(RNGs)e
- X(in)h(more)f(detail.)262 1980 y Fh(RNG)i(algorithm)e(0:)21
- Xb(A)16 b(trivial)e(RNG)20 b Fl(A)14 b(trivial)f(RNG)h(is)g(included)g(in)g
- X(the)h(pac)o(k-)365 2030 y(age,)20 b(primarily)c(for)i(testing)i(purp)q
- X(oses.)34 b(The)19 b(generates)i(it)d(pro)q(duces)i(are)g(not)365
- X2080 y(\\random")c(in)h(virtually)e(an)o(y)i(sense)i(of)e(the)h(w)o(ord;)h
- X(it)e(simply)e(pro)q(duces)k(gener-)365 2129 y(ates)c(from)d(an)i
- X(arithmetical)e(progression)i(determined)g(b)o(y)g(its)g(initial)e(seeds.)20
- Xb(F)m(or)365 2179 y(example,)f(if)g(it)g(is)g(seeded)i(with)e(5)g(and)g(7,)h
- X(resp)q(ectiv)o(ely)m(,)i(it)d(will)e(pro)q(duce)k(the)365
- X2229 y(sequence)16 b(5,)d(12,)g(19,)g(26,)g(etc.)365 2295 y(This)h(RNG)f(tak)
- Xo(es)h(t)o(w)o(o)g Ff(long)p Fl(s)f(as)h(seeds.)20 b(It)14
- Xb(returns)h(generates)h(of)d(t)o(yp)q(e)i Ff(long)p Fl(.)262
- X2378 y Fh(RNG)g(algorithm)e(1:)21 b(4.3bsd)15 b(random)k Fl(This)g(is)g(UNIX)
- Xg(4.3bsd)f Ff(random)p Fl(.)31 b(It)19 b(is)g(a)365 2428 y(31-bit)f
- X(nonlinear)g(additiv)o(e)g(feedbac)o(k)h(generator)h(with)e(a)g(range)h(of)f
- X(2)1534 2413 y Fb(31)1587 2428 y Fl(and)h(a)p eop
- X%%Page: 28 31
- Xbop 262 162 a Fi(B)41 b(RNGS)14 b(CURRENTL)m(Y)f(INST)m(ALLED)g(IN)h(THE)g(P)
- Xm(A)o(CKA)o(GE)286 b Fl(28)365 307 y(p)q(erio)q(d)19 b(of)f(appro)o(ximately)
- Xe(16)c Fe(\003)g Fl(2)937 292 y Fb(31)984 307 y Fe(\000)g Fl(1.)32
- Xb(It)18 b(is)h(nominall)o(y)d(able)i(to)g(sa)o(v)o(e)h(and)365
- X357 y(restore)g(state,)f(but)f(its)g(state-sa)o(ving)g(co)q(de)h(is)f(buggy)m
- X(.)27 b(Therefore,)18 b(when)g(using)365 407 y Ff(random)e
- XFl(with)g(the)i(mrandom)13 b(pac)o(k)n(age,)k(no)g(more)e(than)i(one)g(RNG)f
- X(should)h(use)365 457 y Ff(random)c Fl(at)h(a)f(time.)365 522
- Xy(This)f(RNG)e(tak)o(es)i(a)f(single)g Ff(long)f Fl(as)i(a)f(seed.)18
- Xb(It)12 b(returns)g(generates)h(of)e(t)o(yp)q(e)h Ff(long)p
- XFl(.)262 604 y Fh(RNG)j(algorithm)e(2:)21 b(the)15 b(Kn)o(uth/Ben)o(tl)o(ey)e
- X(prand)19 b Fl(This)10 b(lagged-Fib)q(onacci)e(RNG)365 654
- Xy(w)o(as)16 b(in)o(tro)q(duced)h(b)o(y)e(Jon)h(Ben)o(tley)h(in)f(his)f
- X(\\Soft)o(w)o(are)h(Exploratorium")d(column)365 704 y(in)19
- Xb Fc(Unix)g(R)n(eview)p Fl(,)g(V)m(ol.)32 b(10,)18 b(No.)33
- Xb(6,)19 b(June)h(1992,)e(and)g(is)h(based)g(on)g(one)g(\014rst)365
- X754 y(presen)o(ted)d(in)d(Donald)f(E.)h(Kn)o(uth's)h Fc(The)h(A)o(rt)e(of)i
- X(Computer)f(Pr)n(o)n(gr)n(amming)p Fl(,)e(V)m(ol.)365 803 y(2,)g(Addison-W)m
- X(esley)m(,)g(Reading,)f(Mass.,)i(1981.)j(It)d(has)g(a)f(range)h(of)f
- X(1,000,000,00)o(0.)365 869 y(This)g(RNG)e(tak)o(es)i(a)f(single)g
- XFf(long)f Fl(as)i(a)f(seed.)18 b(It)12 b(returns)g(generates)h(of)e(t)o(yp)q
- X(e)h Ff(long)p Fl(.)262 951 y Fh(RNG)j(algorithm)e(3:)21 b(The)16
- Xb(P)o(ortable)d(Com)o(bined)g(RNG)21 b Fl(This)11 b(com)o(bined)f(prime)365
- X1001 y(m)o(ultiplicativ)o(e)i(congruen)o(tial)i(RNG)f(w)o(as)h(dev)o(elop)q
- X(ed)h(based)h(on)e(algorithms)e(and)365 1050 y(selections)20
- Xb(of)e(prime)g(n)o(um)o(b)q(ers)h(presen)o(ted)i(in)d(\\E\016cien)o(t)h(and)g
- X(P)o(ortable)f(Com-)365 1100 y(bined)h(Random)d(Num)o(b)q(er)i(Generators,")h
- X(Pierre)h(L'Ecuy)o(er,)f Fc(Communic)n(ations)365 1150 y(of)g(the)h(A)o(CM)p
- XFl(,)e(V)m(ol.)31 b(10,)19 b(No.)32 b(6,)19 b(June)h(1992,)e(and)g(\\Random)f
- X(Num)o(b)q(er)h(Gen-)365 1200 y(erators:)24 b(Go)q(o)q(d)15
- Xb(Ones)i(are)g(Hard)f(to)g(Find,")f(Stephen)i(P)o(ark)f(and)g(Keith)h
- X(Miller,)365 1250 y Fc(Communic)n(ations)h(of)g(the)f(A)o(CM)p
- XFl(,)f(V)m(ol.)25 b(31,)17 b(No.)26 b(10,)17 b(Octob)q(er)h(1992.)25
- Xb(It)17 b(has)g(a)365 1299 y(range)d(of)g(2147483561.)365 1365
- Xy(This)g(RNG)f(tak)o(es)h(t)o(w)o(o)g Ff(long)p Fl(s)f(as)h(seeds.)20
- Xb(It)14 b(returns)h(generates)h(of)d(t)o(yp)q(e)i Ff(long)p
- XFl(.)262 1447 y Fh(RNG)g(algorithm)e(4:)21 b(4.3bsd)15 b(nrand48)k
- XFl(This)14 b(is)g(UNIX)g(4.3bsd)f Ff(nrand48)p Fl(.)k(It)d(pro-)365
- X1497 y(duces)k(generates)g(using)f(a)f(linear)g(congruen)o(tial)g(algorithm)e
- X(and)j(48-bit)e(in)o(teger)365 1547 y(arithmetic.)i(It)d(has)g(a)g(range)g
- X(of)f(2)917 1531 y Fb(31)952 1547 y Fl(.)365 1612 y(This)g(RNG)f(tak)o(es)h
- X(three)h Ff(unsigned)20 b(short)p Fl(s)12 b(as)h(seeds.)19
- Xb(They)13 b(are)g(passed)h(to)e(the)365 1662 y(seeding)i(pro)q(cedure)h(as)e
- X(t)o(w)o(o)g Ff(long)p Fl(s,)f(and)h(are)g(in)o(terpreted)i(in)e(the)g(follo)
- Xo(wing)e(w)o(a)o(y:)415 1744 y Fe(\017)21 b Fl(The)14 b(16)f(least)h
- X(signi\014can)o(t)g(bits)g(of)f(the)i(second)f Ff(long)g Fl(is)f(the)i
- X(\014rst)f(seed.)415 1809 y Fe(\017)21 b Fl(The)14 b(16)f(least)h
- X(signi\014can)o(t)g(bits)g(of)f(the)i(\014rst)f Ff(long)f Fl(is)h(the)g
- X(second)h(seed.)415 1874 y Fe(\017)21 b Fl(The)14 b(16)f(most)g(signi\014can)
- Xo(t)g(bits)h(of)g(the)g(\014rst)h Ff(long)e Fl(is)h(the)g(third)g(seed.)415
- X1939 y Fe(\017)21 b Fl(The)14 b(16)f(most)g(signi\014can)o(t)g(bits)h(of)g
- X(the)g(second)h Ff(long)e Fl(is)h(ignored.)365 2021 y(This)g(RNG)f(returns)j
- X(generates)f(of)e(t)o(yp)q(e)i Ff(long)p Fl(.)262 2102 y Fh(RNG)g(algorithm)e
- X(5:)21 b(4.3bsd)15 b(rand)20 b Fl(This)15 b(is)f(UNIX)h(4.3bsd)g
- XFf(rand)p Fl(.)k(It)c(uses)h(a)f(m)o(ul-)365 2152 y(tiplicativ)o(e)g
- X(congruen)o(tial)h(algorithm.)22 b(It)16 b(has)g(a)g(p)q(erio)q(d)h(of)e(2)
- X1374 2137 y Fb(32)1425 2152 y Fl(and)h(a)g(range)g(of)365 2202
- Xy(2)386 2187 y Fb(31)421 2202 y Fl(.)365 2268 y(This)c(RNG)e(tak)o(es)i(a)f
- X(single)g Ff(long)f Fl(as)i(a)f(seed.)18 b(It)12 b(returns)g(generates)h(of)e
- X(t)o(yp)q(e)h Ff(long)p Fl(.)262 2350 y Fh(RNG)j(algorithm)e(6,)j(7,)g(and)f
- X(8:)22 b(Press)14 b(and)i(T)l(euk)o(olsky's)e(ran0,)i(ran1,)f(and)g(ran2)365
- X2399 y Fl(These)d(three)h(m)o(ultipli)o(cativ)o(e)8 b(congruen)o(tial)j(RNGs)
- Xf(are)h(adapted)g(from)e(those)j(pre-)365 2449 y(sen)o(ted)k(in)d(\\P)o
- X(ortable)h(Random)d(Num)o(b)q(er)j(Generators,")g(William)c(H.)j(Press)j(and)
- Xp eop
- X%%Page: 29 32
- Xbop 262 162 a Fi(B)41 b(RNGS)14 b(CURRENTL)m(Y)f(INST)m(ALLED)g(IN)h(THE)g(P)
- Xm(A)o(CKA)o(GE)286 b Fl(29)365 307 y(Saul)15 b(A.)h(T)m(euk)o(olsky)m(,)e
- XFc(Computers)j(in)f(Physics)p Fl(,)g(V)m(ol.)23 b(6,)15 b(No.)24
- Xb(5,)15 b(Sep/Oct)i(1992.)365 357 y(They)f(all)e(ha)o(v)o(e)i(a)f(p)q(erio)q
- X(d)h(of)f(2)868 342 y Fb(31)913 357 y Fe(\000)10 b Fl(2)16
- Xb(and)f(a)g(range)h(of)f(2)1295 342 y Fb(31)1340 357 y Fe(\000)10
- Xb Fl(1.)46 b(These)17 b(RNGs)365 407 y(tak)o(e)d(a)g(single)f
- XFf(long)g Fl(as)h(a)g(seed.)19 b(They)14 b(return)i(generates)f(of)e(t)o(yp)q
- X(e)i Ff(double)p Fl(.)262 490 y Fh(RNG)g(algorithm)e(9:)21
- Xb(Marsaglia's)15 b(Ultra)g(RNG)20 b Fl(W)m(e)12 b(obtained)h(the)h(source)g
- X(co)q(de)365 540 y(for)19 b(this)h(generator)g(b)o(y)f(anon)o(ymous)e(ftp)j
- X(from)d Ff(nic.funit.fi)g Fl(\(tak)o(e)j(the)g(\014le)365 589
- Xy Ff(fsultra.zip)e Fl(from)h(the)h(directory)h Ff(/pub/msdos/science/)o
- X(math/)o(fsult)o(ra)p Fl(\).)365 639 y(A)e(note)g(in)f(the)h(`)p
- XFf(readme)p Fl(')e(\014le)i(sa)o(ys:)27 b(\\T)m(o)18 b(obtain)g(p)q
- X(ermission)g(to)g(incorp)q(orate)365 689 y(this)d(program)d(in)o(to)i(an)o(y)
- Xg(commercial)d(pro)q(duct,)k(please)g(con)o(tact)g(the)g(authors)g(at)365
- X739 y(the)i(e-mail)c(address)18 b(giv)o(en)d(ab)q(o)o(v)o(e)h
- X([a\014r@stat.fsu.edu)g(or)g(geo@stat.fsu.edu])g(or)365 789
- Xy(at)g(Departmen)o(t)g(of)g(Statistics)h(and)f(Sup)q(ercomputer)h
- X(Computations)d(Researc)o(h)365 839 y(Institute,)20 b(Florida)d(State)i(Univ)
- Xo(ersit)o(y)m(,)f(T)m(allahassee,)g(FL)g(32306.")29 b(This)18
- Xb(RNG)365 888 y(is)d(one)g(of)e(those)j(originally)c(presen)o(ted)17
- Xb(in)d(\\A)g(New)h(Class)g(of)f(Random)e(Num)o(b)q(er)365 938
- Xy(Generators,")18 b(George)f(Marsaglia)f(and)g(Arif)h(Zaman,)e
- XFc(The)j(A)o(nnals)f(of)h(Applie)n(d)365 988 y(Pr)n(ob)n(ability)p
- XFl(,)13 b(V)m(ol.)k(1,)c(No.)18 b(3,)13 b(1991.)k(It)d(is)g(a)g
- X(\\subtract-with-b)q(orro)o(w")g(generator)365 1038 y(with)g(a)f(range)i(of)e
- X(2)676 1023 y Fb(32)725 1038 y Fl(and)g(a)h(staggering)g(p)q(erio)q(d)g(of)f
- X(10)1257 1023 y Fb(354)1308 1038 y Fl(.)365 1104 y(This)18
- Xb(RNG)f(tak)o(es)i(t)o(w)o(o)e Ff(unsigned)j(long)p Fl(s)e(as)g(seeds.)32
- Xb(It)18 b(returns)i(generates)f(of)365 1154 y(t)o(yp)q(e)c
- XFf(double)p Fl(.)p eop
- X%%Trailer
- Xend
- Xuserdict /end-hook known{end-hook}if
- X%%EOF
- END_OF_FILE
- if test 85170 -ne `wc -c <'doc/mrandom.ps.2'`; then
- echo shar: \"'doc/mrandom.ps.2'\" unpacked with wrong size!
- fi
- # end of 'doc/mrandom.ps.2'
- fi
- echo shar: End of archive 5 \(of 6\).
- cp /dev/null ark5isdone
- MISSING=""
- for I in 1 2 3 4 5 6 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 6 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-