Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21920

Re: Distribution

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'python.': 0.04; 'situation.': 0.04; 'suppose': 0.05; 'type,': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'output': 0.10; '10}': 0.16; 'naive': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; '(i.e.': 0.17; 'wrote:': 0.18; 'skip:[ 20': 0.19; 'from:addr:web.de': 0.23; 'module,': 0.23; 'defined': 0.24; 'guess': 0.26; 'resolution': 0.26; 'module': 0.26; 'code': 0.26; 'all,': 0.27; 'server.': 0.28; 'project,': 0.28; "i'm": 0.28; 'mix': 0.29; "who'd": 0.30; 'sufficient': 0.32; 'requests': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.34; 'arrival': 0.34; 'skip:i 40': 0.34; 'to:addr:python-list': 0.35; 'however,': 0.35; 'project': 0.35; 'two': 0.36; 'received:org': 0.36; 'run': 0.37; 'similar': 0.37; 'using': 0.37; 'another': 0.37; 'some': 0.38; 'doing': 0.38; 'getting': 0.38; 'should': 0.38; 'same.': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'type': 0.61; 'total': 0.61; 'talking': 0.62; '1000': 0.62; 'below': 0.62
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Distribution
Date Tue, 20 Mar 2012 10:15:01 +0100
Organization None
References <33044d51-c481-4796-a722-406f412cf994@x7g2000pbi.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p50849737.dip.t-dialin.net
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.823.1332234906.3037.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332234906 news.xs4all.nl 6882 [2001:888:2000:d::a6]:51342
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21920

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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