@stdlib/random-base-bernoulli
Version:
Bernoulli distributed pseudorandom numbers.
8 lines (7 loc) • 2.27 kB
JavaScript
;var l=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var g=l(function(W,m){
var a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),u=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),p=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),f=require('@stdlib/assert-is-plain-object/dist'),A=require('@stdlib/assert-is-probability/dist').isPrimitive,v=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/utils-constant-function/dist'),T=require('@stdlib/utils-noop/dist'),s=require('@stdlib/random-base-mt19937/dist').factory,j=require('@stdlib/math-base-assert-is-nan/dist'),x=require('@stdlib/array-to-json/dist'),o=require('@stdlib/error-tools-fmtprodmsg/dist');function F(){var t,e,r,i;if(arguments.length===0)e=s();else if(arguments.length===1&&f(arguments[0]))if(t=arguments[0],c(t,"prng")){if(!v(t.prng))throw new TypeError(o('0nt6u',"prng",t.prng));e=t.prng}else e=s(t);else{if(i=arguments[0],!A(i))throw new TypeError(o('0nt6y',i));if(arguments.length>1){if(t=arguments[1],!f(t))throw new TypeError(o('0nt2V',t));if(c(t,"prng")){if(!v(t.prng))throw new TypeError(o('0nt6u',"prng",t.prng));e=t.prng}else e=s(t)}else e=s()}return i===void 0?r=P:r=E,a(r,"NAME","bernoulli"),t&&t.prng?(a(r,"seed",null),a(r,"seedLength",null),p(r,"state",d(null),T),a(r,"stateLength",null),a(r,"byteLength",null),a(r,"toJSON",d(null)),a(r,"PRNG",e)):(u(r,"seed",q),u(r,"seedLength",L),p(r,"state",S,w),u(r,"stateLength",O),u(r,"byteLength",N),a(r,"toJSON",R),a(r,"PRNG",e),e=e.normalized),r;function q(){return e.seed}function L(){return e.seedLength}function O(){return e.stateLength}function N(){return e.byteLength}function S(){return e.state}function w(n){e.state=n}function R(){var n={};return n.type="PRNG",n.name=r.NAME,n.state=x(e.state),i===void 0?n.params=[]:n.params=[i],n}function E(){return e()<=i?1:0}function P(n){return j(n)||n<0||n>1?NaN:e()<=n?1:0}}m.exports=F
});var b=l(function(k,y){
var G=g(),J=G();y.exports=J
});var z=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),h=b(),M=g();z(h,"factory",M);module.exports=h;
/** @license Apache-2.0 */
//# sourceMappingURL=index.js.map