On Fri, May 2, 2025 at 9:55 AM Shourya Jain via NumPy-Discussion < numpy-discussion@python.org> wrote:
> Feature request : Add replacement based sampling method with weight decay > for choosing samples from a list/array > > I would like to add it with an algorithm as follows : > for _ in range(target_size): > idx = np.random.choice(a, 1, p=p) # Get a sample > samples.append(a[idx]) # Append sample to samples list > p[idx] *= decay_factor # Update probabilities > p /= np.sum(p) # Normalize probabilities > > This provides a more representative sample than normal sampling with > replacement as elements that have not been sampled get higher probability > of being sampled later. > I would like to add it to the np.random.choice itself, by adding a > parameter decay_factor that defaults to 1 > This seems like an ad hoc algorithm rather than a well-known, well-studied random process. I'm happy to be corrected with references to the literature, but even if there are references, I'm happy to leave this for users to implement on their own. -- Robert Kern
_______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com