3
$\begingroup$

I have a function(say RandOne() ) which return random number upto $2^{31}-1$ (32 bit) . How to use that function to generate random number upto $2^{63}-1$ (64 bit)?

I think we should use something like one to many mapping . Using RandOne function many times and use it to make new function RandTwo() (which generate upto 64 bit number) but how to make sure that probability of any number is uniformly distributed ?

PS: We can assume RandOne() is perfect random generator .Hence probability of each number generated by it is equal .

  • 0
    If you can obtain 32 random bits at a time, and what you need is 64 random bits, what do you think you should do?2012-08-05
  • 0
    concatenation will not make sure that probability of each number is equal . will it ?2012-08-05
  • 1
    tesla, that would depend on the details of RandOne.2012-08-05
  • 0
    It depends. If RandOne just has a 32-bit state, the second value will be determined by the first.2012-08-05
  • 0
    If it is "perfect", all possible pairs $(x_1, x_2)$ will also have equal probabilities of being produced by consecutive calls to RandOne.2012-08-05
  • 0
    yeah , now i get it , silly me. I think , this question should be closed now.2012-08-05
  • 0
    @tesla - please clarify what you mean by "perfect random generator". To me, this term implies that previous results do not impact the number generated. If that's the case, then this is an easy question. If it's not the case, then you may be asking for something that's not actually possible.2012-08-05
  • 0
    bitwise XOR like http://docs.oracle.com/javase/7/docs/api/java/lang/Long.html#hashCode%28%292012-08-05
  • 0
    @labbhattacharjee - the link that you've given describes how to convert 64 bits to 32 bits; not the other way around.2012-08-05

1 Answers 1