import numpy as np
import matplotlib.pyplot as plt
def generate_half_moon(num_points, radius, width):
# Generate points on a circle
= np.linspace(0, np.pi, num_points)
theta = radius * np.cos(theta)
x_circle = radius * np.sin(theta)
y_circle
# The function changes the mean of the standard normal distribution
= x_circle + np.random.normal(0, width, num_points)
x_noisy = y_circle + np.random.normal(0, width, num_points)
y_noisy
# Combine x and y coordinates
= np.column_stack((x_noisy, y_noisy))
half_moon_points
return half_moon_points
# Example usage:
= generate_half_moon(num_points=1000, radius=1.0, width=0.1)
half_moon_data
0], half_moon_data[:, 1])
plt.scatter(half_moon_data[:, "X-axis")
plt.xlabel("Y-axis")
plt.ylabel("Generated Half-Moon")
plt.title( plt.show()
Example of generating samples from a complex distribution by feeding to a function bivariate gaussians. The function can be implemented by a neural network.