{"action":"created","issue":{"url":"https://api.github.com/repos/Sakuten/backend/issues/145","repository_url":"https://api.github.com/repos/Sakuten/backend","labels_url":"https://api.github.com/repos/Sakuten/backend/issues/145/labels{/name}","comments_url":"https://api.github.com/repos/Sakuten/backend/issues/145/comments","events_url":"https://api.github.com/repos/Sakuten/backend/issues/145/events","html_url":"https://github.com/Sakuten/backend/pull/145","id":356157869,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyNTE5OTIw","number":145,"title":"落選者優先の確率変動","user":{"login":"tamazasa","id":40788005,"node_id":"MDQ6VXNlcjQwNzg4MDA1","avatar_url":"https://avatars3.githubusercontent.com/u/40788005?v=4","gravatar_id":"","url":"https://api.github.com/users/tamazasa","html_url":"https://github.com/tamazasa","followers_url":"https://api.github.com/users/tamazasa/followers","following_url":"https://api.github.com/users/tamazasa/following{/other_user}","gists_url":"https://api.github.com/users/tamazasa/gists{/gist_id}","starred_url":"https://api.github.com/users/tamazasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamazasa/subscriptions","organizations_url":"https://api.github.com/users/tamazasa/orgs","repos_url":"https://api.github.com/users/tamazasa/repos","events_url":"https://api.github.com/users/tamazasa/events{/privacy}","received_events_url":"https://api.github.com/users/tamazasa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-09-01T00:55:33Z","updated_at":"2018-09-06T18:13:51Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/Sakuten/backend/pulls/145","html_url":"https://github.com/Sakuten/backend/pull/145","diff_url":"https://github.com/Sakuten/backend/pull/145.diff","patch_url":"https://github.com/Sakuten/backend/pull/145.patch"},"body":" * OS: Linux masato-laptop 4.15.0-33-generic #36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\r\n * devenv: 3c7149cce36dbdaa611a642d4aedd97ea86028c1\r\n * frontend: bc0fbefda7bd3312428acba83ed05937f9049e3d\r\n * backend: 115d57e95fea42a25b8362fcb46084e29d7ad8f2\r\n\r\n\r\n変更内容\r\n================\r\n\r\n**落選者優先の確率変動** #4\r\n※どれだけ変動させるかは **仮に**\r\n******\r\n~~n回落選した人（n ≠ 0）は落選０の応募者のn倍の確率で当たる~~\r\n#### 変更 9/2 20:45\r\n下記のとおりにしないと１日目の第１公演で落ちた生徒が２日間ずっと調整の恩恵を受け続けることになってしまいます。すみませんm(_ _)m\r\n```n回落選した人（n ≠ 0）は当選回数をm回として落選０の応募者の`max(1, n-m)`倍当たる```\r\n******\r\nとしてあります。\r\n\r\n* `numpy`ライブラリの導入\r\n* `random.sample()`から`numpy.random.choice()`への移行\r\n    - `sample()`は均等な確率で抜き出すが、`choice()`では各要素がそれぞれユーザー指定の確率で抜き出される\r\n* `User`データベースに`win_count (int)`、`lose_count (int)`を導入（デフォルトで`0`）\r\n* それに伴うschemaの更新\r\n* `calc_advantage(win_count, lose_count)`の「初回応募のx倍の確率」という形式での確率変動の定義\r\n* **代表者の確率変動**を基準にしたグループ応募の確率変動\r\n**追記**： PR #148 で対策\r\n******\r\n\r\n修正後の挙動:\r\n-------------\r\n\r\n* 負けの回数が多い人ほど多く当選します。\r\n具体的には、`User(id=1)`のみ`lose_count`を`3`とした上で\r\n上記の確率変動幅で応募者6人、当選者3人で20回回すと\r\n```python\r\n{1: 18, 2: 10, 3: 7, 4: 8, 5: 12, 6: 5}\r\n```\r\nとなりました。\r\n* 確率の変動の定義である`calc_advantage(win_count, lose_count)`を利用すれば、\r\n逆に「何度も当たっている人の確率を下げる」ようなこともできます（今はしてません）\r\n\r\n影響範囲\r\n================\r\n  * 確率変動のテストが「3人/6人が当たる抽選を~~10~~20回回して、落選3回の人が一番多く当選している」か確かめるものです。場合によっては乱数の都合でそうならない可能性もあります。\r\n1回落ちたらもう一回走らせてみてください。（僕はまだそういった状況に遭遇していません）\r\n  * 今までの形式のコードが動かなくなることはありません\r\n  * `numpy`の関数が利用できるようになります\r\n[`argmax`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmax.html)のような地味に便利な関数も割とあります"},"comment":{"url":"https://api.github.com/repos/Sakuten/backend/issues/comments/419191254","html_url":"https://github.com/Sakuten/backend/pull/145#issuecomment-419191254","issue_url":"https://api.github.com/repos/Sakuten/backend/issues/145","id":419191254,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTE5MTI1NA==","user":{"login":"codeclimate[bot]","id":36754821,"node_id":"MDM6Qm90MzY3NTQ4MjE=","avatar_url":"https://avatars0.githubusercontent.com/in/9403?v=4","gravatar_id":"","url":"https://api.github.com/users/codeclimate%5Bbot%5D","html_url":"https://github.com/apps/codeclimate","followers_url":"https://api.github.com/users/codeclimate%5Bbot%5D/followers","following_url":"https://api.github.com/users/codeclimate%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/codeclimate%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/codeclimate%5Bbot%5D/repos","events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2018-09-06T18:13:51Z","updated_at":"2018-09-06T18:13:51Z","author_association":"NONE","body":"Code Climate has analyzed commit 5b2788e3 and detected **1 issue** on this pull request.\n\nHere's the issue category breakdown:\n\n| Category | Count |\n|:---:|:---:|\n| Complexity | 1 |\n\n\nView more on [Code Climate](https://codeclimate.com/github/Sakuten/backend/pull/145).\n"}}
{"actor":{"display_login":"codeclimate"}}