
  ## this test computes the p-value for skewness for different sample sizes. 
  ##   by varying the following parameters:
  ##       n: the sample size
  ##    reps: the number of times to draw the sample of size n
  ##   alpha: the threshold for the p-value
  ##
  ##


  # SET VECTORS OF PARAMETERS
  reps <- logscale(seq(4,6,2))
  rep  <- reps[[2]]  # temp for testing

  alphas <- c(0.001, 0.01, 0.05)

  n <- round(logscale(c(2,3,5.8)), -1)

  # CREATE EMPTY MATRIX
  cnames <- c("logn", "lowSkew", "uprSkew", "alpha", "reps")
  thresholds <- matrix(ncol=length(cnames),dimnames=list(NULL, cnames))
  thresholds <- thresholds[0,]

  for (alpha in alphas)  {

    # CREATE QUANTILE PROBABILITIES
    quantiles <- c(alpha/2, 1-alpha/2)


    #// for (rep in reps) 
    {
      skew <- matrix(nrow=length(n), ncol=rep)
      rownames(skew) <- n

      for (i in 1:rep)  {
        dist <- lapply(n, rnorm)
        skew[,i] <- unlist(lapply(dist, skewness))
      }

      # calculate the quantile values
      quantValues <- t(round(apply(skew, 1, quantile, quantiles), 3))
      
      # combine in to a table
      nextRows <- cbind(floor(log(n,10)), quantValues, alpha, rep)
      thresholds <- rbind(thresholds, rep(NA, ncol(thresholds)), nextRows)
    } # end: for reps
 
  } # end: for alpha
  thresholds



## FROM basicWrappers.R
logscale <- function(range=2:5, intervals=2, base=10)  {
# returns a sorted vector of powers of the base. 
# range is a vector of powers
# intervals is applied AFTER powers, so that intervals=3  for range=1:4 would return:
#     (10 * 1/3), (10 * 2/3), (10 * 3/3),  (100 * 1/3), (100 * 2/3), (100 * 3/3),  etc...
#
  factors <- seq(intervals) / (intervals)
  ret <- sort(unlist(lapply((base^range), function(x) {x*factors})))
  return (ret)
}
