title: Improving the distribution of hash function values
body: <p>Suppose I have a very large number of strings (say 10 billion strings of ~50 characters each). I want to distribute the strings into exactly 10 buckets. Each bucket should hold about 10% of the strings. With a hash function h() I can do:</p>
  
  <pre><code>int bucket_for_s = h(s) % 10
  </code></pre>
  
  <p>However this provides no guarantee about the evenness of the distribution. Suppose I do the above for all strings and find that 30% go to bucket 1, 5% go to bucket 2 and so on. My question is:</p>
  
  <p>Given h() distribution, is there a way to generate a new hash function h2() that will distribute the strings more evenly?</p>
  
  <p>Alternatively, is there a process that can generate a series of hash functions h2(), h3()... so that 1: each hash function is better than the previous one and 2: I only have to generate a reasonable number of hash functions?</p>
  
  <p>I should also mention that unfortunately I can't simply split the input into 10 parts because my input is spread across several machines. I am looking for a deterministic solution I can apply to each machine separately and get the same results (so eventually "hello" would go to bucket x, no matter on which machines it was stored).</p>