def mgeo(arr, n=2):
    "\n    Returns array of lenth len(arr) - (n-1)\n\n    # # written by me\n    # # slower for short loops\n    # # faster for n ~ len(arr) and large arr\n    a = []\n    for i in xrange(len(arr)-(n-1)):\n        a.append(stats.gmean(arr[i:n+i]))\n\n    # # Original method# #\n    # # written by me ... ~10x faster for short arrays\n    b = np.array([np.roll(np.pad(arr,(0,n),mode='constant',constant_values=1),i)\n              for i in xrange(n)])\n    return np.product(b,axis=0)[n-1:-n]**(1./float(n))\n    "
    a = []
    for i in range((len(arr) - (n - 1))):
        a.append(stats.gmean(arr[i:(n + i)]))
    return np.asarray(a)
Returns array of lenth len(arr) - (n-1)

# # written by me
# # slower for short loops
# # faster for n ~ len(arr) and large arr
a = []
for i in xrange(len(arr)-(n-1)):
    a.append(stats.gmean(arr[i:n+i]))

# # Original method# #
# # written by me ... ~10x faster for short arrays
b = np.array([np.roll(np.pad(arr,(0,n),mode='constant',constant_values=1),i)
          for i in xrange(n)])
return np.product(b,axis=0)[n-1:-n]**(1./float(n))
def mgeo(arr, n=2):
    "\n    Returns array of lenth len(arr) - (n-1)\n\n    # # written by me\n    # # slower for short loops\n    # # faster for n ~ len(arr) and large arr\n    a = []\n    for i in xrange(len(arr)-(n-1)):\n        a.append(stats.gmean(arr[i:n+i]))\n\n    # # Original method# #\n    # # written by me ... ~10x faster for short arrays\n    b = np.array([np.roll(np.pad(arr,(0,n),mode='constant',constant_values=1),i)\n              for i in xrange(n)])\n    return np.product(b,axis=0)[n-1:-n]**(1./float(n))\n    "
    a = []
    for i in range((len(arr) - (n - 1))):
        a.append(stats.gmean(arr[i:(n + i)]))
    return np.asarray(a)