Kevinpgalligan / ka

A calculator language.
MIT License
5 stars 0 forks source link

Random variables #3

Closed Kevinpgalligan closed 5 months ago

Kevinpgalligan commented 2 years ago

This would basically be a pretty shim over scipy. It would require a RandomVariable type, an Event type, probability function P that accepts Events, expected value function E that accepts random variables, and so on.

X ~ binom(n, p); P(X <= 3); E(X)
Kevinpgalligan commented 7 months ago

Don't need special syntax for assigning random variables, e.g. binom can be a function that returns a random variable and X is just a variable.

X = binom(n, p)

Note: > comparison operator would clash with current unit conversion operator.

Kevinpgalligan commented 5 months ago

Brainstorming:

Kevinpgalligan commented 5 months ago

This is preeeetty much done, just have to add support for adding scalars to / multiply constants by RVs. I would like to support unions of events / joint probability / whatever, as well as adding random variables together, but that gets messy when RVs are dependent on each other. And should be easy enough to manually compute with the existing tools.

Kevinpgalligan commented 5 months ago

Actually, I don't see an immediate use for scalar arithmetic with RVs. Instead of E(X+1) you can just do E(X)+1, for example. So... passing on that for now.