Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21920
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Distribution |
| Date | 2012-03-20 10:15 +0100 |
| Organization | None |
| References | <33044d51-c481-4796-a722-406f412cf994@x7g2000pbi.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.823.1332234906.3037.python-list@python.org> (permalink) |
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)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Distribution "prince.pangeni" <prince.ram85@gmail.com> - 2012-03-19 21:31 -0700
Re: Distribution Peter Otten <__peter__@web.de> - 2012-03-20 10:15 +0100
Re: Distribution Ben Finney <ben+python@benfinney.id.au> - 2012-03-20 22:21 +1100
Re: Distribution Robert Kern <robert.kern@gmail.com> - 2012-03-20 12:00 +0000
Re: Distribution Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-20 11:29 -0400
Re: Distribution Laurent Claessens <moky.math@gmail.com> - 2012-03-20 18:00 +0100
Re: Distribution Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-20 13:47 -0400
Re: Distribution Robert Kern <robert.kern@gmail.com> - 2012-03-20 12:52 +0000
Re: Distribution duncan smith <buzzard@urubu.freeserve.co.uk> - 2012-03-20 20:19 +0000
csiph-web