Pi_30K.gif((500 × 500 पिक्सेल, फ़ाइल का आकार: 476 KB, MIME प्रकार: image/gif), चक्रित, 10 ढाँचे, 2.0 s)

सारांश

 
इस GIF ग्राफ़िक को Matplotlib की मदद से बनाया गया था।
विवरण
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.
स्रोत अपना कार्य
लेखक nicoguaro
मूल कोड
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})

लाइसेंस

मैं, इस कार्य का/की कॉपीराइट धारक, इसे निम्न लाइसेंस के अंतर्गत प्रकाशित करता/करती हूँ:
w:hi:क्रिएटिव कॉमन्स
श्रेय
इस फ़ाइल को क्रिएटिव कॉमन्स श्रेय 3.0 अनरिपोर्टेड लाइसेंस के अंतर्गत लाइसेंस किया गया है।
आप खुलकर:
  • बाँट सकते हैं – रचना की प्रतिलिपि बना सकते हैं, बाँँट सकते हैं और संचारित कर सकते हैं
  • रीमिक्स कर सकते हैं – कार्य को अनुकूलित कर सकते हैं
निम्नलिखित शर्तों के अंतर्गत:
  • श्रेय – यह अनिवार्य है कि आप यथोचित श्रेय प्रदान करें, लाइसेंस की कड़ी प्रदान करें, और अगर कोई बदलाव हुए हों तो उन्हें इंगित करें। आप ऐसा किसी भी उचित तरीके से कर सकते हैं, लेकिन किसी भी तरह उससे यह नहीं संकेत नहीं किया जाना चाहिए कि लाइसेंसधारी द्वारा आपको अथवा आपके इस प्रयोग का समर्थन किया जा रहा हो।

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

चित्रण

source of file अंग्रेज़ी

original creation by uploader अंग्रेज़ी

media type अंग्रेज़ी

image/gif

चित्र का इतिहास

फ़ाइलका पुराना अवतरण देखने के लिये दिनांक/समय पर क्लिक करें।

दिनांक/समयथंबनेलआकारसदस्यप्रतिक्रिया
वर्तमान16:00, 16 फ़रवरी 201716:00, 16 फ़रवरी 2017 के संस्करण का थंबनेल संस्करण500 × 500 (476 KB)NicoguaroMake the plot square and increase gif delay.
15:38, 16 फ़रवरी 201715:38, 16 फ़रवरी 2017 के संस्करण का थंबनेल संस्करण640 × 480 (476 KB)NicoguaroBigger text in the axes, and colors from ColorBrewer. Code in Python.
18:29, 7 नवम्बर 201118:29, 7 नवम्बर 2011 के संस्करण का थंबनेल संस्करण500 × 500 (373 KB)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[
23:12, 14 मार्च 201123:12, 14 मार्च 2011 के संस्करण का थंबनेल संस्करण360 × 369 (363 KB)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

निम्नलिखित पन्ने इस चित्र से जुडते हैं :

चित्र का वैश्विक उपयोग

इस चित्र का उपयोग इन दूसरे विकियों में किया जाता है: