Fitxer:Pi 30K.gif

El contingut de la pàgina no s'admet en altres llengües.
De la Viquipèdia, l'enciclopèdia lliure

Pi_30K.gif(500 × 500 píxels, mida del fitxer: 476 Ko, tipus MIME: image/gif, en bucle, 10 fotogrames, 2,0 s)

Descripció a Commons

Resum

 
Aquesta GIF imatge rasteritzada ha estat creada amb Matplotlib
Descripció
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.
Font Treball propi
Autor nicoguaro
Codi font
InfoField

Python code

from __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})

Llicència

Jo, el titular dels drets d'autor d'aquest treball, el public sota la següent llicència:
w:ca:Creative Commons
reconeixement
Aquest fitxer està subjecte a la llicència de Creative Commons Reconeixement 3.0 No adaptada.
Sou lliure de:
  • compartir – copiar, distribuir i comunicar públicament l'obra
  • adaptar – fer-ne obres derivades
Amb les condicions següents:
  • reconeixement – Heu de donar la informació adequada sobre l'autor, proporcionar un enllaç a la llicència i indicar si s'han realitzat canvis. Podeu fer-ho amb qualsevol mitjà raonable, però de cap manera no suggereixi que l'autor us dóna suport o aprova l'ús que en feu.

Llegendes

Afegeix una explicació d'una línia del que representa aquest fitxer

Elements representats en aquest fitxer

representa l'entitat

Historial del fitxer

Cliqueu una data/hora per veure el fitxer tal com era aleshores.

Data/horaMiniaturaDimensionsUsuari/aComentari
actual18:00, 16 feb 2017Miniatura per a la versió del 18:00, 16 feb 2017500 × 500 (476 Ko)NicoguaroMake the plot square and increase gif delay.
17:38, 16 feb 2017Miniatura per a la versió del 17:38, 16 feb 2017640 × 480 (476 Ko)NicoguaroBigger text in the axes, and colors from ColorBrewer. Code in Python.
20:29, 7 nov 2011Miniatura per a la versió del 20:29, 7 nov 2011500 × 500 (373 Ko)RayhemSlowed animation to avoid looking like a blinky page element, improved resolution, added counter for number of points, shaded points inside/outside the circle. ==Mathematica 7.0 Source== <pre> tinyColor[color_, point_] := {PointSize[Small], color, Point[
01:12, 15 març 2011Miniatura per a la versió del 01:12, 15 març 2011360 × 369 (363 Ko)CaitlinJo{{Information |Description ={{en|1=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 as the number of points goes toward infinity. This ani

La pàgina següent utilitza aquest fitxer:

Ús global del fitxer

Utilització d'aquest fitxer en altres wikis: