{"id":16162390,"url":"https://github.com/sunsided/number-picking-paradox","last_synced_at":"2025-10-11T20:15:11.536Z","repository":{"id":240377768,"uuid":"802470976","full_name":"sunsided/number-picking-paradox","owner":"sunsided","description":"A simulation of the \"Pick the largest number\" Cover Paradox, or the Two Envelopes Problem.","archived":false,"fork":false,"pushed_at":"2024-05-18T11:51:21.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T08:26:29.146Z","etag":null,"topics":["cover-paradox","number-guessing-game","paradox","rust","simulation","statistics","two-envelopes-problem"],"latest_commit_sha":null,"homepage":"https://www-isl.stanford.edu/~cover/papers/paper73.pdf","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunsided.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-18T11:42:58.000Z","updated_at":"2024-05-18T11:51:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"2fa71fb6-2ab7-48dc-b4d9-6661fab94cb1","html_url":"https://github.com/sunsided/number-picking-paradox","commit_stats":null,"previous_names":["sunsided/number-picking-paradox"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fnumber-picking-paradox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fnumber-picking-paradox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fnumber-picking-paradox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunsided%2Fnumber-picking-paradox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunsided","download_url":"https://codeload.github.com/sunsided/number-picking-paradox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247589835,"owners_count":20963022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cover-paradox","number-guessing-game","paradox","rust","simulation","statistics","two-envelopes-problem"],"created_at":"2024-10-10T02:29:58.051Z","updated_at":"2025-10-11T20:15:06.515Z","avatar_url":"https://github.com/sunsided.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎲 The Number Guessing \"Paradox\"\n\nBased on the chapter \"Pick the largest Number\" by Thomas M. Cover in 1987's\n\"Open Problems in Communication and Computation\" (see\ne.g. [here](https://www-isl.stanford.edu/~cover/papers/paper73.pdf)):\n\n\u003e Player 1 writes down any two distinct numbers on separate slips of paper.\n\u003e Player 2 randomly chooses one of these slips of paper and looks at the number.\n\u003e Player 2 must decide whether the number in his hand is the larger of the two numbers.\n\u003e He can be right with a probability of one-half. It seems absurd that he can do better.\n\u003e\n\u003e We argue that Player 2 has a strategy by which he can correctly state whether\n\u003e or not the other number is larger or smaller than the number in his hand\n\u003e with probability _strictly greater than one-half_.\n\u003e\n\u003e **Solution:** The idea is to pick a random _splitting number T_ according to a density\n\u003e `f(t), f(t) \u003e 0, for t ∈ (-∞, ∞)`. If the number in hand is less than _T_, decide that\n\u003e it is the smaller, if greater than _T_, decide that it is the larger.\n\nThis can be visualized by the following table, where the two randomly drawn numbers\nare represented in order (first, second). For simplicity, we only compare against the\nfirst random number as the probability distribution for both of them is equal.\n\n| Numbers    | Random Draw | Test         | Outcome | Decision         | Correct |\n|------------|-------------|--------------|---------|------------------|---------|\n| **75**, 25 | 100         | 100 \u003e **75** | true    | Second is higher | no      |\n| **75**, 25 | 50          | 50 \u003e **75**  | false   | Second is lower  | yes     |\n| **75**, 25 | 0           | 0 \u003e **25**   | false   | Second is lower  | yes     |\n| **25**, 75 | 100         | 100 \u003e **25** | true    | Second is higher | yes     |\n| **25**, 75 | 50          | 50 \u003e **25**  | true    | Second is higher | yes     |\n| **25**, 75 | 0           | 0 \u003e **25**   | false   | Second is lower  | no      |\n\nAccording to this table, 4/6 (or 66%) of all guesses are correct.\n\n## Simulation\n\nThis project implements a simulation on a two naive guessing strategies and the one described above.\nFor the comparison against a random number, two distributions are picked:\n\n- A uniform distribution over the input value range,\n- A normal distribution with μ=0 and σ=10\n\n```plain\nSimulating strategies with 1000000 trials each.\nEvaluating strategy: Always guess the same outcome\n  Probability of correct guess: 49.91%\nEvaluating strategy: Always guess a random outcome\n  Probability of correct guess: 49.99%\nEvaluating strategy: Comparison with a random draw (uniform distribution)\n  Probability of correct guess: 66.74%\nEvaluating strategy: Comparison with a random draw (normal distribution)\n  Probability of correct guess: 75.01%\n```\n\nAs we can see, both random trials outperform 50/50 guessing chance. The strategy using a normal distribution\nresults in an even higher winning probability at ~75% correct guesses.\n\n## Citation\n\n```bibtex\n@Inbook{Cover1987,\n    author=\"Cover, Thomas M.\",\n    editor=\"Cover, Thomas M.\n    and Gopinath, B.\",\n    title=\"Pick the Largest Number\",\n    bookTitle=\"Open Problems in Communication and Computation\",\n    year=\"1987\",\n    publisher=\"Springer New York\",\n    address=\"New York, NY\",\n    pages=\"152--152\",\n    abstract=\"Player 1 writes down any two distinct numbers on separate slips of paper. Player 2 randomly chooses one of these slips of paper and looks at the number. Player 2 must decide whether the number in his hand is the larger of the two numbers. He can be right with probability one-half. It seems absurd that he can do better.\",\n    isbn=\"978-1-4612-4808-8\",\n    doi=\"10.1007/978-1-4612-4808-8_43\",\n    url=\"https://doi.org/10.1007/978-1-4612-4808-8_43\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fnumber-picking-paradox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunsided%2Fnumber-picking-paradox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsided%2Fnumber-picking-paradox/lists"}