PHP function: Generate n non-repeating random number, PHP random number
PHP function: Generate n non-repeating random numbers
Idea: A certain number of distinct random numbers can be generated by depositing the generated random number into an array and then removing the duplicate values in the array.
Program:
Additional notes:
1. Generate random numbers using the Mt_rand () function, which is 4 times times faster than the rand () function;
2, the elimination of duplicate values of the array using the "rollover method", is to use Array_flip () the array of key and value exchange two times. Much faster than using Array_unique ().
How does matlab produce random numbers that are not duplicated?
Rand (1,8) *100
Ans =
Columns 1 through 7
81.4724 90.5792 12.6987 91.3376 63.2359 9.7540 27.8498
Column 8
54.6882
Using Excel to generate n random numbers, how to use an if function to make it non-repeating
Select a1:a1000, and in the formula bar, enter
=rand ()
Press "CTRL + ENTER"
Select b1:b1000, and in the formula bar, enter
=rank (a1,a$1:a$1000)
Press "CTRL + ENTER"
http://www.bkjia.com/PHPjc/827776.html www.bkjia.com true http://www.bkjia.com/PHPjc/827776.html techarticle PHP Function: Generate n non-repeating random number, PHP random number PHP function: Generate n non-repeating random number idea: the generated random number into an array, and then remove the duplicate values in the array ...