Poisson distribution for a newbie

D

diffuser78

I am simulating an event where users come into the pool randomly
starting at time T=0, i.e. For Example, 2 users came at T= 0 into the
the pool, 3 users came at T= 1 into the the pool, 5 users came at T=2
,..........,54 users came at T=45 etc. As cumulative number of users
goes above 1024, we stop the process.

I want to mimic such kind of distribution using poison traffic ( a bell
shaped curve). I looked into wikipedia and some other tutorials but I
wasn't sure how many parameter does the above kind of distribution
would require.

Could somebody put some light on this issue.

PS:: This is not exactly a programming issue but since I was using it
in one of the C programs, I thought somebody might have used similar
thing in past and could help. Thanks.
 
G

gamehack

I am simulating an event where users come into the pool randomly
starting at time T=0, i.e. For Example, 2 users came at T= 0 into the
the pool, 3 users came at T= 1 into the the pool, 5 users came at T=2
,..........,54 users came at T=45 etc. As cumulative number of users
goes above 1024, we stop the process.

I want to mimic such kind of distribution using poison traffic ( a bell
shaped curve). I looked into wikipedia and some other tutorials but I
wasn't sure how many parameter does the above kind of distribution
would require.

Could somebody put some light on this issue.

PS:: This is not exactly a programming issue but since I was using it
in one of the C programs, I thought somebody might have used similar
thing in past and could help. Thanks.

As I was doing Statistics a few months ago, for a Poisson distribution
you need to only know the mean number of events occuring per unit of
something. Eg 5 potholes in 1 mile of road. Then your distribution X is
defined as X~Po(5). But beware that the events have to:
Occur randomly
Independently of each other
At a constant rate
Then you can use the formula to calculate that "x" events occur:
e^(-p) * (p^x)/(x!)
Where "p" is average number of events in the given time interval(5 in
the example).

Regards
 
D

diffuser78

Thanks, I check this in tutorials. But could you expatiate how could I
apply this to the case mentioned in my original post.

thanks once again
 
G

gamehack

Thanks, I check this in tutorials. But could you expatiate how could I
apply this to the case mentioned in my original post.

thanks once again

Right... so your units as far as I can see are Ts. So what you can do
is add up all the people up to 45 Ts and then divide that number by 45,
call that number Z. This will give you the mean number of people coming
to the pool in a period of T. The your distribution would be X~Po(Z).

Regards
 
M

Martin Ambuhl

I am simulating an event where users come into the pool randomly
starting at time T=0, i.e. For Example, 2 users came at T= 0 into the
the pool, 3 users came at T= 1 into the the pool, 5 users came at T=2
,..........,54 users came at T=45 etc. As cumulative number of users
goes above 1024, we stop the process.

Your question has nothing to do with the C programming language. Even
so, I will provide you with some of the information that you should have
already, WARNING! Everything that follows is off-topic.
I want to mimic such kind of distribution using poison traffic ( a bell
shaped curve).

a) It's "Poisson", not "poison"
b) The Poisson distribution is not "a bell shaped curve".
I looked into wikipedia and some other tutorials but I
wasn't sure how many parameter does the above kind of distribution
would require.

A Poisson distribution is given by
Pr(X = x) = exp(-lambda) * pow(lambda,x) / factorial(x)
There is *one* external parameter, lambda
The mean and variance of the distribution are each lambda,
the skewness is 1/sqrt(lambda), and the kurtosis is 3+1/lambda.

The distribution is most easily computed by an iterative procedure,
since
Pr(X = 0) = exp(-lambda)
and
Pr(X = x) = Pr(X = x-1) * lambda / x;

You want to compute this once, filling an array with the cumulative
values, and using rand() to obtain a value to compare against this
array. So if
x = rand()/(1. + RAND_MAX);
and if
x > cum_freq_array[i-1]
and
x <= cum_freq_array
then there were i events in the time period.
Could somebody put some light on this issue.

PS:: This is not exactly a programming issue but since I was using it
in one of the C programs, I thought somebody might have used similar
thing in past and could help. Thanks.

Since this is not a C issue, I make no claim that any of the above is
correct. Check it yourself.
 
B

Ben Bacarisse

I am simulating an event where users come into the pool randomly starting
at time T=0, i.e. For Example, 2 users came at T= 0 into the the pool, 3
users came at T= 1 into the the pool, 5 users came at T=2 ,..........,54
users came at T=45 etc. As cumulative number of users goes above 1024, we
stop the process.

I want to mimic such kind of distribution using poison traffic ( a bell
shaped curve). I looked into wikipedia and some other tutorials but I
wasn't sure how many parameter does the above kind of distribution would
require.

Followup set to comp.programming. This is *so* OT!

Briefly: The Poisson distribution has been suggested (and well described
by others) for events distributed uniformally over time, but in a
simulation you usually need to draw a time from the distribution that
reflects the *gaps* between events given by the Poisson process. This is
good because it is very much easier! You need to draw from an exponential
dist. with mean l, where l is the mean time between arrivals. Your "bell
curve" misunderstanding might come from the fact that the *duration* of a
swim might be drawn from a normal distibution.

Code not posted because the is likely to be an assignment.
 
J

James Dow Allen

I want to mimic such kind of distribution using poison traffic ( a bell
shaped curve).

Bell-shaped? Can you post a lionk to these biazrre bells?
Could somebody put some light on this issue.

Here's the function I use for generating random
Poisson-distributed variables. You must supply
a function which provides uniform variables in
the range (0,1), and must supply m = exp(p) as
argument where p is your Poisson parameter.
(This function is probably based on one of Herman
Rubin's routines.)

/* Return a Poisson random variable with mean = variance = log(m) */
int ran_poisson(double m)
{
static double unif_save = -1;
double z;
int n;

z = m;
z *= unif_save < 0 ? ran_unif(0.0, 1.0) : unif_save;
for (n = 0; z >= 1.0; n += 1)
z *= ran_unif(0.0, 1.0);
unif_save = z;
return n;
}

James D. Allen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top