TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A Family of Better Random Number Generators

163 点作者 marcobambini超过 4 年前

19 条评论

celrod超过 4 年前
Xoshiro over PCG arguments: <a href="http:&#x2F;&#x2F;pcg.di.unimi.it&#x2F;pcg.php" rel="nofollow">http:&#x2F;&#x2F;pcg.di.unimi.it&#x2F;pcg.php</a><p>Response by the author: <a href="https:&#x2F;&#x2F;www.pcg-random.org&#x2F;posts&#x2F;on-vignas-pcg-critique.html" rel="nofollow">https:&#x2F;&#x2F;www.pcg-random.org&#x2F;posts&#x2F;on-vignas-pcg-critique.html</a><p>Personally, I use a SIMD Xoshiro256+ when I want a solid and fast RNG (although I mostly use Julia&#x27;s default -- a MersenneTwister).
评论 #24785844 未加载
评论 #24786103 未加载
评论 #24785769 未加载
评论 #24785609 未加载
rdw超过 4 年前
I used PCG years ago for procedural content generation where random number generation was a bottleneck. It is very fast, so I was happy with it. Additionally the implementation I used[1] is comprehensible enough that I could modify it in various small ways.<p>One property I anecdotally observed about it is that it is a little sensitive to the values you choose for its seed. Too many zero bits or making two generators with nearly-identical seeds would create visible correlation in the outputs. It worked much better if all values were hashed before using them for seeding.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;tlauterbach&#x2F;unity-pcg-csharp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tlauterbach&#x2F;unity-pcg-csharp</a>
plopilop超过 4 年前
The website does not seem to have been updated but the prediction security of PCG has been fully broken recently (and does not rely on the &quot;Challenging&quot; part of the spectrum): <a href="https:&#x2F;&#x2F;hal.inria.fr&#x2F;hal-02700791&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hal.inria.fr&#x2F;hal-02700791&#x2F;</a><p>Hence any cryptographic use of PCG is definitely prohibited
评论 #24788919 未加载
评论 #24791817 未加载
nestorD超过 4 年前
On random numbers, I found the ideas behind &quot;Parallel Random Numbers: As Easy as 1, 2, 3&quot; [0] (which is implemented in JAX) interesting. Their generator is a mapping between keys and random numbers which get rid of the sequential dependency in the generator making it very easy to run in parallel at a GPU scale.<p>[0]: <a href="http:&#x2F;&#x2F;www.thesalmons.org&#x2F;john&#x2F;random123&#x2F;papers&#x2F;random123sc11.pdf" rel="nofollow">http:&#x2F;&#x2F;www.thesalmons.org&#x2F;john&#x2F;random123&#x2F;papers&#x2F;random123sc1...</a>
评论 #24786790 未加载
评论 #24792146 未加载
rainworld超过 4 年前
<p><pre><code> Statistical Quality PCG Family Excellent ChaCha20 Good </code></pre> What a joke.
评论 #24787542 未加载
评论 #24792960 未加载
评论 #24792793 未加载
andreareina超过 4 年前
What applications require unpredictability where you wouldn&#x27;t go full csprng?
评论 #24786843 未加载
评论 #24785565 未加载
评论 #24790183 未加载
评论 #24785479 未加载
评论 #24785498 未加载
评论 #24791405 未加载
评论 #24785471 未加载
EE84M3i超过 4 年前
They describe rc4 as secure, which it hasn&#x27;t been considered for years, so I&#x27;m not sure how seriously to take this site
评论 #24785520 未加载
评论 #24785545 未加载
评论 #24785455 未加载
kevincox超过 4 年前
I&#x27;ve used Pcg32 via <a href="https:&#x2F;&#x2F;docs.rs&#x2F;rand_pcg" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;rand_pcg</a> and been quite happy. That being said I don&#x27;t rely on excellent quality and haven&#x27;t tested it. One of the main reasons I use it is that the implementation works perfectly in WebAssembly.<p>I use it to deal tiles in my version of online Azul: <a href="https:&#x2F;&#x2F;tiles.kevincox.ca" rel="nofollow">https:&#x2F;&#x2F;tiles.kevincox.ca</a><p>I also used it to simulate the Red7 game for strategy testing: <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;kevincox&#x2F;red7-sim" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;kevincox&#x2F;red7-sim</a>
fsiefken超过 4 年前
Is there a fork of Fortune that uses the PCG, Xoshiro or wyhash algorithm?<p>I am not fluent in C or Rust and time constrained, otherwise I would have taken a shot at it<p><a href="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;shlomif&#x2F;fortune-mod&#x2F;master&#x2F;fortune-mod&#x2F;fortune&#x2F;fortune.c" rel="nofollow">https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;shlomif&#x2F;fortune-mod&#x2F;master...</a> <a href="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;wapm-packages&#x2F;fortune&#x2F;master&#x2F;src&#x2F;main.rs" rel="nofollow">https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;wapm-packages&#x2F;fortune&#x2F;mast...</a><p>Or better, with an entropy source like rdrand or rdseed?
评论 #24794361 未加载
m4r35n357超过 4 年前
TinyCC example in README is wrong, should have trailing &#x27;-&#x27;: as in &quot;cat pcg_basic.c pcg32-demo.c | tcc -run -&quot;
jacobolus超过 4 年前
Here’s a Javascript implementation,<p><a href="https:&#x2F;&#x2F;observablehq.com&#x2F;@jrus&#x2F;permuted-congruential-generator" rel="nofollow">https:&#x2F;&#x2F;observablehq.com&#x2F;@jrus&#x2F;permuted-congruential-generat...</a><p>It’s a bit of a pain because Javascript can’t do native 64-bit integer arithmetic. But it should still be fast enough for most purposes.
nimish超过 4 年前
Vigna&#x27;s RNGs are faster and as good statistically so it&#x27;s not clear why you&#x27;d use PCG.<p>They are a neat theoretical construction however I believe they have some serious flaws when attempting to split and construct multiple streams.<p>Honestly though RDRAND is cheap enough that I&#x27;d take true randomness over determinism.
whateveracct超过 4 年前
And there are Haskell bindings: <a href="https:&#x2F;&#x2F;hackage.haskell.org&#x2F;package&#x2F;pcg-random" rel="nofollow">https:&#x2F;&#x2F;hackage.haskell.org&#x2F;package&#x2F;pcg-random</a><p>Nice!
mshachkov超过 4 年前
One might be interested in <a href="https:&#x2F;&#x2F;github.com&#x2F;wangyi-fudan&#x2F;wyhash" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wangyi-fudan&#x2F;wyhash</a>
评论 #24799844 未加载
Tipewryter超过 4 年前
For &quot;Arc4Random&quot; it says &quot;Reproducible Results: Not Always&quot;.<p>Can an algorithm really produce a non-reproducible result?
评论 #24785612 未加载
评论 #24785687 未加载
评论 #24785579 未加载
lucioperca超过 4 年前
Sounds pretty undecidable to me to proof that a pseudo number generator has a challenging prediction difficulty.
dragontamer超过 4 年前
The pcg-random methodology is very good. The basis is the following pattern:<p>#1: Have a &quot;counter&quot; of some kind. The simple counter trivially creates a maximum length cycle. &quot;seed++&quot; is one such counter.<p>#2: Have a &quot;hash&quot; that converts the counter into a random number, using a 1-to-1 bijection. There are a great many 1-to-1 bijections.<p>So your RNG is basically:<p><pre><code> oldSeed = seed; seed = counterFunction(seed); return hash(oldSeed); </code></pre> ------------<p>I used this methodology to make a pretty fast generator myself. The coding was done in a weekend, but it took some weeks to test: <a href="https:&#x2F;&#x2F;github.com&#x2F;dragontamer&#x2F;AESRand" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dragontamer&#x2F;AESRand</a><p>For AESRand:<p>&quot;counterFunction&quot; is a SIMD 2x64-bit Add over the XMM register. I chose an odd number arbitrarily (which are just the first 16 prime numbers: 0x01030507...), which will trivially cycle after 2^64 numbers.<p>&quot;hash&quot; is aesenc(aesenc(seed, constant), constant), where constant is an arbitrary (chosen to be the same odd number that was used in the &quot;counterFunction&quot; step). The 2nd parameter to aesend is just an XOR.<p>I also run a 2nd parallel aesdec(aesenc(seed, constant), constant) to generate a 2nd set of 128-bit random numbers, for 256-bits to be made across the hash. Yes, a 128-bit seed &quot;hashes&quot; into a 256-bit random number. Since this passes statistical tests, its probably fine, and this is a good source of instruction-level-parallelism.<p>All in all, I achieved 30GB&#x2F;sec random numbers. Or 256-bits of random numbers every 3.7 cycles that passes BigCrush, TestU01, and PractRand.<p>--------<p>AES is a 1-to-1 bijection: that&#x27;s a necessary condition for AES to be decoded. Though I use AES, this function is NOT cryptographically sound. I&#x27;m just using AES because its the fastest high-quality bijection in the entire modern CPU instruction set. x86, ARM, and POWER9 all implement single-cycle AES instructions.<p>It is possible to write a portable AESRand across the different CPUs (ARM, x86, and POWER9). I got far enough to prove that its possible, but then my real work started to ramp up and I had to drop this hobby project. Its very tricky to do so: ARM, x86, and POWER9 implement AESENC slightly differently: shuffling the fundamental steps in different ways.<p>Or in the case of POWER9, it executes in big-endian mode instead of little-endian (like ARM &#x2F; x86). Redesigning the algorithm to be portable across the shuffled &quot;SubBytes&quot; and &quot;MixColumns&quot; steps between the CPUs is tricky but possible.
tshoaib超过 4 年前
Would the outputs of these algorithms be considered pseudo-random?
s9w超过 4 年前
The Drama between the author of PCG (u&#x2F;ProfONeill) and the author of xoshiro (u&#x2F;sebastianovigna) is one of the more entertanining parts of the C++ community. Too bad that despite that fierce competition, the &lt;random&gt; standard header itself is universally hated.
评论 #24788455 未加载
评论 #24786174 未加载
评论 #24785598 未加载