-2

I want to generate random numbers . Now, I want to generate a new set of random numbers in a way that that increases the probability of returning the numbers that were generated earlier.What is the best way of achieving this ?

harveyslash
  • 5,906
  • 12
  • 58
  • 111
user2935569
  • 347
  • 2
  • 7
  • 15
  • 1
    If you use the same seed for the random number generator it will generate the same sequence of numbers. – Henry Jul 04 '14 at 06:37
  • This may be the answer... http://stackoverflow.com/questions/12458383/java-random-numbers-using-a-seed – Jakub Jul 04 '14 at 06:38

2 Answers2

1

I dont know if predefined functions exist or not, but I have something in mind that you can try.

  1. Make an ArrayList of the numbers. (eg. if you want to generate from 0to30, then make an ArrayList of Integers from 0 to 30).
  2. Shuffle the ArrayList(Collections.shuffle())
  3. Pick the first 2 numbers.
  4. Then, just add those 2 numbers into the ArrayList as many times as you want the probablity to shift towards them.
  5. Shuffle again and pick
harveyslash
  • 5,906
  • 12
  • 58
  • 111
0

You can store that values on array. And you can have a random condition also for having a new pair of number or pick randomly on your array.

bumbumpaw
  • 2,522
  • 1
  • 24
  • 54