Skip to content

Instantly share code, notes, and snippets.

@jacobh
Created March 23, 2012 19:18
Show Gist options
  • Save jacobh/2174049 to your computer and use it in GitHub Desktop.
Save jacobh/2174049 to your computer and use it in GitHub Desktop.
%!PS-Adobe-3.0
%%Creator: groff version 1.19.2
%%CreationDate: Sat Mar 24 03:12:37 2012
%%DocumentNeededResources: font Times-Bold
%%+ font Courier-Bold
%%+ font Times-Roman
%%+ font Courier-Oblique
%%+ font Symbol
%%+ font Courier
%%DocumentSuppliedResources: procset grops 1.19 2
%%Pages: 2
%%PageOrder: Ascend
%%DocumentMedia: Default 595 842 0 () ()
%%Orientation: Portrait
%%EndComments
%%BeginDefaults
%%PageMedia: Default
%%EndDefaults
%%BeginProlog
%%BeginResource: procset grops 1.19 2
%!PS-Adobe-3.0 Resource-ProcSet
/setpacking where{
pop
currentpacking
true setpacking
}if
/grops 120 dict dup begin
/SC 32 def
/A/show load def
/B{0 SC 3 -1 roll widthshow}bind def
/C{0 exch ashow}bind def
/D{0 exch 0 SC 5 2 roll awidthshow}bind def
/E{0 rmoveto show}bind def
/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
/G{0 rmoveto 0 exch ashow}bind def
/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/I{0 exch rmoveto show}bind def
/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
/K{0 exch rmoveto 0 exch ashow}bind def
/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/M{rmoveto show}bind def
/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
/O{rmoveto 0 exch ashow}bind def
/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/Q{moveto show}bind def
/R{moveto 0 SC 3 -1 roll widthshow}bind def
/S{moveto 0 exch ashow}bind def
/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/SF{
findfont exch
[exch dup 0 exch 0 exch neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/MF{
findfont
[5 2 roll
0 3 1 roll
neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/level0 0 def
/RES 0 def
/PL 0 def
/LS 0 def
/MANUAL{
statusdict begin/manualfeed true store end
}bind def
/PLG{
gsave newpath clippath pathbbox grestore
exch pop add exch pop
}bind def
/BP{
/level0 save def
1 setlinecap
1 setlinejoin
72 RES div dup scale
LS{
90 rotate
}{
0 PL translate
}ifelse
1 -1 scale
}bind def
/EP{
level0 restore
showpage
}def
/DA{
newpath arcn stroke
}bind def
/SN{
transform
.25 sub exch .25 sub exch
round .25 add exch round .25 add exch
itransform
}bind def
/DL{
SN
moveto
SN
lineto stroke
}bind def
/DC{
newpath 0 360 arc closepath
}bind def
/TM matrix def
/DE{
TM currentmatrix pop
translate scale newpath 0 0 .5 0 360 arc closepath
TM setmatrix
}bind def
/RC/rcurveto load def
/RL/rlineto load def
/ST/stroke load def
/MT/moveto load def
/CL/closepath load def
/Fr{
setrgbcolor fill
}bind def
/setcmykcolor where{
pop
/Fk{
setcmykcolor fill
}bind def
}if
/Fg{
setgray fill
}bind def
/FL/fill load def
/LW/setlinewidth load def
/Cr/setrgbcolor load def
/setcmykcolor where{
pop
/Ck/setcmykcolor load def
}if
/Cg/setgray load def
/RE{
findfont
dup maxlength 1 index/FontName known not{1 add}if dict begin
{
1 index/FID ne{def}{pop pop}ifelse
}forall
/Encoding exch def
dup/FontName exch def
currentdict end definefont pop
}bind def
/DEFS 0 def
/EBEGIN{
moveto
DEFS begin
}bind def
/EEND/end load def
/CNT 0 def
/level1 0 def
/PBEGIN{
/level1 save def
translate
div 3 1 roll div exch scale
neg exch neg exch translate
0 setgray
0 setlinecap
1 setlinewidth
0 setlinejoin
10 setmiterlimit
[]0 setdash
/setstrokeadjust where{
pop
false setstrokeadjust
}if
/setoverprint where{
pop
false setoverprint
}if
newpath
/CNT countdictstack def
userdict begin
/showpage{}def
/setpagedevice{}def
}bind def
/PEND{
countdictstack CNT sub{end}repeat
level1 restore
}bind def
end def
/setpacking where{
pop
setpacking
}if
%%EndResource
%%EndProlog
%%BeginSetup
%%BeginFeature: *PageSize Default
<< /PageSize [ 595 842 ] /ImagingBBox null >> setpagedevice
%%EndFeature
%%IncludeResource: font Times-Bold
%%IncludeResource: font Courier-Bold
%%IncludeResource: font Times-Roman
%%IncludeResource: font Courier-Oblique
%%IncludeResource: font Symbol
%%IncludeResource: font Courier
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron
/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
/Courier@0 ENC0/Courier RE/Courier-Oblique@0 ENC0/Courier-Oblique RE
/Times-Roman@0 ENC0/Times-Roman RE/Courier-Bold@0 ENC0/Courier-Bold RE
/Times-Bold@0 ENC0/Times-Bold RE
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Bold@0 SF -.2(NA)72 36 S(ME).2 E/F1 10/Courier-Bold@0 SF
(drand48)102 48 Q/F2 10/Times-Roman@0 SF(,)A F1(erand48)4 E F2(,)A F1
(jrand48)4 E F2(,)A F1(lcong48)4 E F2(,)A F1(lrand48)4 E F2(,)A F1
(mrand48)4 E F2(,)A F1(nrand48)4 E F2(,)A F1(seed48)4 E F2(,)A F1
(srand48)4 E F2<8a>4 E
(pseudo random number generators and initialization routines)102 60 Q F0
(LIBRAR)72 84 Q(Y)-.35 E F2(Standard C Library \(libc, \255lc\))102 96 Q
F0(SYNOPSIS)72 120 Q F1(#include <stdlib.h>)102 132 Q/F3 10
/Courier-Oblique@0 SF(double)102 150 Q F1(drand48)102 162 Q F2(\()A F3
(void)A F2(\);)1.666 E F3(double)102 180 Q F1(erand48)102 192 Q F2(\()A
F3(unsigned short xsubi[3])A F2(\);)1.666 E F3(long)102 210 Q F1
(jrand48)102 222 Q F2(\()A F3(unsigned short xsubi[3])A F2(\);)1.666 E
F3(void)102 240 Q F1(lcong48)102 252 Q F2(\()A F3
(unsigned short param[7])A F2(\);)1.666 E F3(long)102 270 Q F1(lrand48)
102 282 Q F2(\()A F3(void)A F2(\);)1.666 E F3(long)102 300 Q F1(mrand48)
102 312 Q F2(\()A F3(void)A F2(\);)1.666 E F3(long)102 330 Q F1(nrand48)
102 342 Q F2(\()A F3(unsigned short xsubi[3])A F2(\);)1.666 E F3
(unsigned short)102 360 Q/F4 10/Symbol SF(*)6 E F1(seed48)102 372 Q F2
(\()A F3(unsigned short seed16v[3])A F2(\);)1.666 E F3(void)102 390 Q F1
(srand48)102 402 Q F2(\()A F3(long seedval)A F2(\);)1.666 E F0
(DESCRIPTION)72 426 Q F2(The)102 438 Q F1(rand48)2.796 E F2 .296(\(\) f)
B .297(amily of functions generates pseudo-random numbers, using a line\
ar congruential algorithm)-.1 F -.1(wo)102 450 S .376(rking on inte).1 F
.376(gers 48 bits in size.)-.15 F .376(The particular formula emplo)
5.376 F .376(yed is r\(n+1\) = \(a)-.1 F F4(*)2.876 E F2 .375
(r\(n\) + c\) mod m.)2.875 F(The)5.375 E(def)102 462 Q .678(ault v)-.1 F
.678(alue for the multiplicand `a' is 0x5deece66d \(25214903917\).)-.25
F .679(The def)5.679 F .679(ault v)-.1 F .679(alue for the the addend)
-.25 F .785(`c' is 0xb \(11\).)102 474 R .785(The modulo is al)5.785 F
-.1(wa)-.1 G .785(ys \214x).1 F .785(ed at m = 2)-.15 F F4(**)3.285 E F2
3.285(48. r\(n\))3.285 F .784(is called the seed of the random number)
3.285 F(generator)102 486 Q(.)-.55 E -.15(Fo)102 504 S 3.22(rt).15 G .72
(he six generator routines described ne)-3.22 F .72
(xt, the \214rst computational step is to perform a single iteration of)
-.15 F(the algorithm.)102 516 Q(The)102 534 Q F1(drand48)4.154 E F2
1.654(\(\) and)B F1(erand48)4.154 E F2 1.654(\(\) functions return v)B
1.654(alues of type double.)-.25 F 1.653
(The full 48 bits of r\(n+1\) are)6.654 F .4
(loaded into the mantissa of the returned v)102 546 R .4
(alue, with the e)-.25 F .4(xponent set such that the v)-.15 F .4
(alues produced lie in the)-.25 F(interv)102 558 Q(al [0.0, 1.0\).)-.25
E(The)102 576 Q F1(lrand48)3.1 E F2 .6(\(\) and)B F1(nrand48)3.1 E F2 .6
(\(\) functions return v)B .6(alues of type long in the range [0, 2)-.25
F F4(**)A F2 3.1(31-1]. The)B(high-)3.1 E .139
(order \(31\) bits of r\(n+1\) are loaded into the lo)102 588 R .139
(wer bits of the returned v)-.25 F .139
(alue, with the topmost \(sign\) bit set to)-.25 F(zero.)102 600 Q(The)
102 618 Q F1(mrand48)3.159 E F2 .659(\(\) and)B F1(jrand48)3.159 E F2
.659(\(\) functions return v)B .659(alues of type long in the range [-2)
-.25 F F4(**)A F2 .658(31, 2)B F4(**)A F2 3.158(31-1]. The)B
(high-order \(32\) bits of r\(n+1\) are loaded into the returned v)102
630 Q(alue.)-.25 E(The)102 648 Q F1(drand48)2.66 E F2(\(\),)A F1
(lrand48)2.66 E F2 .16(\(\), and)B F1(mrand48)2.66 E F2 .161
(\(\) functions use an internal b)B(uf)-.2 E .161(fer to store r\(n\).)
-.25 F -.15(Fo)5.161 G 2.661(rt).15 G .161(hese func-)-2.661 F
(tions the initial v)102 660 Q
(alue of r\(0\) = 0x1234abcd330e = 20017429951246.)-.25 E 1.034
(On the other hand,)102 678 R F1(erand48)3.534 E F2(\(\),)A F1(nrand48)
3.534 E F2 1.034(\(\), and)B F1(jrand48)3.534 E F2 1.034
(\(\) use a user)B 1.034(-supplied b)-.2 F(uf)-.2 E 1.034
(fer to store the seed)-.25 F(r\(n\), which consists of an array of 3 s\
horts, where the zeroth member holds the least signi\214cant bits.)102
690 Q 179.695(BSD October)72 750 R(8, 1993)2.5 E(1)196.645 E 0 Cg EP
%%Page: 2 2
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(RAND48 \(3\))72 48 R
(BSD Library Functions Manual)118.874 E -.834(RAND48 \(3\))118.874 F
(All functions share the same multiplicand and addend.)102 96 Q(The)102
114 Q/F1 10/Courier-Bold@0 SF(srand48)4.703 E F0 2.203
(\(\) function is used to initialize the internal b)B(uf)-.2 E 2.204
(fer r\(n\) of)-.25 F F1(drand48)4.704 E F0(\(\),)A F1(lrand48)4.704 E
F0 2.204(\(\), and)B F1(mrand48)102 126 Q F0 .591
(\(\), such that the 32 bits of the seed v)B .59
(alue are copied into the upper 32 bits of r\(n\), with the lo)-.25 F
(wer)-.25 E 1.393(16 bits of r\(n\) arbitrarily being set to 0x330e.)102
138 R(Additionally)6.394 E 3.894(,t)-.65 G 1.394
(he constant multiplicand and addend of the)-3.894 F
(algorithm are reset to the def)102 150 Q(ault v)-.1 E(alues gi)-.25 E
-.15(ve)-.25 G 2.5(na).15 G(bo)-2.5 E -.15(ve)-.15 G(.).15 E(The)102 168
Q F1(seed48)2.575 E F0 .075
(\(\) function also initializes the internal b)B(uf)-.2 E .075
(fer r\(n\) of)-.25 F F1(drand48)2.574 E F0(\(\),)A F1(lrand48)2.574 E
F0 .074(\(\), and)B F1(mrand48)2.574 E F0(\(\),)A -.2(bu)102 180 S 2.637
(th).2 G .137(ere all 48 bits of the seed can be speci\214ed in an arra\
y of 3 shorts, where the zeroth member speci\214es the)-2.637 F(lo)102
192 Q 1.43(west bits.)-.25 F(Ag)6.43 E 1.429(ain, the constant multipli\
cand and addend of the algorithm are reset to the def)-.05 F 1.429
(ault v)-.1 F(alues)-.25 E(gi)102 204 Q -.15(ve)-.25 G 3.194(na).15 G
(bo)-3.194 E -.15(ve)-.15 G 5.694(.T).15 G(he)-5.694 E F1(seed48)3.194 E
F0 .695(\(\) function returns a pointer to an array of 3 shorts which c\
ontains the old seed.)B(This array is statically allocated; thus, its c\
ontents are lost after each ne)102 216 Q 2.5(wc)-.25 G(all to)-2.5 E F1
(seed48)2.5 E F0(\(\).)A(Finally)102 234 Q(,)-.65 E F1(lcong48)3.006 E
F0 .506(\(\) allo)B .506(ws full control o)-.25 F -.15(ve)-.15 G 3.005
(rt).15 G .505(he multiplicand and addend used in)-3.005 F F1(drand48)
3.005 E F0(\(\),)A F1(erand48)3.005 E F0(\(\),)A F1(lrand48)102 246 Q F0
(\(\),)A F1(nrand48)2.635 E F0(\(\),)A F1(mrand48)2.635 E F0 .135
(\(\), and)B F1(jrand48)2.635 E F0 .135(\(\), and the seed used in)B F1
(drand48)2.635 E F0(\(\),)A F1(lrand48)2.635 E F0 .135(\(\), and)B F1
(mrand48)102 258 Q F0 2.873(\(\). An)B .373
(array of 7 shorts is passed as ar)2.873 F .372
(gument; the \214rst three shorts are used to initialize the seed;)-.18
F .096(the second three are used to initialize the multiplicand; and th\
e last short is used to initialize the addend.)102 270 R .097(It is)
5.097 F(thus not possible to use v)102 282 Q(alues greater than 0xf)-.25
E .5 -.25(fff a)-.25 H 2.5(st).25 G(he addend.)-2.5 E 1.107
(Note that all three methods of seeding the random number generator al)
102 300 R -.1(wa)-.1 G 1.107(ys also set the multiplicand and).1 F
(addend for an)102 312 Q 2.5(yo)-.15 G 2.5(ft)-2.5 G
(he six generator calls.)-2.5 E -.15(Fo)102 330 S 2.5(ram).15 G(ore po)
-2.5 E(werful random number generator)-.25 E 2.5(,s)-.4 G(ee)-2.5 E/F2
10/Courier@0 SF(random)2.5 E F0(\(3\).)A/F3 10/Times-Bold@0 SF 1.666
(SEE ALSO)72 354 R F2(rand)102 366 Q F0(\(3\),)A F2(random)2.5 E F0
(\(3\))A F3 -.5(AU)72 390 S(THORS).5 E F0(Martin Bir)102 402 Q(gmeier)
-.18 E 179.695(BSD October)72 750 R(8, 1993)2.5 E(2)196.645 E 0 Cg EP
%%Trailer
end
%%EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment