这个是自己想的概率解法,求大佬指点。
1 oblivious 2019-04-19 00:14:49 +08:00 合格:990 choose 100 / 1000 choose 100 = 0.347 不合格:1 - 0.347 = 0.653 简单验证: from random import sample failed = 0 repeat = 100000 for i in range(repeat): list1 = ([0] * 990) + ([1] * 10) sampled = sample(list1, 100) if sum(sampled) > 0: failed += 1 print(failed/repeat) 0.65397 [Finished in 8.4s] |
2 oblivious 2019-04-19 00:15:56 +08:00 感觉很蠢因为代码不能缩进。 ``` # 测试一下代码环境 if True: print('Test...') ``` |
![]() | 3 rrfeng 2019-04-19 00:23:37 +08:00 via Android 一个以上是指 2 个起 算合格概率:100 个全好,100 个有一个坏 |
4 oblivious 2019-04-19 00:26:44 +08:00 自闭了,求问怎么在 v2 打出漂亮的代码 block。 不死心: <code> if True: print('Test...') </code> |
5 wAtcher789 2019-04-19 00:39:36 +08:00 via Android 可以看下超几何分布 |
7 fulingfan OP @oblivious (```) from random import sample failed = 0 repeat = 100000 for i in range(repeat): list1 = ([0] * 990) + ([1] * 10) sampled = sample(list1, 100) if sum(sampled) > 0: failed += 1 print(failed/repeat) (```) |
![]() | 10 WinG 2019-04-19 02:20:05 +08:00 好像不需要排列组合. 全部及格的概率 : (990 / 1000) * (989 / 999) .................. (890 / 900) 不及格概率 1 - (990 / 1000) * (989 / 999) .................. (890 / 900) |