Created
May 8, 2024 12:41
-
-
Save dolphin2410/4ffd6f89a5147764e9f02facae9c30f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.linear_model import LinearRegression | |
import matplotlib.pyplot as plt | |
import numpy as np | |
data_time = [1.08E-01, 1.25E-01, 1.41E-01, 1.58E-01, 1.75E-01, 1.91E-01] | |
data_velocity_y = [-2.78E+00, -3.00E+00, -3.27E+00, -3.56E+00, -3.71E+00, -3.88E+00] | |
regression = LinearRegression() | |
regression.fit(np.array(data_time).reshape(-1, 1), np.array(data_velocity_y).reshape(-1, 1)) | |
coef = regression.coef_[0][0] | |
intercept = regression.intercept_ | |
print(coef) | |
plt.title("vy") | |
plt.plot([data_time[0], data_time[5]], [data_time[0]*coef + intercept, data_time[5]*coef + intercept]) | |
plt.scatter(data_time, data_velocity_y) | |
plt.xlabel("t") | |
plt.ylabel("vy") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment