R/binMetrics.R

Defines functions binCentrality binPurity binMAE binMean

binMean <- function(mz,intensity) {
	sum(mz * intensity)/sum(intensity)
}

binMAE <- function(mz,intensity) {
	sum(abs(mz - binMean(mz,intensity)) * intensity) / sum(intensity)
}

binPurity <- function(mz,intensity,dp = 2){
	1 - binMAE(mz,intensity) / (1*10^-dp/2)
}

binCentrality <- function(mz,intensity,dp = 2){
	1 - abs(binMean(mz,intensity) - round(mz[1],dp))/(1*10^-dp/2)
}
jasenfinch/binneR documentation built on Aug. 21, 2023, 9:22 a.m.