Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with hypergeometric1F1 #78

Closed
amarshankarc opened this issue Mar 28, 2024 · 1 comment
Closed

issue with hypergeometric1F1 #78

amarshankarc opened this issue Mar 28, 2024 · 1 comment

Comments

@amarshankarc
Copy link

Define the probability mass function (PMF) function

beta_poisson_pmf<- function(x, alpha, beta, N) {

Beta function term

beta_term <- gamma(x + alpha) * gamma(alpha + beta) / (gamma(alpha) * gamma(x + alpha + beta))

Poisson term

poisson_term <- N^x / gamma(x + 1)

Confluent hypergeometric function term

hypergeo_term <- hypergeometric1F1(x + alpha, x + alpha + beta, -N)

Combine terms

result <- beta_term * poisson_term *hypergeo_term

return(result)
}
print(beta_poisson_pmf(1,2,3,10))
IAM GETTING BETA POISSON PROBABILITY MASS FUNCTION AS NEGATIVE AND ABOVE ONE WHICH IS NOT POSSIBLE

@merliseclyde
Copy link
Owner

Please note from the documentation that BAS::hypergeometric1F1 computes the log of the function by default.

hypergeometric1F1(a, b, c, laplace = FALSE, log = TRUE)

> BAS::hypergeometric1F1(1+2,1 + 2 + 3,-10)
[1] -3.467487
> BAS::hypergeometric1F1(1+2,1 + 2 + 3,-10, log=FALSE)
[1] 0.03119531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants