Direct disks box.py
From Werner KRAUTH
(Difference between revisions)
Revision as of 14:01, 16 September 2015 Werner (Talk | contribs) ← Previous diff |
Revision as of 14:55, 23 September 2015 Werner (Talk | contribs) (→Program) Next diff → |
||
Line 23: | Line 23: | ||
condition = True | condition = True | ||
print L | print L | ||
- | + | ||
=Version= | =Version= | ||
See history for version information. | See history for version information. | ||
[[Category:Python]] | [[Category:Python]] |
Revision as of 14:55, 23 September 2015
This page presents the program direct_disks_box.py, a direct-sampling algorithm for four disks in a square box of sides 1.
Contents |
Description
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
Version
See history for version information.