A store queue and the maths behind it.

Mathematical theory in a store? Seems unlikely, right?. Well, not really.

Let’s dive into a situation where you go to a mobile phone company store with only one counter. And, yes the company recently released a phone which is selling like hot cakes. Everyone wants it, so do you. Now, you are standing outside the store, waiting patiently and peeking through the transparent glass wall of the store curiously. Now, your curious mind notices something. You observe that each customer is spending a lot time asking so many questions to the store employees, browsing through other models, and also spending a lot of time while paying.  Also, the rush is real. Bunch of new customers are pouring into the store every now and then. 

This how the store as a system looks like:

entrance → browsing → counter → exit

Thus, the scenario is that a bunch of people are entering the store steadily and that every customer is spending a lot(A LOT) of time in the store, and yes, the store isn’t that big. Now, you can’t help but wonder why isn’t the store overflowing with people by now. Shouldn’t the store, intuitively, be a sea of customers with no place to stand on? But interestingly, the store isn’t even that packed really. Wonder why? Well, this is where a simple yet fascinating mathematical principle comes in.

In queueing theory, a discipline within the mathematical theory of probability, Little’s result, theorem, lemma, law, or formula is a theorem by John Little which states that the long-term average number L of customers in a stationary system is equal to the long-term average effective arrival rate λ multiplied by the average time W that a customer spends in the system. 

Little’s Law tells us that the average number of customers in the store L, is the effective arrival rate λ, times the average time that a customer spends in the store W, or simply:

L = λ * W

Although it looks intuitively easy, it is quite a remarkable result, as the relationship is “not influenced by the arrival process distribution, the service distribution, the service order, or  practically anything else.” 

The result applies to any system, and particularly, it applies to systems within systems.  So in a bank, the customer line might be one subsystem, and each of the tellers another subsystem, and Little’s result could be applied to each one, as well as the whole thing. The only requirements are that the system be stable and non-preemptive; this rules out transition states such as initial  startup or shutdown.

In some cases it is possible not only to mathematically relate the average number in the system to the average wait but even to relate the entire probability distribution (and moments) of the number in the system to the wait.

Assume customers arrive at the rate of 10 per hour and stay an average of 0.5 hour. This means we  should find the average number of customers in the store at any time to be 5.

L = 5

Now suppose the store is considering doing more advertising to raise the arrival rate to 20 per hour. The store must either be prepared to host an average of 10 occupants or must reduce the time each customer spends in the store to 0.25 hour. The store might achieve the latter by ringing up the  bill faster or by adding more counters.

We can apply Little’s Law to systems within the store. For example, consider the counter and its queue. Assume we notice that there are on average 2 customers in the queue and at the counter. We know the arrival rate is 10 per hour, so customers must be spending 0.2 hours on average checking  out.

W = 0.2

The above referenced website discusses common queueing theory: Little’s Law.  While it claims the arrival process distribution is not a factor, it is indirectly a factor in that the mean arrival process distribution will equate to effective arrival rate, λ is important.  Other factors, such asthe service distribution, order of processing may indirectly influence the Little Law expression factors.

If the arrival rate exceeds the exit rate, then the system is deemed unstable, and the queue length will increase at the delta rate; VisualSim users will see an increasing Number_in_Queue rate.  If stable, the average number in a simple queue would be the arrival rate times the time spent in the queue.  VisualSim computes standard queue statistics:

    // Name                             Type      Value
      “Queue_Number                     int       0  ; “
      “Number_in_Queue                  int       0  ; “
      “Number_Entered                   int       0  ; “
      “Number_Exited                    int       0  ; “
      “Number_Rejected                  int       0  ; “
      “Min_Buffer_Occupancy             double    0.0; “
      “Mean_Buffer_Occupancy            double    0.0; “
      “StDev_Buffer_Occupancy           double    0.0; “
      “Max_Buffer_Occupancy             double    0.0; “
      “Min_Delay_thru_Queue             double    0.0; “
      “Mean_Delay_thru_Queue            double    0.0; “
      “StDev_Delay_thru_Queue           double    0.0; ”      “Max_Delay_thru_Queue             double    0.0; “; 

Number_in_Queue is identical to Little’s Law L Mean_Delay_thru_Queue is identical to Little’s Law W

Using Little’s Law in VisualSim, where λ = (Number_Entered / DeltaTime):

Number_in_Queue   = (Number_Entered / DeltaTime) * Min_Delay_thru_Queue

Additional queue statistics are captured to provide additional insights; Number_Entered, Number_Exited, and Number_Rejected provide simple queue metrics, for example.  DeltaTime is the time of the statistic.