multithreading - Chance of the same worker getting X tasks out of Y total (in a pool of Z workers) -


this probability theory question, rusty can't seem wrap head around start.

i have pool of z workers. each worker has limit, x, how many tasks must perform before recycled. each new task grabbed worker @ random (1/z chance of worker grabbing it).

after y tasks has been given, odds 1 worker has reached x threshold?

i wish calculate because need perform "cleanup" periodically, , instead of picking number @ random, related number of workers , task limit (which may tweak @ later point), i'll clean-up once there's 25-30-35% chance 1 worker done for.

consider worker w. each time task enters system, there 1/z chance w grabs task. total of y tasks enter system.

y tasks, each grabbed probability 1/z: number of grabbed tasks, g_w, random variable binomial distribution.

the probability worker w has reached x threshold after y tasks p(g_w >= x).

you can approximate distribution , probability using normal distribution mean y/z , variance y(z-1)/z^2. can use function evaluates normal distribution's cumulative distribution, available in every programming language.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -