prince.pangeni wrote: > Hi all, > I am doing a simulation project using Python. In my project, I want > to use some short of distribution to generate requests to a server. > The request should have two distributions. One for request arrival > rate (should be poisson) and another for request mix (i.e. out of the > total requests defined in request arrival rate, how many requests are > of which type). > Example: Suppose the request rate is - 90 req/sec (generated using > poisson distribution) at time t and we have 3 types of requests (i.e. > r1, r2, r2). The request mix distribution output should be similar to: > {r1 : 50 , r2 : 30 , r3 : 10} (i.e. out of 90 requests - 50 are of r1 > type, 30 are of r2 type and 10 are of r3 type). > As I an new to python distribution module, I am not getting how to > code this situation. Please help me out for the same.
You don't say what distribution module you're talking of, and I guess I'm not the only one who'd need to know that detail. However, with sufficient resolution and duration the naive approach sketched below might be good enough. # untested DURATION = 3600 # run for one hour RATE = 90 # requests/sec RESOLUTION = 1000 # one msec requests = ([r1]*50 + [r2]*30 + [r3]*10) time_slots = [0]*(RESOLUTION*DURATION) times = range(RESOLUTION*DURATION) for _ in range(DURATION*RATE): time_slots[random.choice(times)] += 1 for time, count in enumerate(time_slots): for _ in range(count): issue_request_at(random.choice(requests), time) -- http://mail.python.org/mailman/listinfo/python-list