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
0
votes
2 answers

How to compute a binomial distribution in postgreSQL

I have a function that computes a binomial distribution naively as follows CREATE OR REPLACE FUNCTION random_binomial(n int, p float) RETURNS int AS $$ DECLARE -- Loop variable i int; -- Result of the function result float =…
Esteban Zimanyi
  • 201
  • 3
  • 6
0
votes
2 answers

How can I get the index of a given combination?

I have a sequence of arrays of numbers with 5 elements each, from 0 to 8, and I have to order than using that combination, I mean: i=0, {0,0,0,0,0} i=1, {0,0,0,0,1} i=2, {0,0,0,0,2} i=3, {0,0,0,0,3} i=4, {0,0,0,0,4} i=5, {0,0,0,0,5} i=6,…
0
votes
0 answers

Python np.binom function only returns 1

Probably a bit more of a maths question! I've got the following code that uses the binomial coefficent, np.binom to calculate propensity functions: for j in range(len(LHS)): cj = stoch_rate for i in range(len(popul_num)): if i >= LHS[i,j]: …
Mike5298
  • 377
  • 1
  • 13
0
votes
0 answers

Generalised Linear Model - Response error is constant; boundary (singular) fit; leading leading minor of order 4 is not positive definite

I am trying to run the code below in order to simulate P-values using a generalised linear model. (I am running a logistic regression for power analysis): #which_p_value = "x1" which_p_value = "groupcategory" #which_p_value =…
0
votes
1 answer

How to find R approximation for CLT

The distribution for the number of faulty lightbulbs is the binomial distribution. i.e. the number of faulty lightbulbs is: Use R to produce a graphical representation that compares the true pmf for the number of faulty lightbulbs found and its…
0
votes
1 answer

CPP - Binomial Coefficient - i get wrong results

Task: Write and test a C++ function that computes binomial coefficients. Three Definitions of the Binomial Coefficients are given (see picture below). I personally used the middle one definition. My problem: But the Problem is, that I'm getting…
limonade
  • 45
  • 6
0
votes
2 answers

Fastest way to calculate binomial coefficients in Java

I'm calculating binomial coefficients of arbitrary size using the following recursive function private static final BigDecimal ZERO = new BigDecimal("0"); private static final BigDecimal ONE = new BigDecimal("1"); private static BigDecimal…
0
votes
2 answers

Binomial Coefficient with array

I'm trying to write a code for the binomial coefficient. I have already made the method for the binomial coefficient but my program have to initialize an array which should display the binomial coefficient but I am only allowed to use the binomial…
0
votes
1 answer

R: GLM dropping a few of my variable levels in the output

I'm aware that this question has now been asked a few times and have all the replies that I could find but still, I slightly different case: I have a model predicting Acc by two factors, namely Condition and Language, each of them with two levels…
Orestes_Fox
  • 189
  • 11
0
votes
3 answers

Calculating the highest possible damage achievable using 6 items from a pool of ~25

I am writing an app in javascript to try to figure out item builds for characters in a video game. There are about 25 top-tier items, and you can carry 6 at a time. They have very different effects, which leads me to believe that while one item may…
Shawn
  • 19,465
  • 20
  • 98
  • 152
0
votes
1 answer

Cannot create a proper N Choose R Method

I have this assignment for writing Java code: Given a set of n items, how many ways can we pick r elements from n? This is known as the “choose function” (or binomial coefficient), and we can calculate the number of r-sized subsets of n (where…
user9743667
0
votes
1 answer

How to pull the coefficient values from a logistic regression into a dataframe in R?

I did run a logistic regression model fit in R for some dataset. I can see the Coefficients per predictor via summary(model_fit), but now I need to store them in a data frame. Below are my values how I see them via summary. Coefficients: …
0
votes
0 answers

How to fix the intercept in a binomial GLM model?

Looking for some help fitting a binomial model with a fixed intercept. I've seen this question covered successfully with linear models by subtracting the explicit intercept from the regression and and then fit the intercept-free model: intercept <-…
Thomas Moore
  • 192
  • 1
  • 12
0
votes
2 answers

R: error when trying to write an equivalent function n choose k

I'm taking the class of introduction for R programming. we were asked to write a function that will be the same as n choose k: choose(n, k) we were asked to check if the function works by running n = 200, k = 50. I wrote the following code: …
Noa Even
  • 137
  • 1
  • 10
0
votes
0 answers

How to fit and check negative binomial distribution to counts data in R?

I have a sample which is distributed as such , say, rnorm(300, mean=100, sd=10) (The rnorm just used as a sample data). I want to fit a negative binomial to it (a) visually using ggplot2 or base R package (b) also run an appropriate test to check…