あらすじ Haskellでの乱数生成ライブラリは長らく群雄割拠の時代が続いていました。 その理由は、公式のrandomパッケージの使い勝手がすこぶる悪かったため、 各々が独自のインターフェースでまともな乱数生成ライブラリを公開していました。 その時代は、random-1.2の登場により終わりを迎えました。 これからはrandomパッケージを使えば基本的に問題ないでしょう。 Before random-1.2 Haskellの公式の乱数生成ライブラリがrandomだったのですが、 このライブラリは System.Randomといういかにも標準的なモジュールを提供している割に使い物になりませんでした。 そのため、 mwc-random tf-random xorshift mersenne-random-pure64 などのライブラリが独自のインターフェースを提供していました。 randomの
This can arise when you have different threads. But it’s of prime importance in a lazy language like Haskell, since it makes it possible to generate deterministic random numbers lazily. For instance, split is used in QuickCheck’s Gen monad. An easy implementation of split is to duplicate the current state. But, the two parallel sequences will not be independent: indeed they will be identical. A sl
import Data.Bits (xor, shiftL, shiftR) import Data.Word (Word32) getNext :: Word32 -> Word32 getNext seed = s3 where s1 = seed `xor` (shiftL seed 13) s2 = s1 `xor` (shiftR s1 17) s3 = s2 `xor` (shiftL s2 5)
10倍は遅すぎませんか? 本の虫: Haskellで書いてみたらC++の10倍遅かった を読みました. 10倍は差が出過ぎなのではないかと思いました. C++ソースコード まずC++のソースコードが完全なものではないので補完しました. #include <algorithm> #include <array> #include <iostream> #include <random> template <typename Random> bool coin_toss(const unsigned int try_count, const unsigned int length, Random &r) { unsigned int count{}; int prev{}; std::uniform_int_distribution<> d(0, 1); for (unsigned int i
mwc-random: Fast, high quality pseudo random number generation This package contains code for generating high quality random numbers that follow either a uniform or normal distribution. The generated numbers are suitable for use in statistical applications. The uniform PRNG uses Marsaglia's MWC256 (also known as MWC8222) multiply-with-carry generator, which has a period of 2^8222 and fares well in
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く