Ejemplo n.º 1
0
def run_tracker():
    sim, tracker = setup()
    readings, truths, filtered, residuals = filtering(sim, tracker)
    # plot_results(readings, filtered, residuals)

    # perform estimation
    cor = Correlator(residuals[-sample_size:])
    correlation = cor.autocorrelation(used_taps)
    R_mehra = estimate_noise_mehra(correlation, tracker.K, tracker.F,
                                   tracker.H)
    R_approx = estimate_noise_approx(correlation[0], tracker.H, tracker.P)
    abs_err_approx = R_approx - measurement_var
    rel_err_approx = abs_err_approx / measurement_var
    abs_err_mehra = R_mehra - measurement_var
    rel_err_mehra = abs_err_mehra / measurement_var
    print("True: %.6f" % measurement_var)
    print("Filter: %.6f" % tracker.R)

    print("Estimated (approximation): %.6f" % R_approx)
    print("Absolute error: %.6f" % abs_err_approx)
    print("Relative error: %.6f %%" % (rel_err_approx * 100))

    print("Estimated (mehra): %.6f" % R_mehra)
    print("Absolute error: %.6f" % abs_err_mehra)
    print("Relative error: %.6f %%" % (rel_err_mehra * 100))
    print("-" * 15)
    return (abs_err_mehra, rel_err_mehra, abs_err_approx, rel_err_approx)
Ejemplo n.º 2
0
def perform_estimation(residuals, residuals_posterior, tracker, H_arr, Ks):
    cor = Correlator(residuals)
    correlation = cor.autocorrelation(used_taps)
    R_mehra = estimate_noise_mehra(correlation, Ks[-1], tracker.F, H_arr[-1])
    R_extended = estimate_noise_extended(correlation, Ks, tracker.F, H_arr)
    R_approx = estimate_noise_approx(correlation[0], H_arr[-1], tracker.P)
    cor_posterior = Correlator(residuals_posterior)
    correlation_posterior = cor_posterior.autocorrelation(used_taps)
    R_approx_posterior = estimate_noise_approx(correlation_posterior[0],
                                               H_arr[-1], tracker.P,
                                               "posterior")

    truth = R_proto * measurement_var
    error_extended = matrix_error(R_extended, truth)
    error_mehra = matrix_error(R_mehra, truth)
    error_approx = matrix_error(R_approx, truth)
    error_approx_posterior = matrix_error(R_approx_posterior, truth)

    print("Extended estimation:")
    print("\tEstimated R:", R_extended)
    print("\tError: %.6f" % error_extended)
    print("Mehra estimation:")
    print("\tEstimated R:", R_mehra)
    print("\tError: %.6f" % error_mehra)
    print("Approximate estimation:")
    print("\tEstimated R:", R_approx)
    print("\tError: %.6f" % error_approx)
    print("Approximate estimation (posterior):")
    print("\tEstimated R:", R_approx_posterior)
    print("\tError: %.6f" % error_approx_posterior)

    return (error_extended, error_mehra, error_approx, error_approx_posterior)
Ejemplo n.º 3
0
def perform_estimation(residuals, tracker):
    cor = Correlator(residuals)
    C_arr = cor.autocorrelation(used_taps)
    print("Truth:\n", sim_var)
    R = estimate_noise_mehra(C_arr, tracker.K, tracker.F, tracker.H)
    print("Mehra Method:\n", R)
    R_approx = estimate_noise_approx(C_arr[0], tracker.H, tracker.P)
    print("Approximated Method:\n", R_approx)
def perform_estimation(residuals, tracker, F_arr, K_arr):
    residuals = residuals - np.average(residuals, axis=0)
    cor = Correlator(residuals)
    C_arr = cor.autocorrelation(used_taps)
    R = estimate_noise_mehra(C_arr, tracker.K, tracker.F, tracker.H)
    R_approx = estimate_noise_approx(C_arr[0], tracker.H, tracker.P)
    R_extended = estimate_noise_extended(C_arr, K_arr, F_arr, tracker.H)
    return R_approx
Ejemplo n.º 5
0
 def test_mehra_estimate(self):
     C_arr = np.asarray([[[31.371682426081264]], [[-6.9977524908455147]],
                         [[0.70876720569959328]], [[-7.1734736799032239]],
                         [[6.8883804618764914]], [[-2.6670500807302022]]])
     K = np.asarray([[0.32765478], [0.64824051]])
     F = np.array([[1, 0.1], [0, 1]])
     H = np.array([[1, 0]])
     R = estimate_noise_mehra(C_arr, K, F, H)
     assert R.shape == (1, 1)
def perform_estimation(residuals, tracker, F_arr, K_arr):
    cor = Correlator(residuals)
    C_arr = cor.autocorrelation(used_taps)
    print("Simulated:\n", R_proto * sim_var)
    R = estimate_noise_mehra(C_arr, tracker.K, tracker.F, tracker.H)
    print("Mehra:\n", R)
    R_approx = estimate_noise_approx(C_arr[0], tracker.H, tracker.P)
    print("Approximation:\n", R_approx)
    R_extended = estimate_noise_extended(C_arr, K_arr, F_arr, tracker.H)
    print("Extended:\n", R_extended)
Ejemplo n.º 7
0
def perform_estimation(residuals, tracker, H, F_arr, K_arr):
    cor = Correlator(residuals)
    correlation = cor.autocorrelation(used_taps)
    R_extended = estimate_noise_extended(correlation, K_arr, F_arr, H)
    R_mehra = estimate_noise_mehra(correlation, K_arr[-1], F_arr[-1], H)
    R_approx = estimate_noise_approx(correlation[0], H, tracker.P)
    truth = R_proto * measurement_var
    error_extended = matrix_error(R_extended, truth)
    error_mehra = matrix_error(R_mehra, truth)
    error_approx = matrix_error(R_approx, truth)
    return (error_extended, error_mehra, error_approx)
Ejemplo n.º 8
0
def perform_estimation(residuals, tracker, F_arr, Ks):
    residuals = residuals - np.average(residuals, axis=0)
    cor = Correlator(residuals)
    C_arr = cor.autocorrelation(used_taps)
    truth = R_proto * (sim_var + measurement_var)
    R = estimate_noise_mehra(C_arr, tracker.K, tracker.F, tracker.H)
    error_mehra = matrix_error(R, truth)
    R_approx = estimate_noise_approx(C_arr[0], tracker.H, tracker.P)
    error_approx = matrix_error(R_approx, truth)
    R_extended = estimate_noise_extended(C_arr, Ks, F_arr, tracker.H)
    error_extended = matrix_error(R_extended, truth)
    return (error_mehra, error_approx, error_extended)
Ejemplo n.º 9
0
def perform_estimation(residuals, tracker, lags):
    cor = Correlator(residuals[-sample_size:])
    correlation = cor.autocorrelation(lags)
    R_mehra = estimate_noise_mehra(correlation, tracker.K, tracker.F,
                                   tracker.H)
    R_approx = estimate_noise_approx(correlation[0], tracker.H, tracker.P,
                                     "posterior")
    truth = R_proto * measurement_var
    error_mehra = matrix_error(R_mehra, truth)
    error_approx = matrix_error(R_approx, truth)
    print("Truth:\n", truth)
    print("Estimation Mehra:\n", R_mehra)
    print("Error Mehra:\n", error_mehra)
    print("Estimation Mohamed:\n", R_approx)
    print("Error Mohamed:\n", error_approx)
    print("-" * 15)
    return (error_mehra, error_approx)
Ejemplo n.º 10
0
def perform_estimation(residuals, tracker, F_arr, K_arr):
    cor = Correlator(residuals)
    correlation = cor.autocorrelation(used_taps)
    R_extended = estimate_noise_extended(correlation, K_arr, F_arr, tracker.H)
    R_mehra = estimate_noise_mehra(correlation, K_arr[-1], F_arr[-1],
                                   tracker.H)
    R_approx = estimate_noise_approx(correlation[0], tracker.H, tracker.P)
    truth = R_proto * measurement_var
    print("Truth:\n", truth)
    print("Extended Estimation:\n", R_extended)
    print("Error:\n", matrix_error(R_extended, truth))
    print("Mehra estimation:\n", R_mehra)
    print("Error:\n", matrix_error(R_mehra, truth))
    print("Approximated estimation:\n", R_approx)
    print("Error:\n", matrix_error(R_approx, truth))
    print("-" * 15)
    error = matrix_error(R_extended, truth)
    return error
Ejemplo n.º 11
0
def perform_estimation(residuals, tracker, F_arr, K_arr):
    residuals = residuals - np.average(residuals, axis=0)
    cor = Correlator(residuals)
    C_arr = cor.autocorrelation(used_taps)
    truth = R_proto * sim_var
    matrix_size = matrix_error(truth, 0)
    print("Truth:\n", truth)
    R = estimate_noise_mehra(C_arr, tracker.K, tracker.F, tracker.H)
    error_R = matrix_error(R, truth)
    print("Mehra:\n", R)
    print("\t Relative error: %.6f" % (error_R / matrix_size))
    R_extended = estimate_noise_extended(C_arr, K_arr, F_arr, tracker.H)
    error_R_extended = matrix_error(R_extended, truth)
    print("Extended:\n", R_extended)
    print("\t Relative error: %.6f" % (error_R_extended / matrix_size))
    R_approx = estimate_noise_approx(C_arr[0], tracker.H, tracker.P)
    error_R_approx = matrix_error(R_approx, truth)
    print("Approximation:\n", R_approx)
    print("\t Relative error: %.6f" % (error_R_approx / matrix_size))