Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. import random
  2. import numpy as np
  3.  
  4. #numbers to sample from, could be a more complicated distribution
  5. list_of_numbers = np.random.rand(1000) * 50
  6.  
  7. valid_samples = list()
  8.  
  9. while(len(valid_samples) < required_length):
  10. sample = [random.choice(list_of_numbers) for _ in range(100)]
  11. if (sum(sample) < 1000):
  12. valid_samples.append(sample)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement