source: node_modules/d3-random/src/bernoulli.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 375 bytes
Line 
1import defaultSource from "./defaultSource.js";
2
3export default (function sourceRandomBernoulli(source) {
4 function randomBernoulli(p) {
5 if ((p = +p) < 0 || p > 1) throw new RangeError("invalid p");
6 return function() {
7 return Math.floor(source() + p);
8 };
9 }
10
11 randomBernoulli.source = sourceRandomBernoulli;
12
13 return randomBernoulli;
14})(defaultSource);
Note: See TracBrowser for help on using the repository browser.