UNPKG

@stdlib/random-base-chisquare

Version:

Chi-square distributed pseudorandom numbers.

8 lines (7 loc) 2.29 kB
"use strict";var c=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var p=c(function(B,h){ var s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),o=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),v=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),T=require('@stdlib/assert-is-positive-number/dist').isPrimitive,l=require('@stdlib/assert-is-plain-object/dist'),f=require('@stdlib/assert-is-function/dist'),m=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/utils-constant-function/dist'),j=require('@stdlib/utils-noop/dist'),x=require('@stdlib/math-base-assert-is-nan/dist'),u=require('@stdlib/random-base-gamma/dist').factory,F=require('@stdlib/array-to-json/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function G(){var a,t,r,e,i;if(arguments.length===0)a=u();else if(arguments.length===1&&l(arguments[0]))if(r=arguments[0],m(r,"prng")){if(!f(r.prng))throw new TypeError(g('0o76u',"prng",r.prng));a=u({prng:r.prng})}else a=u(r);else{if(i=arguments[0],!T(i))throw new TypeError(g('0o771',i));if(arguments.length>1){if(r=arguments[1],!l(r))throw new TypeError(g('0o72V',r));if(m(r,"prng")){if(!f(r.prng))throw new TypeError(g('0o76u',"prng",r.prng));a=u(i/2,.5,{prng:r.prng})}else a=u(i/2,.5,r)}else a=u(i/2,.5)}return i===void 0?e=A:e=P,t=a.PRNG,s(e,"NAME","chisquare"),r&&r.prng?(s(e,"seed",null),s(e,"seedLength",null),v(e,"state",d(null),j),s(e,"stateLength",null),s(e,"byteLength",null),s(e,"toJSON",d(null))):(o(e,"seed",L),o(e,"seedLength",O),v(e,"state",w,R),o(e,"stateLength",N),o(e,"byteLength",S),s(e,"toJSON",E)),s(e,"PRNG",t),e;function L(){return t.seed}function O(){return t.seedLength}function N(){return t.stateLength}function S(){return t.byteLength}function w(){return t.state}function R(n){t.state=n}function E(){var n={};return n.type="PRNG",n.name=e.NAME,n.state=F(t.state),i===void 0?n.params=[]:n.params=[i],n}function P(){return a()}function A(n){return x(n)||n<=0?NaN:a(n/2,.5)}}h.exports=G });var y=c(function(C,q){ var J=p(),M=J();q.exports=M });var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),b=y(),z=p();V(b,"factory",z);module.exports=b; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map