gr_noise_source_X( ) only negative seeds?

Hi All

When seeded with a positive number gr_noise_source_X seems to always
return the same sequence.


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 :slight_smile:


  • This looks like it returns a uniform random deviate between 0.0 and
  • 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
d_seed = -d_seed;
for (j=NTAB+7;j>=0;j–) {

I have submitted a patch to [email protected] for gr_noise_source and qa

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/

— gnuradio-core/src/lib/gengen/ (revision 4763)
+++ gnuradio-core/src/lib/gengen/ (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)