nomos-specs/mixnet/poisson.py

14 lines
475 B
Python
Raw Normal View History

2024-01-23 01:29:14 +00:00
import numpy
def poisson_interval_sec(rate_per_min: int) -> float:
# If events occur in a Poisson distribution with rate_per_min,
# the interval between events follows the exponential distribution
# with the rate_per_min (i.e. with the scale 1/rate_per_min).
interval_min = numpy.random.exponential(scale=1 / rate_per_min, size=1)[0]
return interval_min * 60
def poisson_mean_interval_sec(rate_per_min: int) -> float:
return 1 / rate_per_min * 60