RandomVariable - crowlogic/arb4j GitHub Wiki

In probability theory, a random variable is a function that assigns a real number to each realization of a random experiment. The set of possible outcomes is called the sample space.

Formally, let's denote the sample space as $\Omega$. A random variable $X$ is then a function:

$$X : \Omega \rightarrow \mathbb{R}$$

where $\mathbb{R}$ is the set of real numbers.

This definition implies that to each element $\omega \in \Omega$, $X$ assigns a real number $X(\omega)$. This assignment is done in such a way that for each interval $(a, b) \subseteq \mathbb{R}$, the set of all $\omega$ such that $a < X(\omega) < b$ is an event in $\Omega$. In other words, the preimage of any Borel set under $X$ is an event.

A key concept related to random variables is that of their distribution, which gives the probabilities associated with the possible values of the random variable. For a discrete random variable, the distribution is given by a probability mass function, while for a continuous random variable, it is given by a probability density function.

Furthermore, random variables can be characterized by various quantities such as their expected value (or "mean"), variance, and higher moments, which provide information about the "average" value, spread, and shape of the distribution, respectively.