Description Usage Arguments Details Value Author(s) See Also Examples
Create uniform random 64-bit integers within defined range
1 | runif64(n, min = lim.integer64()[1], max = lim.integer64()[2], replace=TRUE)
|
n |
length of return vector |
min |
lower inclusive bound for random numbers |
max |
upper inclusive bound for random numbers |
replace |
set to FALSE for sampleing from a finite pool, see |
For each random integer we call R's internal C interface unif_rand()
twice.
Each call is mapped to 2^32 unsigned integers. The two 32-bit patterns are concatenated
to form the new integer64. This process is repeated until the result is not a NA_INTEGER64
.
a integer64 vector
Jens Oehlschlägel <Jens.Oehlschlaegel@truecluster.com>
1 2 3 4 5 6 7 8 9 10 | runif64(12)
runif64(12, -16, 16)
runif64(12, 0, as.integer64(2^60)-1) # not 2^60-1 !
var(runif(1e4))
var(as.double(runif64(1e4, 0, 2^40))/2^40) # ~ = 1/12 = .08333
table(sample(16, replace=FALSE))
table(runif64(16, 1, 16, replace=FALSE))
table(sample(16, replace=TRUE))
table(runif64(16, 1, 16, replace=TRUE))
|
Loading required package: bit
Attaching package: ‘bit’
The following object is masked from ‘package:base’:
xor
Attaching package bit64
package:bit64 (c) 2011-2017 Jens Oehlschlaegel
creators: integer64 runif64 seq :
coercion: as.integer64 as.vector as.logical as.integer as.double as.character as.bitstring
logical operator: ! & | xor != == < <= >= >
arithmetic operator: + - * / %/% %% ^
math: sign abs sqrt log log2 log10
math: floor ceiling trunc round
querying: is.integer64 is.vector [is.atomic} [length] format print str
values: is.na is.nan is.finite is.infinite
aggregation: any all min max range sum prod
cumulation: diff cummin cummax cumsum cumprod
access: length<- [ [<- [[ [[<-
combine: c rep cbind rbind as.data.frame
WARNING don't use as subscripts
WARNING semantics differ from integer
for more help type ?bit64
Attaching package: ‘bit64’
The following objects are masked from ‘package:base’:
:, %in%, is.double, match, order, rank
integer64
[1] 2294380315572898759 -2822386010932617694 9091387110124089933
[4] -5286496093141725349 4257730952285763297 -6237727915299162168
[7] -5851339940848374561 3445124979186902524 -7381195515451320888
[10] 8681375796314779615 -5721869735650798256 1093754371783053699
integer64
[1] -13 -10 10 -15 -5 7 1 7 -5 -7 0 -7
integer64
[1] 720961133535215846 303823581203269861 302771674715977331 46706259418449217
[5] 668957022423243428 814397828142160069 493299669251030133 928509290350600189
[9] 407040608158510952 173863229215307710 555037300913277371 216661864307588184
[1] 0.08348684
[1] 0.08125748
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 2 3 4 5 7 9 10 12 14 16
2 1 1 1 2 1 1 3 1 1 2
1 2 6 7 8 12 13 14 15 16
2 2 1 1 1 1 1 2 4 1
1 2 4 5 7 8 9 13 16
2 3 1 2 1 2 1 2 2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.