Jump to content

File:Circle area Monte Carlo integration2.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 723 × 723 pixels, file size: 188 KB)

Summary

Description calculation of pi via monte carlo methods
Date
Source with R (source below) directly to SVG and the inkscape to polish it a bit (numbers)
Author Thomas Steiner
Other versions
SVG development
InfoField
 
The SVG code is valid.
 
This chart was created with R.
Source code
InfoField

R code

## for more about SVG, see eg http://www.stat.auckland.ac.nz/~paul/Talks/gridSVG/slide1.html
 
 set.seed(20070209)
 n<-1000
 pts<-array(runif(2*n, min=-1,max=1),dim=c(n,2))
 
 out <- pts[,1]^2+pts[,2]^2>1
 
 ci<-seq(0,2*pi,length=300)
 circle<-array(dim=c(300,2))
 circle[,1]=cos(ci)
 circle[,2]=sin(ci)
 
 library(RSvgDevice)
 devSVG("Circle_area_Monte_Carlo_integration2.svg", width=10, height=10)
 
 plot(pts[out,],type="n",axes=F,xaxs="i",xlim=c(-1,1),ylim=c(-1,1),xlab="",ylab="")
 polygon(circle,col="lightgray")
 lines(pts[!out,],type="p",col="darkgreen")
 lines(pts[out,],type="p",col="red")
 lines(c(1,-1,-1,1,1),c(1,1,-1,-1,1),col="black",lwd=2)
 text(x=0.8,y=-0.9,sum(out),col="red",cex=5)
 text(x=0,y=-0.9,(n-sum(out)),col="darkgreen",cex=5)
 #ev noch dazuschreiben, was der quotient ist? 
 4*(1-sum(out)/n)-pi
 dev.off()
794 / 206 = 3.85436893204 (= approx. π: 3.14159265359)

Licensing

w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 2.5 Generic 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.
 
This W3C-unspecified chart was created with R.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

9 February 2007

image/svg+xml

8494b0d9e0cb08f4b254cdf55e6b257fe384af8f

192,032 byte

723 pixel

723 pixel

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current23:08, 9 February 2007Thumbnail for version as of 23:08, 9 February 2007723 × 723 (188 KB)Thire{{Information| |Description = calculation of pi via monte carlo methods |Source = with R (source below) directly to SVG and the inkscape to polish it a bit (numbers) |Date = 9 feb. 2007 |Author = Thomas Steiner |Permission = [[:de:B
No pages on the English Wikipedia use this file (pages on other projects are not listed).

Global file usage

The following other wikis use this file: