Throw darts at a unit square, take the fraction that hit a point (x < .7, y < .5) and multiply by 100. (Also works to calculate pi.)
I get 36.0.
#!/usr/bin/python from random import random trials=200 hits=0 for i in range(trials): x=random() y=random() if x<.7: if y<.5: hits+=1 print 100*(float(hits)/float(trials))
It’s samping variation. Set trials = 1e9 and see what you get.
If I knew how to take fractions, I would have just done 7/(1/5).
Current theme: default
Less Wrong (text)
Less Wrong (link)
Arrow keys: Next/previous image
Escape or click: Hide zoomed image
Space bar: Reset image size & position
Scroll to zoom in/out
(When zoomed in, drag to pan; double-click to close)
Keys shown in yellow (e.g., ]) are accesskeys, and require a browser-specific modifier key (or keys).
]
Keys shown in grey (e.g., ?) do not require any modifier keys.
?
Esc
h
f
a
m
v
c
r
q
t
u
o
,
.
/
s
n
e
;
Enter
[
\
k
i
l
=
-
0
′
1
2
3
4
5
6
7
8
9
→
↓
←
↑
Space
x
z
`
g
Throw darts at a unit square, take the fraction that hit a point (x < .7, y < .5) and multiply by 100. (Also works to calculate pi.)
I get 36.0.
It’s samping variation. Set trials = 1e9 and see what you get.
If I knew how to take fractions, I would have just done 7/(1/5).