MethodError: no method matching binomial

matlab
#1

Dear all,

How can I fix MethodError: no method matching binomial:

pr = 5.6783
for i = 1:round(pr/2)
n = 1/binomial(pr,i)
end

Best

0 Likes

#2

First, please quote your code.

Second, it is unclear what you are expecting from binomial when called with a Float64 and an Int; as Base.binomial is for calculating n \choose k. Perhaps you are interested in

0 Likes

#3

Thank you in advance!
why do we need to install a third part package in PC, quit complex for such very simple problem ?

0 Likes

#4

Because there are almost infinitely many problems that people consider simple, and they can’t all be covered in Base and the standard libraries.

Also, you are mistaken: installing packages is not complex, it is a very simple operation.

2 Likes

#5

I don’t know if that’s what’s expected here, but the usual generalization of binomial coefficients to non-integer upper index is

{r \choose k} = \frac{r(r-1) \ldots (r-k+1)}{k!}.
2 Likes