Questions tagged [binomial-coefficients]

It is the coefficient of the `x^k` term in the polynomial expansion of the binomial power `(1 + x)^n` which is `(n!)/((n-k)!*k!)`.

It is the coefficient of the x^k term in the polynomial expansion of the binomial power (1 + x)^n which is (n!)/((n-k)!*k!).

This family of numbers also arises in many areas of mathematics other than algebra, notably in combinatorics. For any set containing n elements, the number of distinct k-element subsets of it that can be formed (the k-combinations of its elements) is given by the binomial coefficient C(n, k). Therefore C(n, k) is often read as "n choose k".

213 questions
3
votes
1 answer

%mod compatible ways of generating Binomial Coefficients

I would like to optimize a part of my program where I'm calculating the sum of Binomial Coefficients up to K. i.e. C(N,0) + C(N,1) + ... + C(N,K) Since the values go beyond the data type (long long) can support, I'm to calculate values mod M and…
srbhkmr
  • 2,074
  • 1
  • 14
  • 19
3
votes
4 answers

How can I randomly sample binomial thing?

For example, I want to randomly line the 0, 1 (50% respectively) 10 times. So, there should be five "0" and five "1". But, when I used: rbinom(10,1,0.5) sometimes, it generates four "0" and six "1". I noticed that the sample() function has also…
yoo
  • 491
  • 3
  • 10
3
votes
1 answer

Mapping pnbinom() in R to scipy.stats.nbinom.pmf(k, n, p, loc=0) in SciPy

I am having hard time to understand how the pnbinom(q, size, prob, mu, lower.tail = TRUE, log.p = FALSE) in R to the scipy.stats.nbinom.pmf(k, n, p, loc=0) in SciPy. For the R function, the definitions of the parameters are as follows. q =vector…
Omar Shehab
  • 1,004
  • 3
  • 14
  • 26
3
votes
2 answers

Provide a single Excel Formula for calculating Binomial Coefficients (N,K) in Excel with positive or negative N

Is there a single excel formula that can take integer inputs N and K and generate the binomial coefficient (N,K), for positive or negative (or zero) values of N? The range of N and K should be fairly small e.g. -11 < N < +11 and -1 < K < +11. …
steveOw
  • 879
  • 12
  • 41
3
votes
1 answer

Binomial Distribution Compression

I am currently have difficulty coming up with a fast and low memory solution for a problem. I am attempting to solve using the binomial distribution. I have a binomial distribution that can take on 5 values, the probabilities of the values occurring…
3
votes
5 answers

R Stargazer with pglm model - convert binominal pglm model in plm model

I am using stargazer to create my plm summary tables. library(plm) library(pglm) data("Unions", package = "pglm") anb1 <- plm(wage ~ union + exper + rural, Unions, model = "random", method = "bfgs") stargazer(anb1) Unfortunately stargazer does not…
Nils
  • 129
  • 1
  • 9
3
votes
2 answers

How to find a sum of the first r binomial coefficients for fixed n?

I have already tried the basic way to solve this series but it takes time for the larger values of n & r. Is there any way to reduce this expression in a single expression whose time complexity doesn't depend on the value of n OR r.Range…
3
votes
2 answers

Smart algorithm for finding the divisors of a binomial coefficient

I'm interested in tips for my algorithm that I use to find out the divisors of a very large number, more specifically "n over k" or C(n, k). The number itself can range very high, so it really needs to take time complexity into the 'equation' so to…
3
votes
1 answer

Precision Arithmetic and Overflow for Factorial

Recall IEEE Double Precision Arithmetic. Now, for which n > 1 can binom(n,k) be computed in IEEE Double Precision? Additionally on the same interval, when will intermediate factorial values overflow? For my first question, I have found the interval…
3
votes
4 answers

How to calculate EXTREMELY big binomial coefficients modulo by prime number?

This problem's answer turns out to be calculating large binomial coefficients modulo prime number using Lucas' theorem. Here's the solution to that problem using this technique: here. Now my questions are: Seems like my code expires if the data…
Johnson Steward
  • 534
  • 3
  • 16
3
votes
2 answers

Newton's binomial - doesn't work for bigger numbers

I wrote a program which is supposed to print the value of Newton's binomial. number - number of tests, t[i][0] - n, t[i][1] - k. It seems to be ok for small numbers n and k, but when I want to type bigger numbers it prints 0, 1 or small, negative…
DominikM
  • 33
  • 3
3
votes
3 answers

C++ Binomial Distribution

I am trying to make a C++ program for the following formula: I made the choose part of the function: #include #include using namespace std; int choose(); void binomialdistribution(); int main(){ choose(); …
hockeynl
  • 151
  • 2
  • 9
3
votes
2 answers

Integer calculation of the binomial coefficient using boost::math::binomial_coefficient, returning value as boost::multiprecision::cpp_int? How?

I would like to calculate the binomial coefficient as an integer for up to about numberLeaves=100, K=10. I believe this should be possible to store in about a 128 bit integer. Therefore, I'd like to use boost::multiprecision::cpp_int to store the…
Dan Nissenbaum
  • 13,558
  • 21
  • 105
  • 181
3
votes
6 answers

What is a good way to implement choose notation in Java?

... preferably in Java. Here is what I have: //x choose y public static double choose(int x, int y) { if (y < 0 || y > x) return 0; if (y == 0 || y == x) return 1; double answer = 1; for (int i = x-y+1; i <= x; i++) { answer…
echoblaze
  • 11,176
  • 13
  • 44
  • 49
3
votes
0 answers

How to calculate C(n, k) % 3?

UPDATE: C(n, k) means Binomial Coefficient I'm dealing with a number theory problem. I've transformed the big problem into a simple problem: How to calculate C(n,k)%3, for which n<=10^15. There are about m ( <= 10 000 ) data-set needed to calculate…
abcdabcd987
  • 2,043
  • 2
  • 23
  • 34
1 2
3
14 15