📖 INDEX
LOADING ENGINE...
np.random.choice()
AI & DATA SCIENCE // np-random-choice
Generates a random sample from a given 1-D array.
Syntax
sample = np.random.choice([1, 2, 3, 4, 5], size=3)Examples
Example 01Basic Usage
sample = np.random.choice([1, 2, 3, 4, 5], size=3)Best Practices
- Refer to the official NumPy documentation for deep vectorization techniques.
- Avoid writing custom Python for-loops for operations that can be vectorized with NumPy.