Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A problem in trajectories.py #127

Open
neugzy opened this issue Mar 4, 2024 · 1 comment
Open

A problem in trajectories.py #127

neugzy opened this issue Mar 4, 2024 · 1 comment

Comments

@neugzy
Copy link

neugzy commented Mar 4, 2024

I think there is a problem in this code segment.

def poly_fit(traj, traj_len, threshold):
"""
Input:
- traj: Numpy array of shape (2, traj_len)
- traj_len: Len of trajectory
- threshold: Minimum error to be considered for non linear traj
Output:
- int: 1 -> Non Linear 0-> Linear
"""
t = np.linspace(0, traj_len - 1, traj_len)
res_x = np.polyfit(t, traj[0, -traj_len:], 2, full=True)[1]
res_y = np.polyfit(t, traj[1, -traj_len:], 2, full=True)[1]
if res_x + res_y >= threshold:
return 1.0
else:
return 0.0

res_x and res_y are residuals of quadratic terms, so if the value of (res_x + res_y) is bigger than threshold, indicating that the trajectories don't conform to the quadratic distribution. But the code indicates Non Linear. Is not contradictory?

@neugzy
Copy link
Author

neugzy commented Mar 4, 2024

I think the code should be changed to the following:
res_x = np.polyfit(t, traj[0, -traj_len:], 1, full=True)[1]
res_y = np.polyfit(t, traj[1, -traj_len:], 1, full=True)[1]

Is my idea correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant