@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 2.74 kB
JavaScript
// 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 r from"./../../utils/define-nonenumerable-read-write-accessor.js";import t from"./../../assert/is-plain-object.js";import o from"./../../assert/is-function.js";import i from"./../../assert/has-own-property.js";import s from"./../../utils/constant-function.js";import a from"./../../utils/noop.js";import u from"./improved-ziggurat.js";import m from"./../../math/base/assert/is-nan.js";import p from"./../../array/to-json.js";import f from"./../../assert/is-number.js";import l from"./../../assert/is-positive-number.js";import g from"./../../assert/is-nan.js";var d=f.isPrimitive,c=l.isPrimitive,b=g;function h(e,n){return!d(e)||b(e)?new TypeError("invalid argument. `mu` must be a number primitive and not `NaN`. Value: `"+e+"`."):c(n)?null:new TypeError("invalid argument. `sigma` must be a positive number. Value: `"+n+"`.")}function v(e,n,r){return n+r*e()}var j=e,y=n,w=r,N=t,L=o,E=i,O=s,T=a,P=u.factory,V=m,G=p,R=h,A=v;function J(){var e,n,r,t,o,i,s;if(0===arguments.length)n=P();else if(1===arguments.length){if(!N(r=arguments[0]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+r+"`.");if(E(r,"prng")){if(!L(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");n=P({prng:r.prng})}else n=P(r)}else{if(i=R(s=arguments[0],e=arguments[1]))throw i;if(arguments.length>2){if(!N(r=arguments[2]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+r+"`.");if(E(r,"prng")){if(!L(r.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+r.prng+"`.");n=P({prng:r.prng})}else n=P(r)}else n=P()}return o=void 0===s?c:d,t=n.PRNG,j(o,"NAME","normal"),r&&r.prng?(j(o,"seed",null),j(o,"seedLength",null),w(o,"state",O(null),T),j(o,"stateLength",null),j(o,"byteLength",null),j(o,"toJSON",O(null))):(y(o,"seed",a),y(o,"seedLength",u),w(o,"state",f,l),y(o,"stateLength",m),y(o,"byteLength",p),j(o,"toJSON",g)),j(o,"PRNG",t),o;function a(){return t.seed}function u(){return t.seedLength}function m(){return t.stateLength}function p(){return t.byteLength}function f(){return t.state}function l(e){t.state=e}function g(){var n={type:"PRNG"};return n.name=o.NAME,n.state=G(t.state),n.params=void 0===s?[]:[s,e],n}function d(){return A(n,s,e)}function c(e,r){return V(e)||V(r)||r<=0?NaN:A(n,e,r)}}var M=J,S=M(),x=e,z=S,k=J;x(z,"factory",k);export default z;
//# sourceMappingURL=normal.js.map