def test_distributions_normal_random_sample(): d = NormalDistribution(0, 1) x = numpy.array([ 0.44122749, -0.33087015, 2.43077119, -0.25209213, 0.10960984]) assert_array_almost_equal(d.sample(5, random_state=5), x) assert_raises(AssertionError, assert_array_almost_equal, d.sample(5), x)
def test_distributions_normal_random_sample(): d = NormalDistribution(0, 1) x = numpy.array([ 0.44122749, -0.33087015, 2.43077119, -0.25209213, 0.10960984]) assert_array_almost_equal(d.sample(5, random_state=5), x) assert_raises(AssertionError, assert_array_almost_equal, d.sample(5), x)
def visit_helper(self, k): """ Returns a tuple x,y that coresponds to the coords which we will manipulate""" mu_x, mu_y, sigma = int(round(k.pt[0])), int(round(k.pt[1])), k.size # Remember, it may be wise to expand simga - greater varience = less honed attack sigma += self.params.SIGMA_CONSTANT d_x = NormalDistribution(mu_x, sigma) d_y = NormalDistribution(mu_y, sigma) x = d_x.sample() y = d_y.sample() if (self.params.small_image): x /= self.params.inflation_constant y /= self.params.inflation_constant if (x >= self.params.X_SHAPE): x = self.params.X_SHAPE - 1 elif (x < 0): x = 0 if (y >= self.params.Y_SHAPE): y = self.params.Y_SHAPE - 1 elif (y < 0): y = 0 return int(x), int(y)
def sample_from_kp(k): mu_x, mu_y, sigma = int(round(k.pt[0])), int(round(k.pt[1])), k.size # Remember, it may be wise to expand simga # greater varience = less honed attack sigma += params.SIGMA_CONSTANT d_x = NormalDistribution(mu_x, sigma) d_y = NormalDistribution(mu_y, sigma) x = d_x.sample() y = d_y.sample() if (params.small_image): x /= params.inflation_constant y /= params.inflation_constant x = int(x) y = int(y) if (x >= params.X_SHAPE): x = params.X_SHAPE - 1 elif (x < 0): x = 0 if (y >= params.Y_SHAPE): y = params.Y_SHAPE - 1 elif (y < 0): y = 0 return int(x), int(y)