How to implement guide with numpy's np.random.choice not respecting the weights parameter for large arrays
I'm working with NumPy 1.22.0 to randomly sample elements from a large array, and I'm having an scenario where the `np.random.choice` function does not seem to respect the weights I've defined. The array I'm sampling from is quite large, with around 1 million elements, and the weights are also an array of the same length. Here's the code snippet I've been using: ```python import numpy as np data = np.arange(1000000) weights = np.random.rand(1000000) weights /= weights.sum() # Normalizing the weights # Attempting to sample 1000 elements sample = np.random.choice(data, size=1000, p=weights) ``` However, when I analyze the output, it appears that the sampling is pretty uniform across the array, which contradicts the weight distribution I set up. I expected certain values to occur much more frequently based on their weights, especially those with significantly higher values. I've also tried using smaller arrays and different weight distributions, but I'm still seeing that the output doesn't correlate with the weights. Additionally, I'm running this code on a machine with 32 GB RAM and an Intel i7 CPU, and it seems to be performing well regarding execution time; the scenario lies solely with the output. Have I misunderstood how the weights parameter works, or could there be a bug in the version I'm using? Any insights would be appreciated!