import math


def ssr(precinct, seed):
    """
    Sum of Square Roots (SSR) pseudorandom function from Rivest, 2008:
    http://people.csail.mit.edu/rivest/Rivest-ASumOfSquareRootsSSRPseudorandomSamplingMethodForElectionAudits.pdf

    Input: precinct number (as an integer) and seed (a string of 15 digits)

    >>> ssr(23951, "279016755606125")
    0.93591273640868167

                        0.93591273640868167
    vs from paper: xi = 0.93591273640858040364659219
    """

    if not seed  or  len(seed) < 15:
        return ""

    p = "%06d" % precinct
    return math.modf(math.sqrt(int(p[0:2] + seed[ 0: 5])) +
                     math.sqrt(int(p[2:4] + seed[ 5:10])) +
                     math.sqrt(int(p[4:6] + seed[10:15])) )[0]