if I take the result of a 32bit hash function(the param is random string) and apply module N on the result - will the values be evenly distributed?
so if I have a histogram of values [0,N-1] will the histogram be evenly distributed ?
Thanks
if I take the result of a 32bit hash function(the param is random string) and apply module N on the result - will the values be evenly distributed?
It depends on the hash function. For a good hash function the output should be uniformly distributed.
so if I have a histogram of values [0,N-1] will the histogram be evenly distributed ?
For any reasonable hash function, yes.
Keep in mind that real-world hash functions are sometimes terrible. Many programming languages will, as the hash of an integer (using the built-in hashing function), return the original value. This is not a problem if your input is truly random, but usually the reason to use a hash function is to take an input that has some structure, and produce hashes that (hopefully) don't.