Skip to content

Instantly share code, notes, and snippets.

@pschulam
Created August 1, 2013 20:22
Show Gist options
  • Save pschulam/6134896 to your computer and use it in GitHub Desktop.
Save pschulam/6134896 to your computer and use it in GitHub Desktop.
Python numeric tricks.
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