@stdlib/random-base-hypergeometric
Version:
Hypergeometric distributed pseudorandom numbers.
14 lines (13 loc) • 3.25 kB
JavaScript
var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var S=l(function(ie,O){
var q=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,m=require('@stdlib/error-tools-fmtprodmsg/dist');function X(t,r,e){return q(t)?q(r)?q(e)?e>t?new RangeError(m('0oR7D',e)):r>t?new RangeError(m('0oR7E',r)):null:new TypeError(m('0oR2m',e)):new TypeError(m('0oR3X',r)):new TypeError(m('0oR2d',t));}O.exports=X
});var L=l(function(ue,E){
var v=require('@stdlib/math-base-special-factorial/dist');function Y(t,r,e,i){var n,u,a;for(i<e?(n=v(e)*v(r+e-i)/(v(r+e)*v(e-i)),a=0):(n=v(r)*v(i)/(v(i-e)*v(r+e)),a=i-e),u=t();u>n;)u-=n,n*=(r-a)*(i-a)/((a+1)*(e-i+1+a)),a+=1;return a}E.exports=Y
});var T=l(function(se,R){
var p=L();function Z(t,r,e,i){var n,u,a,o;return i>r/2?(a=r-i,2*e<=r?(n=e,u=r-e,o=p(t,n,u,a),e-o):(u=e,n=r-e,o=p(t,n,u,a),i-r+e+o)):(a=i,2*e<=r?(n=e,u=r-e,o=p(t,n,u,a),o):(n=r-e,u=e,o=p(t,n,u,a),i-o))}R.exports=Z
});var w=l(function(oe,I){
var g=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),x=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),V=require('@stdlib/assert-is-plain-object/dist'),P=require('@stdlib/assert-is-function/dist'),j=require('@stdlib/assert-has-own-property/dist'),A=require('@stdlib/utils-constant-function/dist'),_=require('@stdlib/utils-noop/dist'),c=require('@stdlib/random-base-mt19937/dist').factory,b=require('@stdlib/math-base-assert-is-nonnegative-integer/dist'),F=require('@stdlib/constants-float64-pinf/dist'),$=require('@stdlib/array-to-json/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist'),k=S(),G=T();function K(){var t,r,e,i,n,u,a;if(arguments.length===0)r=c();else if(arguments.length===1){if(t=arguments[0],!V(t))throw new TypeError(h('0oR2V',t));if(j(t,"prng")){if(!P(t.prng))throw new TypeError(h('0oR6u',"prng",t.prng));r=t.prng}else r=c(t)}else{if(n=arguments[0],u=arguments[1],a=arguments[2],i=k(n,u,a),i)throw i;if(arguments.length>3){if(t=arguments[3],!V(t))throw new TypeError(h('0oR2V',t));if(j(t,"prng")){if(!P(t.prng))throw new TypeError(h('0oR6u',"prng",t.prng));r=t.prng}else r=c(t)}else r=c()}return n===void 0?e=U:e=Q,g(e,"NAME","hypergeometric"),t&&t.prng?(g(e,"seed",null),g(e,"seedLength",null),x(e,"state",A(null),_),g(e,"stateLength",null),g(e,"byteLength",null),g(e,"toJSON",A(null)),g(e,"PRNG",r)):(f(e,"seed",o),f(e,"seedLength",N),x(e,"state",C,D),f(e,"stateLength",W),f(e,"byteLength",B),g(e,"toJSON",H),g(e,"PRNG",r),r=r.normalized),e;function o(){return r.seed}function N(){return r.seedLength}function W(){return r.stateLength}function B(){return r.byteLength}function C(){return r.state}function D(s){r.state=s}function H(){var s={};return s.type="PRNG",s.name=e.NAME,s.state=$(r.state),n===void 0?s.params=[]:s.params=[n,u,a],s}function Q(){return G(r,n,u,a)}function U(s,d,y){return s===F||d===F||!b(s)||!b(d)||!b(y)||y>s?NaN:G(r,s,d,y)}}I.exports=K
});var z=l(function(ge,J){
var ee=w(),re=ee();J.exports=re
});var te=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),M=z(),ne=w();te(M,"factory",ne);module.exports=M;
/** @license Apache-2.0 */
//# sourceMappingURL=index.js.map
;