import numpy as np import pandas as pd import matplotlib.pyplot as plt # Define a random function with two inputs def random_function(x, y): return (np.sin(x) + x * np.cos(y) + y + 3**(x/3)) # Define the number of random samples to generate n_samples = 1000 # Generate random X and Y values within a specified range x_min, x_max = -10, 10 y_min, y_max = -10, 10 # Generate random values for X and Y X_random = np.random.uniform(x_min, x_max, n_samples) Y_random = np.random.uniform(y_min, y_max, n_samples) # Evaluate the random function at the generated X and Y values Z_random = random_function(X_random, Y_random) # Create a dataset dataset = pd.DataFrame({ 'X': X_random, 'Y': Y_random, 'Z': Z_random }) # Display the dataset print(dataset.head()) # Create a 2D scatter plot of the sampled data plt.figure(figsize=(8, 6)) scatter = plt.scatter(dataset['X'], dataset['Y'], c=dataset['Z'], cmap='viridis', s=10) plt.colorbar(scatter, label='Function Value') plt.title('Scatter Plot of Randomly Sampled Data') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.show()