UNPKG

@stdlib/random-base-levy

Version:

Lévy distributed pseudorandom numbers.

12 lines (11 loc) 2.76 kB
"use strict";var o=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var d=o(function(ee,c){ var Q=require('@stdlib/assert-is-number/dist').isPrimitive,W=require('@stdlib/assert-is-positive-number/dist').isPrimitive,m=require('@stdlib/error-tools-fmtprodmsg/dist'),k=require('@stdlib/assert-is-nan/dist');function B(r,e){return !Q(r)||k(r)?new TypeError(m('0ob6v',r)):W(e)?null:new TypeError(m('0ob72',e));}c.exports=B });var q=o(function(re,y){ var C=require('@stdlib/stats-base-dists-normal-quantile/dist');function D(r,e,t){var i=C(1-r()/2,0,1);return e+t/(i*i)}y.exports=D });var f=o(function(te,E){ var a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),h=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),b=require('@stdlib/assert-is-plain-object/dist'),N=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-has-own-property/dist'),O=require('@stdlib/utils-constant-function/dist'),H=require('@stdlib/utils-noop/dist'),l=require('@stdlib/random-base-mt19937/dist').factory,L=require('@stdlib/math-base-assert-is-nan/dist'),I=require('@stdlib/array-to-json/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),K=d(),S=q();function U(){var r,e,t,i,u,s;if(arguments.length===0)e=l();else if(arguments.length===1){if(r=arguments[0],!b(r))throw new TypeError(g('0ob2V',r));if(w(r,"prng")){if(!N(r.prng))throw new TypeError(g('0ob6u',"prng",r.prng));e=r.prng}else e=l(r)}else{if(u=arguments[0],s=arguments[1],i=K(u,s),i)throw i;if(arguments.length>2){if(r=arguments[2],!b(r))throw new TypeError(g('0ob2V',r));if(w(r,"prng")){if(!N(r.prng))throw new TypeError(g('0ob6u',"prng",r.prng));e=r.prng}else e=l(r)}else e=l()}return u===void 0?t=M:t=J,a(t,"NAME","levy"),r&&r.prng?(a(t,"seed",null),a(t,"seedLength",null),h(t,"state",O(null),H),a(t,"stateLength",null),a(t,"byteLength",null),a(t,"toJSON",O(null)),a(t,"PRNG",e)):(v(t,"seed",x),v(t,"seedLength",j),h(t,"state",z,F),v(t,"stateLength",A),v(t,"byteLength",V),a(t,"toJSON",G),a(t,"PRNG",e),e=e.normalized),t;function x(){return e.seed}function j(){return e.seedLength}function A(){return e.stateLength}function V(){return e.byteLength}function z(){return e.state}function F(n){e.state=n}function G(){var n={};return n.type="PRNG",n.name=t.NAME,n.state=I(e.state),u===void 0?n.params=[]:n.params=[u,s],n}function J(){return S(e,u,s)}function M(n,p){return L(n)||L(p)||p<=0?NaN:S(e,n,p)}}E.exports=U });var R=o(function(ne,P){ var X=f(),Y=X();P.exports=Y });var Z=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),T=R(),_=f();Z(T,"factory",_);module.exports=T; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map