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

Dealing With Combinations

In C# I created a list array containing a list of varied indexes. I'd like to display 1 combination of 2 combinations of different indexes. The 2 combinations inside the one must not be repeated. I am trying to code a tennis tournament with 14…
Andrei Pak
  • 57
  • 7
3
votes
2 answers

Strange precision issues in R when computing cumulative binomial probability

I've been running into some weird problems when using this code: positions<-c(58256) occurrencies<-c(30) frequency<-c(11/5531777) length<-c(4) prob<-c(0) for(i in 0:(occurrencies-1)) { pow<-frequency^i pow1<-(1-frequency)^(positions-i) …
Tito Candelli
  • 217
  • 1
  • 10
2
votes
7 answers

How would you write this algorithm for large combinations in the most compact way?

The number of combinations of k items which can be retrieved from N items is described by the following formula. N! c = ___________________ (k! * (N - k)!) An example would be how many combinations of 6 Balls can be drawn…
2
votes
2 answers

Python - Encoding all possible 5-combinations into an integer

I've got a set of 25 integers, ranging from 0 to 24 and my application involves selecting 5 of them (there are no repeated values, no value can be selected more than once) obtaining a combination like this one [15, 7, 12, 3, 22]. It's important to…
2
votes
1 answer

Negative binomial glm.nb : Different results with unbalanced variable and complete separation

I am fitting a negative binomial model using glm.nb from the MASS package of R with as output Y depending on variable y1, x, and z . The problem is that I get different estimated coefficients using the same model but with the following equivalent…
Ph.D.Student
  • 704
  • 6
  • 27
2
votes
1 answer

High precision sum with R involving binomial coefficients and logs

I am trying to get the sum of terms obtained from the products of binomial coefficients (very large integers) and logarithms (small reals), each terms having alternating signs. For example: library(Rmpfr) binom <- function(n,i)…
Denis Cousineau
  • 311
  • 4
  • 16
2
votes
0 answers

difference result sympy binomial function(n,m)

Let there be the following program from sympy import * n,m=symbols('n m') print(binomial(n,m).subs([(m,0),(n,-1)])) print(binomial(n,m).subs([(n,-1),(m,0)])) result: 1 zoo Why is the result different?
Vladimir
  • 21
  • 1
2
votes
1 answer

Binomial Experiment

How do I use the Binomial function to solve this experiment: number of trials -> n=18, p=10% success x=2 The answer is 28% . I am using Binomial(18, 0.1) but how I pass the n=2? julia> d=Binomial(18,0.1) Binomial{Float64}(n=18,…
merchmallow
  • 774
  • 3
  • 15
2
votes
1 answer

Disproving asymptotic lower bound of central binomial coefficient

I was recently learning about binomial coefficients and was wondering about how to disprove 2nCn (or the central binomial coefficient) not being lower-bounded by 4^n; in other words: Some extremely generous bounds can be easily constructed, such as…
2
votes
1 answer

Find euler function of binomial coefficient

I've been trying to solve this problem: Find Euler's totient function of binomial coefficient C(n, m) = n! / (m! (n - m)!) modulo 10^9 + 7, m <= n < 2 * 10^5. One of my ideas was that first, we can precalculate the values of phi(i) for all i from 1…
Legolas131
  • 23
  • 4
2
votes
1 answer

Parallel binomial coefficients using SIMD instructions

Background I've recently been taking some old code (~1998) and re-writing some of it to improve performance. Previously in the basic data structures for a state I stored elements in several arrays, and now I'm using raw bits (for the cases that…
Nathan S.
  • 5,244
  • 3
  • 45
  • 55
2
votes
4 answers

Plot log(n over k)

I've never used Matlab before and I really don't know how to fix the code. I need to plot log(1000 over k) with k going from 1 to 1000. y = @(x) log(nchoosek(1000,x)); fplot(y,[1 1000]); Error: Warning: Function behaves unexpectedly on array…
Dennis
  • 41
  • 4
2
votes
1 answer

How do I calculate binomial coefficient with memoization?

The recursive form is like that: co:: (Int,Int) -> Int co| k == 0 || k == n = 1 | 0 < k, k < n = co(n-1,k-1) + co(n-1,k) | otherwise = 0 How do I memorize so I don't have to make the same calculations that often?
2
votes
2 answers

Cumulative binomial distribution for large numbers

I have the following function implemented in python: # Calculation of cumulative binomial distribution def PDP(p, N, min): pdp=0 for k in range(min, N+1): pdp +=…
2
votes
1 answer

Binomial Coefficient [Prolog]

bc(0,N,R,R):- N>0,R is 1,!. bc(M,0,R,R):- M>0,R is 1,!. bc(N,N,R,R):- R is 1,!. bc(M,N,R,R1):- M1 is M - 1, N1 is N - 1, bc(M1,N1,R,R2), bc(M1,N,R,R3), R1 is R2+R3. Why does it return false? Task is: Write recursive procedure…