Created
March 11, 2019 05:10
-
-
Save stemangiola/3edef9f41b63946964ef4bebd25e9708 to your computer and use it in GitHub Desktop.
approximated modified bessel second kind log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approximated_modified_bessel_second_kind_log = function(z, v, s = max(0,v-10)){ | |
# s = 0 not approximated | |
0.5 * ( log(pi) - log(2) ) + (-z - 0.5 * log(z)) + | |
foreach(j = s:floor(v-0.5), .combine = c) %do% { | |
lgamma(j + abs(v) - 0.5 + 1) - | |
( lgamma(j + 1) + lgamma(-j + abs(v) - 0.5 + 1) ) - | |
j*(log(2) + log(z)) | |
} %>% matrixStats::logSumExp() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment