V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
fulingfan
V2EX  ›  问与答

[排列组合] 求概率问题,求大佬们指教

  •  
  •   fulingfan · 2019-04-18 23:33:02 +08:00 · 2232 次点击
    这是一个创建于 1805 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题描述

    这个是自己想的概率解法,求大佬指点。

    第 1 条附言  ·  2019-04-19 01:16:55 +08:00
    存在一个以及一个以上
    10 条回复    2019-04-19 02:20:05 +08:00
    oblivious
        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]
    oblivious
        2
    oblivious  
       2019-04-19 00:15:56 +08:00
    感觉很蠢因为代码不能缩进。

    ```
    # 测试一下代码环境
    if True:
    print('Test...')
    ```
    rrfeng
        3
    rrfeng  
       2019-04-19 00:23:37 +08:00 via Android
    一个以上是指 2 个起

    算合格概率:100 个全好,100 个有一个坏
    oblivious
        4
    oblivious  
       2019-04-19 00:26:44 +08:00
    自闭了,求问怎么在 v2 打出漂亮的代码 block。

    不死心:
    <code>
    if True:
    print('Test...')
    </code>
    wAtcher789
        5
    wAtcher789  
       2019-04-19 00:39:36 +08:00 via Android
    可以看下超几何分布
    fulingfan
        6
    fulingfan  
    OP
       2019-04-19 01:17:23 +08:00
    @rrfeng 一个及一个以上
    fulingfan
        7
    fulingfan  
    OP
       2019-04-19 01:19:14 +08:00
    @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)
    (```)
    fulingfan
        8
    fulingfan  
    OP
       2019-04-19 01:20:39 +08:00
    @oblivious 回复里面不能用 markdown 语法,唉
    fulingfan
        9
    fulingfan  
    OP
       2019-04-19 01:27:53 +08:00
    @oblivious 测试下,markdown 语法下是可以显示缩进的
    WinG
        10
    WinG  
       2019-04-19 02:20:05 +08:00
    好像不需要排列组合.

    全部及格的概率 : (990 / 1000) * (989 / 999) .................. (890 / 900)

    不及格概率 1 - (990 / 1000) * (989 / 999) .................. (890 / 900)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5480 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:54 · PVG 16:54 · LAX 01:54 · JFK 04:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.