Monday, 15 August 2011

python 2.7 - I need to calculate the likelihood P(D|N) and also to implement my function that it allows arrays as input arguments -


I have tried to do this with it but it gives me a 'local variable' a 'referenced before assignment' error Input Logic: N: Integer (array) n: Integer (array) k: Integer (array): Pre's def probability (N, N, K): "Call": l = probability for example: probability (6, 10,5) => 1.190748e-05 "" If Easten (N, List) is: #N Array is L = Zero (L): Output Logic: l: Float (Array) Example:) I, I Enumerate (N): L [I] = (log_factorial (I) -log_factorial (Ik) -n * log (I)) Other: #n scaler L = AP (log_factorial (n) - log_factorial (nk) -n * log (n) returns) (L)

Where am I? Or is there another way to solve it?

"post-text" itemprop = "text">

If you do not call the function with N as a list, then it will not go to if section l is not defined when the return is reached. The actual error, however, is that the else section is indented. What to do:

  Import from zero Zero, from APP, Import from scipy.special import gammaln log_factorial = lambda z: gammaln (z + 1) def probability (N, N, K) ): If iStance (N, list): For the # N array L = ZERO (LAN), I enumerate (N): L [i] = AP (log_factorial (I) -log_factorial (Ik) - N * Log (I)) : # N Scaler L = XP (log_factorial (n) - log_factorial (nk) -n * log (n)) return el possibility ([6], 10,5) probability (6, 10,5)  / Pre> 

No comments:

Post a Comment