A Generalized Residual Technique For

A Generalized Residual Technique For

1 1 Supporting material for `A generalized residual technique for 2 analysing complex movement models using earth mover's 3 distance' 1;a 1;2;b 3;4;c 1;2;d 4 Jonathan R. Potts , Marie Auger-M´eth´e Karl Mokross Mark A. Lewis 5 1 Centre for Mathematical Biology, Department of Mathematical and Statistical Sciences, 6 University of Alberta, Canada 7 2 Department of Biological Sciences, University of Alberta, Edmonton, Canada 8 3 School of Renewable Natural Resources, Louisiana State University Agricultural Center, 9 Baton Rouge, Louisiana, 70803 10 4 Projeto Din^amicaBiol´ogica de Fragmentos Florestais. INPA. Av. Andr´eAra´ujo2936. 11 Petr´opolis. Manaus. Brazil. 69083-000 12 a E-mail: [email protected]. Centre for Mathematical Biology, Department of Mathematical 13 and Statistical Sciences, 632 CAB, University of Alberta, Canada, T6G 2G1. Tel: 14 +1-780-492-1636. 15 b E-mail: [email protected] 16 c E-mail: [email protected]. 17 d E-mail: [email protected]. 18 Appendix A: Instructions for running code 19 Running simulations 20 Simulations are coded in C, but can be run from within R (explained below). The file dfr.exe 21 is ready to work on a Windows 64 bit computer. Users of 32 bit Windows operating systems 22 should replace this file with dfr32.exe. Mac users should replace this file with dfr mac. They 23 should also replace all the *.txt files with the *.txtm versions (txtm stands for text-Mac) 24 included in the SI. Users of other operating systems (e.g. Linux) will have to compile the 25 source code themselves, which consists of all the attached *.c and *.h files. Linux/Unix 26 versions of the text files are called *.txtu (text-Unix) rather than *.txt. 2 27 The programme dfr.exe enables the user to simulate paths in an environment with two layers 28 that affect the movement as per Equation (8) in the main text. The user needs to construct 29 these layers in advance of running the programme. Each layer should be saved as a plain text 30 file with tabs separating the x-values and carriage returns separating the y-values. Examples 31 are given in random field scale 10.txt and random field scale 1000.txt. The former 32 described Layer 1 from the main text and the latter Layer 2. 33 The user also needs to construct a file denoting the environment-free jump distribution as a grid. 34 The file dfr jump probs exp5.txt provides an example of this. To aid construction, we provide 35 both and R script dfr weibull to table.R and a Python script dfr weibull to table.py, 36 which turns a Weibull distribution (a generalisation of the exponential distribution) to a grid 37 useable for dfr.exe. To construct this using the R script, type the following into the R terminal 38 source("dfr weibull to table.R") 39 The shape and scale parameters (weibull a and weibull b), together with the size of the 40 jump array (array size x by array size y) and the lattice spacing (lattice spacing) can 41 be modified in the script. 42 For Python users, go to the DOS command line or Unix/Mac/Linux terminal and type the 43 following 44 python dfr weibull to table.py shape scale x y l > dfr jump probs exp5.txt 45 where shape should be replaced with the Weibull shape parameter (e.g. 1 in the case in the 46 paper), scale with the scale parameter (e.g. 5), x and y with the width and height (e.g. 79), 47 respectively, of the jump distribution grid (outside this grid the jump probabilities are zero, to 48 aid computational speed), and l with the distance between adjacent grid points in the layers 49 (e.g. 1). 3 50 Finally, it is necessary to construct a file detailing the start positions of the simulated animals, 51 which is a list of x- and y-values of the start positions with x in the left column and y in the 52 right, as in dfr start pos random.txt. 53 We first explain how to use the DOS command line or Unix/Mac/Linux terminal to perform 54 example simulations, which is the recommended method if you are familiar with command line 55 invocations. Then we explain how to do the same using R. 56 Using the command line/terminal. The following command will print out the positions 57 of 100 different individuals, each performing 1000 steps according to the model in Eqn 4 of the 58 main text, with α = 1:5, β = 10. 59 dfr -l1 random field scale 10.txt -l2 random field scale 1000.txt -spf 60 dfr start pos random.txt -jpf dfr jump probs exp5.txt -l1w 1.5 -l2w 10 -kv 0 61 -i 100 -ts 1000 -bw 1000 -bh 1000 -jpw 40 -jph 40 > dfr.txt 62 The output of this simulation, which takes a couple of minutes to run, is found in dfr.txt. 63 Typing dfr with no parameters gives a usage statement, as follows, which explains how to 64 make general use of this programme. 65 Usage: dfr.exe [-l1 <layer-1>] 66 [-l2 <layer-2>] 67 [-jpf <jump-prob-file>] 68 [-l1w <layer-1-weight>] 69 [-l2w <layer-2-weight>] 70 [-kv <k-val-for-von-Mises>] 71 [-i <number-of-indivs>] 72 [-spf <start-position-file>] 73 [-ts <number-of-timesteps>] 74 [-bw <box-width>] 4 75 [-bh <box-height>] 76 [-jpw <jump-prob-array-width>] 77 [-jph <jump-prob-array-height>] 78 The parameter k is for using correlated random walks. It is the sole parameter of a von Mises 79 distribution with mean 0, and gives the distribution of the turning angles between successive 80 steps. 81 The user is encouraged to adapt the source code to make it useable for other scenarios (more 82 layers, individual interactions etc.). However, when doing this, the authors kindly request that 83 the user makes the code generally available and keeps the lead author informed of where it can 84 be found. This will enable an ad hoc open source situation to evolve. 85 Using R. The following command will print out the positions of 100 different individuals, each 86 performing 1000 steps according to the model in Eqn 4 of the main text, with α = 1:5, β = 10. 87 x=system("dfr -l1 random field scale 10.txt -l2 random field scale 1000.txt 88 -spf dfr start pos random.txt -jpf dfr jump probs exp5.txt -l1w 1.5 -l2w 10 89 -kv 0 -i 100 -ts 1000 -bw 1000 -bh 1000 -jpw 40 -jph 40", ignore.stderr=TRUE, 90 intern=TRUE) 91 This takes a couple of minutes to run. Now put the output into a text file called dfr.txt using 92 the following command 93 write.table(x, file="dfr.txt", quote=FALSE, row.names=FALSE, col.names=FALSE) 94 Typing system("dfr") gives a usage statement, as follows, which explains how to make general 95 use of this programme. 96 Usage: dfr.exe [-l1 <layer-1>] 97 [-l2 <layer-2>] 98 [-jpf <jump-prob-file>] 5 99 [-l1w <layer-1-weight>] 100 [-l2w <layer-2-weight>] 101 [-kv <k-val-for-von-Mises>] 102 [-i <number-of-indivs>] 103 [-spf <start-position-file>] 104 [-ts <number-of-timesteps>] 105 [-bw <box-width>] 106 [-bh <box-height>] 107 [-jpw <jump-prob-array-width>] 108 [-jph <jump-prob-array-height>] 109 The parameter k is for using correlated random walks. It is the sole parameter of a von Mises 110 distribution with mean 0, and gives the distribution of the turning angles between successive 111 steps. 112 Analysing data using EMD 113 In R, to find the EMDs between the each of the simulated data points in the file dfr.txt, 114 created above, and the model used to create it, use the dfr emm.R file. Users should feel free 115 to alter the values of pos file, layer1, layer2, jump prob, alpha, and betav. 116 Python users should instead run the following from the command line: 117 python dfr emm.py dfr.txt random field scale 10.txt random field scale 1000.txt 118 dfr jump probs exp5 py.txt 1.5 10 > dfr emm.txt 119 In general, the format of the input is as follows: 120 python dfr emm.py [positional-data] [layer-1] [layer-2] 121 [jump-probability-grid] α β > <output-file> 6 122 The output of either the Python or the R script is a file <output-file> with four columns. 123 The first is the EMD and the second is the standardised EMD. The third and fourth are the x- 124 and y-coordinates of the vector v^n from the main text (Eqn 5). This gives enough information 125 for the user to construct wagon wheels, dharma wheels and so forth. 126 Please feel free to email JRP for any questions regarding these instructions. 7 127 Appendix B: Generalizing the Earth Mover's Distance (EMD) 128 The Main Text takes a pedagogical approach to introducing the EMD. Here, we take a more 129 formal, mathematical approach, by introducing the Wasserstein Metric in its full generality 130 and then proving that it gives Equation (1) from the Main Text with the assumptions stated 131 therein. Let (Ω; d) be a measure space (Ambrosio, 2005). Let p be a strictly positive integer. Let µ and ν be two probability measures on M with finite p-th moment.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us