I tried it with this but it gives me an error 'local variable 'l' referenced before assignment'
def likelihood(N,n,k):
"""
Call:
l = likelihood(N,n,k)
Input argument:
N: integer (array)
n: integer (array)
k: integer (array)
Output argument:
l: float (array)
Example:
likelihood(6,10,5)
=>
1.190748e-05
"""
if isinstance(N,list): # N is array
l = zeros(len(N))
for i, I in enumerate(N):
l[i]=exp(log_factorial(I)-log_factorial(I-k)-n*log(I))
else: # N is scalar
l= exp(log_factorial(N)-log_factorial(N-k)-n*log(N))
return(l)
Where am I wrong? Or is there another way to solve it?