Created
August 11, 2015 15:25
-
-
Save kos59125/90b08ea47cfccccc64a6 to your computer and use it in GitHub Desktop.
Generates a random number on Poisson distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LAMBDA=$1 | |
X=0 | |
V=0 | |
while [ `echo "$V <= $LAMBDA" | bc` -eq 1 ] | |
do | |
W=`echo "$V - l(1 - $RANDOM / 32768)" | bc -l` | |
V=$W | |
X=`expr $X + 1` | |
done | |
echo $X |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment