Closed capezza closed 1 year ago
This should be better and faster. If I am not wrong these functions are called many times.
F_diff <- function(x) { abs_x <- abs(x) exp_x <- exp(-abs_x) exp_2x <- exp_x^2 exp_x_p1_2 <- (1 + exp_x)^2 out <- exp_x / exp_x_p1_2 return(out) }
Simlarly for F_diff2
F_diff2 <- function(x) { abs_x <- abs(x) exp_x <- exp(-abs_x) exp_2x <- exp_x^2 exp_3x <- exp_x * exp_2x exp_x_p1_3 <- (1 + exp_3x + 3 * exp_2x + 3 * exp_x) out <- sign(x) * (exp_2x - exp_x) / exp_x_p1_3 }
Yes I noticed a good increase in speed after changing this
This should be better and faster. If I am not wrong these functions are called many times.
Simlarly for F_diff2