Work in progress

This commit is contained in:
2025-09-29 08:59:47 +02:00
parent 8a2a9d1064
commit b93df4af0f
26 changed files with 22986 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import numpy as np
import matplotlib.pyplot as plt
# Együtthatók
a, b, c, d = 1, -2, 3, -1
# X értékek
x = np.linspace(-2, 2, 400)
# Harmadfokú polinom értékek
y = a + b*x + c*x**2 + d*x**3
# Válassz néhány pontot a polinomról
x_points = np.linspace(-2, 2, 10)
y_points = a + b*x_points + c*x_points**2 + d*x_points**3
# Lineáris regresszió illesztése a pontokra
coeffs = np.polyfit(x_points, y_points, 1) # 1. fokú polinom = egyenes
lin_y = coeffs[0]*x + coeffs[1]
# Ábrázolás
plt.plot(x, y, label='Harmadfokú polinom')
plt.scatter(x_points, y_points, color='blue', marker='x', s=80, label='Polinom pontjai')
plt.plot(x, lin_y, color='black', linestyle='--', label='Lineáris regresszió')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Polinom és lineáris regresszió')
plt.legend()
plt.grid(True)
plt.show()