add sample_by_weights (tested)
Merge pull request #15 from lindahua/master

add sample_by_weights function