Ads removed from the pastie. \o/
Running costs stayed. :-(
Donations welcome!
Bitcoin: |
1QC38uPBSy7WSYz1whM5SYTHAdhqkN6o8V |
Ethereum: |
0x0855778a6181a69cc7d5d08c71c4f5846010eb67 |
Verge: |
D8fo1fszrNmUK4kfQW5owhYMv3osPvgn2g |
Paste ID: |
# mwLQY |
Date posted: |
Wed, 18 Jan 2012 22:26:01 +0000 |
Date of expiration: |
never (permanent entry) |
Description: |
(PHP) Generate / Create (pseudo) random numbers between -1 and 1 |
<?php
/**To generate (pseudo) random numbers in range of -1 and 1 you can use the cosine
* that will return a number in range of -1.0 and 1.0.
*
* Note for nerds:
* It's not a real big problem that the cosine is deterministic due to the fact that mt_rand isn't really perfect, too. Hence this is PSEUDO random number generation.
*/
// In case your mt_rand() implementation returns (for whatever reason) values between 0.0 and 1.0 go with:
$r = -$r;
?>