Code Monkey home page Code Monkey logo

m-m-1-queue-simulation's Introduction

M-M-1-Queue-Simulation

This program simulates an M/M/1 Queue in Python

M/M/1 Queue

Much of this is motivated from https://en.wikipedia.org/wiki/M/M/1_queue.

The state space is the set {0,1,2,3,...}, where the value corresponds to the number of customers in the system. We let Pn denote the probability of n customers in the system.

Arrivals occur at rate λ according to a Poisson process, which moves the system from state i to state i+1 (since a customer as arrived). Service times are exponentially distributed with rate parameter μ so that 1/μ is the mean service time.

A single server serves customers one at a time from the front of the queue, according to a first-come, first-served discipline. When the service is complete the customer leaves the queue and the number of customers in the system reduces by one, i.e., the system moves from state i to i−1.

Suppose the system is in state n. Then, the balance equation reads

(λ+μ)Pn = λPn−1 + μPn+1

Essentially, (λ+μ)Pn: rate of an arrival or departure to Pn λPn−1: rate of an arrival to Pn−1 μPn+1: rate of a departure from Pn+1

The boundary condition (near an empty queue) is that λP0=μP1.

Thus, P1 = λ/μ(P0)

P2 = λ/μ(P1) + 1/μ(μP1−λP0 )= λ/μ(P1) = (λ/μ)^2(P0)

Pn =(λ/μ)^n(P0)

m-m-1-queue-simulation's People

Contributors

sarthak0120 avatar karans785 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.