sample_seq: Sampling a random integer sequence

View source: R/other.R

sample_seqR Documentation

Sampling a random integer sequence

Description

This function provides a very efficient way to pull an integer random sample sequence from an integer interval.

Usage

sample_seq(low, high, length)

Arguments

low

The lower limit of the interval (inclusive).

high

The higher limit of the interval (inclusive).

length

The length of the sample.

Details

The algorithm runs in O(length) expected time, even if high-low is big. It is much faster (but of course less general) than the builtin sample function of R.

Value

An increasing numeric vector containing integers, the sample.

Author(s)

Gabor Csardi csardi.gabor@gmail.com

References

Jeffrey Scott Vitter: An Efficient Algorithm for Sequential Random Sampling, ACM Transactions on Mathematical Software, 13/1, 58–67.

See Also

Other other: convex_hull(), running_mean()

Examples


rs <- sample_seq(1, 100000000, 10)
rs


igraph documentation built on Oct. 20, 2024, 1:06 a.m.