
This directory contains the supplementary material for the Evaluating
Spacing paper.  It has the following files:
  code_eval_spacing.R       script generating figures
  data/litds.rds            R database with literature samples
  data/bimodal.rds          R database with bi-modal variants
  data/unimodal.rds         R database with unimodal (uniform, normal) draws
  data/models.rds           R database with height/length quantiles
  gen_litds.R               script generating litds.rds
  gen_bimodal.R             script generating bimodal.rds
  gen_unimodal.R            script generating unimodal.rds

code_eval_spacing.R is meant to be sourced within an R session.  It can use
two top-level variables to control what it runs and produces; if they do
not exist then they are created and all figures will be generated.
  save.pdf if TRUE writes the figures to disk in PDF format, if FALSE
           it uses the screen (meant for debugging)
  analysis is a vector of names of the figures/analysis to perform.
           See the top of the script for a description.
Much of the work is plotting results that have already been generated in
the four data files - this script should run fairly quicklykk.  It
assumes the Dimodal library is already installed on the system; the
package can be found at www.primachvis.com/data/Dimodal_latest.tgz.
It also uses the library pracma for numeric integration and gtools for
its function sorting strings with embedded numbers.

The four data files store results that take a very long time to generate.
They can be read with the readRDS() function - see the code script how.
Each has a CONTENTS attribute that has a simple description of the
contents, with a full specification at the top of the scripts that create
them.

gen_litds.R numerically integrates the expected spacing of the 80-some
literature samples to find the modes, anti-modes, and rise, and then
runs repeated trials of each through Dimodal to get the peaks and flats
in both spacings, storing each in matrices.  The script uses the Dimodal,
pracma, and parallel libraries.  Just source the file and it will produce
litds.rds after half a day or so.

gen_bimodal.R defines the three bi-modal variants, changing the mean,
standard deviation, and draw size of the second normal.  It numerically
integrates the expected spacing for each to find the mode and anti-mode
positions and rise in Di between.  It then repeatedly samples each
variant, runs the draw through Dimodal to collect feature positions,
and also passes them through the four existing multi-modal tests presented
in the paper.  The number of trials defined at the top of the script
determine when the peaks, flats, changepoints, and existing tests are
run.  The script uses the Dimodal library, pracma and parallel for
numeric integration, and ditest, Rfolding, and multimode libraries for
the existing tests.  Each of the three variants will take a very long
time to run, up to a week; internally we hacked the script to run each
in parallel and manually combined the results into the final data.

gen_unimodal.R is similar to the bi-modal, except that draws are made
from one uniform or normal variant.  It uses the Dimodal, diptest,
Rfolding, and multimode libraries.  The run time is less than a day.

models.rds was produced by the development version of the work and that
code is not being released.  The data is a list with two elements,
'peaks' and 'flats'.  Each is an array with the Kaiser filter window
size in the first dimension, the draw size in the second, and the
quantile in the third.  The contents are the critical values for that
combination of parameters.


