I rolled a small random number generator that should be able to handle weighted probabilities as a test to compare the code size of hand rolling to C++'s discrete rng, plz rate it and suggest how it can be made better, been a while since I did anything in C
int rand_discrete(int* distribution, size_t dist_size) {
// Error whatever you want here
if(dist_size == 0)
return -1;
int prob_total = distribution[0];
for(size_t i = 1; i < dist_size; ++i)
prob_total += distribution[i];
int random_variable = rand() % prob_total;
double probability = (double)prob_t...