实现rand() [英] implementation of rand()
问题描述
编辑:这是为了图像处理,所以相对较高的质量意味着体面的循环长度和良好的均匀性。 p>
查看这个随机数生成器的集合。他是随机数生成的领先专家,所以我有信心使用他推荐的任何东西。该清单中的发电机很小,有些只需要几个无符号的长度作为状态。
Marsaglia的发电机绝对是高品质,您的标准长期和良好的制服分配。他们通过严格的统计测试,尽管它们不会用于加密。
I am writing some embedded code in C and need to use the rand() function. Unfortunately, rand() is not supported in the library for the controller. I need a simple implementation that is fast, but more importantly has little space overhead, that produces relatively high-quality random numbers. Does anyone know which algorithm to use or sample code?
EDIT: It's for image processing, so "relatively high quality" means decent cycle length and good uniform properties.
Check out this collection of random number generators from George Marsaglia. He's a leading expert in random number generation, so I'd be confident using anything he recommends. The generators in that list are tiny, some requiring only a couple unsigned longs as state.
Marsaglia's generators are definitely "high quality" by your standards of long period and good uniform distribution. They pass stringent statistical tests, though they wouldn't do for cryptography.
这篇关于实现rand()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!