Author rhettinger
Recipients docs@python, johnnyd, mark.dickinson, rhettinger, vstinner
Date 2018-01-15.18:41:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516041703.0.0.467229070634.issue32554@psf.upfronthosting.co.za>
In-reply-to
Content
I'm getting a nice improvement in dispersion statistics by shuffling in higher bits right at the end:

     /* Disperse patterns arising in nested frozensets */
  +  hash ^= (hash >> 11) ^ (~hash >> 25);
     hash = hash * 69069U + 907133923UL;

Results for range() check:

                     range       range
                    baseline      new
  1st percentile     35.06%      40.63%
  1st decile         48.03%      51.34%
  mean               61.47%      63.24%      
  median             63.24%      65.58% 

Test code for the letter_range() test:

                     letter      letter
                    baseline      new
  1st percentile     39.59%      40.14%
  1st decile         50.90%      51.07%
  mean               63.02%      63.04%      
  median             65.21%      65.23% 


    def letter_range(n):
        return string.ascii_letters[:n]

    def powerset(s):
        for i in range(len(s)+1):
            yield from map(frozenset, itertools.combinations(s, i))

    # range() check
    for i in range(10000):
        for n in range(5, 19):
            t = 2 ** n
            mask = t - 1
            u = len({h & mask for h in map(hash, powerset(range(i, i+n)))})
            print(u/t*100)

    # letter_range() check needs to be restarted (reseeded on every run)
    for n in range(5, 19):
        t = 2 ** n
        mask = t - 1
        u = len({h & mask for h in map(hash, powerset(letter_range(n)))})
        print(u/t)
History
Date User Action Args
2018-01-15 18:45:16rhettingerunlinkissue32554 messages
2018-01-15 18:41:43rhettingersetrecipients: + rhettinger, mark.dickinson, vstinner, docs@python, johnnyd
2018-01-15 18:41:42rhettingersetmessageid: <1516041703.0.0.467229070634.issue32554@psf.upfronthosting.co.za>
2018-01-15 18:41:42rhettingerlinkissue32554 messages
2018-01-15 18:41:42rhettingercreate