Forum: GNU Radio gr_noise_source_X( ) only negative seeds?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
93bcc40cd07916689fe7de8afde22af1?d=identicon&s=25 Tim Meehan (Guest)
on 2007-03-09 01:07
(Received via mailing list)
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 :-)

 * 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--) {
93bcc40cd07916689fe7de8afde22af1?d=identicon&s=25 Tim Meehan (Guest)
on 2007-03-16 13:49
(Received via mailing list)
I have submitted a patch to  patch-gnuradio@  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)
This topic is locked and can not be replied to.