Skip to content

Instantly share code, notes, and snippets.

@kos59125
Created August 11, 2015 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kos59125/90b08ea47cfccccc64a6 to your computer and use it in GitHub Desktop.
Save kos59125/90b08ea47cfccccc64a6 to your computer and use it in GitHub Desktop.
Generates a random number on Poisson distribution
#!/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