UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 2.59 kB
// 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"./gamma.js";import m from"./../../math/base/assert/is-nan.js";import p from"./../../array/to-json.js";import l from"./../../assert/is-positive-number.js";var f=l.isPrimitive;function g(e,n){return f(e)?f(n)?null:new TypeError("invalid argument. `beta` must be a positive number. Value: `"+n+"`."):new TypeError("invalid argument. `alpha` must be a positive number. Value: `"+e+"`.")}var c=e,d=n,b=t,h=r,v=o,y=i,j=a,w=s,L=u.factory,N=m,E=p,O=g;function T(){var e,n,t,r,o,i,a;if(0===arguments.length)e=L();else if(1===arguments.length){if(!h(r=arguments[0]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+r+"`.");if(y(r,"prng")){if(!v(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");e=L({prng:r.prng})}else e=L(r)}else{if(a=O(n=arguments[0],t=arguments[1]))throw a;if(arguments.length>2){if(!h(r=arguments[2]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+r+"`.");if(y(r,"prng")){if(!v(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");e=L(n,t,{prng:r.prng})}else e=L(n,t,r)}else e=L(n,t)}return i=void 0===n?P:T,o=e.PRNG,c(i,"NAME","invgamma"),r&&r.prng?(c(i,"seed",null),c(i,"seedLength",null),b(i,"state",j(null),w),c(i,"stateLength",null),c(i,"byteLength",null),c(i,"toJSON",j(null))):(d(i,"seed",s),d(i,"seedLength",u),b(i,"state",l,f),d(i,"stateLength",m),d(i,"byteLength",p),c(i,"toJSON",g)),c(i,"PRNG",o),i;function s(){return o.seed}function u(){return o.seedLength}function m(){return o.stateLength}function p(){return o.byteLength}function l(){return o.state}function f(e){o.state=e}function g(){var e={type:"PRNG"};return e.name=i.NAME,e.state=E(o.state),e.params=void 0===n?[]:[n,t],e}function T(){return 1/e()}function P(n,t){return N(n)||N(t)||n<=0||t<=0?NaN:1/e(n,t)}}var P=T,V=P(),G=e,R=V,A=T;G(R,"factory",A);export default R; //# sourceMappingURL=invgamma.js.map