Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save n0obcoder/006e308c6aa933ba5bdbf98a9c981afe to your computer and use it in GitHub Desktop.

Select an option

Save n0obcoder/006e308c6aa933ba5bdbf98a9c981afe to your computer and use it in GitHub Desktop.
# Defining the number of data points to be generated
num_points = 100
# Let's generate the synthetic data points
x_list = []
y_list = []
for _ in range(num_points):
# Selecting a random integer from the predefined range
x = random.randint(x_range[0] , x_range[1])
# Calculating the dependent valiable 'y' using the formula of a straight line y = mx + c
y = m_synthetic*x + c_synthetic
# Randomly choosing the deviation (noise) for both the dependent as well as the independent variable, so that the dataset becomes a little noisy
deviation_x = random.randint(-deviation , deviation)
deviation_y = random.randint(-deviation , deviation)
# Finally, appending the noisy data points in the respective lists
x_list.append(x + deviation_x)
y_list.append(y + deviation_y)
x_min, y_min, x_max, y_max = min(x_list) , min(y_list) , max(x_list) , max(y_list)
print('\nFollowing are the extreme ends of the synthetic data points...')
print('x_min, x_max: {}, {}'.format(x_min, x_max))
print('y_min, y_max: {}, {}'.format(y_min, y_max))
Following are the extreme ends of the synthetic data points...
x_min, x_max: -2022, 1966
y_min, y_max: -1392.3200000000002, 1352.16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment