PHP implementation of a simple probability-related code, PHP probability code
This paper describes a simple probabilistic correlation code for PHP implementations. Share to everyone for your reference, as follows:
<?phpfor ($i =1; $i <100000; $i + +) {$x =mt_rand (0,100), if ($x <20) {$a = $a +1;} Else{if ($x <50) {$b = $b +1;} else{$c = $c +1;}}} echo $a. '
'; Echo $b. '
'; Echo $c. '
Output Result:
19589
29795
50615
Key in Mt_rand (0,100)
Probability is represented by the number of occurrences of a $ A $b $c
Add: The above code is not typeset, it seems a little difficult to read, fortunately the code is not many. Small series here is recommended a site of the PHP format landscaping tools to help you in the future of PHP programming code layout, increase the readability of the code:
PHP Code online format Beautification tool:
Http://tools.jb51.net/code/phpformat
In addition, because PHP is a C language style, the following tool can also be used to implement the PHP code format :
C Language Style/html/css/json code formatting beautification tool:
Http://tools.jb51.net/code/ccode_html_css_json
More interested in PHP related content readers can view the site: "PHP Math Skills Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP array" operation Skills Daquan, " PHP Sorting algorithm Summary, "PHP Common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string Usage Summary" and " A summary of common PHP database operation techniques
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1133049.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133049.html techarticle PHP Implementation of a simple probability-related code, PHP probability code This article describes a PHP implementation of a simple probability-related code. Share to everyone for your reference, as follows: PHPF ...