Description Usage Arguments Value Author(s) Examples
meanThreeSigRej
will perform an interative rejection using the mean
and three sigma of the data. The function will compute the mean and standard
deviation of the input vector, reject all entries lying farther than three-sigma, and
iterate until the mean varies (fractionaly) by less than the tolerance value. The
function will return a data frame with the mean, standard deviation value and the
number of iterations until the convergence was reached.
1 | meanThreeSigRej(vec, maxI, tolerance)
|
vec |
a vector with the data to consider |
maxI |
an integer with the maximum amount of iterations allowed |
tolerance |
a double with the tolerance value (as |
A data frame with the fields mean
, sd
(the standard deviation) and convergenceAtIter
(the iteration where the convergence was reached).
Alberto Krone-Martins, Andre Moitinho
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Create a simple data set with the values and errors
toyData <- c(rnorm(30, mean=0, sd=5), 10000, 1000)
# Call the function to perform cuts
toyDataItStat <- meanThreeSigRej(toyData)
cat(paste("True mean = 0\n"))
cat(paste("Before rejection mean =",round(mean(toyData),2),"\n"))
cat(paste("After rejetion mean =",round(toyDataItStat$mean,2),"\n"))
# Clean the environment
rm(list=c("toyData", "toyDataItStat"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.