BUG: fix missing check for memory allocation failure in ufuncs

closes gh-4018
Merge pull request #4020 from juliantaylor/memcrash

BUG: fix missing check for memory allocation failure in ufuncs
MAINT: implement median as percentile
ENH: add extended axis and keepdims support to median and percentile
ENH: improve median/percentile performance for small arrays

numpy reduce overhead is significant in the q range check, saves about
15-25% runtime for array sizes < 10000
avoid slower weighting path if median of odd elements is requested
DOC: document _ureduce better