UNPKG

@stdlib/esm

Version:

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

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