File:Probabilidade paradoxo do aniversário.svg

Summary

Description
Português: grafico do paradoxo do aniversário
Date
Source Own work
Author Lechatjaune

Licensing

Summary

Description
Português: Gráfico da probabilidade de pareamento no W:pt:paradoxo do aniversariante. Baseado em Birthday_Paradox.svg
Date
Source Own work
Author Lechatjaune
SVG development
InfoField
 The SVG code is valid.
 This plot was created with Matplotlib.
Category:Valid SVG created with Matplotlib code#Probabilidade%20paradoxo%20do%20aniversário.svg
 Category:Translation possible - SVGThis plot uses embedded text that can be easily translated using a text editor.
Source code
InfoField

Python code

#Cálculo das probabilidades para o paradoxo do aniversariante
#Veja: https://pt.wikipedia.org/wiki/Paradoxo_do_anivers%C3%A1rio

import matplotlib.pyplot as plt

probabilidades = [0,]
p = 1
n_dias = 60 # número de dias a calcular

for i in range(0, n_dias):
      p *= (1 - i/365)   # Anos bissextos são desprezados 
      probabilidades.append(1 - p)


# Plota o gráfico
fig, ax = plt.subplots(1, 1)

plt.step(range(0, n_dias+1), probabilidades)

# Definições de eixos
ax.xaxis.set_ticks_position('bottom')
ax.set_ylim(bottom=0, top=1)
ax.set_xlim(left=0, right=n_dias)


# Adiciona rótulo aos eixos
plt.xlabel('número de pessoas', fontsize=14)
plt.ylabel('probabilidade de pareamento', fontsize=14)

# Adiciona grelha
plt.grid(True)

# Adiciona linha de ~50%
h = probabilidades[23] 
plt.plot([0, 23], [h, h], color='red', linestyle='dotted', linewidth=2)
plt.plot([23, 23], [0, h], color='red', linestyle='dotted', linewidth=2)

# Escreve p(23) = 0.507
ax.text(24, 0.25, 'p(23) = {:.3f}'.format(h), horizontalalignment='left', fontsize=14)

plt.savefig('probabilidade.svg', format='svg')

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 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.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#Probabilidade%20paradoxo%20do%20aniversário.svgCategory:Self-published work
Category:Birthday paradox graph
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 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.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#Probabilidade%20paradoxo%20do%20aniversário.svgCategory:Self-published work
Category:Birthday paradox graph Category:Portuguese-language diagrams
Category:Birthday paradox graph Category:CC-BY-SA-4.0 Category:Portuguese-language diagrams Category:Self-published work Category:Translation possible - SVG Category:Valid SVG created with Matplotlib code