def fill(self, arr, vle_min=-1.0, vle_max=1.0): """Fills numpy array with random numbers. Parameters: arr: numpy array. vle_min: minimum value in random distribution. vle_max: maximum value in random distribution. """ arr = ravel(arr) arr[:] = (my_random.rand(arr.size) * (vle_max - vle_min) + vle_min)[:]
def fill_normal_real(self, arr, mean, stddev, clip_to_sigma=5.0): """ #Fills real-valued numpy array with random normal distribution. #Parameters: # arr: numpy array. # mean: # stddev: # min_val, max_val (optional): clipping values of output data. """ arr = ravel(arr) arr[:] = my_random.normal(loc=mean, scale=stddev, size=arr.size)[:] numpy.clip(arr, mean - clip_to_sigma * stddev, mean + clip_to_sigma * stddev, out=arr)
def plain(self): return ravel(self.mem)