Created
February 17, 2016 20:23
-
-
Save tvladeck/0469f0bcfb2599c1baa7 to your computer and use it in GitHub Desktop.
NBD with t distributed beta
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
# NBD with t distributed beta | |
beta.nbd.density <- function(x, r, alpha, a, b) | |
{ | |
# params: | |
# x: count we are evaluating density at | |
# r: nbd r parameter | |
# alpha: nbd alpha parameter | |
# a: beta alpha parameter | |
# b: beta beta parameter | |
# output: | |
# probability density at x | |
k <- gamma(x + r) * alpha^r / (gamma(r) * factorial(x) * beta(a, b)) | |
f <- function(t) (alpha + t)^-(r + x) * t^(alpha + x - 1) * (1 - t)^(b - 1) | |
i <- integrate(f, lower = 0, upper = 1) | |
return(k*i$value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment