Sample a fixed number of balls, without replacement, from multiple urns.
rmultihyper(n, k)
n | a vector describing the number of balls in each urn |
---|---|
k | the total number of balls to draw from the urns |
A vector or array corresponding to the number of balls sampled from each of the urns, in the same format as n
.
Requesting a non-integer or negative number of balls, or more than are available in all the urns, will throw an error.
If k
is a vector of length > 1, only the first element will be used.
Specifying only one or two urns will respectively return k
or call stats::rhyper()
and issue a warning.
If \(k = \sum n\) then the function should return n
.
stats::rhyper()
for sampling two different colours of balls from a single urn (equivalent to sampling one colour from two urns)
rmultihyper(c(5, 10, 8), 6)#> [1] 0 2 4# 90% sample of citation counts data k <- round(0.9 * sum(citations)) rmultihyper(citations, k)#> citing #> cited AmS AISM AoS ANZS Bern BioJ Bcs Bka Biost CJS CSSC CSTM CmpSt CSDA EES #> AmS 38 1 2 0 0 0 6 1 3 2 4 3 1 14 1 #> AISM 0 16 3 1 4 0 0 2 0 0 5 18 0 10 0 #> AoS 9 21 261 4 45 12 27 65 11 15 17 37 6 66 1 #> ANZS 0 5 2 5 0 0 2 2 0 0 0 2 1 8 0 #> Bern 1 7 24 0 20 0 2 4 0 1 2 9 3 7 0 #> BioJ 0 0 3 1 0 49 13 7 1 0 4 6 2 23 0 #> Bcs 8 1 14 9 4 42 177 27 48 16 9 11 2 56 4 #> Bka 6 9 32 5 11 11 56 67 24 14 11 21 3 58 1 #> Biost 4 0 6 0 0 17 42 13 52 2 2 4 0 13 2 #> CJS 0 2 7 1 2 1 6 4 2 13 4 7 2 17 1 #> CSSC 2 5 0 1 0 5 1 0 0 0 29 19 5 11 0 #> CSTM 1 4 0 3 1 2 0 0 0 0 26 80 3 23 0 #> CmpSt 0 0 1 0 2 0 0 0 1 0 0 2 3 10 0 #> CSDA 5 4 17 0 2 12 14 9 6 10 35 24 21 441 13 #> EES 0 0 0 0 0 0 4 0 0 0 0 0 0 3 33 #> Envr 0 0 0 0 0 0 0 1 3 1 0 0 0 6 5 #> ISR 3 0 3 2 1 0 0 0 0 0 3 1 0 7 0 #> JABES 0 0 0 2 0 0 5 0 0 0 1 1 0 5 3 #> JASA 13 16 103 13 23 26 112 64 41 34 26 30 18 132 7 #> JAS 0 0 1 2 0 2 1 0 0 1 8 12 2 18 0 #> JBS 0 0 0 2 0 23 11 0 2 0 0 1 0 6 0 #> citing #> cited Envr ISR JABES JASA JAS JBS JCGS JMA JNS JRSS-A JRSS-B JRSS-C JSCS #> AmS 0 5 1 12 4 4 3 3 0 1 1 3 1 #> AISM 1 0 0 3 0 0 1 18 11 0 2 0 3 #> AoS 5 0 2 110 7 8 26 123 43 0 35 6 15 #> ANZS 0 0 0 4 4 0 1 11 1 0 0 0 4 #> Bern 0 0 0 9 0 0 4 19 6 0 3 0 3 #> BioJ 1 0 0 4 8 24 2 0 2 0 0 1 5 #> Bcs 8 2 27 61 18 43 7 16 13 4 5 25 6 #> Bka 8 5 3 81 8 13 21 58 13 1 21 7 7 #> Biost 0 0 0 31 4 10 3 1 3 8 0 10 4 #> CJS 2 0 0 14 5 0 1 25 8 0 3 1 2 #> CSSC 0 0 0 3 16 0 0 3 0 0 0 0 8 #> CSTM 1 2 0 0 25 2 0 26 4 1 1 1 21 #> CmpSt 0 0 2 4 1 0 4 5 4 0 1 0 2 #> CSDA 12 4 9 18 36 8 20 49 12 0 3 2 28 #> EES 6 0 6 6 0 0 0 0 0 0 0 3 1 #> Envr 29 0 3 10 2 0 8 4 0 0 0 3 0 #> ISR 2 20 0 5 4 0 1 3 0 2 1 0 2 #> JABES 6 0 12 8 2 0 0 0 0 0 0 2 3 #> JASA 16 5 18 210 16 18 30 88 19 10 37 27 15 #> JAS 0 0 0 0 33 0 1 2 0 0 1 0 11 #> JBS 0 0 0 0 2 87 0 0 0 0 0 0 0 #> citing #> cited JSPI JSS JTSA LDA Mtka SJS StataJ StCmp Stats StMed SMMR StMod StNee #> AmS 11 8 1 0 2 2 1 0 2 8 1 1 0 #> AISM 27 1 2 0 8 1 0 1 1 1 0 0 2 #> AoS 96 6 9 5 8 20 3 30 4 15 5 2 8 #> ANZS 14 2 0 0 0 2 0 1 0 0 0 0 1 #> Bern 20 2 4 0 1 4 0 0 1 1 0 0 11 #> BioJ 8 2 0 5 2 1 0 1 2 51 7 0 2 #> Bcs 33 12 3 26 2 17 0 12 1 184 36 5 7 #> Bka 75 7 0 8 8 21 1 17 3 52 13 7 3 #> Biost 6 5 0 10 0 4 0 0 0 82 13 7 0 #> CJS 14 4 0 2 3 4 1 0 2 8 4 0 0 #> CSSC 5 0 2 0 1 0 0 0 2 11 0 0 0 #> CSTM 33 0 0 1 5 3 0 0 18 7 1 0 0 #> CmpSt 3 2 0 0 0 3 0 2 0 0 0 0 0 #> CSDA 47 29 4 4 3 9 1 22 7 36 4 12 2 #> EES 2 0 0 0 0 2 0 0 0 3 0 0 0 #> Envr 9 1 0 0 0 5 0 4 1 10 0 0 0 #> ISR 7 1 0 2 0 0 2 0 5 1 0 1 0 #> JABES 4 0 0 0 0 0 0 1 0 6 0 0 0 #> JASA 99 10 13 20 9 22 0 42 3 85 15 12 3 #> JAS 12 3 0 0 0 0 0 0 6 4 0 0 0 #> JBS 0 2 0 0 1 0 0 0 0 35 2 0 1 #> citing #> cited StPap SPL StSci StSin Tech Test #> AmS 0 6 7 2 0 0 #> AISM 3 15 2 5 0 5 #> AoS 7 38 16 115 15 34 #> ANZS 1 6 0 1 1 2 #> Bern 1 29 2 14 0 5 #> BioJ 1 2 1 4 0 0 #> Bcs 1 19 37 12 5 15 #> Bka 1 31 24 65 8 11 #> Biost 2 6 24 2 0 0 #> CJS 2 9 0 8 3 6 #> CSSC 6 5 1 2 0 3 #> CSTM 31 29 0 3 2 7 #> CmpSt 0 2 0 0 0 1 #> CSDA 6 10 12 5 4 14 #> EES 0 0 2 0 0 4 #> Envr 0 0 2 2 4 6 #> ISR 1 2 3 0 0 0 #> JABES 0 0 2 0 2 3 #> JASA 9 38 44 93 13 30 #> JAS 7 3 4 0 1 3 #> JBS 2 0 3 0 0 0 #> [ reached getOption("max.print") -- omitted 26 rows ]