The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 16th, 2024, 4:04pm
Pages: 1
Send Topic Print
How to chose seed? (Read 4956 times)
neoflash
Community Fellow
*****
Offline

Mixed-Signal
Designer

Posts: 397

How to chose seed?
Nov 15th, 2006, 10:20pm
 
How we choose the value of seed, of random number generator and how it affects?
Does this number play any role, besides specify a determistic start point? What if I chose seed=111?
Back to top
 
 
View Profile   IP Logged
neoflash
Community Fellow
*****
Offline

Mixed-Signal
Designer

Posts: 397

Re: How to chose seed?
Reply #1 - Nov 15th, 2006, 10:21pm
 
attach the sample usage here: dT = jitter*$rdist_normal(seed,0,1);
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: How to chose seed?
Reply #2 - Nov 16th, 2006, 11:24am
 
As far as I know, it's just a start point in the sequence of pseudo-random numbers.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
neoflash
Community Fellow
*****
Offline

Mixed-Signal
Designer

Posts: 397

Re: How to chose seed?
Reply #3 - Nov 16th, 2006, 5:03pm
 
I have attached one sample code from this website, why author chose seed=286, not other number?

module osc2 (out);

output out; voltage out;                  // output signal
parameter real freq=1 from (0:inf);            // output frequency
parameter real vl=-1;                        // high output voltage
parameter real vh=1;                        // low output voltage
parameter real tt=0.01/freq from (0:inf);      // transition time of output
parameter real jitter=0 from [0:0.1/freq);      // white period jitter
integer n, seed;
real next, dT;

analog begin
   @(initial_step) begin
     seed = 286;
     next = 0.5/freq + $abstime;
   end
   @(timer(next)) begin
     n = !n;
     dT = jitter*$rdist_normal(seed,0,1);
     next = next + 0.5/freq + `M_SQRT1_2*dT;
   end
   V(out) <+ transition(n ? vh : vl, 0, tt);
end
endmodule
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: How to chose seed?
Reply #4 - Nov 16th, 2006, 7:20pm
 
It was a completely arbitrary choice. The only criteria I used was to use a different seed for each rdist function present in the system. If you give the same seed to two different rdist functions they will produce an identical sequence of random numbers.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: How to chose seed?
Reply #5 - Nov 17th, 2006, 5:54am
 
Ken Kundert wrote on Nov 16th, 2006, 7:20pm:
It was a completely arbitrary choice. The only criteria I used was to use a different seed for each rdist function present in the system. If you give the same seed to two different rdist functions they will produce an identical sequence of random numbers.


By "two different rdist functions" Ken does not mean to say that $rdist_normal() and $rdist_uniform will give the same sequence of random numbers.  I am fairly sure he meant "give the same seed to two different calls of the same rdist function":

Modifying the example:

integer n, seed, seed2;
real next, dT, dT2;

analog begin
 @(initial_step) begin
   seed = 286;
   seed2 = 286;
   next = 0.5/freq + $abstime;
 end
 @(timer(next)) begin
   n = !n;
   dT = jitter*$rdist_normal(seed,0,1);
   dT2 = jitter*$rdist_normal(seed2,0,1); // will have the same sequence of values as dT
  next = next + 0.5/freq + `M_SQRT1_2*dT;
 end
 V(out) <+ transition(n ? vh : vl, 0, tt);
end

dT2 will have the exact same sequence of random values as dT.  Also, seed and seed2 are changed by the $rdist function calls, and the sequence of their values will be the same.

I wonder: if you did
 rn1 = $rdist_normal(seed,0,1);
 rn2 = $rdist_uniform(seed2,-1,1);

will "seed" and "seed2" have the same sequence of (integer) values?  I guess you might or might not, since the LRM doesn't say.

-Geoffrey
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.