Percentage-based outcomes

    Date: 02/17/05 (PHP Community)    Keywords: php, google

    I'm in need of a program that will take a number as input and use said input to determine the percentage of time it will return true. Just off the top of my head, without looking at google or even the PHP manual, I'm thinking something simple like generating a random number from 1-100 and subtracting the input number from it. The result would then be tested to if it is equal to or less than 0, at which point it would return false - else, it would return true.

    Of course, I already see an obvious problem: if looking for say a 99% chance of success, and the random number is anything less than 99 the function would return false and would actually have only a 2% chance of returning true.

    Any thoughts a good way to accomplish this?

    Source: http://www.livejournal.com/community/php/261246.html

« ftp || stripping HTML formatting »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home