###### Asked in PHP Programming

PHP Programming

# Why are random numbers useful in PHP?

## Answer

###### Wiki User

###### June 03, 2009 11:41PM

Random numbers can be used for many different things.

Personally i use the rand() directive for security measures to define a session identifier.

Also i use the rand feature (sometimes) for user authentication while using captcha images.

basically, when you need a random number, use rand() ;)

## Related Questions

###### Asked in Math and Arithmetic, Statistics, Java Programming

### What is a random number and how are generated?

Random numbers that are generated by a computer are
pseudo-random (not really random), but they will pass enough
statistical tests for randomness to be useful in simulation random
processes. Java has random number generators in the standard
libraries.
See the related link if you need more information.

###### Asked in PHP Programming

### How do you pick a random value from a PHP array?

To pick random results from an array in PHP you will need to use
the array_rand() function, you can select the amount of results you
wish it too select too.
<?php
$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$rand_results = array_rand($array, 3); // will select 3 random
results from the array and store in a new array
?>

###### Asked in Numbers , Mathematical Constants

### Why do you use pseudorandom numbers in simulations?

Generation of random numbers is not a simple process. In order
for a number to be truly random it must be uniformly distributed
(each random number in the interval of random numbers has equal
chance of being selected), efficiently generated (the random
numbers hsould not degenerate into constant values or recycle too
frequently) and absent of patterns. Computers can generate random
numbers using a mathematical process that artificially creates
psuedorandom numbers more efficiently than true random numbers can
be generated in a process akin to spinning the roulette wheel.

###### Asked in Microsoft Excel

### Which function is used to randomize number in Excel?

There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.
There is a RAND function which can generate random numbers. The
RANDBETWEEN function can generate numbers between a lower and upper
limit.

###### Asked in Mathematical Constants

### Why do you use pseudorandom numbers in simulation?

There are two main reasons. One is that most sequences of random
numbers are generated using algorithms. These are tested to ensure
that the numbers appear to be random but, because they are
generated systematically, they are pseudo random numbers and not
truly random.
It is sometimes necessary to re-run a simulation -
reproducibility is an important requirement of scientific research.
This would clearly be impossible if truly random numbers were used.
However, given the necessary "seed or seeds", the same sequence can
be reproduced.

###### Asked in Homeschooling, Algebra

### Why is it important to ensure that an experimental sample is totally random?

To ensure that the results produced from your sample are fair
and true. For example, if you had to pick 10 random numbers between
1 and 6, you could just say numbers that come into your head, but
that wouldn't be random because you're choosing the numbers. A more
random and fair way would be to roll a die 10 times and use those
numbers, because you are in no way picking the numbers.