I try to convert source code in R to Delphi code...
Thank you in advance for your help...
nparACT_IS = function(data_hrs, mean_all, bin_hr){
## ---- IS numerator calculation
result_ISnum <- matrix(NA, nrow = 24)
n <- nrow(data_hrs)
p <- 1440/bin_hr
for (h in 1:24){
s <- ceiling(n/p)
data_hrs3 <- data_hrs
data_hrs3[s*p] <- NA
data_hrs3 <- matrix(data_hrs3)
hrlydat <- data_hrs3[c(seq(h,nrow(data_hrs3),24)),]
hrlymean <- mean(hrlydat, na.rm = T)
x <- (hrlymean-mean_all)^2
result_ISnum[h,] <- x
}
ISnum <- sum(result_ISnum)
ISnumerator <- n*ISnum
## ---- IS denominator calculation
result_ISdenom <- matrix(NA, nrow = n)
for (j in 1:n){
y <- ((data_hrs[j,]-mean_all)^2)
result_ISdenom[j,] <- y
}
ISdenom <- sum(result_ISdenom)
ISdenominator <- p*ISdenom
## -----------------------------
IS <- round(ISnumerator/ISdenominator, digits = 2)
return_IS <- c(IS, ISdenom, n, p)
return(return_IS)
},