summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/math/random.cc
diff options
context:
space:
mode:
authorAndrej Rode <mail@andrejro.de>2018-03-19 23:33:03 +0100
committerMarcus Müller <marcus.mueller@ettus.com>2018-03-30 16:51:31 +0200
commit26ca54a29ad74ca3612db7433a855f4fd41f7d61 (patch)
tree3ee575b442936be1c721e08aa3dc038f7f5e7b7a /gnuradio-runtime/lib/math/random.cc
parent57a92af4e9f4b5eba42a00749b0936d06a2779b4 (diff)
analog: improve readability of laplacian distribution
Diffstat (limited to 'gnuradio-runtime/lib/math/random.cc')
-rw-r--r--gnuradio-runtime/lib/math/random.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc
index af90a33429..cedaf4b97f 100644
--- a/gnuradio-runtime/lib/math/random.cc
+++ b/gnuradio-runtime/lib/math/random.cc
@@ -141,11 +141,12 @@ namespace gr {
float
random::laplacian()
{
- float z = ran1()-0.5;
- if(z>0) return -logf(1-2*z);
- else return logf(1+2*z);
+ float z = ran1();
+ if (z > 0.5f){
+ return -logf(2.0f * (1.0f - z) );
+ }
+ return logf(2 * z);
}
-
/*
* Copied from The KC7WW / OH2BNS Channel Simulator
* FIXME Need to check how good this is at some point