Created
September 5, 2018 13:01
-
-
Save ruliana/f63541e21547a23f6e94f5de547533e0 to your computer and use it in GitHub Desktop.
Simple bootstrapping with numpy
This file contains 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
def bootstrap(np_array, func, n_samples=1000, size=None): | |
size = size if size else len(np_array) | |
return np.apply_along_axis(func, 1, np.random.choice(np_array, size=(n_samples, size))) | |
# Example use | |
bootstrap(some_array, np.mean) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment