← Back to context

Comment by manucorporat

4 hours ago

the language can do a lot of very expressive things, every language feature works in your favor too, but agree with you, i would not use my own language for anything production.

like this:

D ~ unif_int(1, 6); Print("P(rolled a 6 | rolled > 3) =", P(D == 6 | D > 3));

or:

loss ~ unif(0, 1000); claim = if loss > 200 { loss - 200 } else { 0 }; p = P(claim > 0); Print("P(insurer pays a claim) =", p)

notice that "claim" is also a random variable! result of a if expression

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.