[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Discuss-gnuradio] Re: gr_noise_source_X( ) only negative seeds?

**From**: |
Tim Meehan |

**Subject**: |
[Discuss-gnuradio] Re: gr_noise_source_X( ) only negative seeds? |

**Date**: |
Fri, 16 Mar 2007 08:48:53 -0400 |

I have submitted a patch to patch-gnuradio@ for gr_noise_source and qa code
The patch is to gr_noise_source_X rather than gr_random::ran1()
I am not sure why but most implementations from ran1() set all positive
values of seeds to 1. Rather then mess with what may be convention I
thought it might be better to fix in gr_noise_source.
Index: gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t
===================================================================
--- gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t (revision 4763)
+++ gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t (working copy)
@@ -43,7 +43,8 @@
gr_make_io_signature (1, 1, sizeof (@TYPE@))),
d_type (type),
d_ampl (ampl),
- d_rng (seed)
+ // for ran1() positive values for seed all return same sequence
+ d_rng ((seed < 0)?seed:-seed)
{
}
On 3/8/07, Tim Meehan <address@hidden> wrote:

Hi All
When seeded with a positive number gr_noise_source_X seems to always
return the same sequence.
i.e.
call gr_noise_source_f(gr.GAUSSIAN,1,Z) where Z > 0 the sequence is
always the same. Called with a negative seed (Z < 0 ) it behaves as I
would expect.
Am I missing something?
I think this is from lines below in gr_random, but the comment
made me scared to touch it :-)
/*
* This looks like it returns a uniform random deviate between 0.0 and 1.0
* It looks similar to code from "Numerical Recipes in C".
*/
float gr_random::ran1()
{
int j;
long k;
float temp;
if (d_seed <= 0 || !d_iy) {
if (-d_seed < 1) <<<<<<<<<< HERE
d_seed=1; <<<<<<<<<< and HERE
else
d_seed = -d_seed;
for (j=NTAB+7;j>=0;j--) {
k=d_seed/IQ;
<snip>