@lazy-random/util-probabilities
Version:
24 lines (23 loc) • 843 B
JavaScript
!function(e, t) {
"object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define([ "exports" ], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).LazyRandomUtilProbabilities = {});
}(this, (function(e) {
"use strict";
e.get_prob = function get_prob(e, t) {
let o = t, n = [], f = 0, i = e - 1;
for (;i--; ) {
let t = Math.round(o / e);
n.push(t), f += t, o -= t;
}
return n.unshift(t - f), n;
}, e.get_prob_float = function get_prob_float(e, t) {
let o = t, n = [], f = 0, i = e - 1;
for (;i--; ) {
let t = o / e;
n.push(t), f += t, o -= t;
}
return n.unshift(t - f), n;
}, Object.defineProperty(e, "__esModule", {
value: !0
});
}));
//# sourceMappingURL=index.umd.production.min.cjs.map