{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Calculate expected stationary mean and variance of M/M/1 queue length. \n", "====================================\n", "The probability of the queue having length $n$ is $p_{n} = (1-\\rho)\\rho^n$ so the expected mean is:\n", "$$\n", "\\begin{align}\n", "E(\\bar{n}) &= \\sum_{n=0}^\\infty np_{n} \\\\\n", "&= \\sum_{n=0}^\\infty n(1-\\rho)\\rho^n \\\\\n", "&= (1-\\rho) \\rho \\sum_{n=0}^\\infty n\\rho^{n-1} \\\\\n", "\\end{align}\n", "$$\n", "Use this standard result\n", "$$\n", "\\boxed{\n", "\\begin{align}\n", "\\sum_{n=0}^\\infty n\\rho^{n-1} = \\frac{1}{(1-\\rho)^2}\n", "\\end{align}\n", "}\n", "$$\n", "so\n", "$$\n", "\\begin{align}\n", "&= (1-\\rho) \\rho \\sum_{n=0}^\\infty n\\rho^{n-1} \\\\\n", "&= (1-\\rho) \\rho \\frac{1}{(1-\\rho)^2} \\\\\n", "&= \\frac{\\rho}{1-\\rho} \\\\\n", "\\end{align}\n", "$$\n", "Finally we have the result:\n", "$$\n", "\\boxed{\n", "\\begin{align}\n", "E(\\bar{n}) = \\frac{\\rho}{1-\\rho}\n", "\\end{align}\n", "}\n", "$$\n", "\n", "To find the variance we first need to find this relation:\n", "$$\n", "\\begin{align}\n", "\\sum_{n=0}^\\infty n^2\\rho^n &= \\sum_{n=0}^\\infty (n^2\\rho^n-n\\rho^n+n\\rho^n) \\\\\n", "&= \\sum_{n=0}^\\infty (n(n-1)\\rho^n+n\\rho^n) \\\\\n", "&= \\sum_{n=0}^\\infty n(n-1)\\rho^n+ \\sum_{n=0}^\\infty n\\rho^n \\\\\n", "&= 2\\rho^2 \\sum_{n=0}^\\infty \\frac{n(n-1)}{2} \\rho^{n-2} + \\rho \\sum_{n=0}^\\infty n\\rho^{n-1} \\\\\n", "\\end{align}\n", "$$\n", "Use these standard results\n", "$$\n", "\\boxed{\n", "\\begin{align}\n", "\\sum_{n=0}^\\infty \\frac{n(n-1)}{2} \\rho^{n-2} = \\frac{1}{(1-\\rho)^3} \\\\\n", "\\sum_{n=0}^\\infty n\\rho^{n-1} = \\frac{1}{(1-\\rho)^2}\n", "\\end{align}\n", "}\n", "$$\n", "so\n", "$$\n", "\\begin{align}\n", "& 2\\rho^2 \\sum_{n=0}^\\infty \\frac{n(n-1)}{2} \\rho^{n-2} + \\rho \\sum_{n=0}^\\infty n\\rho^{n-1} \\\\\n", "&= \\frac{2\\rho^2}{(1-\\rho)^3} + \\frac{\\rho}{(1-\\rho)^2} \\\\\n", "&= \\frac{\\rho}{(1-\\rho)^2} \\left( \\frac{2\\rho}{1-\\rho} + 1 \\right) \\\\\n", "&= \\frac{\\rho}{(1-\\rho)^2} \\left( \\frac{2\\rho + (1-\\rho)}{1-\\rho} \\right) \\\\\n", "&= \\frac{\\rho}{(1-\\rho)^2} \\left( \\frac{1 + \\rho}{1-\\rho} \\right) \\\\\n", "&= \\frac{\\rho(1 + \\rho)}{(1-\\rho)^3}\n", "\\end{align}\n", "$$\n", "Giving the relation:\n", "$$\n", "\\boxed{\n", "\\begin{align}\n", "\\sum_{n=0}^\\infty n^2\\rho^n &= \\frac{\\rho(1 + \\rho)}{(1-\\rho)^3} \\\\\n", "\\end{align}\n", "}\n", "$$\n", "\n", "The variance then is\n", "$$\n", "\\begin{align}\n", "Var(\\bar{n}) &= \\sum_{n=0}^\\infty n^2 p_{n} - E(\\bar{n})^2 \\\\\n", "&= \\sum_{n=0}^\\infty n^2(1-\\rho)\\rho^n - \\left(\\frac{\\rho}{1-\\rho}\\right)^2 \\\\\n", "&= (1-\\rho) \\sum_{n=0}^\\infty n^2\\rho^n - \\left(\\frac{\\rho}{1-\\rho}\\right)^2 \\\\\n", "&= (1-\\rho) \\frac{\\rho(1 + \\rho)}{(1-\\rho)^3} - \\frac{\\rho^2}{(1-\\rho)^2} \\\\\n", "&= \\frac{\\rho + \\rho^2}{(1-\\rho)^2} - \\frac{\\rho^2}{(1-\\rho)^2} \\\\\n", "&= \\frac{\\rho}{(1-\\rho)^2}\\\\\n", "\\end{align}\n", "$$\n", "Finally we have the result:\n", "$$\n", "\\boxed{\n", "\\begin{align}\n", "Var(\\bar{n}) &= \\frac{\\rho}{(1-\\rho)^2}\n", "\\end{align}\n", "}\n", "$$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }