2018-11-22から1日間の記事一覧

Xorshiftアルゴリズムで乱数

XorshiftアルゴリズムとはXORとシフトだけで品質の良い疑似乱数を生成するアルゴリズム。 // 周期 (2^32 - 1) 版 Xorshiftアルゴリズム #include <stdint.h> static uint32_t x = 2463534242; void xorshift32_seed(uint32_t seed) { if (seed != 0){ x = seed; } } ui</stdint.h>…