Sampling Algorithms (Non-Weighted) StatsBase. rng: optional random number generator (defaults to Random.GLOBAL_RNG)Īll following functions write results to x (pre-allocated) and return x.For sampling without replacement, k must not exceed n. wv: the weight vector (of type AbstractWeights), for weighted sampling.You can also specify more than one item to be selected, in which case they will be returned in a random order. This is equivalent to a truly random choice by using a random choice wheel. a: source array representing the population Enter up to 100,000 items (numbers, letters, words, IDs, names, emails, etc.) and our choice picker will choose one of them at random.The functions below are not exported (one can still import them from StatsBase via using though). Here are a list of algorithms implemented in the package. That being said, if you know that a certain algorithm is particularly suitable for your context, directly calling an internal algorithm function might be slightly more efficient. It performs reasonably fast for most cases. Note that the choices made in sample are decided based on extensive benchmarking (see perf/sampling.jl and perf/wsampling.jl). Internally, this package implements multiple algorithms, and the sample (and sample!) methods integrate them into a poly-algorithm, which chooses a specific algorithm based on inputs. Optionally specify a random number generator rng as the first argument (defaults to Random.GLOBAL_RNG). a sample where items appear in the same order as in a) should be taken. ordered dictates whether an ordered sample (also called a sequential sample, i.e. replace dictates whether sampling is performed with replacement. Sampling probabilities are proportional to the weights given in w. Select a weighted sample from an array a and store the result in x. Wsample!(, a, w, x replace=true, ordered=false)
0 Comments
Leave a Reply. |