@stdlib/random-base-negative-binomial
Version:
Negative binomial distributed pseudorandom numbers.
10 lines (9 loc) • 3.77 kB
JavaScript
;var h=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var S=h(function(ie,N){
var I=require('@stdlib/assert-is-positive-number/dist').isPrimitive,K=require('@stdlib/assert-is-number/dist').isPrimitive,q=require('@stdlib/error-tools-fmtprodmsg/dist'),Q=require('@stdlib/assert-is-nan/dist');function X(a,t){return I(a)?!K(t)||Q(t)?new TypeError(q('0on6w',t)):t<=0||t>=1?new RangeError(q('0on7X',t)):null:new TypeError(q('0on71',a));}N.exports=X
});var E=h(function(se,j){
var l=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),c=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),T=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),g=require('@stdlib/assert-has-own-property/dist'),L=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-uint32array/dist'),A=require('@stdlib/assert-is-boolean/dist').isPrimitive,P=require('@stdlib/assert-is-function/dist'),R=require('@stdlib/utils-constant-function/dist'),Y=require('@stdlib/utils-noop/dist'),V=require('@stdlib/math-base-assert-is-nan/dist'),v=require('@stdlib/random-base-poisson/dist').factory,y=require('@stdlib/random-base-gamma/dist').factory,b=require('@stdlib/blas-base-gcopy/dist'),O=require('@stdlib/array-uint32/dist'),U=require('@stdlib/object-assign/dist'),Z=require('@stdlib/array-to-json/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist'),_=S();function $(){var a,t,i,e,r,s,m,d,p,o;if(m=!0,arguments.length===0)e={copy:!1},i=v(e);else if(arguments.length===1){if(e=arguments[0],!L(e))throw new TypeError(u('0on2V',e));if(g(e,"copy")&&!A(e.copy))throw new TypeError(u('0on2o',"copy",e.copy));if(g(e,"prng")){if(!P(e.prng))throw new TypeError(u('0on6u',"prng",e.prng));i=v({prng:e.prng})}else{if(g(e,"state")&&!w(e.state))throw new TypeError(u('0on6z',"state",e.state));e=U({},e),e.copy===!1?m=!1:e.state&&(e.state=b(e.state.length,e.state,1,new O(e.state.length),1)),e.copy=!1,i=v(e)}}else{if(o=arguments[0],p=arguments[1],d=_(o,p),d)throw d;if(arguments.length>2){if(e=arguments[2],!L(e))throw new TypeError(u('0on2V',e));if(g(e,"copy")&&!A(e.copy))throw new TypeError(u('0on2o',"copy",e.copy));if(g(e,"prng")){if(!P(e.prng))throw new TypeError(u('0on6u',"prng",e.prng));i=v({prng:e.prng})}else{if(g(e,"state")&&!w(e.state))throw new TypeError(u('0on6z',"state",e.state));e=U({},e),e.copy===!1?m=!1:e.state&&(e.state=b(e.state.length,e.state,1,new O(e.state.length),1)),e.copy=!1,i=v(e)}}else e={copy:!1},i=v(e)}return e&&e.prng?o===void 0?a=y({prng:e.prng}):a=y(o,p/(1-p),{prng:e.prng}):(e.state?t=e.state:(t=i.state,i.state=t),o===void 0?a=y({state:t,copy:!1}):a=y(o,p/(1-p),{state:t,copy:!1})),o===void 0?r=H:r=D,s=i.PRNG,l(r,"NAME","negative-binomial"),e&&e.prng?(l(r,"seed",null),l(r,"seedLength",null),T(r,"state",R(null),Y),l(r,"stateLength",null),l(r,"byteLength",null),l(r,"toJSON",R(null))):(c(r,"seed",G),c(r,"seedLength",J),T(r,"state",W,k),c(r,"stateLength",M),c(r,"byteLength",z),l(r,"toJSON",C)),l(r,"PRNG",s),r;function G(){return s.seed}function J(){return s.seedLength}function M(){return s.stateLength}function z(){return s.byteLength}function W(){return s.state}function k(n){if(!w(n))throw new TypeError(u('0on70',n));m&&(n=b(n.length,n,1,new O(n.length),1)),s.state=n}function C(){var n={};return n.type="PRNG",n.name=r.NAME,n.state=Z(s.state),o===void 0?n.params=[]:n.params=[o,p],n}function D(){return i(a())}function H(n,f){return V(n)||V(f)||f<=0||f>=1?NaN:i(a(n,f/(1-f)))}}j.exports=$
});var B=h(function(oe,x){
var ee=E(),re=ee();x.exports=re
});var te=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),F=B(),ne=E();te(F,"factory",ne);module.exports=F;
/** @license Apache-2.0 */
//# sourceMappingURL=index.js.map