tracks_fused, tracks_ais, tracks_radar = kf_independent_fusion.track(
    start_time, measurements_radar, measurements_ais, fusion_rate=1)
# calculate CI
alpha = 0.9
ci_nees = scipy.stats.chi2.interval(alpha, 4)
ci_anees = np.array(scipy.stats.chi2.interval(
    alpha, 4 * num_estimates)) / num_estimates

# calculate some metrics
# calculate NEES
nees = calc_metrics.calc_nees(tracks_fused, ground_truth)
# calculate ANEES
anees = calc_metrics.calc_anees(nees)
# calculate RMSE
rmse = calc_metrics.calc_rmse(tracks_fused, ground_truth)
# calculate percentage NEES within CI
percentage_nees_within_CI = calc_metrics.calc_percentage_nees_within_ci(
    nees, ci_nees)

metrics_info = "Percentage NEES within CI: " + str(percentage_nees_within_CI) + "\n" + "RMSE: " + str(rmse) + "\n" + \
               "ANEES: " + str(anees) + "\n" + "Alpha: " + str(alpha) + "\n" + "CI NEES: " + str(ci_nees) + "\n" + \
               "CI ANEES: " + str(ci_anees)
print(metrics_info)

# plot
fig = plt.figure(figsize=(10, 6))
ax = fig.add_subplot(1, 1, 1)
ax.set_xlabel("$x$")
ax.set_ylabel("$y$")
ax.axis('equal')
Beispiel #2
0
        # fix the length of the fusions to dependent (as it is a bit shorter)
        num_tracks = len(tracks_fused_ais_as_measurement) - 1
        # get the num_tracks last elements
        tracks_fused_ais_as_measurement = tracks_fused_ais_as_measurement[
            -num_tracks:]

        # Calculate some metrics
        stats_individual = {}
        # calculate NEES
        stats_individual["NEES"] = calc_metrics.calc_nees(
            tracks_fused_ais_as_measurement, ground_truth)
        # calculate ANEES
        stats_individual["ANEES"] = calc_metrics.calc_anees(
            stats_individual["NEES"])
        # calculate RMSE
        stats_individual["RMSE"] = calc_metrics.calc_rmse(
            tracks_fused_ais_as_measurement, ground_truth)
        stats_individual["seed"] = seed
        stats_individual["fusion_type"] = "ais as measurement"
        stats_overall.append(stats_individual)

    # plot some results
    alpha = 0.95
    ci_nees = scipy.stats.chi2.interval(alpha, 4)
    ci_anees = np.array(scipy.stats.chi2.interval(alpha,
                                                  4 * num_tracks)) / num_tracks

    # plot ANEES and confidence interval
    fig_ci_anees = plt.figure(figsize=(10, 6))
    ax_ci_anees = fig_ci_anees.add_subplot(1, 1, 1)
    ax_ci_anees.set_xlabel("MC seed")
    ax_ci_anees.set_ylabel("ANEES")
Beispiel #3
0
        #                                                   ground_truth[-num_steps_metrics:])
        # stats_individual["seed"] = seed
        # stats_individual["fusion_type"] = "independent"
        # stats_overall.append(stats_individual)

        stats_individual = {}
        # calculate NEES
        stats_individual["NEES"] = calc_metrics.calc_nees(
            tracks_fused_dependent[-num_steps_metrics:],
            ground_truth[-num_steps_metrics:])
        # calculate ANEES
        stats_individual["ANEES"] = calc_metrics.calc_anees(
            stats_individual["NEES"])
        # calculate RMSE
        stats_individual["RMSE"] = calc_metrics.calc_rmse(
            tracks_fused_dependent[-num_steps_metrics:],
            ground_truth[-num_steps_metrics:])
        stats_individual["seed"] = seed
        stats_individual["fusion_type"] = "dependent"
        stats_overall.append(stats_individual)

        stats_individual = {}
        # calculate NEES
        stats_individual["NEES"] = calc_metrics.calc_nees(
            tracks_kf_fusion[-num_steps_metrics:],
            ground_truth[-num_steps_metrics:])
        # calculate ANEES
        stats_individual["ANEES"] = calc_metrics.calc_anees(
            stats_individual["NEES"])
        # calculate RMSE
        stats_individual["RMSE"] = calc_metrics.calc_rmse(
            -num_tracks:]
        # remove the first element of ground_truth (because we only fuse the n-1 last with dependent fusion)
        ground_truth = ground_truth[-num_tracks:]

        # Calculate some metrics
        stats_individual = {}
        # calculate NEES
        stats_individual["NEES"] = calc_metrics.calc_nees(
            tracks_fused_independent[-num_steps_metrics:],
            ground_truth[-num_steps_metrics:])
        # calculate ANEES
        stats_individual["ANEES"] = calc_metrics.calc_anees(
            stats_individual["NEES"])
        # calculate RMSE
        stats_individual["RMSE"] = calc_metrics.calc_rmse(
            tracks_fused_independent[-num_steps_metrics:],
            ground_truth[-num_steps_metrics:])
        stats_individual["seed"] = seed
        stats_individual["fusion_type"] = "independent"
        stats_overall.append(stats_individual)

        stats_individual = {}
        # calculate NEES
        stats_individual["NEES"] = calc_metrics.calc_nees(
            tracks_fused_dependent[-num_steps_metrics:],
            ground_truth[-num_steps_metrics:])
        # calculate ANEES
        stats_individual["ANEES"] = calc_metrics.calc_anees(
            stats_individual["NEES"])
        # calculate RMSE
        stats_individual["RMSE"] = calc_metrics.calc_rmse(