Skip to main content
Module

x/simplestatistics/index.js>sample

simple statistics for node & browser javascript
Go to Latest
function sample
import { sample } from "https://deno.land/x/simplestatistics@v7.7.5/index.js";

Create a simple random sample from a given array of n elements.

The sampled values will be in any order, not necessarily the order they appear in the input.

Examples

var values = [1, 2, 4, 5, 6, 7, 8, 9]; sample(values, 3); // returns 3 random values, like [2, 5, 8];

Parameters

x

input array. can contain any type

n

count of how many elements to take

randomSource