UNPKG

@stdlib/random-base-t

Version:

Student's t-distributed pseudorandom numbers.

8 lines (7 loc) 3.45 kB
"use strict";var q=function(u,i){return function(){return i||u((i={exports:{}}).exports,i),i.exports}};var h=q(function(Y,N){ var p=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),w=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),l=require('@stdlib/assert-has-own-property/dist'),b=require('@stdlib/assert-is-positive-number/dist').isPrimitive,O=require('@stdlib/assert-is-plain-object/dist'),y=require('@stdlib/assert-is-uint32array/dist'),E=require('@stdlib/assert-is-boolean/dist').isPrimitive,W=require('@stdlib/math-base-assert-is-nan/dist'),L=require('@stdlib/assert-is-function/dist'),T=require('@stdlib/utils-constant-function/dist'),k=require('@stdlib/utils-noop/dist'),c=require('@stdlib/random-base-chisquare/dist').factory,g=require('@stdlib/random-base-improved-ziggurat/dist').factory,m=require('@stdlib/blas-base-gcopy/dist'),d=require('@stdlib/array-uint32/dist'),S=require('@stdlib/object-assign/dist'),C=require('@stdlib/array-to-json/dist'),s=require('@stdlib/error-tools-fmtprodmsg/dist'),A=require('@stdlib/math-base-special-sqrt/dist');function D(){var u,i,a,o,e,r,f,n;if(f=!0,arguments.length===0)e={copy:!1},a=g(e);else if(arguments.length===1)if(O(arguments[0])){if(e=arguments[0],l(e,"copy")&&!E(e.copy))throw new TypeError(s('0p72o',"copy",e.copy));if(l(e,"prng")){if(!L(e.prng))throw new TypeError(s('0p76u',"prng",e.prng));a=g({prng:e.prng})}else{if(l(e,"state")&&!y(e.state))throw new TypeError(s('0p76z',"state",e.state));e=S({},e),e.copy===!1?f=!1:e.state&&(e.state=m(e.state.length,e.state,1,new d(e.state.length),1)),e.copy=!1,a=g(e)}}else{if(n=arguments[0],!b(n))throw new TypeError(s('0p77a',n));e={copy:!1},a=g(e)}else{if(n=arguments[0],!b(n))throw new TypeError(s('0p771',n));if(e=arguments[1],!O(e))throw new TypeError(s('0p72V',e));if(l(e,"copy")&&!E(e.copy))throw new TypeError(s('0p72o',"copy",e.copy));if(l(e,"prng")){if(!L(e.prng))throw new TypeError(s('0p76u',"prng",e.prng));a=g({prng:e.prng})}else{if(l(e,"state")&&!y(e.state))throw new TypeError(s('0p76z',"state",e.state));e=S({},e),e.copy===!1?f=!1:e.state&&(e.state=m(e.state.length,e.state,1,new d(e.state.length),1)),e.copy=!1,a=g(e)}}return e&&e.prng?n===void 0?u=c({prng:e.prng}):u=c(n,{prng:e.prng}):(e.state?i=e.state:(i=a.state,a.state=i),n===void 0?u=c({state:i,copy:!1}):u=c(n,{state:i,copy:!1})),n===void 0?r=B:r=z,o=a.PRNG,p(r,"NAME","t"),e&&e.prng?(p(r,"seed",null),p(r,"seedLength",null),w(r,"state",T(null),k),p(r,"stateLength",null),p(r,"byteLength",null),p(r,"toJSON",T(null))):(v(r,"seed",U),v(r,"seedLength",j),w(r,"state",x,J),v(r,"stateLength",G),v(r,"byteLength",V),p(r,"toJSON",M)),p(r,"PRNG",o),r;function U(){return o.seed}function j(){return o.seedLength}function G(){return o.stateLength}function V(){return o.byteLength}function x(){return o.state}function J(t){if(!y(t))throw new TypeError(s('0p770',t));f&&(t=m(t.length,t,1,new d(t.length),1)),o.state=t}function M(){var t={};return t.type="PRNG",t.name=r.NAME,t.state=C(o.state),n===void 0?t.params=[]:t.params=[n],t}function z(){return a()/A(u()/n)}function B(t){return W(t)||t<=0?NaN:a()/A(u(t)/t)}}N.exports=D });var R=q(function(Z,P){ var H=h(),I=H();P.exports=I });var K=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),F=R(),Q=h();K(F,"factory",Q);module.exports=F; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map