2018-08-14 04:54:00 +00:00
|
|
|
/*!
|
2019-06-12 18:51:19 +00:00
|
|
|
* \file bayesian_estimation_test.cc
|
2019-07-20 10:55:46 +00:00
|
|
|
* \brief This file implements feasibility test for the BCE library.
|
2019-06-12 18:51:19 +00:00
|
|
|
* \author Gerald LaMountain, 2018. gerald(at)ece.neu.edu
|
2018-08-14 04:54:00 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-07-26 10:38:20 +00:00
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2018-08-14 04:54:00 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2018-08-14 04:54:00 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "bayesian_estimation.h"
|
2018-08-14 04:54:00 +00:00
|
|
|
#include <armadillo>
|
|
|
|
#include <gtest/gtest.h>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <random>
|
2018-08-14 04:54:00 +00:00
|
|
|
|
|
|
|
#define BAYESIAN_TEST_N_TRIALS 100
|
|
|
|
#define BAYESIAN_TEST_ITER 10000
|
|
|
|
|
|
|
|
TEST(BayesianEstimationPositivityTest, BayesianPositivityTest)
|
|
|
|
{
|
|
|
|
Bayesian_estimator bayes;
|
|
|
|
arma::vec bayes_mu = arma::zeros(1, 1);
|
|
|
|
int bayes_nu = 0;
|
|
|
|
int bayes_kappa = 0;
|
|
|
|
arma::mat bayes_Psi = arma::ones(1, 1);
|
2018-08-21 16:11:03 +00:00
|
|
|
arma::vec input = arma::zeros(1, 1);
|
2018-08-14 04:54:00 +00:00
|
|
|
|
2019-09-13 06:56:37 +00:00
|
|
|
// -- Perform initializations ------------------------------
|
2018-08-14 04:54:00 +00:00
|
|
|
|
|
|
|
std::random_device r;
|
|
|
|
std::default_random_engine e1(r());
|
|
|
|
std::normal_distribution<float> normal_dist(0, 5);
|
|
|
|
|
|
|
|
for (int k = 0; k < BAYESIAN_TEST_N_TRIALS; k++)
|
|
|
|
{
|
|
|
|
bayes.init(bayes_mu, bayes_kappa, bayes_nu, bayes_Psi);
|
|
|
|
|
|
|
|
for (int n = 0; n < BAYESIAN_TEST_ITER; n++)
|
|
|
|
{
|
2018-08-21 16:11:03 +00:00
|
|
|
input(0) = static_cast<double>(normal_dist(e1));
|
2018-08-14 04:54:00 +00:00
|
|
|
bayes.update_sequential(input);
|
|
|
|
|
2018-08-21 16:11:03 +00:00
|
|
|
arma::mat output = bayes.get_Psi_est();
|
|
|
|
double output0 = output(0, 0);
|
|
|
|
ASSERT_EQ(output0 > 0.0, true);
|
2018-08-14 04:54:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|