Example of weighted random sampling with a reservoir algorithm written in fortran 90 (source: Weighted random sampling with a reservoir)
Weighted random sampling with a reservoir size:100
Example of results with a weight function of type x**2:
Initial population (left); sampling (right)