In R there’s a function lchoose(a,b) which computes the logarithm of the binomial coefficient or choose(a,b) number (number of ways to choose b items from a set of a). This is the only way to work with really big numbers.

I’m trying to work out the probability of certain address collision situations in networks of devices using ipv6. There are 2^64 host suffixes in an ipv6 address so I need to calculate things like choose(2^64,100) and obviously I need to do this with the logarithm because that number is going to be astronomically ridiculous (lchoose(2^64,100) ~ 4072 according to R)

Is there a Julia way to do this. Yes I’m aware I could use stirling’s approximation and work directly with that, but figured there’s probably already something defined somewhere?

julia> using SpecialFunctions
julia> logabsbinomial(big"2"^64, 100) |> first
4072.40258002808648985786554627251204975606540801181314771372293997172075937879

or logabsbinomial maybe is more accurate? they diverge in the 12 or 13th decimal place. Doesn’t really matter, the important thing is any of these approximate calcs show my probability is very close to 1

I would expect logabsbinomial to be more accurate since the lgamma variant can have some cancellation in different parts of the domain, but this is speculation rather than informed information.