/* Prob.js 1.0.6 (c) 2016 Google, Inc. License: Apache 2.0 */ !function(){"use strict";function assert(condition,message){if(!condition){if(message=message||"Assertion failed","undefined"!=typeof Error)throw new Error(message);throw message}}function binarySearch(arr,needle){for(var high=arr.length,low=-1;high-low>1;){var mid=Math.floor(low+(high-low)/2);arr[mid]=1||0===w);return w=Math.sqrt(-2*Math.log(w)/w),y1=x1*w,y2=x2*w,y1*sd+mean};return f.Min=Number.NEGATIVE_INFINITY,f.Max=Number.POSITIVE_INFINITY,f.Mean=mean,f.Variance=sd*sd,f.Type=Prob.Type.CONTINUOUS,f},Prob.exponential=function(lambda){lambda="undefined"!=typeof lambda?lambda:1;var mean=1/lambda,f=function(rand){return-1*Math.log(rand01(rand||mt))*mean};return f.Min=0,f.Max=Number.POSITIVE_INFINITY,f.Mean=mean,f.Variance=Math.pow(lambda,-2),f.Type=Prob.Type.CONTINUOUS,f},Prob.lognormal=function(mu,sigma){mu="undefined"!=typeof mu?mu:0,sigma="undefined"!=typeof sigma?sigma:1;var nf=Prob.normal(mu,sigma),f=function(rand){return Math.exp(nf(rand))};return f.Min=0,f.Max=Number.POSITIVE_INFINITY,f.Mean=Math.exp(mu+sigma*sigma/2),f.Variance=(Math.exp(sigma*sigma)-1)*Math.exp(2*mu+sigma*sigma),f.Type=Prob.Type.CONTINUOUS,f},Prob.poisson=function(lambda){lambda="undefined"!=typeof lambda?lambda:1;var L=Math.exp(-lambda),f=function(rand){for(var k=0,p=1;;){if(p*=rand01(rand||mt),L>=p)break;k++}return k};return f.Min=0,f.Max=Number.POSITIVE_INFINITY,f.Mean=lambda,f.Variance=lambda,f.Type=Prob.Type.DISCRETE,f},Prob.zipf=function(s,N){s="undefined"!=typeof s?s:1,N="undefined"!=typeof N?N:100,assert(N>=1,"N must be >= 1");for(var sum=0,i=1;N>=i;i++)sum+=1/Math.pow(i,s);var cdf=[0],sumProb=0;for(i=1;N>=i;i++)sumProb+=1/(sum*Math.pow(i,s)),cdf[i]=sumProb;var f=function(rand){return binarySearch(cdf,rand01(rand||mt))};return f.Min=1,f.Max=N+1,f.Mean=null,f.Variance=null,f.Type=Prob.Type.DISCRETE,f},"function"==typeof define&&define.amd&&define("prob",[],function(){return Prob})}(); //# sourceMappingURL=prob-min.js.map