Fichier:Pi 30K.gif
De testwiki
Aller à la navigation
Aller à la recherche
Pi_30K.gif (500 × 500 pixels, taille du fichier : 476 kio, type MIME : image/gif, en boucle, 10 trames, 2,0 s)
Ce fichier provient de Wikimedia Commons et peut être utilisé par d'autres projets. Sa description sur sa page de description est affichée ci-dessous.
Description
| DescriptionPi 30K.gif |
English: As points are randomly scattered inside the unit square, some fall within the unit circle. The fraction of points inside the circle over all points approaches pi/4 as the number of points goes toward infinity. This animation represents this method of computing pi out to 30,000 iterations.
Português: Conforme os pontos são espalhados aleatoriamente no quadrado unitário, alguns caem dentro do círculo unitário. A fração de pontos dentro do círculo sobre todos os pontos se aproxima de pi/4 à medida que o número de pontos tende ao infinito. Essa animação representa esse método de cálculo de pi até 30 000 iterações. |
| Source | Travail personnel |
| Auteur | nicoguaro |
| Code source InfoField | Python codefrom __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.animation as animation
from matplotlib import rcParams
# In Windows the next line should provide the full path to convert.exe
# since convert is a Windows command
#rcParams['animation.convert_path'] = "C:\Program Files\ImageMagick-6.9.3\convert.exe"
rcParams['mathtext.fontset'] = 'cm'
rcParams['font.size'] = 14
red = "#e41a1c"
blue = "#377eb8"
gray = "#eeeeee"
def update(n):
ax.cla()
pts = np.random.uniform(low=0, high=1, size=(2, n))
circ = pts[:, pts[0, :]**2 + pts[1, :]**2 <= 1]
out_circ = pts[:, pts[0, :]**2 + pts[1, :]**2 > 1]
pi_approx = 4*circ.shape[1]/n
circle = mpatches.Wedge((0, 0), 1, 0, 90, color=gray)
ax.add_artist(circle)
plt.plot(circ[0, :], circ[1, :], marker='.', markersize=1,
linewidth=0, color=red)
plt.plot(out_circ[0, :], out_circ[1, :], marker='.',markersize=1,
linewidth=0, color=blue)
plt.title(r"$n = {}, \pi \approx {:.4f}$".format(n, pi_approx))
plt.axis("square")
plt.xlim(0, 1)
plt.ylim(0, 1)
nvec = np.round(np.logspace(2, 5, 10))
nvec = [3000, 4000, 5000, 6500, 8500, 10000, 15000, 18000, 24000, 30000]
fig = plt.figure(figsize=(5, 5))
ax = fig.add_subplot(111)
ani = animation.FuncAnimation(fig, update, frames=nvec, blit=False)
ani.save("monte_carlo_pi.gif", writer='imagemagick',
savefig_kwargs={'delay': 6})
|
Conditions d’utilisation
Moi, en tant que détenteur des droits d’auteur sur cette œuvre, je la publie sous la licence suivante :
Ce fichier est disponible selon les termes de la licence Creative Commons Attribution 3.0 Non Transposé.
- Vous êtes libre :
- de partager – de copier, distribuer et transmettre cette œuvre
- d’adapter – de modifier cette œuvre
- Sous les conditions suivantes :
- paternité – Vous devez donner les informations appropriées concernant l'auteur, fournir un lien vers la licence et indiquer si des modifications ont été faites. Vous pouvez faire cela par tout moyen raisonnable, mais en aucune façon suggérant que l’auteur vous soutient ou approuve l’utilisation que vous en faites.
Légendes
Ajoutez en une ligne la description de ce que représente ce fichier
Éléments décrits dans ce fichier
dépeint
Valeur sans élément de Wikidata
image/gif
Historique du fichier
Cliquer sur une date et heure pour voir le fichier tel qu'il était à ce moment-là.
| Date et heure | Vignette | Dimensions | Utilisateur | Commentaire | |
|---|---|---|---|---|---|
| actuel | 16 février 2017 à 17:00 | 500 × 500 (476 kio) | wikimediacommons>Nicoguaro | Make the plot square and increase gif delay. |
Utilisation du fichier
La page suivante utilise ce fichier :
