PandA-2024.02
point_stats.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import sys
4 import numpy as np
5 
6 points = np.array( [(float(x),float(y),float(z)) for (x,y,z) in map(lambda L: L.strip().split(), sys.stdin.readlines())] )
7 
8 N = points.shape[0]
9 
10 # Johan Philip. "The Probability Distribution of the Distance between two Random Points in a Box", numerically estimated with Mathematica
11 # an underestimate, actually, because we set a lower bound at the vdW threshold
12 expected_dist = 12.69
13 
14 dists = np.zeros((N,N))
15 for (i,A) in enumerate(points):
16  for (j,B) in enumerate(points):
17  if i!=j:
18  dists[i,j] = np.linalg.norm(A-B)
19  else:
20  dists[i,j] = expected_dist;
21 
22 print 'Distance mean:',np.mean(dists)
23 print 'Distance variance:',np.var(dists)
24 minpair = np.unravel_index(np.argmin(dists), (N,N))
25 print 'Closest pair:',minpair, np.min(dists)
26 print ' p0',points[minpair[0]]
27 print ' p1',points[minpair[1]]
28 maxpair = np.unravel_index(np.argmax(dists), (N,N))
29 print 'Furthest pair:',maxpair, np.max(dists),'( max',20.0*np.sqrt(3.),')'
30 print ' p0',points[maxpair[0]]
31 print ' p1',points[maxpair[1]]
unsigned map[NUM_VERTICES]
Definition: bfs.c:12

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13