#all made by chatgpt
import matplotlib.pyplot as plt
import numpy as np

# Data extracted from the table
distances = [0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 1280, 2560, 5120]
avg_times = [33.709, 22.864, 17.015, 16.991, 16.954, 18.766, 15.499, 11.804, 9.622, 8.434, 7.591, 5.455, 4.918, 4.837]
std_dev = [1.786, 1.904, 0.965, 1.010, 1.341, 1.087, 1.319, 1.308, 1.139, 1.219, 1.175, 1.097, 0.902, 1.126]

# Remove zero for log scaling
distances = np.array(distances[1:])
avg_times = np.array(avg_times[1:])
std_dev = np.array(std_dev[1:])

# Control sample (facing away)
control_distance = 5400  # Placed near the end of the x-range
control_avg = 4.223
control_std = 1.010

# Plot
plt.figure(figsize=(8, 5))
plt.errorbar(distances, avg_times, yerr=std_dev, fmt='o-', capsize=5, label='Measured points')
plt.errorbar(control_distance, control_avg, yerr=control_std, fmt='s', color='red', capsize=5, label='Facing away')

# Log scales
plt.xscale('log')
plt.yscale('log')

# Labels & styling
plt.title("Distance vs Average Sample Time (Log–Log Scale)")
plt.xlabel("Distance (log scale)")
plt.ylabel("Average Sample Time (ms, log scale)")
plt.legend()
plt.grid(True, which="both", linestyle='--', alpha=0.6)
plt.tight_layout()

plt.show()
