randomness test

v1
Brett 2023-07-23 13:59:11 -04:00
parent ec16f5412b
commit f6ca082e15
1 changed files with 16 additions and 9 deletions

View File

@ -57,25 +57,32 @@ int main() {
BLT_ERROR("Hello Error!"); BLT_ERROR("Hello Error!");
BLT_FATAL("Hello Fatal!"); BLT_FATAL("Hello Fatal!");
int vals[100]; constexpr int size = 100;
uint32_t vals[size];
for (int & val : vals) for (uint32_t & val : vals)
val = 0; val = 0;
uint32_t seed = 1023; uint32_t seed = 1023;
for (int i = 0; i < 1203000; i++){ for (int i = 0; i < 10000000; i++){
seed = seed * i; seed = seed * i;
vals[blt::random::randomInt(seed, 0, 100)]++; vals[blt::random::randomInt(seed, 0, size)] += 1;
} }
std::fstream csv("./randoms2.csv", std::ios::out); uint32_t mean = 0;
for (uint32_t& val : vals)
mean += val;
mean /= size;
csv << "index,count\n"; uint32_t std = 0;
for (int i = 0; i < 100; i++){ for (uint32_t& val : vals) {
csv << i << "," << vals[i] << "\n"; auto e = (val - mean);
std += e * e;
} }
csv.close(); auto stdev = sqrt((double)std / (double)size);
BLT_INFO("STDDEV of # random values: %f", stdev);
return 0; return 0;
} }