deno.land / x / simplestatistic@v7.7.1 / test / sample_with_replacement.test.js

sample_with_replacement.test.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* eslint no-shadow: 0 */
const test = require("tap").test;const Random = require("random-js");const random = new Random.Random(Random.MersenneTwister19937.seed(0));const ss = require("../");
function rng() { return random.real(0, 1);}
test("sampleWithReplacement", function (t) { const input = [1, 2, 3, 4, 5, 6]; t.same(ss.sampleWithReplacement(input, 2, rng), [6, 5]); t.same(ss.sampleWithReplacement(input, 3, rng), [3, 6, 4]); t.same(ss.sampleWithReplacement(input, 4, rng), [5, 2, 3, 4]); t.same(ss.sampleWithReplacement(input, 0, rng), []); t.same(ss.sampleWithReplacement([], 1, rng), []); t.end();});
simplestatistic

Version Info

Tagged at
2 years ago