Running examples in ‘PAWL-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: PAWL-package
> ### Title: PARALLEL ADAPTIVE WANG-LANDAU
> ### Aliases: PAWL-package PAWL
> ### Keywords: package
> 
> ### ** Examples
> 
>   demo(discreteexample)


	demo(discreteexample)
	---- ~~~~~~~~~~~~~~~

> #rm(list = ls())
> try(detach(package:PAWL, unload = TRUE), silent = TRUE)

> library(PAWL)

> ### toy example: the state space is made of three states
> # target distribution:
> targetpdf <- c(0.5, 0.4, 0.1)

> # target log probability:
> parameters <- list(logpi = log(targetpdf))

> logdensity <- function(x, parameters){
+     parameters$logpi[x]
+ }

> # we have to specify a proposal mechanism
> # for the Metropolis-Hastings kernel
> # since the (default) continuous
> # gaussian random walk cannot be used
> transitionmatrix <- t(matrix(c(0.5, 0.5, 0.0,
+                                0.3, 0.5, 0.2,
+                                0.0, 0.6, 0.4), ncol = 3))

> proposalparam <- list(transitionmatrix = transitionmatrix, card = 3)

> # function that generates proposal:
> rproposal <- function(states, proposalparam){
+     for (index in 1:length(states)){
+         states[index] <- sample(x = 1:proposalparam$card, 
+                                 size = 1, prob = proposalparam$transitionmatrix[states[index],])
+     }
+   return(list(states = states))
+ }

> # function to compute the density of the proposal kernel
> # (necessary to compute the acceptance rate)
> dproposal <- function(states, ys, proposalparam){
+     for (index in 1:(length(states))){
+         states[index] <- log(transitionmatrix[states[index], ys[index]])
+     }
+   return(states)
+ }

> proposalinstance <- proposal(rproposal = rproposal, 
+                              dproposal = dproposal, 
+                              proposalparam = proposalparam)
adaptiveproposal unspecified: set to FALSE
sigma_init unspecified: set 1

> # function to draw starting points for the MCMC algorithms:
> rinit <- function(size) return(rep(1, size))

> # define the target
> discretetarget <- target(name = "discrete toy example", dimension = 1, type = "discrete",
+                          rinit = rinit, logdensity = logdensity, parameters = parameters)
dinit has to be specified if you want to use SMC
> # specify Metropolis-Hastings tuning parameters:
> mhparameters <- tuningparameters(nchains = 1, niterations = 10000, storeall = TRUE)

> # Rprof(tmp <- tempfile())
> amhresults <- adaptiveMH(discretetarget, mhparameters, proposalinstance)
[1] "Launching Adaptive Metropolis-Hastings algorithm with parameters:"
Object of class tuningparameters.
*number of parallel chains: 1 
*number of iterations: 10000 
*compute mean: FALSE 
*compute mean (burnin): 0 
*save every nth iteration: 1 
saving every 1 iterations
hence saving a vector of size 10001 x 1 x 1 = 10001 
Iteration 200 / 10000 
Iteration 400 / 10000 
Iteration 600 / 10000 
Iteration 800 / 10000 
Iteration 1000 / 10000 
Iteration 1200 / 10000 
Iteration 1400 / 10000 
Iteration 1600 / 10000 
Iteration 1800 / 10000 
Iteration 2000 / 10000 
Iteration 2200 / 10000 
Iteration 2400 / 10000 
Iteration 2600 / 10000 
Iteration 2800 / 10000 
Iteration 3000 / 10000 
Iteration 3200 / 10000 
Iteration 3400 / 10000 
Iteration 3600 / 10000 
Iteration 3800 / 10000 
Iteration 4000 / 10000 
Iteration 4200 / 10000 
Iteration 4400 / 10000 
Iteration 4600 / 10000 
Iteration 4800 / 10000 
Iteration 5000 / 10000 
Iteration 5200 / 10000 
Iteration 5400 / 10000 
Iteration 5600 / 10000 
Iteration 5800 / 10000 
Iteration 6000 / 10000 
Iteration 6200 / 10000 
Iteration 6400 / 10000 
Iteration 6600 / 10000 
Iteration 6800 / 10000 
Iteration 7000 / 10000 
Iteration 7200 / 10000 
Iteration 7400 / 10000 
Iteration 7600 / 10000 
Iteration 7800 / 10000 
Iteration 8000 / 10000 
Iteration 8200 / 10000 
Iteration 8400 / 10000 
Iteration 8600 / 10000 
Iteration 8800 / 10000 
Iteration 9000 / 10000 
Iteration 9200 / 10000 
Iteration 9400 / 10000 
Iteration 9600 / 10000 
Iteration 9800 / 10000 
Iteration 10000 / 10000 

> # Rprof()
> # print(summaryRprof(tmp))
> # unlink(tmp)
> chains <- ConvertResults(amhresults)
[1] "converting chains before plotting..."
[1] "...done"

> cat("AMH: target probabilities:", targetpdf, "\n")
AMH: target probabilities: 0.5 0.4 0.1 

> amhcount <- tabulate(chains$X1, nbins = 3)

> cat("AMH: obtained frequencies:", amhcount / sum(amhcount), "\n")
AMH: obtained frequencies: 0.4830517 0.4107589 0.1061894 

> # we bin such that states 1 and 2 are in bin 1, and state 3 is in bin 2
> getPos <- function(points, logdensity) 2 - (points <= 2)

> # we further specify some parameters, like the bins,
> # the desired frequency in each bin...
> positionbinning <- binning(position = getPos,
+                             name = "position",
+                             bins = c(1, 2),
+                             desiredfreq = c(0.8, 0.2),
+                             useLearningRate = FALSE)
fhthreshold unspecified: set to 0.5 
splitThreshold unspecified: set to 0.1
minSimEffort unspecified: set 200
learningrate unspecified: set to x -> x^(-1)
useFH unspecified: set to FALSE 
autobinning unspecified: set to FALSE

> pawlresults <- pawl(discretetarget, binning = positionbinning, AP = mhparameters, proposalinstance)
[1] "Launching Particle Wang-Landau algorithm ..."
saving every 1 iterations
hence saving a vector of size 10001 x 1 x 1 = 10001 
iteration 200 / 10000 
iteration 400 / 10000 
iteration 600 / 10000 
iteration 800 / 10000 
iteration 1000 / 10000 
iteration 1200 / 10000 
iteration 1400 / 10000 
iteration 1600 / 10000 
iteration 1800 / 10000 
iteration 2000 / 10000 
iteration 2200 / 10000 
iteration 2400 / 10000 
iteration 2600 / 10000 
iteration 2800 / 10000 
iteration 3000 / 10000 
iteration 3200 / 10000 
iteration 3400 / 10000 
iteration 3600 / 10000 
iteration 3800 / 10000 
iteration 4000 / 10000 
iteration 4200 / 10000 
iteration 4400 / 10000 
iteration 4600 / 10000 
iteration 4800 / 10000 
iteration 5000 / 10000 
iteration 5200 / 10000 
iteration 5400 / 10000 
iteration 5600 / 10000 
iteration 5800 / 10000 
iteration 6000 / 10000 
iteration 6200 / 10000 
iteration 6400 / 10000 
iteration 6600 / 10000 
iteration 6800 / 10000 
iteration 7000 / 10000 
iteration 7200 / 10000 
iteration 7400 / 10000 
iteration 7600 / 10000 
iteration 7800 / 10000 
iteration 8000 / 10000 
iteration 8200 / 10000 
iteration 8400 / 10000 
iteration 8600 / 10000 
iteration 8800 / 10000 
iteration 9000 / 10000 
iteration 9200 / 10000 
iteration 9400 / 10000 
iteration 9600 / 10000 
iteration 9800 / 10000 
iteration 10000 / 10000 

> pawlchains <- ConvertResults(pawlresults)
[1] "converting chains before plotting..."
[1] "...done"

> cat("PAWL: desired frequencies:", positionbinning@desiredfreq, "\n")
PAWL: desired frequencies: 0.8 0.2 

> pawlcount <- tabulate(getPos(pawlchains$X1, pawlchains$logdens), nbins = 2)

> cat("PAWL: obtained frequencies:", pawlcount / sum(pawlcount), "\n")
PAWL: obtained frequencies: 0.80002 0.19998 

> # show the trace plot of log theta:
> #PlotLogTheta(pawlresults)
> 
> counts <- tabulate(pawlchains$X1, nbins = 3)

> counts <- counts[1:2]

> counts <- counts / sum(counts)

> cat("PAWL: obtained proportions inside bin 1:", counts, "\n")
PAWL: obtained proportions inside bin 1: 0.5384327 0.4615673 

> cat("PAWL: compared to:", targetpdf[1:2] / sum(targetpdf[1:2]), "\n")
PAWL: compared to: 0.5555556 0.4444444 
>   demo(gaussianexample)


	demo(gaussianexample)
	---- ~~~~~~~~~~~~~~~

> # remove all objects
> #graphics.off()
> #rm(list = ls())
> # try to detach the package if it was already loaded
> try(detach(package:PAWL, unload = TRUE), silent = TRUE)

> # load the package
> library(PAWL)

> # starting points for MCMC algorithms
> rinit <- function(size) rnorm(size)

> # target log density function: a gaussian distribution N(mean = 2, sd = 3)
> parameters <- list(mean = 2, sd = 3)

> logdensity <- function(x, parameters) dnorm(x, parameters$mean, parameters$sd, log = TRUE)

> # creating the target object
> gaussiantarget <- target(name = "gaussian", dimension = 1,
+                          rinit = rinit, logdensity = logdensity,
+                          parameters = parameters)
dinit has to be specified if you want to use SMC
> # setting a seed for the RNG
> set.seed(17)

> #######
> ## Adaptive Metropolis-Hastings
> #######
> #mhparameters <- tuningparameters(nchains = 10, niterations = 1000, storeall = TRUE)
> #amhresults <- adaptiveMH(gaussiantarget, mhparameters)
> #range(amhresults$alllogtarget)
> ## check that it's working
> #PlotHist(results = amhresults, component = 1)
> #curve(dnorm(x, mean = gaussiantarget@parameters$mean,
> #            sd = gaussiantarget@parameters$sd), add = TRUE, lwd = 2, col = "red")
> 
> 
> ######
> # Parallel Adaptive Wang-Landau
> ######
> N <- 10

> T <- 2000

> # here we disable the adaptive proposal to highlight the automatic binning
> # mechanism
> proposal <- createAdaptiveRandomWalkProposal(N, gaussiantarget@dimension,
+                                              adaptiveproposal = FALSE)
adaptationrate unspecified: set to x -> x^(-0.6)
sigma_init unspecified: set 1

> pawlparameters <- tuningparameters(nchains = N, niterations = T, storeall = TRUE)

> print(pawlparameters)
Object of class tuningparameters.
*number of parallel chains: 10 
*number of iterations: 2000 
*compute mean: FALSE 
*compute mean (burnin): 0 
*save every nth iteration: 1 

> #########
> # PAWL where we bin along the state space
> getPos <- function(points, logdensity) points

> ## we further specify some parameters, like the bins,
> ## the desired frequency in each bin
> ncuts <- 2

> positionbinning <- binning(position = getPos,
+                             name = "position",
+                             binrange = c(-20, -3),
+                             ncuts = ncuts,
+                             useLearningRate = TRUE,
+                             autobinning = TRUE)
desiredfreq unspecified: set to 1 / nbins for each bin
fhthreshold unspecified: set to 0.5 
splitThreshold unspecified: set to 0.1
minSimEffort unspecified: set 200
learningrate unspecified: set to x -> x^(-1)
useFH unspecified: set to TRUE 

> print(positionbinning)
Object of class binning.
*name: position 
*autobinning: TRUE 
*bins: -Inf -20 -3 
*Flat Histogram threshold: 0.5 
*split threshold: 0.1 
*use Flat Histogram criterion: TRUE 
*use learning rate: TRUE 
*min number of iterations between FH: 200 

> pawlresults <- pawl(gaussiantarget, binning = positionbinning, AP = pawlparameters,
+                     proposal = proposal)
[1] "Launching Particle Wang-Landau algorithm ..."
saving every 1 iterations
hence saving a vector of size 2001 x 10 x 1 = 20010 
iteration 100 / 2000 
/** diagnosis at iteration 100 
* current number of bins = 3 
desired freq - proportions:
 1 0.05841584 -1.058416 
* skewed bins: 2 
* bins with enough points to be split: 2 3 
* bins to split: 2 
*/
iteration 200 / 2000 
/** diagnosis at iteration 200 
* current number of bins = 4 
desired freq - proportions:
 1 1 -2.516 -0.242 
* skewed bins: 3 
* bins with enough points to be split: 3 4 
* bins to split: 3 
*/
iteration 300 / 2000 
/** diagnosis at iteration 300 
* current number of bins = 5 
desired freq - proportions:
 1 1 -0.308 -2.48 -0.803 
* skewed bins: 3 
* bins with enough points to be split: 3 4 5 
* bins to split: 3 
*/
iteration 400 / 2000 
/** diagnosis at iteration 400 
* current number of bins = 6 
desired freq - proportions:
 1 -0.374 -1.616 -2.768 -0.428 -0.158 
* skewed bins: 2 5 
* bins with enough points to be split: 2 3 4 5 6 
* bins to split: 2 
*/
iteration 500 / 2000 
/** diagnosis at iteration 500 
* current number of bins = 7 
desired freq - proportions:
 1 1 -4.46 -0.128 0.4 -0.884 0.052 
* skewed bins: 3 5 6 
* bins with enough points to be split: 3 6 7 
* bins to split: 3 
*/
iteration 600 / 2000 
/** diagnosis at iteration 600 
* current number of bins = 8 
desired freq - proportions:
 1 -4.088 -0.728 -1.496 1 1 0.076 0.031 
* skewed bins: 2 3 7 
* bins with enough points to be split: 2 4 8 
* bins to split: 2 
*/
iteration 700 / 2000 
/** diagnosis at iteration 700 
* current number of bins = 9 
desired freq - proportions:
 0.007 -0.824 -2.84 -0.536 -0.32 0.832 0.928 0.64 0.178 
* skewed bins: 2 4 5 7 
* bins with enough points to be split: 1 3 9 
*/
iteration 800 / 2000 
/** diagnosis at iteration 800 
* current number of bins = 9 
desired freq - proportions:
 -0.371 -0.188 -1.172 -0.008 -0.296 0.916 0.904 0.556 0.2125 
* skewed bins: 2 4 5 
* bins with enough points to be split: 1 3 5 9 
* bins to split: 5 
*/
iteration 900 / 2000 
/** diagnosis at iteration 900 
* current number of bins = 10 
desired freq - proportions:
 -1.1 1 -0.104 0.28 0.952 0.088 0.952 0.952 1 0.4 
* skewed bins: 3 5 6 8 
* bins with enough points to be split: 1 10 
*/
iteration 1000 / 2000 
/** diagnosis at iteration 1000 
* current number of bins = 10 
desired freq - proportions:
 -1.232 0.976 0.352 0.616 0.976 0.544 0.976 0.976 1 0.4 
* skewed bins: 2 5 6 8 
* bins with enough points to be split: 1 10 
*/
iteration 1100 / 2000 
/** diagnosis at iteration 1100 
* current number of bins = 10 
desired freq - proportions:
 -1.288 0.984 0.568 0.744 0.984 0.696 0.984 0.984 1 0.4 
* skewed bins: 2 5 6 8 
* bins with enough points to be split: 1 10 
*/
iteration 1200 / 2000 
/** diagnosis at iteration 1200 
* current number of bins = 10 
desired freq - proportions:
 -1.21175 0.256 0.61 0.772 0.988 0.772 0.988 0.988 1 0.4 
* skewed bins: 5 6 8 
* bins with enough points to be split: 1 2 10 
*/
iteration 1300 / 2000 
/** diagnosis at iteration 1300 
* current number of bins = 10 
desired freq - proportions:
 -1.0136 -0.1136 0.1312 0.2224 0.7024 0.6736 0.9904 0.9904 1 0.4 
* skewed bins: 3 6 8 
* bins with enough points to be split: 1 2 3 4 10 
*/
iteration 1400 / 2000 
/** diagnosis at iteration 1400 
* current number of bins = 10 
desired freq - proportions:
 -0.844 -0.188 -0.04 -0.012 0.224 0.128 0.896 0.988 0.936 0.3825 
* skewed bins: 8 
* bins with enough points to be split: 1 2 3 4 6 10 
*/
iteration 1500 / 2000 
/** diagnosis at iteration 1500 
* current number of bins = 10 
desired freq - proportions:
 -0.7318571 -0.2171429 -0.05942857 0.07428571 0.28 0.1977143 0.8354286 0.9691429 0.9331429 0.2684286 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 10 
*/
iteration 1600 / 2000 
/** diagnosis at iteration 1600 
* current number of bins = 10 
desired freq - proportions:
 -0.5975 -0.089 0.061 0.082 0.256 0.238 0.793 0.889 0.73 0.167125 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 9 10 
*/
iteration 1700 / 2000 
/** diagnosis at iteration 1700 
* current number of bins = 10 
desired freq - proportions:
 -0.4866667 0.032 0.1653333 0.184 0.3386667 0.3226667 0.736 0.7493333 0.528 0.08 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 9 10 
*/
iteration 1800 / 2000 
/** diagnosis at iteration 1800 
* current number of bins = 10 
desired freq - proportions:
 -0.398 0.124 0.1696 0.1696 0.3424 0.1792 0.5656 0.5944 0.4588 0.0478 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
Flat histogram criterion met at iteration 1850 !
iteration 1900 / 2000 
iteration 2000 / 2000 

> # histogram of the binned coordinate
> PlotHistBin(pawlresults, positionbinning)
[1] "converting chains before plotting..."
[1] "...done"

> #########
> ## PAWL where we bin along the energy (= - log density)
> getPos <- function(points, logdensity) - logdensity 

> # we can get the range using pre exploratory mcmc
> preexpresults <- preexplorationAMH(gaussiantarget, N, 1000)
Pre exploration to get log energy range
[1] "Launching Adaptive Metropolis-Hastings algorithm with parameters:"
Object of class tuningparameters.
*number of parallel chains: 10 
*number of iterations: 1000 
*compute mean: FALSE 
*compute mean (burnin): 0 
*save every nth iteration: -1 
adaptationrate unspecified: set to x -> x^(-0.6)
sigma_init unspecified: set 1
Iteration 100 / 1000 
Iteration 200 / 1000 
Iteration 300 / 1000 
Iteration 400 / 1000 
Iteration 500 / 1000 
Iteration 600 / 1000 
Iteration 700 / 1000 
Iteration 800 / 1000 
Iteration 900 / 1000 
Iteration 1000 / 1000 

> binrange <- preexpresults$SuggestedRange

> # or specify it ourselves
> #binrange <- c(2.1, 20)
> # we further specify some parameters, like the bins,
> # the desired frequency in each bin...
> ncuts <- 2

> energybinning <- binning(position = getPos,
+                             name = "energy",
+                             binrange = binrange,
+                             ncuts = ncuts,
+                             useLearningRate = TRUE,
+                             autobinning = TRUE,
+                             alongenergy = TRUE)
desiredfreq unspecified: set to 1 / nbins for each bin
fhthreshold unspecified: set to 0.5 
splitThreshold unspecified: set to 0.1
minSimEffort unspecified: set 200
learningrate unspecified: set to x -> x^(-1)
useFH unspecified: set to TRUE 

> print(energybinning)
Object of class binning.
*name: energy 
*autobinning: TRUE 
*bins: -Inf 2.027298 4.683023 
*Flat Histogram threshold: 0.5 
*split threshold: 0.1 
*use Flat Histogram criterion: TRUE 
*use learning rate: TRUE 
*min number of iterations between FH: 200 

> # launching the algorithm...
> pawlresults <- pawl(gaussiantarget, binning = energybinning, AP = pawlparameters,
+                     proposal = proposal)
[1] "Launching Particle Wang-Landau algorithm ..."
saving every 1 iterations
hence saving a vector of size 2001 x 10 x 1 = 20010 
right end bin reached: disactivating bin diagnosis
iteration 100 / 2000 
iteration 200 / 2000 
Flat histogram criterion met at iteration 200 !
iteration 300 / 2000 
iteration 400 / 2000 
Flat histogram criterion met at iteration 400 !
iteration 500 / 2000 
iteration 600 / 2000 
Flat histogram criterion met at iteration 600 !
iteration 700 / 2000 
iteration 800 / 2000 
Flat histogram criterion met at iteration 800 !
iteration 900 / 2000 
iteration 1000 / 2000 
Flat histogram criterion met at iteration 1000 !
iteration 1100 / 2000 
iteration 1200 / 2000 
Flat histogram criterion met at iteration 1200 !
iteration 1300 / 2000 
iteration 1400 / 2000 
Flat histogram criterion met at iteration 1400 !
iteration 1500 / 2000 
iteration 1600 / 2000 
Flat histogram criterion met at iteration 1600 !
iteration 1700 / 2000 
iteration 1800 / 2000 
Flat histogram criterion met at iteration 1800 !
iteration 1900 / 2000 
iteration 2000 / 2000 
Flat histogram criterion met at iteration 2000 !

> # histogram of the binned coordinate
> #PlotHistBin(pawlresults, energybinning)
> ##
> #########
> 
> #########
> ## results
> #
> getFrequencies(pawlresults, energybinning)
/* Frequency check
*Do the obtained frequencies match the desired frequencies?
*final bins: -Inf 2.027298 4.683023 
*corresponding frequencies: 0.3317841 0.332084 0.3361319 
*initial bins: -Inf 2.027298 4.683023 
*desired frequencies:  0.3333333 0.3333333 0.3333333 
*obtained frequencies: 0.3317841 0.332084 0.3361319 
[1] 0.3317841 0.3320840 0.3361319

> # Histogram of the chains
> #PlotHist(pawlresults, 1)
> # Trace plot of the log theta penalties
> #print(PlotLogTheta(pawlresults))
> # trace plot of all the variables
> # (here there is only one variable)
> #print(PlotAllVar(pawlresults))
> 
> 
> 
> 
> 
> 
> 
>   demo(mixture2kexample)


	demo(mixture2kexample)
	---- ~~~~~~~~~~~~~~~~

> #rm(list = ls())
> try(detach(package:PAWL, unload = TRUE), silent = TRUE)

> library(PAWL)

> set.seed(17)

> mixture <- createMixtureTarget()
ncomponents unspecified: setting it to 2
mixtureparameters unspecified: putting some default parameters
$ncomponents
[1] 2

$componentweights
[1] 0.5 0.5

$componentmeans
[1] 0.0 2.5

$componentvariances
[1] 0.3 0.3

no sample provided and no sample size: setting size to 100
generating sample of size 100 

> N <- 10

> T <- 5000

> betaindex <- mixture@dimension

> getBeta <- function(points, logdensity) exp(points[,betaindex])

> betabinning <- binning(position = getBeta,
+                        name = "beta",
+                        binrange = c(2, 16),
+                        autobinning = TRUE,
+                        fhthreshold = 0.5,
+                        useLearningRate = TRUE)
number of cuts (ncuts) unspecified: set to 9
desiredfreq unspecified: set to 1 / nbins for each bin
splitThreshold unspecified: set to 0.1
minSimEffort unspecified: set 200
learningrate unspecified: set to x -> x^(-1)
useFH unspecified: set to TRUE 

> print(betabinning)
Object of class binning.
*name: beta 
*autobinning: TRUE 
*bins: -Inf 2 3.75 5.5 7.25 9 10.75 12.5 14.25 16 
*Flat Histogram threshold: 0.5 
*split threshold: 0.1 
*use Flat Histogram criterion: TRUE 
*use learning rate: TRUE 
*min number of iterations between FH: 200 

> pawlparameters <- tuningparameters(nchains = N, niterations = T, storeall = TRUE)

> print(pawlparameters)
Object of class tuningparameters.
*number of parallel chains: 10 
*number of iterations: 5000 
*compute mean: FALSE 
*compute mean (burnin): 0 
*save every nth iteration: 1 

> ### Launching the algorithm...
> pawlresults <- pawl(mixture, binning = betabinning, AP = pawlparameters)
[1] "Launching Particle Wang-Landau algorithm ..."
adaptationrate unspecified: set to x -> x^(-0.6)
sigma_init unspecified: set 1
saving every 1 iterations
hence saving a vector of size 5001 x 10 x 7 = 350070 
iteration 100 / 5000 
/** diagnosis at iteration 100 
* current number of bins = 10 
desired freq - proportions:
 -5.871287 -0.3267327 0.4356436 0.6633663 0.6930693 0.7821782 0.9108911 0.8910891 0.9009901 0.9207921 
* skewed bins: 7 8 9 
* bins with enough points to be split: 1 2 
*/
iteration 200 / 5000 
/** diagnosis at iteration 200 
* current number of bins = 10 
desired freq - proportions:
 -4.99005 -0.3034826 0.06467662 0.4328358 0.6666667 0.7064677 0.8557214 0.8308458 0.8606965 0.8756219 
* skewed bins: 9 
* bins with enough points to be split: 1 2 3 4 
*/
iteration 300 / 5000 
/** diagnosis at iteration 300 
* current number of bins = 10 
desired freq - proportions:
 -4.521595 -0.2524917 0.2325581 0.3654485 0.4850498 0.6777409 0.6810631 0.730897 0.8039867 0.7973422 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 
*/
iteration 400 / 5000 
/** diagnosis at iteration 400 
* current number of bins = 10 
desired freq - proportions:
 -4.01995 -0.1995012 0.2194514 0.3990025 0.478803 0.553616 0.5835411 0.6209476 0.6683292 0.6957606 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 500 / 5000 
/** diagnosis at iteration 500 
* current number of bins = 10 
desired freq - proportions:
 -3.616766 0.03992016 0.243513 0.3453094 0.3612774 0.4570858 0.491018 0.5329341 0.5429142 0.6027944 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 600 / 5000 
/** diagnosis at iteration 600 
* current number of bins = 10 
desired freq - proportions:
 -3.194676 0.1181364 0.2462562 0.296173 0.327787 0.3494176 0.40599 0.4608985 0.4825291 0.5074875 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 700 / 5000 
/** diagnosis at iteration 700 
* current number of bins = 10 
desired freq - proportions:
 -2.881598 0.1911555 0.2582026 0.2853067 0.3195435 0.3323823 0.3552068 0.3694722 0.3851641 0.3851641 
* skewed bins: 3 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 800 / 5000 
/** diagnosis at iteration 800 
* current number of bins = 10 
desired freq - proportions:
 -2.646692 0.1710362 0.1922597 0.2322097 0.2771536 0.309613 0.3283396 0.3445693 0.3970037 0.3945069 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 900 / 5000 
/** diagnosis at iteration 900 
* current number of bins = 10 
desired freq - proportions:
 -2.463929 0.08879023 0.2053274 0.2608213 0.2774695 0.281909 0.3029967 0.3318535 0.3507214 0.36404 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1000 / 5000 
/** diagnosis at iteration 1000 
* current number of bins = 10 
desired freq - proportions:
 -2.274725 0.1168831 0.1518482 0.2307692 0.2707293 0.2817183 0.2907093 0.3036963 0.3156843 0.3126873 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1100 / 5000 
/** diagnosis at iteration 1100 
* current number of bins = 10 
desired freq - proportions:
 -2.06812 0.1135332 0.1562216 0.2070845 0.2152589 0.2270663 0.2633969 0.2788374 0.2970027 0.3097184 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1200 / 5000 
/** diagnosis at iteration 1200 
* current number of bins = 10 
desired freq - proportions:
 -1.89592 0.03913405 0.1631973 0.1898418 0.2231474 0.2414654 0.2422981 0.2472939 0.2672773 0.2822648 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1300 / 5000 
/** diagnosis at iteration 1300 
* current number of bins = 10 
desired freq - proportions:
 -1.750192 0.04996157 0.1245196 0.1729439 0.1998463 0.2213682 0.2359723 0.2398155 0.2482706 0.2574942 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1400 / 5000 
/** diagnosis at iteration 1400 
* current number of bins = 10 
desired freq - proportions:
 -1.625268 0.05710207 0.1049251 0.1563169 0.1920057 0.1998572 0.206995 0.2162741 0.24197 0.2498216 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1500 / 5000 
/** diagnosis at iteration 1500 
* current number of bins = 10 
desired freq - proportions:
 -1.516989 0.0532978 0.1059294 0.1425716 0.1672219 0.188541 0.1992005 0.2111925 0.2251832 0.2238508 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1600 / 5000 
/** diagnosis at iteration 1600 
* current number of bins = 10 
desired freq - proportions:
 -1.422236 0.005621487 0.1030606 0.1499063 0.1530294 0.1742661 0.1942536 0.2023735 0.2198626 0.2198626 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1700 / 5000 
/** diagnosis at iteration 1700 
* current number of bins = 10 
desired freq - proportions:
 -1.338624 0.005291005 0.09758965 0.1263962 0.1481481 0.1704879 0.1763668 0.196943 0.2057613 0.2116402 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1800 / 5000 
/** diagnosis at iteration 1800 
* current number of bins = 10 
desired freq - proportions:
 -1.264298 0.004997224 0.09383676 0.1304831 0.1554692 0.1665741 0.1626874 0.1721266 0.188784 0.1893393 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 1900 / 5000 
/** diagnosis at iteration 1900 
* current number of bins = 10 
desired freq - proportions:
 -1.197791 0.00473435 0.08153603 0.1162546 0.1394003 0.1457128 0.1630721 0.1683325 0.188848 0.1899001 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2000 / 5000 
/** diagnosis at iteration 2000 
* current number of bins = 10 
desired freq - proportions:
 -1.137931 0.004497751 0.103948 0.1129435 0.129935 0.141929 0.1514243 0.1569215 0.1664168 0.169915 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2100 / 5000 
/** diagnosis at iteration 2100 
* current number of bins = 10 
desired freq - proportions:
 -1.08377 0.004283674 0.09281295 0.118039 0.1323179 0.1351737 0.1385055 0.1513565 0.1523084 0.1589719 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2200 / 5000 
/** diagnosis at iteration 2200 
* current number of bins = 10 
desired freq - proportions:
 -1.03453 0.00408905 0.06678782 0.09904589 0.131304 0.1363017 0.1399364 0.1467515 0.1549296 0.1553839 
* skewed bins:  
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2300 / 5000 
/** diagnosis at iteration 2300 
* current number of bins = 10 
desired freq - proportions:
 -0.9895698 0.003911343 0.08952629 0.09908735 0.1086484 0.1164711 0.1277705 0.1434159 0.1473272 0.1534116 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2400 / 5000 
/** diagnosis at iteration 2400 
* current number of bins = 10 
desired freq - proportions:
 -0.9483549 0.003748438 0.06538942 0.1078717 0.1107872 0.121616 0.1249479 0.1291129 0.1382757 0.1466056 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2500 / 5000 
/** diagnosis at iteration 2500 
* current number of bins = 10 
desired freq - proportions:
 -0.9104358 0.01319472 0.07716913 0.08636545 0.09796082 0.1083567 0.1223511 0.1255498 0.1387445 0.1407437 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2600 / 5000 
/** diagnosis at iteration 2600 
* current number of bins = 10 
desired freq - proportions:
 -0.8754325 0.05113418 0.05882353 0.07996924 0.09688581 0.100346 0.1103422 0.118416 0.1264898 0.1330258 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2700 / 5000 
/** diagnosis at iteration 2700 
* current number of bins = 10 
desired freq - proportions:
 -0.8430211 0.03998519 0.07256572 0.08737505 0.09366901 0.1058867 0.1055165 0.1081081 0.1129211 0.1169937 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2800 / 5000 
/** diagnosis at iteration 2800 
* current number of bins = 10 
desired freq - proportions:
 -0.812924 0.03855766 0.06676187 0.07176009 0.08568368 0.09639414 0.1046055 0.1103177 0.115673 0.1231703 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 2900 / 5000 
/** diagnosis at iteration 2900 
* current number of bins = 10 
desired freq - proportions:
 -0.7593933 0.01723544 0.03895209 0.07480179 0.08341951 0.09513961 0.1016891 0.1078938 0.1161668 0.1240951 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 3000 / 5000 
/** diagnosis at iteration 3000 
* current number of bins = 10 
desired freq - proportions:
 -0.7007664 0.01166278 0.04431856 0.0583139 0.07264245 0.09163612 0.0973009 0.1046318 0.1089637 0.1112962 
* skewed bins: 2 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 3100 / 5000 
/** diagnosis at iteration 3100 
* current number of bins = 10 
desired freq - proportions:
 -0.6459207 -0.006127056 0.02676556 0.06288294 0.07707191 0.08803612 0.09029345 0.09738794 0.1009352 0.1086746 
* skewed bins: 2 3 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 3200 / 5000 
/** diagnosis at iteration 3200 
* current number of bins = 10 
desired freq - proportions:
 -0.5945017 -0.03717588 0.04342393 0.05373321 0.06466729 0.0787254 0.08934708 0.09278351 0.1015308 0.1074664 
* skewed bins: 2 3 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 3300 / 5000 
/** diagnosis at iteration 3300 
* current number of bins = 10 
desired freq - proportions:
 -0.5461981 -0.06634353 0.04665253 0.05846713 0.07058467 0.07603756 0.08118752 0.0881551 0.09269918 0.09875795 
* skewed bins: 2 3 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
iteration 3400 / 5000 
/** diagnosis at iteration 3400 
* current number of bins = 10 
desired freq - proportions:
 -0.5007351 -0.09379594 0.04410468 0.05527786 0.06733314 0.07497795 0.08144663 0.08732726 0.0905616 0.09350191 
* skewed bins: 2 3 
* bins with enough points to be split: 1 2 3 4 5 6 7 8 9 10 
*/
Flat histogram criterion met at iteration 3402 !
iteration 3500 / 5000 
iteration 3600 / 5000 
iteration 3700 / 5000 
iteration 3800 / 5000 
iteration 3900 / 5000 
iteration 4000 / 5000 
iteration 4100 / 5000 
iteration 4200 / 5000 
iteration 4300 / 5000 
iteration 4400 / 5000 
iteration 4500 / 5000 
iteration 4600 / 5000 
iteration 4700 / 5000 
iteration 4800 / 5000 
iteration 4900 / 5000 
iteration 5000 / 5000 

> chains <- ConvertResults(pawlresults)
[1] "converting chains before plotting..."
[1] "...done"

> getFrequencies(pawlresults, betabinning)
/* Frequency check
*Do the obtained frequencies match the desired frequencies?
*final bins: -Inf 2 3.75 5.5 7.25 9 10.75 12.5 14.25 16 
*corresponding frequencies: 0.1020596 0.09956009 0.1035593 0.1012398 0.1011598 0.10004 0.09892022 0.09828034 0.09768046 0.0975005 
*initial bins: -Inf 2 3.75 5.5 7.25 9 10.75 12.5 14.25 16 
*desired frequencies:  0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 
*obtained frequencies: 0.1020596 0.09956009 0.1035593 0.1012398 0.1011598 0.10004 0.09892022 0.09828034 0.09768046 0.0975005 
 [1] 0.10205959 0.09956009 0.10355929 0.10123975 0.10115977 0.10003999
 [7] 0.09892022 0.09828034 0.09768046 0.09750050

> ## Plot the reaction coordinate values along the binning axis,
> ## with red vertical lines denoting the endpoints of the bins
> # print(PlotHistBin(pawlresults, betabinning))
> ## Plot the log penalties associated with each bin
> # print(PlotLogTheta(pawlresults))
> ## Plot sigma versus iterations, where sigma is 
> ## the vector of the standard deviations used by the MH kernel along the iterations.
> #plot(pawlresults$sigma, type = "l")
> #PlotAllVar(chains)
> #X11()
> print(PlotComp1vsComp2(chains, "X3", "X4"))
Error in grid.Call.graphics(C_setviewport, vp, TRUE) : 
  VECTOR_ELT() can only be applied to a 'list', not a 'double'
Calls: demo ... push.vp.vpTree -> push.vp -> push.vp.viewport -> grid.Call.graphics
Execution halted