0
$\begingroup$

I wonder if that is possible to create a number generator that will satisfy following requirements:

  1. If seed S is provided, then generator will return a number Nx that belongs to a "family" N.
  2. If number produced by the generator (Nx) is provided as a seed, then generator will return a number Ny that belongs to N as well.
  3. "Belongs to 'N'" means that there is a function F(x,y) that returns 'true' if numbers belong to same family N and 'false' otherwise.

Is it possible to create such a generator with the function F?

Update 1: Amount of 'families' is not known. As well as amount of values that belong to each family (generator can use numbers from whole 128 bits range for each family). Thus, numbers sets returned from different generators can have intersections (the more numbers generated the more is probability of it).

Thanks, Dmitry

$\endgroup$
  • $\begingroup$ Is a "family" just a subset of the output set? $\endgroup$ – Alex G. Oct 27 '16 at 20:31
  • $\begingroup$ And do families form a partition of the output set? I.e. is "x is in the same family as y" an equivalence relation? $\endgroup$ – Alex G. Oct 27 '16 at 20:32
  • $\begingroup$ Yes, let's say we have 128 bits for all numbers. Family is a subset of it. $\endgroup$ – pnt_of_view Oct 27 '16 at 20:34
  • $\begingroup$ Yes, if X1 was a seed for X2, then 'X1 is in the same family as X2' and 'X2 is in the same family as X1'. Moreover, generated this way X1, X2,... XN all belong to same family. $\endgroup$ – pnt_of_view Oct 27 '16 at 20:36
  • $\begingroup$ Ok, then for each subset $N$, just define a random number generator which accepts elements of $N$ as input and outputs elements of $N$. Then put these all together to get a random number generator that accepts any input and has the desired properties. $\endgroup$ – Alex G. Oct 27 '16 at 20:37
0
$\begingroup$
Maybe, it's good for you

abstract class MyRandom{
   private Random rnd;
   private long startSeed;

   protected MyRandom(long seed){
       rnd = new Random(seed);
       startSeed = seed;
   }

   public long nextLong(){
      while(true){
          long nextTry = rnd.nextLong();
          if(F(startSeed, nextTry)) return nextTry;
      }

   }

   protected abstract boolean F(long n1, long n2); 
}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.