Now we define a function called sample_points for generating (x,y) pairs. It takes the parameter k as input, which implies the number of (x,y) pairs we want to sample:
def sample_points(k):
num_points = 100
#amplitude
amplitude = np.random.uniform(low=0.1, high=5.0)
#phase
phase = np.random.uniform(low=0, high=np.pi)
x = np.linspace(-5, 5, num_points)
#y = a*sin(x+b)
y = amplitude * np.sin(x + phase)
#sample k data points
sample = np.random.choice(np.arange(num_points), size=k)
return (x[sample], y[sample])