Hi list,

I recently find that the noise seed block needs negative seed for
gaussian and uniform distributions. The commit 0d6871b3 has provided
documentation for this and also changed the seed in noise seed from
positive value to 0 to avoid misleading. However, the seed value in
channel model block hasn't been updated. And in some python scripts,
we use `randint(0, 100000)` as the seed. This is misleading and doesn't
give what we want.

I attach a patch to address the issue.

-- 
alick
Fedora 16 (Verne) user
https://fedoraproject.org/wiki/User:Alick
>From 96699e5a3e9b7b7f585245e8232bb2cbfed75c62 Mon Sep 17 00:00:00 2001
From: Alick Zhao <[email protected]>
Date: Fri, 2 Nov 2012 19:41:47 +0800
Subject: [PATCH] fix noise seed in channel_model

This is a followup of the fix in commit 0d6871b3.

The channel_model block is a heir-block which contains a noise source
inside. The noise source need the seed to be negative to generate
gaussian or uniform noise.
---
 gnuradio-core/src/lib/hier/gr_channel_model.h      |    2 +-
 gnuradio-core/src/lib/hier/gr_channel_model.i      |    2 +-
 .../examples/narrowband/benchmark_add_channel.py   |    2 +-
 gr-digital/examples/ofdm/benchmark_add_channel.py  |    2 +-
 gr-filter/include/filter/channel_model.h           |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.h b/gnuradio-core/src/lib/hier/gr_channel_model.h
index 3f289e3..f0b31b1 100644
--- a/gnuradio-core/src/lib/hier/gr_channel_model.h
+++ b/gnuradio-core/src/lib/hier/gr_channel_model.h
@@ -36,7 +36,7 @@ GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0
 					    double frequency_offset=0.0,
 					    double epsilon=1.0,
 					    const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1),
-					    double noise_seed=3021);
+					    double noise_seed=0);
 
 /*!
  * \brief channel simulator
diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.i b/gnuradio-core/src/lib/hier/gr_channel_model.i
index 24a9388..9aa6ebf 100644
--- a/gnuradio-core/src/lib/hier/gr_channel_model.i
+++ b/gnuradio-core/src/lib/hier/gr_channel_model.i
@@ -26,7 +26,7 @@ gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0,
 					    double frequency_offset=0.0,
 					    double epsilon=1.0,
 					    const std::vector<gr_complex> &taps=std::vector<gr_complex>(1, 1),
-					    double noise_seed=3021);
+					    double noise_seed=0);
 
 class gr_channel_model : public gr_hier_block2
 {
diff --git a/gr-digital/examples/narrowband/benchmark_add_channel.py b/gr-digital/examples/narrowband/benchmark_add_channel.py
index 841833a..c69ee60 100755
--- a/gr-digital/examples/narrowband/benchmark_add_channel.py
+++ b/gr-digital/examples/narrowband/benchmark_add_channel.py
@@ -44,7 +44,7 @@ class my_top_block(gr.top_block):
         self.src = gr.file_source(gr.sizeof_gr_complex, ifile)
         #self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
         self.channel = gr.channel_model(noise_voltage, frequency_offset,
-                                        time_offset, noise_seed=random.randint(0,100000))
+                                        time_offset, noise_seed=-random.randint(0,100000))
         self.phase = gr.multiply_const_cc(complex(math.cos(phase_offset),
                                                   math.sin(phase_offset)))
         self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile)
diff --git a/gr-digital/examples/ofdm/benchmark_add_channel.py b/gr-digital/examples/ofdm/benchmark_add_channel.py
index 01776d2..cbdd990 100755
--- a/gr-digital/examples/ofdm/benchmark_add_channel.py
+++ b/gr-digital/examples/ofdm/benchmark_add_channel.py
@@ -46,7 +46,7 @@ class my_top_block(gr.top_block):
         self.src = gr.file_source(gr.sizeof_gr_complex, ifile)
         #self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
         self.channel = gr.channel_model(noise_voltage, frequency_offset,
-                                        time_offset, noise_seed=random.randint(0,100000))
+                                        time_offset, noise_seed=-random.randint(0,100000))
         self.phase = gr.multiply_const_cc(complex(math.cos(phase_offset),
                                                   math.sin(phase_offset)))
         self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile)
diff --git a/gr-filter/include/filter/channel_model.h b/gr-filter/include/filter/channel_model.h
index 2e808de..49c0818 100644
--- a/gr-filter/include/filter/channel_model.h
+++ b/gr-filter/include/filter/channel_model.h
@@ -68,7 +68,7 @@ namespace gr {
 				  double frequency_offset=0.0,
 				  double epsilon=1.0,
 				  const std::vector<gr_complex> &taps=std::vector<gr_complex>(1,1),
-				  double noise_seed=3021);
+				  double noise_seed=0);
 
       virtual void set_noise_voltage(double noise_voltage) = 0;
       virtual void set_frequency_offset(double frequency_offset) = 0;
-- 
1.7.7.6

_______________________________________________
Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to