scieee AI-readable full text Open interactive document viewer

Evaluation of pairwise distances among points forming a regular orthogonal grid in a hypercube

Sadílek, Václav; Vořechovský, Miroslav

Abstract

Cartesian grid is a basic arrangement of points that form a regular orthogonal grid (ROG). In some applications, it is needed to evaluate all pairwise distances among ROG points. This paper focuses on ROG discretization of a unit hypercube of arbitrary dimension. A method for the fast enumeration of all pairwise distances and their counts for a high number of points arranged into high-dimensional ROG is presented. The proposed method exploits the regular and collapsible pattern of ROG to reduce the number of evaluated distances. The number of unique distances is identified and frequencies are determined using combinatorial rules. The measured computational speed-up compared to a nave approach corresponds to the presented theoretical analysis. The proposed method and algorithm may find applications in various fields. The paper shows application focused on the behaviour of various distance measures with the motivation to find the lower bounds on the criteria of point distribution uniformity in Monte Carlo integration.

Full text

Copyright © 2018 The Author(s). Published by VGTU Press This is an Open Access article distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited. Journal of Civil Engineering and Management ISSN 1392-3730 / eISSN 1822-3605 2018 Volume 24 Issue 5: 410–423 https://doi.org/10.3846/jcem.2018.5189 *Corresponding author. E-mail: [email protected] EVALUATION OF PAIRWISE DISTANCES AMONG POINTS FORMING AREGULAR ORTHOGONAL GRID IN AHYPERCUBE Václav SADÍLEK , Miroslav VOŘECHOVSKÝ * Institute of Structural Mechanics, Faculty of Civil Engineering, Brno University of Technology, Czech Republic Received 22 March 2018; accepted 19 June 2018 Abstract. Cartesian grid is a basic arrangement of points that form aregular orthogonal grid (ROG). In some applications, it is needed to evaluate all pairwise distances among ROG points. This paper focuses on ROG discretization of a unit hypercube of arbitrary dimension. A method for the fast enumeration of all pairwise distances and their counts for a high number of points arranged into high-dimensional ROG is presented. The proposed method exploits the regular and collapsible pattern of ROG to reduce the number of evaluated distances. The number of unique distances is identified and frequencies are determined using combinatorial rules. The measured computational speed-up compared to a naïve approach corresponds to the presented theoretical analysis. The proposed method and algorithm may find applications in various fields. The paper shows application focused on the behaviour of various distance measures with the motivation to find the lower bounds on the criteria of point distribution uniformity in Monte Carlo integration. Keywords: full factorial design, design of experiments, pairwise distances, Audze-Eglãjs criterion, optimization, periodic space. Introduction The measuring of distances is fundamental to geospatial analysis (Tobler 1970). It is closely related to the concept of route. For example, the package gdistance (van Etten 2012) was designed to determine grid-based distances and routes, and to be used in combination with other packages available within R (R Core Team 2016). Another application of distance distributions between points in spatial processes can be found when modelling connectivity in wireless mobile systems such as cellular, ad-hoc and sensor networks. Since connectivity can be expressed as a function of the distance between nodes, distance distributions between points in spatial processes are of special importance (Moltchanov 2012). The study of point distribution is also very relevant to the field of design of experiments (DoE) and statistical sampling for Monte Carlo integration. The present paper primarily concerns the distribution of points relevant to statistical sampling for computer experiments (Iman, Conover 1980; Morris, Mitchell 1995), where the optimal placement of sampling points is an as yet unsolved problem. In computer experimentation (Sacks etal. 1989), which is apowerful tool for the investigation of problems encompassing the randomness of observed phenomena, the task is to prepare aplan of the simulations that should be performed, i.e. what is known as the Design of Experiments (DoE) should be carried out. Asimilar task is included in the response surface method first introduced by Box (1954) and since then improved and adapted in various ways (e.g. Bucher, Bourgund 1990; Gupta, Manohar 2004; Hamzah etal. 2017), where training points have to be placed appropriately. In Monte Carlo integration it is desirable to minimize the number of simulations (point count sim N ) while making sure statistical estimates remain of high quality. This is achieved by the uniform filling of the design domain, which is aunit var N -dimensional hypercube ( var N is the number of input random variables), and the appropriate transformation of points of such asampling plan in accordance with the required probability distribution and mutual dependencies among the inputs. Individual simulations are then represented by design points placed within the hypercube. Designs for the placement of points inside the design domain that supposedly distribute the points uniformly are known as space filling designs (see e.g. Damblin etal. 2013). Journal of Civil Engineering and Management, 2018, 24(5): 410–423 411 Designs with a general sim N and var N that are supposed to fill the hypercube uniformly are usually sought for via heuristic optimization (Morris, Mitchell 1995; Mortazavi et al. 2017; Siddiquea, Adelib 2016; Vořechovský, Novák 2009). There are many different criteria that are designed to measure this uniformity and are subject to minimization during such optimization. One of the criteria that accentuate the space-filling property of the final design is the Audze-Eglãjs (AE) criterion (Audze, Eglãjs 1977). Another example is the periodic version of the AE criterion, hereinafter referred to as the PAE criterion (Eliáš, Vořechovský 2016), which removes a major flaw of the AE criterion. Many other criteria have been defined with the aim of ensuring the uniform filling of agiven space. They are often based on the evaluation of discrepancy, e.g. Centered 2 L -discrepancy (Fang, Ma 2001), Wrap-Around 2 L -discrepancy (Fang, Ma 2001). Maximin or miniMax criteria (Husslage 2006; Johnson etal. 1990) may also be used. The criteria used for the illustration of application in this article are the Audze-Eglãjs (AE) criterion (Audze, Eglãjs 1977; Bates etal. 2003), or its generalization into the φ criterion (Morris, Mitchell 1995) and the PAE criterion (Eliáš, Vořechovský 2016). The effective control of an optimization algorithm is often conditional upon the knowledge of the lower bound of the optimization criterion (the minimum that can be reached during optimization) and the mean value. Various means of optimization exist. For example, heuristic algorithms based on columnwise-pairwise exchanges (the shuffling of pre-sampled coordinates) (Li, Wu 1997; Morris, Mitchell 1995; Vořechovský, Novák 2009; Chen etal. 2016; Huang et al. 2016) can drastically profit from the knowledge of the minimum (or maximum in the case of maximization) of the objective function (e.g. the AE criterion). The available methods of filling aunit hypercube with points are basically divided into two types: deterministic and stochastic. Historically, non-random lattices (such as ROGs, triangular lattices or hexagonal lattices) have also been used as models for anumber of physical and environmental phenomena, e.g. elements of crystals, the placement of seedlings in the landscape, the locations of facilities in cities, etc. (Chu 2006). Therefore, the evaluation of distances in regular lattices may be important in these fields of expertise as well. Deterministic methods place the design points in regular patterns and may ensure perfect space-filling. One such example is full factorial design (Chudoba etal. 2013; Montgomery 2006). It is abasic design that, in repeatable computer experiments, has only one representant for each location and explores combinations of all factors with all levels for that factor. In this paper, we consider such a Cartesian grid (regular orthogonal grid) of sim N points in adesign domain that is a unit hypercube of dimension var N (sometimes denoted as var [0,1] N ). In particular, we study the pairwise distances among all pairs of these sim N points. The list of the distances featured in such adesign is needed in the evaluation of many criteria concerning the optimality of that design (Maximin, miniMax, AE, PAE, φ criterion) (Audze, Eglãjs 1977; Bates etal. 2003; Eliáš, Vořechovský 2016; Husslage 2006; Johnson etal. 1990; Morris, Mitchell 1995). Due to the regularity and perfect space-filling of certain deterministic designs it is reasonable to expect these designs to provide acriterion value that is the minimum or close to the minimum for agiven configuration ( ) sim var ,NN . The ROG designs studied in this paper are presumed to be optimal or near-optimal designs as regards many criteria related to uniformity, regularity, discrepancy and space-fillingness. It is supposed that they provide conservative estimates of the lower bounds on the design optimality criteria. Since these deterministic designs are restricted just to specific numbers of design points ( var sim N NN= , N being anatural number expressing the number of different input values for each random input variable), the article also anticipates the possibility of interpolation of the lower bound for an arbitrary sim N of astochastic design. This paper presents a method for the fast enumeration of all pairwise distances among points arranged into a regular orthogonal grid (ROG) in aunit hypercube and is organized as follows. Section 1 describes the ROG arrangement of points. Section2 provides an analysis of distances in ROG and identifies main transformations of simple distances identified by simple combinatorial operations. Section3 presents the speed-up compared to naïve evaluation of distances. Section4 presents an application of the Figure 1. Regular grids of five points ( 5N= ) in unit cubes of var 1, 2N= and 3 dimensions 412 V. Sadílek et al. Evaluation of pairwise distances among points forming aregular orthogonal grid in ahypercube method in determining the bounds of optimality criterion and design of computer experiments. 1. Unit hypercube filled with regular orthogonal grid of points AGrid or Mesh is defined as smaller shapes formed after the discretization of ageometric domain. A regular grid is defined as atessellation of var N -dimensional Euclidean space by congruent parallelotopes (e.g. bricks). Several types of gridding systems exist, e.g. hexagonal grids or triangular grids generalized to arbitrary dimensions. This paper considers a rectangular domain (aunit hypercube) and its division into a regular Cartesian grid. A Cartesian grid (ROG) of points is aspecial case where the elements are equal lines, squares, cubes, etc. We consider a ROG of points arranged in the unit hypercube arranged such that the number of points reads: var sim N NN= , (1) where N is the number of equidistant coordinates along each individual dimension. It corresponds to a tessellation of a unit hypercube into sim N identical cubes; the points are placed in the intersections of lines passing through their centroids. In this arrangement, the points form an orthogonal grid inside a unit hypercube the dimension of which is var N . Examples of such hypercubes are a line ( var 1N= ), a square ( var 2N= ), acube, etc. In this paper, ROG is considered such that the number of equidistant points, N , is identical along each edge. Figure1 shows examples of such ROGs for various dimensions. An i th point of ROG is arow vector with var N coordinates: ( ) var ,1 ,2 , , , ,, ,, i i i iv iN xx x x= ……x . (2) The coordinates are found within the unit hypercube: , 01 iv x≤≤ . All points then form a matrix x (also referred to as the sampling plan in Section 4): var var sim sim sim sim var 1,1 1, 1, 1 ,1 , , ,1 , , vN i i iv iN NN Nv NN xxx xxx xxx         = =          x x x x      . (3) The notation used in this paper is such that the number or symbol following the comma in the lower index stands for the dimension var 1,vN∈〈 〉 . When all the coordinates are multiplied by number N then the sampling plan becomes a matrix of rank numbers, π . In this way the ROG is scaled from the unit hypercube in to a hypercube of length N . Individual points form row vectors of indices: ( ) var ,1 ,2 , , , ,, ,, i i i iv iN =ππ π ππ , where sim 1, ,iN= and ,{1, 2, , } iv Nπ∈ … , see Figure 1 left – the rank numbers are denoted on the top axis. var var sim sim sim var 1,1 1, 1, ,1 , , ,1 , , vN i iv iN N Nv NN πππ     πππ =    πππ      π. (4) The uniform distribution of points within the unit hypercube is considered with the coordinates: ,sim ,var 1 1 2 1 iv iv iN xvN N π− ≤≤ =≤≤ . (5) The pairwise difference of points i and j is a row vector: ij i j = −δ ππ , (6) that consists of differences of rank numbers along individual dimensions: ,,,ijv iv jv δ =π −π . Using these differences in index numbers, the Euclidean distance between points i and j reads: ( ) var var 22 ,, , 11 1 ij i v j v ij v N v N v L xx N = = = −= δ ∑∑ . (7) The number of distances between all pairs of sim N points is generally: ( ) sim sim sim p 1 22 NN NN−  = =    . (8) This number is 2 sim ()N which implies its rapid growth with increasing discretization N and the dimension var N . The calculation of distances between all pairs of points in ROG can be simplified. 2. Analysis of distances in ROG The ROG is a collapsible arrangement and therefore the projections of pairwise distances along individual dimensions imply repeated vectors of index differences ij δ . It is possible to obtain a list of all possible vectors of index differences, ij δ , by considering only a limited list of vectors, t δ . This list contains vectors that exhaust unique vectors ij δ irrespective of the order of elements. The number of such types of vectors is denoted as c N . The vectors t δ are indexed by “ t ” and their list is selected so as to represent distances from the point 1 (1, ,1)= …π . The point 1 π has the lowest possible indices and is placed in the “bottom left corner” of the hypercube. Therefore, we can write the vectors as: 11 c , 1 t tt tN≡ = − ≤≤δδ ππ . (9) The considered set of points t π is selected to exhaust all points that fulfil: , , var { : for 1 } tv tw t vwNπ ≥π ≤ < ≤ . (10) In other words, all vectors t π form all possible nonincreasing sequences of indices. Figure2 illustrates the sit- Journal of Civil Engineering and Management, 2018, 24(5): 410–423 413 uation for 3N= and var 3N= . The full list of vectors t δ is divided into three lists of vectors of dimensions 1, 2 and 3. It can be seen that the points in increasing dimensions progressively form asimplex. We are now interested in obtaining the total number of such vectors t δ . For agiven design with ( ) var ,NN , the number is equal to the number of ways to place N types of elements into avector of length var N (number of multisubsets). These are combinations with repetition: ( ) ( ) var var cvar var var 1! 1 ! 1! N NN NNN N N N N +− +−    =   = =  −     . (11) As can be seen from Figure 2, when var 3NN= = , the number of vector types is c10N= . Eqn(11) can be simplified by decomposing the factorial in the numerator and cancelling the ( ) 1!N− terms in the numerator and denominator: ( ) var 1 0 c var ! N i Ni NN − = + = ∏ . (12) Now, it is easy to write the bounds on c N by taking either 0i= (lower bound) or var /2iN= (upper bound): var var var sim c var var var () 2 !! ! N N N NN NN N N N+ = . (13) The lower bound on the left hand side provides a useful estimate that quickly tends towards c N with increasing N . It helps to show that the number of vector types is much lower than the total number of pairs, p N . A direct comparison of Eqn(8) with the lower bound in Eqn(13) reveals that while p N is proportional to 2 sim N , the number c N is proportional to sim N only. This fact is documented in Figure4 (left), where the number of pairs, p N , is independent of dimension and steeply grows with in creasing sim N . The number c N slightly depends on var N ; however, the slope is half of that for p N . To show a more complex example of vectors t δ , Table1 presents all vectors t δ for 5N= and var 3N= . The number of pairwise distances in such a grid is p 7,750N= , while the number of unique types of vectors is c 35N= . The table is accompanied by the corresponding Euclidean point distances in a unit hypercube, t L (squared and multiplied by 2 N ). Eqn(7) can be reused to calculate the Euclidean lengths using the index differences ,,ij v t v =δδ : var 2, 1 || || t t tv v N NL = ⋅= = δ ∑ δ . (14) With all possible vector types, t δ , and the associated distances, t L , we are now interested in obtaining the total number of occurrences of each vector type, denoted as t n . One can show that this number is a product of three coefficients: pdn c ,2 tttt n n n n tN = × × ≤≤ , (15) where the three coefficients p t n , d t n and n t n represent three types of spatial transformations of t δ : rotations, reflections and translations. Note that we index the vector types from 2t= ; this is because 1 δ is the null-vector. One can check that the number of pairwise distances (Eqn(8)) equals to the sum of all t n ’s: c p im 2 s 2 t t NN Nn =  = =    ∑ . (16) The coefficients are derived in the following subsections. 2.1. Number of permutations p t n of integer difference vectors When considering a distance corresponding to a certain pattern t δ , it is important to count the number of ways to achieve this distance from the point 1 π . In particular, p t n corresponds to the number of ways to rotate the vector around the point 1 π which is equivalent to renumbering the dimensions. In other words, one must consider how many times the differences ,tv δ can be permuted. To make Figure 2. Enumeration of all vectors t δ and the corresponding visualization in a 3D grid with 3N= points along each dimension 414 V. Sadílek et al. Evaluation of pairwise distances among points forming aregular orthogonal grid in ahypercube an example, ( ) 21,0,0=δ corresponds to unit distance from 1 π along the first dimension. However, the same type of vector can also be placed along the remaining two dimensions ( ( ) 0,1, 0 and ( ) 0,0,1 ), because we consider the metric to be isotropic. Basically, one has to count the number of different arrangements of indexes ,tv δ , some of which might be identical. In other words, one has to count the number of permutations with repetition: var var 1 ,0 ,1 , 1 , p 0 !! !! ! ! N t t tN k t t k NN nn n n n− − = =   =⋅ ∏  , (17) where ,tk n are the numbers of repetitions of index differences k in vector t δ . These numbers of repetitions can be counted as: ( ) var ,, 1 tk tv v N nk = = δ− ∑ 1 , (18) where ()x1 is an indicator function returning one if there is a match, i.e. arepetition ( 0x= ). Otherwise ( 0x≠ ), the indicator function returns zero. To explain how the formula works, we return to the example of vector ( ) 21,0,0=δ . The total number of permutations of these three index differences is var !N , see the numerator in Eqn(17). However, since the zero difference is featured more than once, some arrangements in the permutations are identical. In particular, the zero difference is repeated twice and therefore one has to consider that permutations with repetition only count for different arrangements. The numerator in Eqn(17) must be divided by the numbers of arrangements of indistinguishable differences. One has to go through the list of all possible index differences, {0,1, , 1}kN∈ …− , that can occur in t δ and count the number of occurrences for each k . In this example, the zero difference yielding 2,0 2n= is featured twice, the unit difference ( 2,1 1n= ) once and an index difference of two or higher ( 2,2 2,3 2,4 0nnn= = = ) zero times. Therefore, the denominator reads 2! 1! 0! 0! 0! 2⋅⋅⋅⋅= . Finally, the number of distinguishable arrangements of ( ) 21,0,0=δ is therefore p 23!/2 3n= = , see Table1. Figure3 (left) illustrates that ( ) 11 3,2=δ a2D design has the same distance from 1 π as avector ( ) 2,3 , so that p 11 2n= . Figure 3. Illustration of the three types of transformation corresponding to p t n , d t n and n t n for agrid with 5N= and var 2N= 2.2. Number of space diagonals ( r -agonals) d t n The second coefficient, d t n , corresponds to the number of reflections of each vector type, t δ . The vector t δ forms aspace diagonal ( r -agonal, i.e. the longest diagonal) of a hyperrectangle (sometimes called an n -orthotope or just a box). The dimension of such a diagonal t δ can be quantified as the number of nonzero index differences: ( ) var , 1 tt N v v r = = δ ∑1 , var 1t rN≤≤ , (19) Table 1. Enumeration of all vectors t δ with their corresponding numbers t n and the associated lengths in a unit hypercube for a3D grid ( var 3N= ) with 5N= points along each dimension t t δ p t n d t n n t n t n ( ) 2 t NL⋅ ( ) 2 t NL⋅ 1(0, 0, 0) – – – – – – 2(1, 0, 0) 3 1 100 300 1 1 3(2, 0, 0) 3 1 75 225 4 4 4(3, 0, 0) 3 1 50 150 9 4 5(4, 0, 0) 3 1 25 75 16 1 6(1, 1, 0) 3 2 80 480 2 2 7(2, 1, 0) 6 2 60 720 5 5 8(3, 1, 0) 6 2 40 480 10 5 9(4, 1, 0) 6 2 20 240 17 2 10 (2, 2, 0) 3 2 45 270 8 8 11 (3, 2, 0) 6 2 30 360 13 8 12 (4, 2, 0) 6 2 15 180 20 5 13 (3, 3, 0) 3 2 20 120 18 8 14 (4, 3, 0) 6 2 10 120 25 5 15 (4, 4, 0) 3 2 5 30 32 2 16 (1, 1, 1) 1 4 64 256 3 3 17 (2, 1, 1) 3 4 48 576 6 6 18 (3, 1, 1) 3 4 32 384 11 6 19 (4, 1, 1) 3 4 16 192 18 3 20 (2, 2, 1) 3 4 36 432 9 9 21 (3, 2, 1) 6 4 24 576 14 9 22 (4, 2, 1) 6 4 12 288 21 6 23 (3, 3, 1) 3 4 16 192 19 9 24 (4, 3, 1) 6 4 8 192 26 6 25 (4, 4, 1) 3 4 4 48 33 3 26 (2, 2, 2) 1 4 27 108 12 12 27 (3, 2, 2) 3 4 18 216 17 12 28 (4, 2, 2) 3 4 9 108 24 9 29 (3, 3, 2) 3 4 12 144 22 12 30 (4, 3, 2) 6 4 6 144 29 9 31 (4, 4, 2) 3 4 3 36 36 6 32 (3, 3, 3) 1 4 8 32 27 12 33 (4, 3, 3) 3 4 4 48 34 9 34 (4, 4, 3) 3 4 2 24 41 6 35 (4, 4, 4) 1 4 1 4 48 3 Journal of Civil Engineering and Management, 2018, 24(5): 410–423 415 where ()x1 is an indicator function returning one for nonzero integer differences ,iv δ and zero otherwise. For a given dimension, t r , the number of various space diagonals in a hyper-rectangle is: 1 d2 t r t n− = . (20) For example, the number of space diagonals for vectors 6 (1,1,0)=δ and 7 (2,1,0)=δ forming diagonals of asquare/ rectangle is equal to dd 67 2rr= = and the number of triagonals in 3 dimensional space with vectors 16 (1,1,1)=δ or 17 (2,1,1)=δ (cube/cuboid) is dd 16 17 4nn= = . Figure 3 (centre) illustrates that a two-dimensional vector ( ) 11 3,2=δ is one of two possible diagonals in the same rectangle, so that of d 11 2n= . 2.3. Number of hyperrectangles n t n The last coefficient, n t n , corresponds to all possible translations of a “sub-hyperrectangle” within the hypercube. The coefficient is a product of the numbers of ways to translate the hyperrectangle along each dimension: ( ) var n, 1 t tv N v nN = = −δ ∏ . (21) The vector ( ) 11 3,2=δ featured in Figure3 (left and centre) is shown to have n 11 6n= possible placements within the square shown in Figure3(right). 2.4. Histogram of pairwise distances Equations (14) and (15) enable the evaluation of all pairwise distances (vector types t δ ) and their counts, t n , in an ROG. We note that the list of vectors t δ may not represent the list of unique pairwise distances. The reason is that the sum of the squared projections of several different vectors t δ may be the same, see e.g. vectors 4 δ and 20 δ in Table1. To obtain the most highly condensed list of different lengths and their frequencies possible, we propose sorting the vectors according to length and grouping the identical ones. The numbers of unique distances are plotted by green lines in Figure4(left). In Figure5, histograms of all distances L , squared distances 2 L and distances raised to the power var 1N+ are presented for various dimensions var N . The reason for presenting var 1N L+ will become clear in Section4. These histograms were obtained for ahigh number of points, sim N . Figure 4. Left: number of pairwise distances. The number of all pairs, p N , (black line) is compared with the number c N of vectors t δ (blue lines) and the number of unique distances u N (green line). The red dashed lines show the approximated formula sim var /!NN from Eqn (13); Right: computing times (black/blue lines). The enumeration of all p N pairwise distances takes much longer than the enumeration of c N distance pairs and their counts. The red dashed lines show Eqns (26) and (27) Figure 5. Probability density functions (histograms) of arandom pairwise distance (left), squared distance (middle) and a distance raised to var 1N+ (right) in ahypercube of dimension var N . The red lines are the exact density functions for a random pair of points 416 V. Sadílek et al. Evaluation of pairwise distances among points forming aregular orthogonal grid in ahypercube When the number of points grows high ( sim N→∞ ), the average distances between two points can be seen as the distance between two points chosen at random inside a unit hypercube. The solution is trivial for var 1N= ( E 1/3L=   ). For var 2N= , the mean distance reads ( ) ( ) 2 2 /15 ln 1 2 /3 0.521405434+ ++ ≈ . This number is a known constant available in the On-Line Encyclopedia of Integer Sequences (OEIS), which is published electronically at https://oeis.org, 2010, Sequence “A091505” (OEIS 2010). Its explicit expression has already been provided by Ghosh (1951). For var 3N= , the mean distance reads ( ) ( ) 4 17 2 2 3 ln 1 2 /5 2ln 2 3 /5 105 15 35 +π −− + + + + ≈ 0.661707181 . This average distance is known as the Robbins constant (Robbins, Bolis 1978), which is available in the OEIS as Sequence “A073012” (OEIS 2010). Average distances are available for dimensions var 4,5,6,7N= and 8 in the OEIS as Sequences “A103983, A103984, A103985, A103986 and A103987” (OEIS 2010). They read 0.7776656535, 0.8785309152, 0.9689420830, 1.0515838734 and 1.1281653402, respectively (see also Bailey et al. 2007; Weisstein n.d.). Table1 in Anderssen etal. (1976) provides approximate values for var 9N= and 10: 1.19985 and 1.26748. The distributions of distances L for increasing dimension var N tend towards Gaussian distribution. Anderssen etal. (1976) provided bounds for the average distance D depending on the dimension, var N : var var var 13 E 1 21 3 63 5 L NN N  ≤ ≤ +−      . (22) We have found atighter upper bound on the mean value that possesses correct asymptotic properties: EL   tends towards var /6N as var N→∞ . The suggested bound reads: var 1/3 E6 N L−    , (23) and provides an exact value for var 1N= ( 1 3 EL=   ). Gates (1985) derived an asymptotic formula: var var 2 var 7 65 E1 6 40 896 LN N N  ≈ − − +…      . (24) This formula is already very accurate for var 2N> . The variance for var 1N= reads simply D 1/18L=   . For higher var N , it is found within 1/16 and 1/18 and tends towards 7/120 as var N→∞ . From this analysis, it is clear that the Euclidean distance of two points picked randomly from aunit hypercube becomes virtually identical and deterministic in very high dimensions. The standard deviation stays approximately constant with increasing dimension var N while the mean value keeps growing. The coefficient of variation of arandom distance L is therefore asymptotically proportional to var 1/ N . In such a case the distance contrast decreases and it is said that the distances concentrate (Aggarwal etal. 2001; Flexer, Schnitzer 2015). This distance concentration in high-dimensional spaces might lead to undesired effects in some applications such as the optimization of the design of experiments (Audze, Eglãjs 1977; Eliáš, Vořechovský 2016). The squared distance, 2 L , has a trivial mean value, var /6N , and variance, var 7 /180N . The central limit theorem tells us that the square of the distance is almost normally distributed for large var N . 3. Speed-up and implementation details The proposed algorithm delivers the list of pairwise distances and their counts quicker than anaïve approach that simply evaluates the distances for all pairs of points. The reason for this is that the number of vector types in an ROG is considerably smaller than the number of all pairs. The ratio between the number of pairs among the sim N points in the unit hypercube, p N (see Eqn(8)), and the number of unique type vectors, c N (Eqns(11), (12)), provides ahint about the speed-up associated with using the proposed methodology. Asymptotically the ratio reads: ( ) ( ) var var var si p c m !! 11 22 N NN NN N N= −= − . (25) We have implemented both the naïve approach and the suggested approach in C language and the computing times for various sim N and var N have been measured. Figure4 (right) displays the computing time of the naïve approach, ( ) p tN , and the time taken by the suggested approach, ( ) c tN . It is no surprise that the times taken by the naïve approach are proportional to the number of pairs, p N . The measured times are almost completely independent of the dimension, var N , and the following formula provides an excellent approximation of the time in seconds: 1 2 p p 1 sim () 2 C tN N C N= ⋅≈ ⋅ , (26) where the constant 1 C has been obtained by fitting the times measured with our hardware (Intel Core i7-860 2.8GHz) as 9 17 10C− = ⋅ [sec]. The computing times obtained with the proposed algorithm seem to be proportional to the number of vectors processed, c N , and they also depend linearly on the dimension: c c var 2 ()tN NN C= ⋅ . (27) The constant 8 21.5 10C− = ⋅ [sec] has been obtained by fitting the times measured using the same hardware and compiler as for the naïve algorithm. By using the lower bound from Eqn(13) one can conclude that the computing time is asymptotically linear in sim N : ( ) s2 im c var () 1! N NN tC= ⋅ − , (28) see the triangles in Figure4 (right), while p N is quadratic in sim N . For high sim N and var N , the speed-up is dramatic: Journal of Civil Engineering and Management, 2018, 24(5): 410–423 417 ( ) p var sim c () 1 ! 0. ( 2 ) tN NN tN ≈− ⋅ . (29) The ratio between these two numbers increases very fast with an increasing number of simulations. The analysis deals with the evaluation of distances and does not take into account the preparation of input arrays of coordinates ij x or vector types i δ . The prototype of an implementation of afunction for the evaluation of pairwise distances and the number of their occurrences in a unit hypercube was made in Python programming language (van Rossum etal. 1991). The Python source code is presented in the Appendix. 4. Application As mentioned in the Introduction, one of the possible applications of the proposed method and algorithm is in the field of the optimal placement of points used in Monte Carlo integration, which is one possible application of the Design of Experiments. Monte Carlo sampling is the most general technique for estimation of probabilistic integrals, such as those representing the statistical moments of functions of random variables (e.g. Kala etal. 2017; Strauss etal. 2017; Vahdatirad etal. 2015), sensitivity analyses or reliability analyses (see e.g. Kong etal. 2013; Liao etal. 2015). Monte Carlo integration approximates an integral of afunction f as an average: ( ) ( ) sim var 1 0, sim 1 1 d N N i i fNf =   ≈ ∑ ∫xx x , (30) where sim 1 { ,, } N …xx is aset of points in the design space var 0,1 N   (aspace of sampling probabilities). These points can be transformed into points in real space, where the function is evaluated. The ratio sim 1/N is a weight that is supposed to be identical for all points as their chance of being selected is supposed to be equal. Therefore, the points must be uniformly distributed throughout the unit hypercube. The way of selecting individual points from the design domain influences the quality of the approximation. According to Koksma-Hlawka inequality (Fang, Ma 2001; Niederreiter 1992), the error of such an approximation depends on the character of the examined function (its bounded variation, ( ) Vf ) and the star discrepancy of the set of integration points, ( ) sim sim *1 , , NN D…xx : ( ) ( ) ( ) ( ) sim var sim sim 10 sim ,1 *1 1d ,, . N N NN i i N ff Vf D =  −≤ ⋅… ∑∫ x xx xx (31) As the character of the examined function is not under the analyst’s control, the only way to decrease the upper bound of the approximation error is to reduce the discrepancy of the set sim 1 { ,, } N …xx . Therefore, uniform designs are sought. These can be obtained by optimizing an originally random design (either Monte Carlo or Latin Hypercube Sampling) using various optimality criteria, either some type of discrepancy criterion or some other criterion aimed at ensuring the uniformity of the final design. The latter type of criterion is usually based on distances between pairs of points in the design domain (traditionally the inter-site distances are considered). Avery general example of such acriterion is the φ criterion. This criterion was first defined by Morris and Mitchell (1995), see also Damblin etal. (2013), Pronzato and Müller (2012): sim 1 ,1 p p ij ij N ij L− = … <    φ=   ∑ , (32) ij L being the inter-site Euclidean distance of points i and j defined by Eqn(7). Alimit case of the φ criterion for p→∞ is the Maximin criterion (Johnson etal. 1990) (sometimes called the mindist criterion): sim Mm ,1 min ij ij N ij L = … ≠ φ= . (33) The value of this criterion must be maximized to obtain a better design. Aspecific case of the φ criterion, in which 2p= , is the Audze-Eglãjs (AE) criterion defined earlier in Audze and Eglãjs (1977) as: sim sim p AE 2 11 11 ij ij NN i EL N= = + =∑∑ . (34) The use of this criterion has been presented in, e.g., Bates etal. (2003), Fuerle and Sienz (2011), Husslage etal. (2011), Janouchová and Kučerová (2013), Kovalovs and Rucevskis (2011), Liefvendahl and Stocki (2006), Vu etal. (2014). Note that the original formulation of the criterion does not feature standardization by the number of pairs considered (division by p N ). Animproved version of the AE criterion, called the Periodic Audze-Eglãjs (PAE) criterion, has recently been published in Eliáš and Vořechovský (2016). It removes a major flaw of the standard AE criterion related to the presence of boundaries: sim sim p PAE 2 11 11 ij i ji NN N EL = = + = ∑∑ , (35) here: ij L is not the Euclidean distance of points in the design space, but adistance redefined as the distance between point i and the nearest image of point j in aperiodically extended space. Taking the nearest distance corresponds to folding and gluing the design domain var N times – compare L and L in Figure6. The new definition of this length (modification of Eqn(7)) stands: ( ) var 2 2,, 1 min ,1 ij ij v ij v v N L =  = ∆ −∆  ∑ , (36) 418 V. Sadílek et al. Evaluation of pairwise distances among points forming aregular orthogonal grid in ahypercube where the projected distance along direction v reads ,,, || ijv iv jv xx∆= − . (37) This distance may also be defined in terms of δ in asimilar manner as to δ as presented in Eqn(7), then: var 22 , 21 1 ij ij v v N LN= = δ ∑ , (38) where: ( ) ( ) , min , for even min , 1 for odd ij v NN NN δ −δ  δ= δ −δ−   . (39) The rightmost column in Table1presents the shortest squared distances 2 ij L in aperiodic space (multiplied by 2 N ). These can be directly compared with the standard squared inter-site distances 2 ij L used in the AE criterion. The proposed algorithm for the evaluation of pairwise distances can be used without any modification. However, to get a list of unique distances in aperiodic space, the list of distances must be sorted according to the periodic length and some vector types must be merged as they become identical to others. The number of unique periodic distances in aperiodic space is roughly one half of the standard distances in ahypercube. The modified formulation of AE and PAE criteria (Eqns(34) and (35)) can be viewed as the computation of the average inverse squared distance 2 1/ ij L (or 2 1/ ij L). The convergence of the average distance measures is studied for the orthogonal grid in Figure7 (bottom left). We argue that this criterion, which can also be understood as the potential energy of a system of charged particles (Eliáš, Vořechovský 2016), changes its character for various dimensions var N and also for various numbers of points, sim N . In a1D situation, the energy tends towards infinity linearly with increasing point count sim NN= . In 2D ( var 2N= ), the energy tends towards infinity as ( ) sim ln N . Such a divergence is not a power law and therefore various sample sizes may yield dissimilar optimal patterns (self-similarity would be manifested through a power law dependence of the criterion on the point count). For 3D and higher var N , the energy tends towards a constant for increasing sim N , see Figure7 (bottom left). This means that for a given var 1N> , ahigher number of points yields adifferent proportion between the long-range and shortrange interactions. This may not be desirable behaviour as the criterion in high dimensions and also for ahigh number of points becomes insensitive to local clusters of points: it becomes dominated by long-range interactions. Therefore, we also consider a modification of the criterion where the inverse distances are raised to a power that might be dependent on the problem dimension, var N . The definition of such a criterion is analogous to the φ criterion but we suggest a reason for the selection of the distance power, p : sim sim p AEp n 11 11 p i ji i N j N N E L = = + =∑∑ , (40) and equivalently, the periodic version: sim sim PAEp n 11 p 11 p i ji ij NN E L N= = + =∑∑ . (41) It is suggested that the power be at least var 1pN= + . Why? With this power, the interaction is dominated by short-range forces. The convergence of the potential energy AEp n E , or better PAEp n E , towards infinity for a uniform distribution of points is a power law. Such a convergence signalizes the self-similarity of the problem (the absence of a length scale). In other words, a zoom into asufficiently representative subdomain has all the features of the full design and the energy value can be easily scaled from the value corresponding to the smaller zoom. This can be shown by studying the behaviour of the radial part of the integral of the potential over the volume V of an var N dimensional domain. The potential energy for a uniform design reads: var var 1d N N p IV L =∫ . (42) After transformation into polar coordinates, one writes: var var 11 dd N p N I VJ L L − = ϕ ∫, (43) where J is the Jacobian. The volume element is thereby given as: ( ) var var var var 2 11 1 d d d sin ii i N NN N VL L − − −− = = ⋅ϕ ϕ ∏ . (44) Therefore, the integral is performed over the product var 1Np L −− . Performing just the radial integration leads to var 1 d N rp L IL L − = ∫ . (45) Figure 6. Illustration of the modified metric (periodic distance L ) in the var N times “folded & glued” 2D design domain