.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/probability/queueing/plot_01_erlang_b.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_probability_queueing_plot_01_erlang_b.py: Erlang's loss formula: how many telephone lines? ======================================================== For Poisson call arrivals offering :math:`A` erlangs of traffic to :math:`c` lines, a call is lost with probability :math:`B(c, A)`. Erlang's formula answers the engineer's question: how many lines keep losses below 1%? .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from mathematicskit.probability import erlang_b .. GENERATED FROM PYTHON SOURCE LINES 18-20 Blocking probability against the number of lines ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 20-34 .. code-block:: Python servers = np.arange(0, 41) fig, ax = plt.subplots() for load in (2.0, 5.0, 10.0, 20.0): blocking = [erlang_b(load, int(c)) for c in servers] ax.semilogy(servers, blocking, label=f"A = {load:g} erlangs") needed = next(int(c) for c, b in zip(servers, blocking) if b < 0.01) print(f"A = {load:>4g} erlangs: {needed} lines keep blocking below 1%") ax.axhline(0.01, color="0.5", ls="--") ax.set_ylim(1e-6, 1.2) ax.set_xlabel("lines c") ax.set_ylabel("blocking probability B(c, A)") ax.legend() ax.set_title("Erlang B formula (1917)") .. image-sg:: /api/gallery/probability/queueing/images/sphx_glr_plot_01_erlang_b_001.png :alt: Erlang B formula (1917) :srcset: /api/gallery/probability/queueing/images/sphx_glr_plot_01_erlang_b_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none A = 2 erlangs: 7 lines keep blocking below 1% A = 5 erlangs: 11 lines keep blocking below 1% A = 10 erlangs: 18 lines keep blocking below 1% A = 20 erlangs: 30 lines keep blocking below 1% Text(0.5, 1.0, 'Erlang B formula (1917)') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.058 seconds) .. _sphx_glr_download_api_gallery_probability_queueing_plot_01_erlang_b.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_erlang_b.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_erlang_b.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_erlang_b.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_