All problems
Exponential Sample Seeded
Problem
Draw an exponential random value with the given mean using inverse transform sampling and a deterministic seeded linear congruential generator.
Generate one uniform value in the open interval from 0 to 1 and return minus the mean times the natural log of one minus that value. A mean of zero always returns zero.
Hint
The inverse CDF of the exponential distribution is minus mean times log of one minus u.
Test cases
case 1
in: [1,42]
expected: 0.8730099789912349
case 2
in: [5,7]
expected: 4.5447891162704845
case 3
in: [1,0]
expected: 0.00000574907077897709
case 4
in: [2.5,123]
expected: 0.5745340035424549
Starter codePython
def exponential_sample_seeded(mean, seed):
# Your code here
pass4 test cases · run your code against them in the editor