Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21946
| From | duncan smith <buzzard@urubu.freeserve.co.uk> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Distribution |
| References | <33044d51-c481-4796-a722-406f412cf994@x7g2000pbi.googlegroups.com> |
| Message-ID | <fD5ar.4711$K92.1917@newsfe10.ams2> (permalink) |
| Organization | http://www.NewsDemon.com |
| Date | 2012-03-20 20:19 +0000 |
On 20/03/12 04:31, 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.
>
> Thanks in advance
>
> Prince
Robert has given you a very good answer. The easiest way is to generate
interarrival times using an exponential distribution, then for each
event select the type from a categorical probability mass function.
Perhaps the easiest and most efficient approach for the latter using
your 'mix distribution' above is to create a list containing 5 instances
of r1, 3 of r2 and 1 of r3. Then select the type by generating a random
index into the list. It is not an ideal solution generally, but good
when the parameters do not change and the required list is small.
Duncan
Back to comp.lang.python | Previous | Next — Previous 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