MCPcopy Create free account
hub / github.com/breck7/scroll / randomGeometric

Function randomGeometric

external/.d3.js:14589–14597  ·  view source on GitHub ↗
(p)

Source from the content-addressed store, hash-verified

14587
14588var geometric = (function sourceRandomGeometric(source) {
14589 function randomGeometric(p) {
14590 if ((p = +p) < 0 || p > 1) throw new RangeError("invalid p");
14591 if (p === 0) return () => Infinity;
14592 if (p === 1) return () => 1;
14593 p = Math.log1p(-p);
14594 return function() {
14595 return 1 + Math.floor(Math.log1p(-source()) / p);
14596 };
14597 }
14598
14599 randomGeometric.source = sourceRandomGeometric;
14600

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected