Stateless pseudorandom/hash algorithm for ℤⁿ → [0,1) There's a problem which I had on a number of unrelated occasions which I usually work around in some way or another. Deep inside, though, it bothers me that I haven't ever found a “proper” solution to this:


  Given an n-tuple of integers, how do I derive a stateless pseudorandom number / hash value in the half-open interval [0,1)?


The usual “solution” people use in this situation is to multiply the parameters by some large primes, or bit-shift them, or do any other complex calculation which produces a result that is “random enough” for the given purpose.  I guess these algorithms have been cargo-culted over a long time, maybe from a PRNG implementation.

Instead of copying one of the circulating code snippets, I'd like to really understand what's going on here.  Is there an algorithm or a set of algorithms which should typically be used in this kind of situation, and if so, what's the proper way to choose the constants?
Every hash function is stateless; that's part of the definition of what it means to be a hash function.

A simple approach is to take a representation of the input in binary, using any standard encoding for the integers and for $n$-vectors of integers, and then hash the result using your favorite hash function.  The output will be a binary string.  Treat it as the binary representation of a number in the range $[0,1)$ (put a decimal point before the start of it, and interpret it in base 2).  That's your output.

Then, choose a suitable hash function for hashing binary strings.  If you need it for cryptographic purposes, you could use SHA256.  If you need it for non-cryptographic purposes, there are many standard, fast hash functions; choose one that meets your requirements.  Since you didn't state any precise requirements in the question, we have no basis to select among any of the standard solutions.