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


Groups > comp.lang.python > #21933

Re: Distribution

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Distribution
Date 2012-03-20 11:29 -0400
Organization > Bestiaria Support Staff <
References <33044d51-c481-4796-a722-406f412cf994@x7g2000pbi.googlegroups.com> <877gyfmsbl.fsf@benfinney.id.au> <jk9rhh$sn9$1@dough.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.832.1332257387.3037.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, 20 Mar 2012 12:00:50 +0000, Robert Kern <robert.kern@gmail.com>
declaimed the following in gmane.comp.python.general:

> On 3/20/12 11:21 AM, Ben Finney wrote:
> > "prince.pangeni"<prince.ram85@gmail.com>  writes:
> >
> >>     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.
> >
> > What is a distribution? That term already means something in Python
> > jargon, and it doesn't match the rest of your use case.
> >
> > So what do you mean by “distribution”? Maybe we can find a less
> > confusing term.
> 
> Judging from the context, he means a probability distribution.
>
	Futhermore, he explicitly mentions Poisson later in the text.

	That should just be a case of finding the mathematical definition of
the distribution and coding something using random (since the random
module has gaussian/normal, but not Poisson -- maybe numpy/simpy?) to
obtain the time variant.

	I suspect the real question is how to handle the weighted selection
of r1-r3. And for such a relatively short sample set (90 entries), the
chunked list shown previously, with randint to index into it is viable.

	The alternative, more generalized (in a way), would be to use a
sorted list of the probabilities (or sums)... (pseudo-code)

probs =	[	(numR1, r1),
				(numR1 + numR2, r2),
				(numR1 + numR2 + numR3, r3)	]
#obviously one is unlikely to actually create constants for the numRs
#more likely to create in line
probs.sort()

ran = random.randint(numR1 + numR2 + numR3)
for (p, r) in probs:
	if ran > p: continue
	theR = r
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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