Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-random

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-random - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

16

dist/d3-random.js

@@ -1,2 +0,2 @@

// https://d3js.org/d3-random/ v2.2.0 Copyright 2020 Mike Bostock
// https://d3js.org/d3-random/ v2.2.1 Copyright 2020 Mike Bostock
(function (global, factory) {

@@ -328,10 +328,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

// https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
const a = 1664525;
const c = 1013904223;
const m = 4294967296; // 2^32
const mul = 0x19660D;
const inc = 0x3C6EF35F;
const eps = 1/0x100000000;
function lcg(s = Math.random()) {
if (!(0 <= s && s < 1)) throw new RangeError("invalid seed");
s = Math.floor(m * s);
return () => (s = (a * s + c) % m) / m;
function lcg(seed = Math.random()) {
if (!(0 <= seed && seed < 1)) throw new RangeError("invalid seed");
let state = seed / eps | 0;
return () => (state = mul * state + inc | 0, eps * (state >>> 0));
}

@@ -338,0 +338,0 @@

@@ -1,2 +0,2 @@

// https://d3js.org/d3-random/ v2.2.0 Copyright 2020 Mike Bostock
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((n=n||self).d3=n.d3||{})}(this,function(n){"use strict";var r=Math.random,o=function n(r){function o(n,o){return n=null==n?0:+n,o=null==o?1:+o,1===arguments.length?(o=n,n=0):o-=n,function(){return r()*o+n}}return o.source=n,o}(r),t=function n(r){function o(n,o){return arguments.length<2&&(o=n,n=0),n=Math.floor(n),o=Math.floor(o)-n,function(){return Math.floor(r()*o+n)}}return o.source=n,o}(r),u=function n(r){function o(n,o){var t,u;return n=null==n?0:+n,o=null==o?1:+o,function(){var e;if(null!=t)e=t,t=null;else do{t=2*r()-1,e=2*r()-1,u=t*t+e*e}while(!u||u>1);return n+o*e*Math.sqrt(-2*Math.log(u)/u)}}return o.source=n,o}(r),e=function n(r){var o=u.source(r);function t(){var n=o.apply(this,arguments);return function(){return Math.exp(n())}}return t.source=n,t}(r),a=function n(r){function o(n){return(n=+n)<=0?()=>0:function(){for(var o=0,t=n;t>1;--t)o+=r();return o+t*r()}}return o.source=n,o}(r),i=function n(r){var o=a.source(r);function t(n){if(0==(n=+n))return r;var t=o(n);return function(){return t()/n}}return t.source=n,t}(r),c=function n(r){function o(n){return function(){return-Math.log1p(-r())/n}}return o.source=n,o}(r),f=function n(r){function o(n){if((n=+n)<0)throw new RangeError("invalid alpha");return n=1/-n,function(){return Math.pow(1-r(),n)}}return o.source=n,o}(r),l=function n(r){function o(n){if((n=+n)<0||n>1)throw new RangeError("invalid p");return function(){return Math.floor(r()+n)}}return o.source=n,o}(r),h=function n(r){function o(n){if((n=+n)<0||n>1)throw new RangeError("invalid p");return 0===n?()=>1/0:1===n?()=>1:(n=Math.log1p(-n),function(){return 1+Math.floor(Math.log1p(-r())/n)})}return o.source=n,o}(r),s=function n(r){var o=u.source(r)();function t(n,t){if((n=+n)<0)throw new RangeError("invalid k");if(0===n)return()=>0;if(t=null==t?1:+t,1===n)return()=>-Math.log1p(-r())*t;var u=(n<1?n+1:n)-1/3,e=1/(3*Math.sqrt(u)),a=n<1?()=>Math.pow(r(),1/n):()=>1;return function(){do{do{var n=o(),i=1+e*n}while(i<=0);i*=i*i;var c=1-r()}while(c>=1-.0331*n*n*n*n&&Math.log(c)>=.5*n*n+u*(1-i+Math.log(i)));return u*i*a()*t}}return t.source=n,t}(r),d=function n(r){var o=s.source(r);function t(n,r){var t=o(n),u=o(r);return function(){var n=t();return 0===n?0:n/(n+u())}}return t.source=n,t}(r),v=function n(r){var o=h.source(r),t=d.source(r);function u(n,r){return n=+n,(r=+r)>=1?()=>n:r<=0?()=>0:function(){for(var u=0,e=n,a=r;e*a>16&&e*(1-a)>16;){var i=Math.floor((e+1)*a),c=t(i,e-i+1)();c<=a?(u+=i,e-=i,a=(a-c)/(1-c)):(e=i-1,a/=c)}for(var f=a<.5,l=o(f?a:1-a),h=l(),s=0;h<=e;++s)h+=l();return u+(f?s:e-s)}}return u.source=n,u}(r),M=function n(r){function o(n,o,t){var u;return 0==(n=+n)?u=n=>-Math.log(n):(n=1/n,u=r=>Math.pow(r,n)),o=null==o?0:+o,t=null==t?1:+t,function(){return o+t*u(-Math.log1p(-r()))}}return o.source=n,o}(r),m=function n(r){function o(n,o){return n=null==n?0:+n,o=null==o?1:+o,function(){return n+o*Math.tan(Math.PI*r())}}return o.source=n,o}(r),p=function n(r){function o(n,o){return n=null==n?0:+n,o=null==o?1:+o,function(){var t=r();return n+o*Math.log(t/(1-t))}}return o.source=n,o}(r),g=function n(r){var o=s.source(r),t=v.source(r);function u(n){return function(){for(var u=0,e=n;e>16;){var a=Math.floor(.875*e),i=o(a)();if(i>e)return u+t(a-1,e/i)();u+=a,e-=i}for(var c=-Math.log1p(-r()),f=0;c<=e;++f)c-=Math.log1p(-r());return u+f}}return u.source=n,u}(r);const w=1664525,y=1013904223,E=4294967296;n.randomBates=i,n.randomBernoulli=l,n.randomBeta=d,n.randomBinomial=v,n.randomCauchy=m,n.randomExponential=c,n.randomGamma=s,n.randomGeometric=h,n.randomInt=t,n.randomIrwinHall=a,n.randomLcg=function(n=Math.random()){if(!(0<=n&&n<1))throw new RangeError("invalid seed");return n=Math.floor(E*n),()=>(n=(w*n+y)%E)/E},n.randomLogNormal=e,n.randomLogistic=p,n.randomNormal=u,n.randomPareto=f,n.randomPoisson=g,n.randomUniform=o,n.randomWeibull=M,Object.defineProperty(n,"__esModule",{value:!0})});
// https://d3js.org/d3-random/ v2.2.1 Copyright 2020 Mike Bostock
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((n=n||self).d3=n.d3||{})}(this,function(n){"use strict";var r=Math.random,t=function n(r){function t(n,t){return n=null==n?0:+n,t=null==t?1:+t,1===arguments.length?(t=n,n=0):t-=n,function(){return r()*t+n}}return t.source=n,t}(r),o=function n(r){function t(n,t){return arguments.length<2&&(t=n,n=0),n=Math.floor(n),t=Math.floor(t)-n,function(){return Math.floor(r()*t+n)}}return t.source=n,t}(r),u=function n(r){function t(n,t){var o,u;return n=null==n?0:+n,t=null==t?1:+t,function(){var e;if(null!=o)e=o,o=null;else do{o=2*r()-1,e=2*r()-1,u=o*o+e*e}while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}}return t.source=n,t}(r),e=function n(r){var t=u.source(r);function o(){var n=t.apply(this,arguments);return function(){return Math.exp(n())}}return o.source=n,o}(r),a=function n(r){function t(n){return(n=+n)<=0?()=>0:function(){for(var t=0,o=n;o>1;--o)t+=r();return t+o*r()}}return t.source=n,t}(r),i=function n(r){var t=a.source(r);function o(n){if(0==(n=+n))return r;var o=t(n);return function(){return o()/n}}return o.source=n,o}(r),c=function n(r){function t(n){return function(){return-Math.log1p(-r())/n}}return t.source=n,t}(r),f=function n(r){function t(n){if((n=+n)<0)throw new RangeError("invalid alpha");return n=1/-n,function(){return Math.pow(1-r(),n)}}return t.source=n,t}(r),l=function n(r){function t(n){if((n=+n)<0||n>1)throw new RangeError("invalid p");return function(){return Math.floor(r()+n)}}return t.source=n,t}(r),h=function n(r){function t(n){if((n=+n)<0||n>1)throw new RangeError("invalid p");return 0===n?()=>1/0:1===n?()=>1:(n=Math.log1p(-n),function(){return 1+Math.floor(Math.log1p(-r())/n)})}return t.source=n,t}(r),s=function n(r){var t=u.source(r)();function o(n,o){if((n=+n)<0)throw new RangeError("invalid k");if(0===n)return()=>0;if(o=null==o?1:+o,1===n)return()=>-Math.log1p(-r())*o;var u=(n<1?n+1:n)-1/3,e=1/(3*Math.sqrt(u)),a=n<1?()=>Math.pow(r(),1/n):()=>1;return function(){do{do{var n=t(),i=1+e*n}while(i<=0);i*=i*i;var c=1-r()}while(c>=1-.0331*n*n*n*n&&Math.log(c)>=.5*n*n+u*(1-i+Math.log(i)));return u*i*a()*o}}return o.source=n,o}(r),d=function n(r){var t=s.source(r);function o(n,r){var o=t(n),u=t(r);return function(){var n=o();return 0===n?0:n/(n+u())}}return o.source=n,o}(r),v=function n(r){var t=h.source(r),o=d.source(r);function u(n,r){return n=+n,(r=+r)>=1?()=>n:r<=0?()=>0:function(){for(var u=0,e=n,a=r;e*a>16&&e*(1-a)>16;){var i=Math.floor((e+1)*a),c=o(i,e-i+1)();c<=a?(u+=i,e-=i,a=(a-c)/(1-c)):(e=i-1,a/=c)}for(var f=a<.5,l=t(f?a:1-a),h=l(),s=0;h<=e;++s)h+=l();return u+(f?s:e-s)}}return u.source=n,u}(r),M=function n(r){function t(n,t,o){var u;return 0==(n=+n)?u=n=>-Math.log(n):(n=1/n,u=r=>Math.pow(r,n)),t=null==t?0:+t,o=null==o?1:+o,function(){return t+o*u(-Math.log1p(-r()))}}return t.source=n,t}(r),m=function n(r){function t(n,t){return n=null==n?0:+n,t=null==t?1:+t,function(){return n+t*Math.tan(Math.PI*r())}}return t.source=n,t}(r),p=function n(r){function t(n,t){return n=null==n?0:+n,t=null==t?1:+t,function(){var o=r();return n+t*Math.log(o/(1-o))}}return t.source=n,t}(r),g=function n(r){var t=s.source(r),o=v.source(r);function u(n){return function(){for(var u=0,e=n;e>16;){var a=Math.floor(.875*e),i=t(a)();if(i>e)return u+o(a-1,e/i)();u+=a,e-=i}for(var c=-Math.log1p(-r()),f=0;c<=e;++f)c-=Math.log1p(-r());return u+f}}return u.source=n,u}(r);const w=1664525,y=1013904223,E=1/4294967296;n.randomBates=i,n.randomBernoulli=l,n.randomBeta=d,n.randomBinomial=v,n.randomCauchy=m,n.randomExponential=c,n.randomGamma=s,n.randomGeometric=h,n.randomInt=o,n.randomIrwinHall=a,n.randomLcg=function(n=Math.random()){if(!(0<=n&&n<1))throw new RangeError("invalid seed");let r=n/E|0;return()=>(r=w*r+y|0,E*(r>>>0))},n.randomLogNormal=e,n.randomLogistic=p,n.randomNormal=u,n.randomPareto=f,n.randomPoisson=g,n.randomUniform=t,n.randomWeibull=M,Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "d3-random",
"version": "2.2.0",
"version": "2.2.1",
"description": "Generate random numbers from various distributions.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -118,6 +118,4 @@ # d3-random

<a name="randomLcg" href="#randomLcg">#</a> d3.<b>randomLcg</b>(<i>[seed]</i>) · [Examples](https://observablehq.com/@fil/linear-congruential-generator)
<a name="randomLcg" href="#randomLcg">#</a> d3.<b>randomLcg</b>([<i>seed</i>]) · [Source](https://github.com/d3/d3-random/blob/master/src/lcg.js), [Examples](https://observablehq.com/@d3/d3-randomlcg)
Returns a [Linear congruential generator](https://en.wikipedia.org/wiki/Linear_congruential_generator). The generator can be called repeatedly to obtain a pseudo-random sequence of values, well-distributed on the interval [0,1) and with a long period (up to 1 billion numbers).
A *seed* can be specified as a number in the interval [0,1). Two generators instanced with the same seed generate the same sequence, allowing to create reproducible pseudo-random experiments. If the *seed* is not specified, it is chosen at random.
Returns a [linear congruential generator](https://en.wikipedia.org/wiki/Linear_congruential_generator); this function can be called repeatedly to obtain pseudorandom values well-distributed on the interval [0,1) and with a long period (up to 1 billion numbers), similar to Math.random. A *seed* can be specified as a number in the interval [0,1). Two generators instanced with the same seed generate the same sequence, allowing to create reproducible pseudo-random experiments. If the *seed* is not specified, one is chosen using Math.random.
// https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
const a = 1664525;
const c = 1013904223;
const m = 4294967296; // 2^32
const mul = 0x19660D;
const inc = 0x3C6EF35F;
const eps = 1/0x100000000;
export default function lcg(s = Math.random()) {
if (!(0 <= s && s < 1)) throw new RangeError("invalid seed");
s = Math.floor(m * s);
return () => (s = (a * s + c) % m) / m;
export default function lcg(seed = Math.random()) {
if (!(0 <= seed && seed < 1)) throw new RangeError("invalid seed");
let state = seed / eps | 0;
return () => (state = mul * state + inc | 0, eps * (state >>> 0));
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc