meanThreeSigRej: Perform cuts in the data

Description Usage Arguments Value Author(s) Examples

Description

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.

Usage

1
meanThreeSigRej(vec, maxI, tolerance)

Arguments

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 (old-new)/old)

Value

A data frame with the fields mean, sd (the standard deviation) and convergenceAtIter (the iteration where the convergence was reached).

Author(s)

Alberto Krone-Martins, Andre Moitinho

Examples

 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"))
 

UPMASK documentation built on May 2, 2019, 2:39 p.m.