# hacky way; just so its easy to reuse code
measurement_model_radar = kf_independent_fusion.measurement_model_radar
measurement_model_ais = measurement_model_radar

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))
Ejemplo n.º 2
0
        # # 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(
            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_fused_ais_as_measurement, _ = kf_ais_as_measurement.track()

        # fix the length of the fusions to dependent (as it is a bit shorter)
        num_tracks = len(tracks_fused_dependent)
        # get the num_tracks last elements
        tracks_fused_independent = tracks_fused_independent[-num_tracks:]
        tracks_fused_ais_as_measurement = tracks_fused_ais_as_measurement[
            -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(
Ejemplo n.º 4
0
            sigma_process=sigma_process,
            sigma_meas_radar=sigma_meas_radar,
            sigma_meas_ais=sigma_meas_ais)

        tracks_fused_ais_as_measurement, _ = kf_ais_as_measurement.track()

        # 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
Ejemplo n.º 5
0
        start_time,
        prior,
        sigma_process_radar=0.01,
        sigma_process_ais=0.01,
        sigma_meas_radar=3,
        sigma_meas_ais=1)
    tracks_fused_independent, _, _ = kf_independent_fusion.track()

    # TODO fix structure
    # TODO fix that the size of tracks fused under independence and dependence have different size than ais as
    #  measurement

    # Calculate some metrics
    stats_individual = {}
    # calculate NEES
    stats_individual["NEES"] = calc_metrics.calc_nees(tracks_fused,
                                                      ground_truth)
    # calculate ANEES
    stats_individual["ANEES"] = calc_metrics.calc_anees(
        stats_individual["NEES"])
    stats_individual["seed"] = seed
    stats_overall.append(stats_individual)

# plot some results
num_tracks = len(tracks_fused)
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))