-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcdf.py
More file actions
50 lines (23 loc) · 1.27 KB
/
cdf.py
File metadata and controls
50 lines (23 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import numpy as np
from show import visualize_trajectory,visualize_trajectory_comparison
import matplotlib.pyplot as plt
def compute_cdf(data):
sorted_data = np.sort(data)
cdf = np.linspace(0, 1, len(sorted_data))
return sorted_data, cdf
def compute_errors(baseline_x, baseline_y, filtered_x, filtered_y):
errors = np.sqrt((baseline_x - filtered_x)**2 + (baseline_y - filtered_y)**2)
return errors
def plot_cdf_of_errors(x_values, y_values, max_delta=0.6, max_skip=3, label="Error CDF", color=None):
"""Compute and plot the CDF of errors between baseline and filtered trajectory"""
baseline_x_interp, baseline_y_interp = visualize_trajectory(x_values, y_values)
errors = compute_errors(baseline_x_interp, baseline_y_interp, x_values, y_values)
num_points = len(errors)
mean_error = np.mean(errors)
rmse = np.sqrt(np.mean(errors**2))
errors_sorted, errors_cdf = compute_cdf(errors)
plt.plot(errors_sorted, errors_cdf,
label=f"{label} (ME={mean_error:.3f}m, RMSE={rmse:.3f}m)",
color=color)
print(f"{label}: total points = {num_points}/1460, mean error = {mean_error:.3f} m, RMSE = {rmse:.3f} m")
return mean_error, rmse, num_points