The Octave Forge package repository is no longer actively maintained. Please find Octave Packages at https://packages.octave.org.

Navigation

Operators and Keywords

Function List:

C++ API

Function File: y = randsample (v, k, replacement=false [, w])

Elements sampled from a vector.

Returns k random elements from a vector v with n elements, sampled without or with replacement.

If v is a scalar, samples from 1:v.

If a weight vector w of the same size as v is specified, the probablility of each element being sampled is proportional to w. Unlike Matlab’s function of the same name, this can be done for sampling with or without replacement.

Randomization is performed using rand().

See also: datasample, randperm.

Package: statistics