Created
September 24, 2015 21:59
-
-
Save bl4ck5un/78c2289ae0f38dd49a45 to your computer and use it in GitHub Desktop.
Sample from two array coherently
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
# x = ... | |
# y = ... | |
idx = np.random.choice(np.arange(len(x)), 1000, replace=False) | |
x_sample = x[idx] | |
y_sample = y[idx] | |
""" | |
a : 1-D array-like or int | |
If an ndarray, a random sample is generated from its elements. If an int, the random sample is generated as if a was np.arange(n) | |
size : int or tuple of ints, optional | |
Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned. | |
replace : boolean, optional | |
Whether the sample is with or without replacement | |
p : 1-D array-like, optional | |
The probabilities associated with each entry in a. If not given the sample assumes a uniform distribution over all entries in a. | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment