Displaying 2 results from an estimated 2 matches for "samplenoreplac".
Did you mean:
samplenoreplace
2010 Mar 05
0
references to (1) R source code in svn repo within .Rd file and (2) to C source code in comments in R code using .Internal() /.Primitive()
..."
###
### corresponding C code may be inspected in
### https://svn.r-project.org/R/branches/% <linebreak>
### R-2-xx-branch/src/main/random.c
###
### <and, optionally something like>
###
### as functions ProbSampleReplace(), ProbSampleNoReplace(),
### SampleReplace(), SampleNoReplace(), .....
### <maybe more>
#
###end.new comment
#
}
}
--- snip ---
(The actual list of C functions would not be urgent at all;
finding the "right" source file alrea...
2017 Oct 18
1
uniform sampling without replacement algorithm
...uced to k
(usually with no copy being done).
When k is much smaller than n, and n is not small, a hashing scheme is
used, in which hash entries record which elements of x in the above
algorithm would have been modified from their original setting in which
x[i] == i.
*/
static SEXP SampleNoReplace (int k, int n)
{
SEXP r;
if (k <= 2) {
/* Special code for k = 0, 1, or 2, mimicing effect of previous code. */
if (k == 0)
return allocVector(INTSXP,0);
int i1 = 1 + (int) (n * unif_rand());
if (k == 1)
return ScalarInteger (i...