I want to implement a random oracle in C ++. Essentially, a function f: {1, ..., n} → [0.1], so that for each input i in {1, ..., n} the output f (i) is a random value in [0 ,1]. But it is important that each call to the function f (i) return the same value.
In other words, I need a very large table f independently and identically distributed random variables [0,1] indexed by integers. Of course, I do not want prekompoputirovat table and store it. Instead, I want this table was realized "on the fly". You give input i, and you get the value from the table f (i).
What is the best way to implement it? One possibility is to use the input integer I, as seed for the random number generator. Then f (i) is a random number generated from the I as a seed. That's good enough? Thanks!
(This question has been edited based on helpful comments.)
source
share