Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Is random numbers after mod still random?

Status
Not open for further replies.

naught

Member level 3
Member level 3
Joined
Aug 25, 2012
Messages
59
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Location
chengdu
Visit site
Activity points
1,739
I`m considering the Linear Feedback Shift Register to generate the uniform distributed numbers.
I tried using short FFs to generate sequences. but it seems to me not random because the FFs is short, and sequence repeated itself in a short and fixed cycle.

So I try the longer FFs, say 63 bits LFSR.
But I have a question here. Since the integers between 0 to 3 is all what I want, and thus I would map all the numbers confined to the range between 0 to 3, by mod function.
say if number 42 is generated, 42 mod 4 => 2, then I get 2.
in the end, just a sequence of 0,1,2,3 is desirable.

Does this change the randomness(even though it`s pseudo random)? and is the sequence still uniformly distributed?

Personally I feel it is, because the mod function is, at least it seems to me, sort of linear(it`s not)
thx in advance.8-O
 
Last edited:

In a maximum length LFSR sequence, each number occurs exactly once. Thus the distribution of the result sequence can be easily counted.
 

I THINK that if your register length is an integer multiple of 4, then you will still have a uniform distribution. But I don't think there is ANY advantage to creating a longer LFSR. Why would you do this?
 

the longer you make it, it may appear more random if you only look at the bottom 2 bits, but you will still get each value 0-3 the same number of times over 2^n samples (where n is the width of the LFSR)
 
  • Like
Reactions: naught

    naught

    Points: 2
    Helpful Answer Positive Rating
What's the problem? You have your whatever length LFSR. You pick the LFSR length such that the repetition lenght is "sufficiently large" for your particular design. The lfsr spits out a single bit per clock. This generates a loooooong string of bits. And you chop this up in pieces of 2-bits in your case, but you could for example do 8-bits if you wanted random bytes. And if an infinite length bit string is random, then so is the chopped up 2-bits per number for your 0-3 range.
 
  • Like
Reactions: naught

    naught

    Points: 2
    Helpful Answer Positive Rating
I changed my mind, instead of using mod function, it might be better to chop off 2-bits of the LFSR.~~~

FvM, barry, TrickyDicky, mrflibble, thank you guys all!!
you guys are amazing!!!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top