diff options
author | Stefan <stefan.wunsch@student.kit.edu> | 2015-09-01 13:21:51 +0200 |
---|---|---|
committer | Stefan <stefan.wunsch@student.kit.edu> | 2015-09-01 13:21:51 +0200 |
commit | ebad2162b40b2b144449ff2927dbe89c683c4972 (patch) | |
tree | 5a8219cd5001f0402a21ac9eb28670c22aefeefb /gnuradio-runtime/lib/math | |
parent | 1206251231696359270a260508551e044f3af33a (diff) |
fix wrong laplacian random numbers and add testcase
Diffstat (limited to 'gnuradio-runtime/lib/math')
-rw-r--r-- | gnuradio-runtime/lib/math/random.cc | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc index 7170f27edf..ecf70e0f9a 100644 --- a/gnuradio-runtime/lib/math/random.cc +++ b/gnuradio-runtime/lib/math/random.cc @@ -130,18 +130,12 @@ namespace gr { return d_gset; } - /* - * Copied from The KC7WW / OH2BNS Channel Simulator - * FIXME Need to check how good this is at some point - */ float random::laplacian() { - float z = ran1(); - if(z < 0.5) - return log(2.0 * z) / M_SQRT2; - else - return -log(2.0 * (1.0 - z)) / M_SQRT2; + float z = ran1()-0.5; + if(z>0) return -log(1-2*z); + else return log(1+2*z); } /* @@ -161,10 +155,6 @@ namespace gr { /* * Complex rayleigh is really gaussian I and gaussian Q - * It can also be generated by real rayleigh magnitude and - * uniform random angle - * Adapted from The KC7WW / OH2BNS Channel Simulator - * FIXME Need to check how good this is at some point */ gr_complex random::rayleigh_complex() @@ -172,13 +162,6 @@ namespace gr { return gr_complex(gasdev(),gasdev()); } - /* Other option - mag = rayleigh(); - ang = 2.0 * M_PI * RNG(); - *Rx = rxx * cos(z); - *Iy = rxx * sin(z); - */ - float random::rayleigh() { |