R/Unc.R

# Uncertainty

Unc <- function(time, nger) {
  
  n <- nger[1]
  for (i in 2:length(nger)) {
    n <- c(n, nger[i]-nger[i-1])
  }
  
  E <- c()
  f <- c()
  
  for (i in 1:length(n)) {
    f <- c(f,n[i]/sum(n))  
    
    if (f[i] > 0) {
      E <- c(E, f[i]*log2(f[i]))  
    }
    
  }
  
  result <- -sum(E)
  
  return(result)
}

Try the SeedCalc package in your browser

Any scripts or data that you put into this service are public.

SeedCalc documentation built on May 2, 2019, 8:26 a.m.