79518572

Date: 2025-03-18 20:19:28
Score: 1.5
Natty:
Report link

import matplotlib.pyplot as plt

import numpy as np

# Data points

distance = np.array([5, 13, 27, 18, 8, 22, 45])

cost = np.array([1500, 600, 1200, 800, 1350, 950, 1000])

# Regression parameters

intercept = 1184.1996

slope = -6.4449

# Create scatter plot for data points

plt.figure(figsize=(8, 6))

plt.scatter(distance, cost, color='blue', label='Data Points')

# Generate x values for the regression line

x_line = np.linspace(min(distance), max(distance), 100)

y_line = intercept + slope * x_line

# Plot the regression line

plt.plot(x_line, y_line, color='red', label=f'Regression Line: y = {intercept:.4f} - {abs(slope):.4f}x')

# Label the axes and add a title

plt.xlabel('Distance from School (miles)')

plt.ylabel('Cost of Supplies ($)')

plt.title('Distance vs. Cost of Supplies')

plt.legend()

plt.grid(True)

plt.show()

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Jaspreet