
NAplot manualThis program reads the results of program nab and plots various Bayesian measures of information (marginals, posterior covariance matrices, resolution kernels etc) calculated by nab and written to the file nab.out. It will read up to two nab.out files and plot the results next to each other. The usual situation would be that one file is the result of running nab on a posterior and the other on a prior.
Type of plot:
(read in from subdirectory `plot'). Below is the syntax for each type of plot and a set of examples that can be run on the demo results files provided in the package.
Input files:
output file for posterior. (must be present)
nab_prior  file name read in from command line (see examples)
and contains nab
pal.in  defines colour of pens in RGB (must be present).
model.ref  defines a reference model to be plotted on marginals
and convergence plot.
confidence_cont  percentage confidence contours to plot on top
of 2D marginal distributions.
inv_prior_cov.matrix  contains inverse prior covariance matrix.
naplot.cmd  contains various plot options to change appearance of
plots (optional file).
finetune  contains increments for moving axis labels and tick
marks for a postscript plot (i.e. finetuning). (Optional file).
resolution.matrix  contains values of resolution matrix calculated and plotted by naplot. All file, except nab_post and nab_prior , are either read from, or written to, the subdirectory plot
Plotting 1D marginals of the posterior probability distribution (PPD)
Calling sequence
plottype = `1dmarg' to activate. n = number of plots to be taken from input files filename_post = name of file containing posterior filename_prior = name of file containing prior (optional argument)
r = rescale all plots to the same maximum amplitude.
f = add an annotated frame around each panel.
fn = add an annotated frame around each panel but remove title
above each panel.
n = no annotated frame and no titles. If options f or fn are used and annotation details are not specified in file plot/naplot.cmd then only a simple frame is plotted. If r and f are used then they must be given in the order `r f' and not in the order `f r'. Note: Order of marginals in posterior and prior files must be the same. Shading is performed with pen 6. Prior marginal is plotted with pen 4, and reference value is drawn with pen 3. Order of plots can be changed by using input file naplot.cmd (see examples below).
Plotting 2D marginals of the posterior probability distribution (PPD)
Calling sequence
plottype = `2dmarg' to activate. r = rescale all contour plots to same maximum amplitude (colour) scale. (The default is to choose colour scale so that all panels are on the same amplitude/colour scale, which allows direct comparison of amplitudes between plots.) If prior/posterior pairs are plotted then they are always plotted on the same scale.
f = add an annotated frame around each panel.
fn = add an annotated frame around each panel and remove title
above each panel.
n = no annotated frame and no titles.
All other arguments as for `1dmarg' case. Note: Order of marginals in posterior and prior files must be the same. Contour shading is performed with pens 1119 read in from file pal.in. Order of plots can be changed by using input file naplot.cmd (see examples below). Note that if r option is used then all panels are amplitude normalized. In this case each panel has a different mapping between PDF value and gray scale, but each maximum amplitude contour will always be black. The default (no r) is to choose gray scale so that all panels are on the same scale, hence a single mapping between value and gray scale for all panels. Now only the highest amplitude of all panels plotted will be black and the smallest amplitude of all panels will be white, and this defines the single colour scale for all panels. Note that if different panels are plotted the scale may change. If prior/posterior pairs are plotted then it only makes sense to plot them on the same amplitude scale and so in this case and the r option does not affect their relative amplitudes. So in short the r option gives maximum contrast within each panel, so you can see the contours, and the default allows true comparison between different panels, which one would normally like to do, darker then means more probability, higher amplitude. Plotting confidence contours
If the file plot/confidence_cont is not present, or has a zero for the number of contours then no confidence contours are plotted. Confidence contours are not plotted on prior PDFs. Here is an example showing the 60%,90%,99%, using the full annotated frame feature, for the receiver function example problem.
Plotting the posterior Correlation matrix
Calling sequence
plottype = `cor' to activate. n = number of variables to be plotted in correlation matrix filename_post = name of input file containing posterior (or prior)
t5 = plot tick marks on matrix every
5 columns and rows. p = input file contains prior distribution and so plot labels are amended accordingly (otherwise posterior is assumed). e0.2 = plot numerical error in estimated correlation matrix rather than the matrix itself and scale error range by a factor of 0.2. (Similarly for any other value) Note: shading is performed with pens 4157 read in from file pal.in. Order of columns and rows can be changed by using input file naplot.cmd (see examples below).
Plotting the posterior Covariance matrix
Calling sequence
plottype = `cov' to activate. n = number of variables to be plotted in correlation matrix filename_post = name of input file containing posterior (or prior)
t5 = plot tick marks on matrix every
5 columns and rows. p = input file contains prior distribution and so plot labels are amended accordingly (otherwise posterior is assumed). e0.2 = plot numerical error in estimated covariance matrix rather than the matrix itself and scale error range by a factor of 0.2. (Similarly for any other value) Note: shading is performed with pens 4157 read in from file pal.in. Order of columns and rows can be changed by using input file naplot.cmd (see examples below).
Plotting the Resolution matrix
Calling sequence
plottype = `res' to activate. filename_post = name of file containing posterior filename_prior = name of file containing prior (optional). If this argument is not present then the inverse prior covariance matrix is read in from file `plot/inv_prior_cov.matrix'. u = plot normal resolution matrix. The default is to plot the nondimensional resolution matrix.
t5 = plot tick marks on matrix
every 5 columns and rows. Note: that off diagonal elements of the normal resolution matrix will depend on dimensional units if more than one variable type is present. The `nondimensional' resolution matrix is a rescaled version of the resolution matrix formed by taking the element in the ith row and jth column and multiplying by the factor sigma_j/sigma_i, where sigma_i is the square root of the ith element on the diagonal of the prior covariance matrix.
Plotting Resolving kernels
Calling sequence
plottype = `reskern' to activate. filename_post = name of file containing posterior n = number of variables to be plotted in resolution matrix (maximum = number of variables) filename_posterior = name of file containing posterior filename_prior = filename of file containing prior (optional). If this argument is not present then the inverse prior covariance matrix is assumed to be in file `inv_prior_cov.matrix'. c = plot columns of the resolution matrix The default is to plot rows. u = plot unnormalized resolution matrix. The default is to plot a `nondimensional' resolution matrix.
Plotting the convergence of integrals as a function of sample size
Calling sequence
plottype = `conv' to activate. n = number of plots to be taken from input files filename_post = name of file containing posterior
s20 = scale numerical integration error box
by a factor of 20 (makes it more visible).
ExamplesHere are examples of how to call each plot type with various options. Go to the directory data/utl/naplot where an example prior and posterior can be plotted. (These are both nab.out files.) For more details examine the command file naplot.cmd in the subdirectory plot. More examples can be found in the the file data/utl/naplot/examples. 1D Marginal distributions:
Plot 24 variables and normalize to same maximum amplitude,
Use annotated frame (specified in plot/naplot.cmd),
Use zoom feature (specified in plot/naplot.cmd),
naplotx 1dmarg 6 nab_post nab_prior f cp plot/naplot.cmd_full plot/naplot.cmd
Change order of first 4 variables to (1,7,13,19) (Requires entry in naplot.cmd='1 4 1 7 13 19'),
If Prior/posterior pairs are plotted they are always area normalized. Plot 2D posterior and prior marginals for first 6 pairs of variables in input files,
Same as above but normalize all shading to the same maximum amplitude,
Plot first 12 2D marginals, on same shading scale, and add a full annotated frame,
Use zoom feature to plot subsections of first 6 2D marginals,
naplotx 2dmarg 6 nab_post f cp plot/naplot.cmd_full plot/naplot.cmd
Plot 2D posterior and prior marginals for 5th 2D marginal in input files
Prior/posterior pairs always have same shading scale. Plot correlation matrix for first 24 variables, with tick marks every 6th row and column,
36 variables,
Correlation matrix for 12x12 submatrix (parameters 112)
Correlation matrix for 12x12 submatrix (parameters 1324) (Requires line in naplot.cmd='1 12 12,14,15,...,24)
Plot error in correlation matrix for first 24 variables with error range multiplied by a scale factor of 0.2,
Plot prior correlation matrix for 36 variables,
Covariance matrix for 12x12 submatrix (112)
Plot error in Covariance matrix for first 24 variables with a scale factor of 0.2
Note order of variables can be changed in naplot.cmd.
Nondimensional resolution matrix for first 24 variables (Uses prior covariance read in from file `inv_prior_cov.matrix')
As above but resolution matrix,
Nondimensional resolution matrix for first 24 variables with prior covariance taken from nab_prior
Resolution matrix 12x12 submatrix for variables 718.
Plot rows of the nondimensional resolution matrix for first 24 variables,
columns of the nondimensional resolution matrix for first 12 variables,
Same as above but for variables (1924)
Plot columns of the resolution matrix for first 6 variables
Note order of variables can be changed in naplot.cmd. Convergence of numerical error in expectation integrals Plot integration error in expectation integrals for first 24 variables with error boxes ampilified by a 20,
Same as above but for 6 variables (1924)
Related sites: References:
Geophysical Inversion with a Neighbourhood Algorithm I: searching
a parameter space, A related paper describes the Neighbourhood resampling algorithm (implemented in program nab) for calculating Bayesian integrals from a finite set of samples produced by the NA algorithm or any other search method (e.g. GA or SA etc.).
Geophysical Inversion with a Neighbourhood Algorithm II: appraising
the ensemble, Postscript and PDF files of these papers can be downloaded from the NA homepage. Enquires to Malcolm Sambridge: malcolm@rses.anu.edu.au 