Direct disks box.py
From Werner KRAUTH
(Difference between revisions)
| Revision as of 14:56, 23 September 2015 Werner (Talk | contribs) ← Previous diff |
Current revision Werner (Talk | contribs) (→Program) |
||
| Line 22: | Line 22: | ||
| L.append(a) | L.append(a) | ||
| condition = True | condition = True | ||
| - | print L | + | print(L) |
| =Version= | =Version= | ||
Current revision
This page presents the program direct_disks_box.py, a direct-sampling algorithm for four disks in a square box of sides 1.
Contents |
[edit]
Description
[edit]
Program
import random, math
N = 4
sigma = 0.2
condition = False
while condition == False:
L = [(random.uniform(sigma, 1.0 - sigma), random.uniform(sigma, 1.0 - sigma))]
for k in range(1, N):
a = (random.uniform(sigma, 1.0 - sigma), random.uniform(sigma, 1.0 - sigma))
min_dist = min(math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) for b in L)
if min_dist < 2.0 * sigma:
condition = False
break
else:
L.append(a)
condition = True
print(L)
[edit]
Version
See history for version information.
