diff --git a/lib/include/srslte/phy/utils/random.h b/lib/include/srslte/phy/utils/random.h index 311f3d936..eb0bc74bc 100644 --- a/lib/include/srslte/phy/utils/random.h +++ b/lib/include/srslte/phy/utils/random.h @@ -25,6 +25,7 @@ #include "srslte/config.h" #include +#include #ifdef __cplusplus extern "C" { @@ -45,6 +46,8 @@ srslte_random_uniform_complex_dist_vector(srslte_random_t q, cf_t* vector, uint3 SRSLTE_API float srslte_random_gauss_dist(srslte_random_t q, float std_dev); +SRSLTE_API bool srslte_random_bool(srslte_random_t q, float prob_true); + SRSLTE_API void srslte_random_free(srslte_random_t q); #ifdef __cplusplus diff --git a/lib/src/phy/utils/random.cpp b/lib/src/phy/utils/random.cpp index 43095977d..4ec130d03 100644 --- a/lib/src/phy/utils/random.cpp +++ b/lib/src/phy/utils/random.cpp @@ -117,6 +117,11 @@ float srslte_random_gauss_dist(srslte_random_t q, float std_dev) return ret; } +bool srslte_random_bool(srslte_random_t q, float prob_true) +{ + return srslte_random_uniform_real_dist(q, 0, 1) < prob_true; +} + void srslte_random_free(srslte_random_t q) { if (q) {