UNPKG

@stdlib/random-iter-negative-binomial

Version:

Create an iterator for generating pseudorandom numbers drawn from a negative binomial distribution.

6 lines (5 loc) 2.13 kB
"use strict";var O=function(a,n){return function(){return n||a((n={exports:{}}).exports,n),n.exports}};var q=O(function(U,b){ var i=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),u=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),f=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),E=require('@stdlib/utils-constant-function/dist'),x=require('@stdlib/utils-noop/dist'),A=require('@stdlib/object-assign/dist'),T=require('@stdlib/assert-is-probability/dist').isPrimitive,V=require('@stdlib/assert-is-plain-object/dist'),F=require('@stdlib/assert-is-positive-number/dist').isPrimitive,j=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,z=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/constants-float64-max/dist'),d=require('@stdlib/random-base-negative-binomial/dist').factory,m=require('@stdlib/symbol-iterator/dist'),s=require('@stdlib/error-tools-fmtprodmsg/dist');function h(a,n,o){var t,e,r,l,v;if(!F(a))throw new TypeError(s('0qB4b',a));if(!T(n))throw new TypeError(s('0qB73',n));if(arguments.length>2){if(!V(o))throw new TypeError(s('0qB2V',o));if(t=A({},o),z(t,"iter")){if(!j(t.iter))throw new TypeError(s('0qB2t',"iter",t.iter))}else t.iter=c;r=d(a,n,t),t.prng===void 0&&t.copy!==!1&&(t.state=r.state)}else r=d(a,n),t={iter:c,state:r.state};return v=0,e={},i(e,"next",y),i(e,"return",P),t&&t.prng?(i(e,"seed",null),i(e,"seedLength",null),f(e,"state",E(null),x),i(e,"stateLength",null),i(e,"byteLength",null)):(u(e,"seed",p),u(e,"seedLength",N),f(e,"state",G,S),u(e,"stateLength",R),u(e,"byteLength",w)),i(e,"PRNG",r.PRNG),m&&i(e,m,L),e;function y(){return v+=1,l||v>t.iter?{done:!0}:{value:r(),done:!1}}function P(g){return l=!0,arguments.length?{value:g,done:!0}:{done:!0}}function L(){return h(a,n,t)}function p(){return r.PRNG.seed}function N(){return r.PRNG.seedLength}function R(){return r.PRNG.stateLength}function w(){return r.PRNG.byteLength}function G(){return r.PRNG.state}function S(g){r.PRNG.state=g}}b.exports=h });var I=q();module.exports=I; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map