java - math.random() follows which algorithms -


am using math.random() method generate random numbers. had doubt method. math.random() algorithms fallow generate random numbers. there random number generated algorithm?

am trying code think not efficient generate random code:

for (int = 0; < n; i++) {      int sd = + (int) (math.random() * (n-i));       string t = one[r];      one[r] = one[i];      one[i] = t;  } 

is there better algorithm random number generation?

use java.util.random api

an instance of class used generate stream of pseudorandom numbers. class uses 48-bit seed, modified using linear congruential formula. (see donald knuth, art of computer programming, volume 3, section 3.2.1.)

algorithm class : pseudorandom number generator known prng. can read more here.

note : math.random() uses java.util.random instance generate psuedo-random numbers internally


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -