@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 3.37 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import e from"./../../utils/define-nonenumerable-read-only-property.js";import n from"./../../utils/define-nonenumerable-read-only-accessor.js";import t from"./../../utils/define-nonenumerable-read-write-accessor.js";import r from"./../../assert/is-plain-object.js";import o from"./../../assert/is-function.js";import i from"./../../assert/has-own-property.js";import a from"./../../utils/constant-function.js";import s from"./../../utils/noop.js";import u from"./mt19937.js";import m from"./../../math/base/assert/is-nonnegative-integer.js";import l from"./../../constants/math/float64-pinf.js";import p from"./../../array/to-json.js";import f from"./../../assert/is-nonnegative-integer.js";import g from"./../../math/base/special/factorial.js";var c=f.isPrimitive;function d(e,n,t){return c(e)?c(n)?c(t)?t>e?new RangeError("invalid argument. `n` must be less than or equal to `N`. Value: `"+t+"`."):n>e?new RangeError("invalid argument. `K` must be less than or equal to `N`. Value: `"+n+"`."):null:new TypeError("invalid argument. `n` must be a nonnegative integer. Value: `"+t+"`."):new TypeError("invalid argument. `K` must be a nonnegative integer. Value: `"+n+"`."):new TypeError("invalid argument. `N` must be a nonnegative integer. Value: `"+e+"`.")}var v=g;function h(e,n,t,r){var o,i,a;for(r<t?(o=v(t)*v(n+t-r)/(v(n+t)*v(t-r)),a=0):(o=v(n)*v(r)/(v(r-t)*v(n+t)),a=r-t),i=e();i>o;)i-=o,o*=(n-a)*(r-a)/((a+1)*(t-r+1+a)),a+=1;return a}var b=h;function y(e,n,t,r){var o;return r>n/2?(o=n-r,2*t<=n?t-b(e,t,n-t,o):r-n+t+b(e,n-t,t,o)):(o=r,2*t<=n?b(e,t,n-t,o):r-b(e,n-t,t,o))}var j=e,w=n,N=t,E=r,L=o,T=i,V=a,O=s,R=u.factory,P=m,G=l,q=p,A=d,J=y;function K(){var e,n,t,r,o,i,a;if(0===arguments.length)n=R();else if(1===arguments.length){if(!E(e=arguments[0]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+e+"`.");if(T(e,"prng")){if(!L(e.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+e.prng+"`.");n=e.prng}else n=R(e)}else{if(r=A(o=arguments[0],i=arguments[1],a=arguments[2]))throw r;if(arguments.length>3){if(!E(e=arguments[3]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+e+"`.");if(T(e,"prng")){if(!L(e.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+e.prng+"`.");n=e.prng}else n=R(e)}else n=R()}return j(t=void 0===o?d:c,"NAME","hypergeometric"),e&&e.prng?(j(t,"seed",null),j(t,"seedLength",null),N(t,"state",V(null),O),j(t,"stateLength",null),j(t,"byteLength",null),j(t,"toJSON",V(null)),j(t,"PRNG",n)):(w(t,"seed",s),w(t,"seedLength",u),N(t,"state",p,f),w(t,"stateLength",m),w(t,"byteLength",l),j(t,"toJSON",g),j(t,"PRNG",n),n=n.normalized),t;function s(){return n.seed}function u(){return n.seedLength}function m(){return n.stateLength}function l(){return n.byteLength}function p(){return n.state}function f(e){n.state=e}function g(){var e={type:"PRNG"};return e.name=t.NAME,e.state=q(n.state),e.params=void 0===o?[]:[o,i,a],e}function c(){return J(n,o,i,a)}function d(e,t,r){return e===G||t===G||!P(e)||!P(t)||!P(r)||r>e?NaN:J(n,e,t,r)}}var M=K,S=M(),x=e,z=S,k=K;x(z,"factory",k);export default z;
//# sourceMappingURL=hypergeometric.js.map