UNPKG

@stdlib/esm

Version:

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

3 lines 4.74 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import t from"./../../utils/define-nonenumerable-read-only-property.js";import e from"./../../utils/define-nonenumerable-read-only-accessor.js";import r from"./../../utils/define-nonenumerable-read-write-accessor.js";import n from"./../../assert/is-plain-object.js";import o from"./../../assert/is-boolean.js";import i from"./../../assert/is-function.js";import a from"./../../assert/has-own-property.js";import s from"./../../utils/constant-function.js";import p from"./../../utils/noop.js";import u from"./improved-ziggurat.js";import m from"./mt19937.js";import l from"./../../math/base/assert/is-nan.js";import f from"./../../blas/base/gcopy.js";import c from"./../../array/uint32.js";import y from"./../../assert/is-uint32array.js";import g from"./../../utils/copy.js";import b from"./../../array/to-json.js";import h from"./../../assert/is-positive-number.js";import d from"./../../math/base/special/pow.js";import v from"./../../math/base/special/ln.js";import w from"./../../math/base/special/exp.js";var j=h.isPrimitive;function E(t,e){return j(t)?j(e)?null:new TypeError("invalid argument. `beta` must be a positive number. Value: `"+e+"`."):new TypeError("invalid argument. `alpha` must be a positive number. Value: `"+t+"`.")}var T=d,O=v;function L(t,e,r){var n,o,i,a,s,p,u,m;for(s=T((i=r-1)+i,.5),n=!0;!0===n;)(u=.5*(1+(a=e())/s))>=0&&u<=1&&((p=t())<=(m=1-(o=T(a,4))/(m=8*r-12))?n=!1:p<(m+=.5*T(o/(8*r-8),2))&&(m=i*O(4*u*(1-u)),(m+=a*a/2)>=O(p)&&(n=!1)));return u}var N=d,A=v;function P(t,e,r,n){var o,i,a,s,p,u,m,l,f,c,y;for(m=(u=(s=r-1)+(p=n-1))*A(u),a=s/u,o=.5/N(u,.5),i=!0;!0===i;)(c=a+(l=e())*o)>=0&&c<=1&&(f=t(),y=s*A(c/s),y+=p*A((1-c)/p),(y+=m+.5*l*l)>=A(f)&&(i=!1));return c}var V=w,G=d,M=v;function R(t,e,r){for(var n,o,i,a,s,p;;)if(a=t(),s=t(),(i=(p=G(a,1/e))+G(s,1/r))<=1)return i>0?p/i:((n=M(a)/e)>(o=M(s)/r)?(o-=n,n=0):(n-=o,o=0),V(n-M(V(n)+V(o))))}var U=L,x=P,z=R;function J(t,e,r,n){return r===n&&r>1.5?U(t,e,r):r>1&&n>1?x(t,e,r,n):z(t,r,n)}var S=t,k=e,q=r,B=n,C=o.isPrimitive,D=i,F=a,H=s,I=p,K=u.factory,Q=m.factory,W=l,X=f,Y=c,Z=y,$=g,_=b,tt=E,et=J;function rt(){var t,e,r,n,o,i,a,s,p;if(s=!0,0===arguments.length)i=Q(o={copy:!1});else if(1===arguments.length){if(!B(o=arguments[0]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+o+"`.");if(F(o,"copy")&&!C(o.copy))throw new TypeError("invalid option. `copy` option must be a boolean. Option: `"+o.copy+"`.");if(F(o,"prng")){if(!D(o.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+o.prng+"`.");i=o.prng}else{if(F(o,"state")&&!Z(o.state))throw new TypeError("invalid option. `state` option must be a Uint32Array. Option: `"+o.state+"`.");!1===(o=$(o,1)).copy?s=!1:o.state&&(o.state=X(o.state.length,o.state,1,new Y(o.state.length),1)),o.copy=!1,i=Q(o)}}else{if(p=tt(r=arguments[0],n=arguments[1]))throw p;if(arguments.length>2){if(!B(o=arguments[2]))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+o+"`.");if(F(o,"copy")&&!C(o.copy))throw new TypeError("invalid option. `copy` option must be a boolean. Option: `"+o.copy+"`.");if(F(o,"prng")){if(!D(o.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+o.prng+"`.");i=o.prng}else{if(F(o,"state")&&!Z(o.state))throw new TypeError("invalid option. `state` option must be a Uint32Array. Option: `"+o.state+"`.");!1===(o=$(o,1)).copy?s=!1:o.state&&(o.state=X(o.state.length,o.state,1,new Y(o.state.length),1)),o.copy=!1,i=Q(o)}}else i=Q(o={copy:!1})}return o&&o.prng?e=K({prng:o.prng}):(o.state?t=o.state:(t=i.state,i.state=t),e=K({state:t,copy:!1})),S(a=void 0===r?h:b,"NAME","beta"),o&&o.prng?(S(a,"seed",null),S(a,"seedLength",null),q(a,"state",H(null),I),S(a,"stateLength",null),S(a,"byteLength",null),S(a,"toJSON",H(null)),S(a,"PRNG",i)):(k(a,"seed",u),k(a,"seedLength",m),q(a,"state",c,y),k(a,"stateLength",l),k(a,"byteLength",f),S(a,"toJSON",g),S(a,"PRNG",i),i=i.normalized),a;function u(){return i.seed}function m(){return i.seedLength}function l(){return i.stateLength}function f(){return i.byteLength}function c(){return i.state}function y(t){if(!Z(t))throw new TypeError("invalid argument. Must provide a Uint32Array. Value: `"+t+"`.");s&&(t=X(t.length,t,1,new Y(t.length),1)),i.state=t}function g(){var t={type:"PRNG"};return t.name=a.NAME,t.state=_(i.state),t.params=void 0===r?[]:[r,n],t}function b(){return et(i,e,r,n)}function h(t,r){return W(t)||W(r)||t<=0||r<=0?NaN:et(i,e,t,r)}}var nt=rt,ot=nt(),it=t,at=ot,st=rt;it(at,"factory",st);export default at; //# sourceMappingURL=beta.js.map