@stdlib/random-base-poisson
Version:
Poisson distributed random numbers.
14 lines (13 loc) • 3.39 kB
JavaScript
;var c=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var N=c(function(ar,O){
var M=require('@stdlib/math-base-special-exp/dist');function V(i,r){for(var e=i(),t=1;e>M(-r);)t+=1,e*=i();return t-1}O.exports=V
});var E=c(function(or,S){
var W=require('@stdlib/math-base-special-factorialln/dist'),L=require('@stdlib/math-base-special-floor/dist'),I=require('@stdlib/math-base-special-signum/dist'),Q=require('@stdlib/math-base-special-sqrt/dist'),w=require('@stdlib/math-base-special-abs/dist'),q=require('@stdlib/math-base-special-ln/dist'),B=require('@stdlib/constants-float64-ln-sqrt-two-pi/dist'),C=1/12,D=1/360;function H(i,r){var e,t,l,p,g,f,o,s,n,u;for(e=Q(r),o=2.53*e+.931,f=.02483*o-.059,t=1.1328/(o-3.4)+1.1239,g=-3.6224/(o-2)+.9277,l=.86*g;;){if(u=i(),u<=l)return n=u/g-.43,n*=2*f/(.5-w(n))+o,n+=r+.445,L(n);if(u>=g?n=i()-.5:(n=u/g-.93,n=I(n)*.5-n,u=g*i()),p=.5-w(n),(p>=.013||p>=u)&&(s=L((2*f/p+o)*n+r+.445),u*=t/(f/(p*p)+o),n=(s+.5)*q(r/s),n+=-r-B+s,n-=(C-D/(s*s))/s,s>=10&&n>=q(u*e)||(n=s*q(r)-r-W(s),s>=0&&s<=9&&n>=q(u))))return s}}S.exports=H
});var x=c(function(vr,R){
var K=N(),U=E();function X(i,r){return r<30?K(i,r):U(i,r)}R.exports=X
});var d=c(function(pr,k){
var v=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),h=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),P=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),Y=require('@stdlib/assert-is-positive-number/dist').isPrimitive,b=require('@stdlib/assert-is-plain-object/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-has-own-property/dist'),j=require('@stdlib/utils-constant-function/dist'),Z=require('@stdlib/utils-noop/dist'),m=require('@stdlib/random-base-mt19937/dist').factory,$=require('@stdlib/math-base-assert-is-nan/dist'),rr=require('@stdlib/array-to-json/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist'),A=x();function er(){var i,r,e,t;if(arguments.length===0)e=m();else if(arguments.length===1&&b(arguments[0]))if(r=arguments[0],_(r,"prng")){if(!T(r.prng))throw new TypeError(y('0ov6u',"prng",r.prng));e=r.prng}else e=m(r);else{if(i=arguments[0],!Y(i))throw new TypeError(y('0ov71',i));if(arguments.length>1){if(r=arguments[1],!b(r))throw new TypeError(y('0ov2V',r));if(_(r,"prng")){if(!T(r.prng))throw new TypeError(y('0ov6u',"prng",r.prng));e=r.prng}else e=m(r)}else e=m()}return i===void 0?t=z:t=u,v(t,"NAME","poisson"),r&&r.prng?(v(t,"seed",null),v(t,"seedLength",null),P(t,"state",j(null),Z),v(t,"stateLength",null),v(t,"byteLength",null),v(t,"toJSON",j(null)),v(t,"PRNG",e)):(h(t,"seed",l),h(t,"seedLength",p),P(t,"state",o,s),h(t,"stateLength",g),h(t,"byteLength",f),v(t,"toJSON",n),v(t,"PRNG",e),e=e.normalized),t;function l(){return e.seed}function p(){return e.seedLength}function g(){return e.stateLength}function f(){return e.byteLength}function o(){return e.state}function s(a){e.state=a}function n(){var a={};return a.type="PRNG",a.name=t.NAME,a.state=rr(e.state),i===void 0?a.params=[]:a.params=[i],a}function u(){return A(e,i)}function z(a){return $(a)||a<=0?NaN:A(e,a)}}k.exports=er
});var G=c(function(gr,F){
var tr=d(),nr=tr();F.exports=nr
});var ir=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),J=G(),sr=d();ir(J,"factory",sr);module.exports=J;
/** @license Apache-2.0 */
//# sourceMappingURL=index.js.map