Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turn the cryptically named scipy.special information theory functions into ufuncs #3981

Merged
merged 9 commits into from
Sep 23, 2014

Conversation

argriffing
Copy link
Contributor

These ufuncs try to be careful about corner cases, and none of them can be directly replaced by existing ufuncs functions like xlogy. The entr(x) ufunc is very similar to -xlogy(x,x), but it has different behavior at negative x. The other two ufuncs are convex on all (x, y) whereas their earlier implementations that were clever enough to handle the limit at the origin still returned nan for some x,y points.

These functions are intended to have the same definitions as the functions of the same name in "disciplined convex programming" (http://stanford.edu/~boyd/papers/disc_cvx_prog.html) projects like cvx and cvxpy (note that these are different from cvxopt). The hope is that because these functions are so carefully defined, they can simplify some of the corner case headaches in higher level scipy functions related to statistics and divergences.

@argriffing
Copy link
Contributor Author

Running generate_ufuncs.py seems to have caused some changes related to earlier PRs. Some typos are fixed and some "versionadded should be in the Notes section" changes are made.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling fbc76f5 on argriffing:infotheory-ufuncs into 8b8531d on scipy:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling fbc76f5 on argriffing:infotheory-ufuncs into 8b8531d on scipy:master.

@pv
Copy link
Member

pv commented Sep 10, 2014

Maybe stuff all of them into a single .pxd file? There's no technical
need to have one .pxd per one function.

@argriffing
Copy link
Contributor Author

@pv OK I put them in to a _convex_analysis.pxd file to emphasize their focus and explain the choices for corner cases or weird parts of the domain. For example, these functions are defined in a context that may depend on the concavity of log(x) more than on its characterization as the inverse function of \sum_{k=0}^\infty{x^k / k!}, so the functions don't deal with imaginary numbers.

@argriffing
Copy link
Contributor Author

test run exceeds 50 minutes

@argriffing
Copy link
Contributor Author

Added the Huber loss function as a ufunc. This element-wise convex function is already used in scikit-learn, cvxpy, and statsmodels.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling 33ff802 on argriffing:infotheory-ufuncs into 8b8531d on scipy:master.

@argriffing
Copy link
Contributor Author

Added the convex Pseudo-Huber function as a ufunc. This is used in statsmodels and could be used in scikit-learn. It's a smoother variant of the Huber function.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) when pulling be7f6b2 on argriffing:infotheory-ufuncs into 8b8531d on scipy:master.

@ev-br
Copy link
Member

ev-br commented Sep 23, 2014

LGTM, merging.

ev-br added a commit that referenced this pull request Sep 23, 2014
turn the cryptically named scipy.special information theory functions into ufuncs
@ev-br ev-br merged commit 6e6ac93 into scipy:master Sep 23, 2014
@ev-br ev-br added this to the 0.15.0 milestone Sep 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.special
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants