Returning very large numbers

I am trying to run a function that outputs a very large number. The problem is that the return says inf.
The function is as follows:

comb.prob <- function(n){

However If I reduce my input numbers by 1/10, R returns a value to me.


comb.prob <- function(n){

I was wondering if there was a way to boost R’s computing power or another method so I could get R to run the first equation?

You might want to try using the log version of choose (lchoose). I show an example with smaller numbers that these are equivalent.

Using some log identities, namely that log(a*b/c)=log(a)+log(b)-log(c)

comb.prob.log <- function(n){

n <- 2
#> [1] 0.01194137
#> [1] 0.01194137

Created on 2022-07-20 by the reprex package (v2.0.1)

Thank you for your reply! It seemed to do the trick.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.