UNPKG

@stdlib/esm

Version:

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

3 lines 2.47 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 t from"./../../utils/define-nonenumerable-read-only-accessor.js";import r from"./../../utils/define-nonenumerable-read-write-accessor.js";import n from"./../../assert/is-positive-number.js";import o from"./../../assert/is-plain-object.js";import i from"./../../assert/is-function.js";import s from"./../../assert/has-own-property.js";import a from"./../../utils/constant-function.js";import u from"./../../utils/noop.js";import m from"./mt19937.js";import p from"./../../math/base/assert/is-nan.js";import f from"./../../array/to-json.js";import l from"./../../math/base/special/sqrt.js";import g from"./../../math/base/special/ln.js";var c=l,d=g;function h(e,t){return t*c(-2*d(e()))}var b=e,j=t,y=r,v=n.isPrimitive,w=o,L=i,N=s,E=a,O=u,P=m.factory,T=p,G=f,R=h;function A(){var e,t,r,n;if(0===arguments.length)r=P();else if(1===arguments.length&&w(arguments[0]))if(N(t=arguments[0],"prng")){if(!L(t.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+t.prng+"`.");r=t.prng}else r=P(t);else{if(!v(e=arguments[0]))throw new TypeError("invalid argument. First argument must be a positive number. Value: `"+e+"`.");if(arguments.length>1){if(!w(t=arguments[1]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+t+"`.");if(N(t,"prng")){if(!L(t.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+t.prng+"`.");r=t.prng}else r=P(t)}else r=P()}return b(n=void 0===e?l:f,"NAME","rayleigh"),t&&t.prng?(b(n,"seed",null),b(n,"seedLength",null),y(n,"state",E(null),O),b(n,"stateLength",null),b(n,"byteLength",null),b(n,"toJSON",E(null)),b(n,"PRNG",r)):(j(n,"seed",o),j(n,"seedLength",i),y(n,"state",u,m),j(n,"stateLength",s),j(n,"byteLength",a),b(n,"toJSON",p),b(n,"PRNG",r),r=r.normalized),n;function o(){return r.seed}function i(){return r.seedLength}function s(){return r.stateLength}function a(){return r.byteLength}function u(){return r.state}function m(e){r.state=e}function p(){var t={type:"PRNG"};return t.name=n.NAME,t.state=G(r.state),t.params=void 0===e?[]:[e],t}function f(){return R(r,e)}function l(e){return T(e)||e<=0?NaN:R(r,e)}}var J=A,M=J(),S=e,V=M,q=A;S(V,"factory",q);export default V; //# sourceMappingURL=rayleigh.js.map