File:Birthday paradox approximation.svg

Summary

Description
English: A graph comparing the accuracy of an approximation of the probability that in a room with n people (shown along the horizontal axis), some two (or more) will share a birthday. The black line, represents the computed probability. The red line represents the approximation
Español: Comparación entre la probabilidad de que dos personas (o más) en un cuarto compartan su cumpleaños (línea negra) y la aproximación:
Date
Source Own work
Author Nicoguaro
SVG development
InfoField
 
The source code of this SVG is invalid due to an error.
 
This W3C-invalid plot was created with Matplotlib.
Category:Invalid SVG created with Matplotlib code#1000Birthday%20paradox%20approximation.svg
 
The file size of this SVG plot may be irrationally large because its text has been converted to paths inhibiting translations.
Category:Path text SVG
Source code
InfoField

Python code

#from __future__ import division # Python 2
import numpy as np
from scipy.special import perm
import matplotlib.pyplot as plt
from matplotlib import rcParams

rcParams['font.family'] = 'serif'
rcParams['font.size'] = 14

num = np.linspace(1, 100, 100)
p = 1 - perm(365, num)/365.**num
p_approx = 1 - np.exp(-num**2/730)

plt.figure(figsize=(8, 5))
plt.step(num, p, "k", lw=2)
plt.plot(num, p_approx, "r", lw=1)
plt.xlabel(r"Number of people - $n$")
plt.ylabel("Probability of a pair")
plt.grid(True)
plt.legend([r"Probability: $\frac{365!}{365^n (365 - n)!}$",
            r"Approximation: $1-e^\frac{-n^2}{2\cdot 365}$"], loc=4)
plt.savefig("Birthday paradox approximation.svg")
plt.show()

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
Category:CC-BY-4.0#Birthday%20paradox%20approximation.svg
Category:Self-published work Category:Birthday paradox Category:Statistics
Category:Birthday paradox Category:CC-BY-4.0 Category:Invalid SVG created with Matplotlib code Category:Path text SVG Category:Self-published work Category:Statistics