Пример #1
0
 def _lowvariance_sources(self, w, num):
     r = np.random.rand() / num
     bins = np.concatenate(((0, ), np.cumsum(w)))
     return ibincount(
         np.histogram(r + np.linspace(0, 1, num, endpoint=False), bins)[0])
Пример #2
0
 def _lowvariance_sources(self, w, num):
     r = np.random.rand()/num
     bins = np.concatenate(((0,),np.cumsum(w)))
     return ibincount(np.histogram(r+np.linspace(0,1,num,endpoint=False),bins)[0])
Пример #3
0
 def _independent_sources(self, w, num):
     # Return an ordered array of source indices from source counts
     # e.g. if the sources are 3x'0', 2x'1', 0x'2', and 1x'3', as specified
     # by the vector [3,2,0,1], then the output will be
     # [0, 0, 0, 1, 1, 3]
     return ibincount(np.random.multinomial(num, w))
Пример #4
0
 def _independent_sources(self, w, num):
     # Return an ordered array of source indices from source counts
     # e.g. if the sources are 3x'0', 2x'1', 0x'2', and 1x'3', as specified
     # by the vector [3,2,0,1], then the output will be
     # [0, 0, 0, 1, 1, 3]
     return ibincount(np.random.multinomial(num,w))