Added boolean random generator

This commit is contained in:
Xavier Arteaga 2020-02-11 15:43:09 +01:00 committed by Xavier Arteaga
parent f9c3dd2748
commit 7a20e3a51e
2 changed files with 8 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "srslte/config.h"
#include <inttypes.h>
#include <stdbool.h>
#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

View File

@ -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) {