Archive for the ‘Modelling’ Category

Joining the queue

Monday, October 5th, 2009

Queue 1

Queues are comprised of customers joining, waiting and then being served. There are two random processes here: arrivals, and serving time, which in this case are both Poisson processes. There can be one or more servers. A handy notation for this is: M/M/n, where the first M describes customer arrival, the second M server processing time, and the n the number of servers.

In this applet, there are 150 queues, each one M/M/5, with a customer arrival rate \lambda of 20 per second, and a server rate \epsilon of 3 per second.

As each customer gets served, their dot turns red, and all the customers shuffle up one. When serving is finished, the dot disappears. As the server has become free, the next customer is served.

This first attempt demonstrates the variation that can occur. Currently, the queues move to the right if serving outpaces arrival. The next step is to have them wait at a particular point, and then moving off when a server is free, with those behind moving up to fill the space.

More queue models to follow, though not sure what their arrival rate will be…

Simulating the Poisson process

Saturday, May 30th, 2009

Simulating poisson

A simulation of the Poisson process, built using Processing.

TheĀ  process models random events occuring in continuous time given that:

  1. Events occur on their own
  2. The average rate of events happening remains constant
  3. Future events have nothing to do with ones which have happened

A process has average rate such as \lambda = \frac{1}{4} per minute. Number of events in t minutes is the discrete random variable X, where X \sim Poisson(\lambda t). The time you have to wait between events follows an exponential distribution T \sim M(lambda).

The simulation works by obtaining a waiting time between each event, through making independent observations on the random variable T \sim M(\lambda). We can do this by solving:

F(t) = u

where u is a random observation on the uniform distribution U(0,1). With the exponention distribution this means solving

1-e^{-\lambda t}=u

which ends up with

t=-\frac{1}{\lambda} log(1-u)

Each time an event is fired, t is recalculated.

Going round in circles

Sunday, October 26th, 2008

Circular momentum is one of those things that I whizzed through in studying – but all the really crucial stuff is packed into a page I read too fast (there was a whole book to read too…)

If you can see this Flash movie, then click on it to set the point circulating away. You will be able to see the green velocity vector perpendicular to that of the point, and a tiny red acceleration vector pointing in the opposition direction (it would be bigger if the dot went faster).

If the position of a point is described as the following vector:
\mathbf{r}=R\cos (\alpha t)\mathbf{i} + R\sin (\alpha t)\mathbf{j}

\alpha t = \theta is the angle of the line joining the point to (0,0) with the positive x-axis, with \alpha  being a constant, and t being time. When \dot{\theta} is constant, we have uniform circular motion.

The angular speed of the point is \omega=\left|\alpha \right|=\left|\dot{\theta}\right| (in radians).

The vector for the point can be differentiated:

\mathbf{v}=\dot{\mathbf{r}}=-\alpha R \sin(\alpha t)\mathbf{i} + \alpha R \cos(\alpha t)\mathbf{j}

The magnitude of the velocity vector is \omega R

which gives a velocity vector perpendicular to the position vector, and tangential to the circle.

Differentiating the velocity vector gives an acceleration vector which is in the opposite direction to the position vector:
\mathbf{a} = \mathbf{\ddot{r}} =-\alpha ^{2} \mathbf{r} = -\omega ^{2} \mathbf{r}

The magnitude of the acceleration vector is \left|\mathbf{a}\right| = \omega ^{2} R = \left|\mathbf{v}\right| ^{2} / R

While the maths of this is all logical, I have to admit to still finding it tricky to intuitively understand the meaning of the velocity and acceleration vectors. But the first time I read this material, it was the meaning of the angular speed which I missed. The normal understanding of speed is as a linear property, and it’s a subtle leap to think of it in radians.