function benchmark_semaphore timeit(@() inner(),1) end function t=inner() t = SemaphoreHost(2); for i=1:1e4 u = t.wait(); u.post(); end end]]>

Here’s the code I used:

n = 125000; % number of coupons p = 0.95; % desired probability t = floor(n*log(n)+(-log(-log(p)))*n); % predicted number required for P(T<t)=p N = 1000; % number of MC % Monte Carlo simulation x = false(1,N); for i = 1:N v = false(1,n); v(randi(n,t,1)) = true; x(i) = all(v); end mean(x+0) % should be close to p]]>

https://store.arduino.cc/arduino-engineering-kit

Good luck and please let us know if you have questions.

Dan

]]>