Created
August 1, 2013 20:22
-
-
Save pschulam/6134896 to your computer and use it in GitHub Desktop.
Python numeric tricks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def log_sum(X): | |
m = X.max(0) | |
r = np.exp(X - m).sum(0) | |
return m + np.log(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment