Comment by kccqzy

3 hours ago

Yeah sure this is how numpy people would do it:

    N = 10**6
    D = np.random.randint(1, 6, N)
    print("P(rolled a 6 | rolled > 3) =", ((D == 6) | (D > 3)).mean())

    loss = np.random.uniform(0, 1000, N)
    claim = np.where(loss > 200, loss - 200, 0)
    p = (claim > 0).mean()
    print("P(insurer pays a claim) =", p)

It’s concise enough that people generally wouldn’t bother writing a library. Unless they really want their custom syntax, then perhaps they write a parser.