UNPKG

@stdlib/random-iter-chisquare

Version:

Create an iterator for generating pseudorandom numbers drawn from a chi-square distribution.

6 lines (5 loc) 2.01 kB
"use strict";var w=function(a,n){return function(){return n||a((n={exports:{}}).exports,n),n.exports}};var m=w(function(I,q){ var i=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),u=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),l=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),O=require('@stdlib/utils-constant-function/dist'),x=require('@stdlib/utils-noop/dist'),A=require('@stdlib/object-assign/dist'),E=require('@stdlib/assert-is-positive-number/dist').isPrimitive,F=require('@stdlib/assert-is-plain-object/dist'),T=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,V=require('@stdlib/assert-has-own-property/dist'),f=require('@stdlib/constants-float64-max/dist'),c=require('@stdlib/random-base-chisquare/dist').factory,d=require('@stdlib/symbol-iterator/dist'),v=require('@stdlib/error-tools-fmtprodmsg/dist');function h(a,n){var t,e,r,g,s;if(!E(a))throw new TypeError(v('0pV71',a));if(arguments.length>1){if(!F(n))throw new TypeError(v('0pV2V',n));if(t=A({},n),V(t,"iter")){if(!T(t.iter))throw new TypeError(v('0pV2t',"iter",t.iter))}else t.iter=f;r=c(a,t),t.prng===void 0&&t.copy!==!1&&(t.state=r.state)}else r=c(a),t={iter:f,state:r.state};return s=0,e={},i(e,"next",p),i(e,"return",L),t&&t.prng?(i(e,"seed",null),i(e,"seedLength",null),l(e,"state",O(null),x),i(e,"stateLength",null),i(e,"byteLength",null)):(u(e,"seed",P),u(e,"seedLength",R),l(e,"state",G,S),u(e,"stateLength",b),u(e,"byteLength",N)),i(e,"PRNG",r.PRNG),d&&i(e,d,y),e;function p(){return s+=1,g||s>t.iter?{done:!0}:{value:r(),done:!1}}function L(o){return g=!0,arguments.length?{value:o,done:!0}:{done:!0}}function y(){return h(a,t)}function P(){return r.PRNG.seed}function R(){return r.PRNG.seedLength}function b(){return r.PRNG.stateLength}function N(){return r.PRNG.byteLength}function G(){return r.PRNG.state}function S(o){r.PRNG.state=o}}q.exports=h });var j=m();module.exports=j; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map