Difference between revisions of "Rn1"

From NetHackWiki
Jump to navigation Jump to search
(cat)
m (update ref to 3.6.6; de-stub since there's really not much that can be written about this)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:rn1}}
 
{{DISPLAYTITLE:rn1}}
{{randomvariable|name=rn1(x,y)|graph=rn1.svg|caption=[[wikipedia:Probability mass function|Probability mass function]] of rn1(10,5).|distribution=[[Wikipedia:discrete uniform distribution|uniform]]|mean=<math>(x-1)/2+y</math>|stddev=<math>\sqrt{(x^2-1)/12}</math>}}
+
{{randomvariable|name=rn1(<var>x</var>,<var>y</var>)|graph=rn1.svg|caption=[[wikipedia:Probability mass function|Probability mass function]] of rn1(10,5)|distribution=[[Wikipedia:discrete uniform distribution|uniform]]|mean={{sfrac|<var>x</var> &minus; 1|2}} + <var>y</var>|stddev=sqrt({{sfrac|x<sup>2</sup> &minus; 1|12}})}}
rn1(x, y)<ref>{{sourcecode|hack.h|291}}</ref> is a pseudo-random number macro used in NetHack when a result should be unweighted. It is equivalent to ''rn2(x) + y''. The range of values is between y and y+x-1 inclusive (that is, y<=rn1(x,y)<x+y).  
+
{{distinguish|rnl}}
 +
'''rn1(<var>x</var>, <var>y</var>)'''{{refsrc|include/hack.h|497|nethack=3.6.6}} is a pseudo-random number macro used in ''NetHack'' when a result should be unweighted. It is equivalent to rn2(<var>x</var>)&nbsp;+ <var>y</var>. The range of values is between <var>y</var> and <var>y</var>&nbsp;+ <var>x</var>&nbsp;&minus;&nbsp;1 inclusive (that is, <var>y</var>&nbsp;&le; rn1(<var>x</var>,<var>y</var>)&nbsp;&lt; <var>x</var>&nbsp;+&nbsp;<var>y</var>).  
  
 
See also [[rn2]].
 
See also [[rn2]].
Line 8: Line 9:
 
<references/>
 
<references/>
  
{{stub}}
 
 
[[Category:Random number functions]]
 
[[Category:Random number functions]]
 +
{{nethack-366}}

Latest revision as of 17:35, 19 March 2022

rn1(x,y)
Distribution uniform
Mean x − 12 + y
Standard deviation sqrt(x2 − 112)
Not to be confused with rnl.

rn1(x, y)[1] is a pseudo-random number macro used in NetHack when a result should be unweighted. It is equivalent to rn2(x) + y. The range of values is between y and y + x − 1 inclusive (that is, y ≤ rn1(x,y) < x + y).

See also rn2.

References