[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Inna Becher <inna.becher@uni-konstanz.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: large numbers in comb(n,k) function: no success |

Date |
Thu, 05 Feb 2009 17:40:40 +0100 |

the formula I need is actually: probability=1- [comb(n-m,k)/comb(n, k)] so I have useful numbers after the computation. (n=180000, m=2, k=2000) Inna William Gould, StataCorp LP schrieb:

Inna Becher <inna.becher@uni-konstanz.de> wrote,I would like to implement a comb(n,k) function. But my Stata does notallow it because of large n, k-numbers. N=180000 and k=2000. Is thereany other way to do it? I wasn't successful by using exp(lnfactorial(n))in mata as well.Maarten buis <maartenbuis@yahoo.co.uk> replied,The outcome of comb(180000,2000) is going to be,ridiculously large (> 8e+307) and it hits the limit of whatcan be stored in double precision [...]Yes, that's right. In fact, the answer is between 1e+4770 and 1e+4771. comb(n, k) is defined n! comb(n, k) = --------- = (n!)/( k! (n-k)! ) k! (n-k)!Thus,ln(comb(n,k) = ln( (n!)/( k! (n-k)! ) ) = ln(n!) - ln(k!) - ln(n-k)!Stata has a lnfactorial() function, so we can plug in and get. scalar n = 180000 . scalar k = 2000 . display lnfactorial(n) - lnfactorial(k) - lnfactorial(n-k) 10983.753In log base 10, that 10983.753/ln(10) = 4770.1833. Hence my statement,the answer is between 1e+4770 and 1e+4771.1e+4770 is unimagineably big. The number of particles in the observableuniverse is estimated to be between 1e+72 and 1e+87, so it would not bepossible to tally 1e+4770.-- Bill wgould@stata.com * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: large numbers in comb(n,k) function: no success***From:*Maarten buis <maartenbuis@yahoo.co.uk>

**Re: st: large numbers in comb(n,k) function: no success***From:*Austin Nichols <austinnichols@gmail.com>

**References**:**Re: st: large numbers in comb(n,k) function: no success***From:*wgould@stata.com (William Gould, StataCorp LP)

- Prev by Date:
**st: Dataset reorganization** - Next by Date:
**Re: st: large numbers in comb(n,k) function: no success** - Previous by thread:
**Re: st: large numbers in comb(n,k) function: no success** - Next by thread:
**Re: st: large numbers in comb(n,k) function: no success** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |