{"action":"created","issue":{"url":"https://api.github.com/repos/tavendo/AutobahnPython/issues/419","labels_url":"https://api.github.com/repos/tavendo/AutobahnPython/issues/419/labels{/name}","comments_url":"https://api.github.com/repos/tavendo/AutobahnPython/issues/419/comments","events_url":"https://api.github.com/repos/tavendo/AutobahnPython/issues/419/events","html_url":"https://github.com/tavendo/AutobahnPython/issues/419","id":90483337,"number":419,"title":"Fix WAMP ID generation","user":{"login":"oberstet","id":233340,"avatar_url":"https://avatars.githubusercontent.com/u/233340?v=3","gravatar_id":"","url":"https://api.github.com/users/oberstet","html_url":"https://github.com/oberstet","followers_url":"https://api.github.com/users/oberstet/followers","following_url":"https://api.github.com/users/oberstet/following{/other_user}","gists_url":"https://api.github.com/users/oberstet/gists{/gist_id}","starred_url":"https://api.github.com/users/oberstet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oberstet/subscriptions","organizations_url":"https://api.github.com/users/oberstet/orgs","repos_url":"https://api.github.com/users/oberstet/repos","events_url":"https://api.github.com/users/oberstet/events{/privacy}","received_events_url":"https://api.github.com/users/oberstet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-23T20:27:46Z","updated_at":"2015-06-23T20:28:02Z","closed_at":null,"body":"* https://github.com/tavendo/WAMP/blob/master/spec/basic.md#ids\r\n* https://en.wikipedia.org/wiki/Birthday_problem#Approximations\r\n\r\n```python\r\nimport random\r\n\r\nMAX = 2**31\r\n#MAX = 2**53\r\nCOUNT = 2**20\r\n#COUNT = 10000\r\n\r\ndef gen_id():\r\n   return random.randint(0, MAX)\r\n\r\nso_far = {}\r\ncollisions = []\r\nc_max = 0\r\nc_min = MAX\r\nc_sum = 0\r\nfor x in xrange(COUNT):\r\n    i = gen_id()\r\n    if i in so_far:\r\n        distance = x - so_far[i]\r\n        if distance > c_max:\r\n            c_max = distance\r\n        if distance < c_min:\r\n            c_min = distance\r\n        c_sum += distance\r\n        collisions.append(distance)\r\n        #print(\"collision: {} in set, id={}, distance={}\".format(len(so_far), i, distance))\r\n    else:\r\n        so_far[i] = x\r\n\r\nif len(collisions):\r\n    print(\"found {} collisions in {}\".format(len(collisions), COUNT))\r\n    print(\"min distance = {}, max distance = {}, avg distance = {}\".format(c_min, c_max, float(c_sum)/float(len(collisions))))\r\nelse:\r\n    print(\"no collisions found!\")\r\n```"},"comment":{"url":"https://api.github.com/repos/tavendo/AutobahnPython/issues/comments/114632800","html_url":"https://github.com/tavendo/AutobahnPython/issues/419#issuecomment-114632800","issue_url":"https://api.github.com/repos/tavendo/AutobahnPython/issues/419","id":114632800,"user":{"login":"oberstet","id":233340,"avatar_url":"https://avatars.githubusercontent.com/u/233340?v=3","gravatar_id":"","url":"https://api.github.com/users/oberstet","html_url":"https://github.com/oberstet","followers_url":"https://api.github.com/users/oberstet/followers","following_url":"https://api.github.com/users/oberstet/following{/other_user}","gists_url":"https://api.github.com/users/oberstet/gists{/gist_id}","starred_url":"https://api.github.com/users/oberstet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oberstet/subscriptions","organizations_url":"https://api.github.com/users/oberstet/orgs","repos_url":"https://api.github.com/users/oberstet/repos","events_url":"https://api.github.com/users/oberstet/events{/privacy}","received_events_url":"https://api.github.com/users/oberstet/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T20:28:02Z","updated_at":"2015-06-23T20:28:02Z","body":"```console\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ python test_randint.py \r\nfound 263 collisions in 1048576\r\nmin distance = 4994, max distance = 1046004, avg distance = 310519.163498\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ python test_randint.py \r\nfound 256 collisions in 1048576\r\nmin distance = 3325, max distance = 953221, avg distance = 352879.664062\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ python test_randint.py \r\nfound 257 collisions in 1048576\r\nmin distance = 128, max distance = 988844, avg distance = 340396.346304\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ python test_randint.py \r\nfound 248 collisions in 1048576\r\nmin distance = 1731, max distance = 987363, avg distance = 325821.637097\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ python test_randint.py \r\nfound 265 collisions in 1048576\r\nmin distance = 832, max distance = 992627, avg distance = 384565.124528\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ python test_randint.py \r\nfound 267 collisions in 1048576\r\nmin distance = 55, max distance = 938903, avg distance = 346952.198502\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ python test_randint.py \r\nfound 251 collisions in 1048576\r\nmin distance = 2937, max distance = 1004476, avg distance = 336690.972112\r\n(pypy260_1)oberstet@thinkpad-t430s:~/scm/scratchbox$ \r\n```"}}