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

    <legend id='JQNQo'><style id='JQNQo'><dir id='JQNQo'><q id='JQNQo'></q></dir></style></legend>

    <i id='JQNQo'><tr id='JQNQo'><dt id='JQNQo'><q id='JQNQo'><span id='JQNQo'><b id='JQNQo'><form id='JQNQo'><ins id='JQNQo'></ins><ul id='JQNQo'></ul><sub id='JQNQo'></sub></form><legend id='JQNQo'></legend><bdo id='JQNQo'><pre id='JQNQo'><center id='JQNQo'></center></pre></bdo></b><th id='JQNQo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JQNQo'><tfoot id='JQNQo'></tfoot><dl id='JQNQo'><fieldset id='JQNQo'></fieldset></dl></div>
      <tfoot id='JQNQo'></tfoot>
        <bdo id='JQNQo'></bdo><ul id='JQNQo'></ul>

      1. <small id='JQNQo'></small><noframes id='JQNQo'>

      2. 提升隨機數生成器

        Boost random number generator(提升隨機數生成器)
        • <bdo id='5xAh7'></bdo><ul id='5xAh7'></ul>
          <legend id='5xAh7'><style id='5xAh7'><dir id='5xAh7'><q id='5xAh7'></q></dir></style></legend>

              • <tfoot id='5xAh7'></tfoot>

                <small id='5xAh7'></small><noframes id='5xAh7'>

                  <tbody id='5xAh7'></tbody>
                <i id='5xAh7'><tr id='5xAh7'><dt id='5xAh7'><q id='5xAh7'><span id='5xAh7'><b id='5xAh7'><form id='5xAh7'><ins id='5xAh7'></ins><ul id='5xAh7'></ul><sub id='5xAh7'></sub></form><legend id='5xAh7'></legend><bdo id='5xAh7'><pre id='5xAh7'><center id='5xAh7'></center></pre></bdo></b><th id='5xAh7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5xAh7'><tfoot id='5xAh7'></tfoot><dl id='5xAh7'><fieldset id='5xAh7'></fieldset></dl></div>
                  本文介紹了提升隨機數生成器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  有人有最喜歡的 boost 隨機數生成器嗎?你能解釋一下如何將它實現到代碼中嗎?我試圖讓梅森龍卷風工作,并想知道是否有人偏愛其他人.

                  Does anyone have a favorite boost random number generator and can you explain a little on how to implement it into code. I am trying to get the mersenne twister to work and was wondering if anyone had preference towards one of the others.

                  推薦答案

                  此代碼改編自 http://www.boost.org/doc/libs/1_42_0/libs/random/index.html:

                  #include <iostream>
                  #include "boost/random.hpp"
                  #include "boost/generator_iterator.hpp"
                  using namespace std;
                  
                  int main() {
                        typedef boost::mt19937 RNGType;
                        RNGType rng;
                        boost::uniform_int<> one_to_six( 1, 6 );
                        boost::variate_generator< RNGType, boost::uniform_int<> >
                                      dice(rng, one_to_six);
                        for ( int i = 0; i < 6; i++ ) {
                            int n  = dice();
                            cout << n << endl;
                       }
                  }
                  

                  解釋一下:

                  • mt19937 是梅森扭曲器生成器,它生成原始隨機數.此處使用了 typedef,因此您可以輕松更改隨機數生成器類型.

                  • mt19937 is the mersenne twister generator,which generates the raw random numbers. A typedef is used here so you can easily change random number generator type.

                  rng 是twister 生成器的一個實例.

                  rng is an instance of the twister generator.

                  one_to_six分布的一個實例.這指定了我們要生成的數字及其遵循的分布.這里我們想要 1 到 6 個,均勻分布.

                  one_to_six is an instance of a distribution. This specifies the numbers we want to generate and the distribution they follow. Here we want 1 to 6, distributed evenly.

                  dice 是獲取原始數字和分布的東西,并為我們創建我們真正想要的數字.

                  dice is the thing that takes the raw numbers and the distribution, and creates for us the numbers we actually want.

                  dice() 是對 dice 對象的 operator() 調用,該對象獲取緊隨其后的下一個隨機數分布,模擬隨機六面擲骰子.

                  dice() is a call to operator() for the dice object, which gets the next random number following the distribution, simulating a random six-sided dice throw.

                  就目前而言,這段代碼每次都會產生相同的擲骰子序列.您可以在其構造函數中隨機化生成器:

                  As it stands, this code produces the same sequence of dice throws each time. You can randomise the generator in its constructor:

                   RNGType rng( time(0) );   
                  

                  或使用其 seed() 成員.

                  or by using its seed() member.

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

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

                  相關文檔推薦

                  read input files, fastest way possible?(讀取輸入文件,最快的方法?)
                  The easiest way to read formatted input in C++?(在 C++ 中讀取格式化輸入的最簡單方法?)
                  Reading from .txt file into two dimensional array in c++(從 .txt 文件讀取到 C++ 中的二維數組)
                  How to simulate a key press in C++(如何在 C++ 中模擬按鍵按下)
                  Why doesn#39;t getline(cin, var) after cin.ignore() read the first character of the string?(為什么在 cin.ignore() 之后沒有 getline(cin, var) 讀取字符串的第一個字符?)
                  What is the cin analougus of scanf formatted input?(scanf 格式輸入的 cin 類比是什么?)
                      • <i id='DSV2A'><tr id='DSV2A'><dt id='DSV2A'><q id='DSV2A'><span id='DSV2A'><b id='DSV2A'><form id='DSV2A'><ins id='DSV2A'></ins><ul id='DSV2A'></ul><sub id='DSV2A'></sub></form><legend id='DSV2A'></legend><bdo id='DSV2A'><pre id='DSV2A'><center id='DSV2A'></center></pre></bdo></b><th id='DSV2A'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DSV2A'><tfoot id='DSV2A'></tfoot><dl id='DSV2A'><fieldset id='DSV2A'></fieldset></dl></div>
                          <tbody id='DSV2A'></tbody>

                      • <tfoot id='DSV2A'></tfoot>
                      • <legend id='DSV2A'><style id='DSV2A'><dir id='DSV2A'><q id='DSV2A'></q></dir></style></legend>
                        • <bdo id='DSV2A'></bdo><ul id='DSV2A'></ul>

                          <small id='DSV2A'></small><noframes id='DSV2A'>

                            主站蜘蛛池模板: 日本免费一区二区三区四区 | 日韩在线精品 | 久草新在线 | 久久久久国产一区二区三区四区 | 国产在线色 | 国产精品视频一区二区三区四蜜臂 | 日本一区二区在线视频 | 日韩精品视频一区二区三区 | 欧美激情精品久久久久久 | 一片毛片 | 国产一区2区 | 羞羞的视频在线 | 国产成人一区二区三区久久久 | 午夜精品视频 | 亚洲精品国产一区 | 99精品久久久 | 国产精品99 | 日韩欧美国产一区二区三区 | 国产精品久久久久久久久久久久久 | 欧美一级大黄 | 日韩av成人在线 | 欧美激情 一区 | 亚洲精品无 | 一区二区三区视频在线免费观看 | 亚洲精品视频网站在线观看 | 久久精品一区 | 成人福利电影 | 成人欧美一区二区 | 亚洲国产成人精品女人久久久 | 正在播放国产精品 | 婷婷综合| 欧美国产一区二区 | 日韩免费av | 欧美在线一区二区三区 | 成人在线精品 | 亚洲精品99 | 欧美黄色性生活视频 | 欧美又大粗又爽又黄大片视频 | 国产精品一区二 | 黄色一级毛片 | 免费精品视频一区 |