久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP 的 shuffle 函數有多隨機?

How random is PHP#39;s shuffle function?(PHP 的 shuffle 函數有多隨機?)
本文介紹了PHP 的 shuffle 函數有多隨機?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

有誰知道 PHP 的 shuffle() 函數的隨機性是什么?它取決于操作系統嗎?它是否使用 PHP 自己的播種機?

Does anyone know what's the randomness of PHP's shuffle() function? Does it depend on the operating system? Does it use PHP's own seeder?

是否可以使用 mt_rand() 作為生成器?

Is it possible to use mt_rand() as generator?

推薦答案

shuffle() 函數基于與 rand() 相同的生成器,也就是系統基于線性同余算法的生成器.這是一個快速生成器,但或多或??少具有隨機性.自 PHP 4.2.0 起,隨機生成器會自動播種,但您可以根據需要使用 srand() 函數來播種.

shuffle() function is based on the same generator as rand(), which is the system generator based on linear congruential algorithm. This is a fast generator, but with more or less randomness. Since PHP 4.2.0, the random generator is seeded automatically, but you can use srand() function to seed it if you want.

mtrand() 基于 Mersenne Twister 算法,其中是最好的偽隨機算法之一.要使用該生成器對數組進行混洗,您需要編寫自己的 shuffle 函數.例如,您可以查看 Fisher-Yates 算法.編寫自己的 shuffle 函數會產生更好的隨機性,但會比內置的 shuffle 函數慢.

mtrand() is based on Mersenne Twister algorithm, which is one of the best pseudo-random algorithms available. To shuffle an array using that generator, you'd need to write you own shuffle function. You can look for example at Fisher-Yates algorithm. Writing you own shuffle function will yield to better randomness, but will be slower than the builtin shuffle function.

這篇關于PHP 的 shuffle 函數有多隨機?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 精品国产不卡一区二区三区 | 国产一区二区三区免费观看在线 | 人人人人干 | 97精品超碰一区二区三区 | 天天碰日日操 | 伊人在线 | 国产精品区一区二 | 亚洲欧美在线观看 | 中文字幕日韩专区 | 99视频在线免费观看 | 亚洲精品第一国产综合野 | 97av视频| 亚洲精品欧美一区二区三区 | 久久国产精品-国产精品 | 精品免费| 久久99精品国产麻豆婷婷 | 成人av电影在线 | 伊人中文字幕 | 亚洲a一区 | 五月激情综合网 | 大象视频一区二区 | 久久久久国色av免费观看性色 | 日韩精品视频一区二区三区 | 久久久久久久国产 | 日日噜噜噜夜夜爽爽狠狠视频97 | 亚洲国产一区二区在线 | 日韩在线观看网站 | 不卡的av在线 | 免费久久久久久 | 欧美日韩中文字幕在线 | 亚洲国产一 | 国产日韩一区二区 | 欧美成人精品在线 | 亚洲一区二区在线播放 | 国产精品视频999 | av中文天堂 | 久久aⅴ乱码一区二区三区 91综合网 | 精品国产黄色片 | 欧美一级片免费看 | 亚洲精品久久久蜜桃网站 | 亚洲精品久久久久久久不卡四虎 |