Advice on following math examples

This comes from exercise 2 from the NumPy section, doesn’t it?

It is amusing you bring this up, because when I read this, I also found that this could perhaps be formulated a bit more carefully, but maybe I am nitpicking. For myself, I interpreted it as:

“Given $q_0, q_1, \ldots ,q_{n-1}$ non-negative and summing to 1, define a probability space $(\Omega, \mathcal{F}, P)$ and a random variable $X : \Omega \to \mathbb{Z}$ such that $P(X = i) = q_i$ for all $i = 0, \ldots, n-1$.”

The notation $P(X = i)$ (or: $\mathbb{P}\{x = i\}$, as they write it in the lecture) is just shorthand for the probability of the event $\{\omega \in \Omega ,:, X(\omega) = i\} \in \mathcal{F}$. This is not uncommon.

The most natural (but not the only) choice would be to work with $\Omega = [0,1]$ and ordinary length of intervals (i.e. Lebesgue measure). Then the cumsum and searchsorted methods can indeed be used nicely to implement a function that returns a particular realization of $X$ (which I would usually denote by lowercase $x$) for a given choice of the vector $q$.

P.S. There is a nice method for rendering formulas on pages that do not have native support for it, see this topic: Viewing Math on the Discourse Forum

1 Like