I have been struggling a bit with the definition of random variables, as it seems to me a bit of an amorphous concept connected to quite a few different ideas. The Wikipedia article also didn't clear things up for me. For this reason, I wanted to check whether my intuition aligns with the definition of random variables, or whether I am missing something important.
The StackExchange "Random Variable" tag defines a random variable as:
A random variable or stochastic variable is a value that is subject to chance variation (i.e., randomness in a mathematical sense)
whereas in the Wikipedia article, for example, I find the following definition:
The formal mathematical treatment of random variables is a topic in probability theory. In that context, a random variable is understood as a measurable function defined on a probability space that maps from the sample space to the real numbers.
These definitions don't appear to be quite the same thing. If I understand the Wikipedia definition correctly, it seems a random variable is not necessarly defined as a variable but as a concept/function that assigns numeric values to specific outcomes. In the example above, such a function would always assign $1$ to "heads" and $0$ to "tails". What confuses me is that this by itself appears to have little to do with probability distributions. A loaded and a fair coin would have the same map from outcomes to numeric values but could have vastly different probabilities for specific outcomes. Does it make sense to say that the random variable of a coin toss is the same for a loaded and a fair coin, or does probability information come into this definition somewhere?
For example, I often come across statements such as
Let $X$ be a real-valued random variable with pdf $f_X(x).$
If I understand this right, $x$ would be an abstract variable which can take on any real value and $f_X(x)$ would be the probability assigned to specific values of $x$. (I aassume the process of assigning numerical values to specific real-world phenomena is already implicitly wrapped up in the definition of $x$.) As I understand it, the random variable $X$ would be a "specialized" version of $x$ in that it takes on values not arbitrarily but following the pdf $f_X(x)$.
As an example, assume that $X$ would be the random variable male body height in cm. In this case, $x$ (being a real variable) could take on any real value between $-\infty$ and $\infty$, whereas $X$ could only take on values between $0$ and about $300$ because its corresponding pdf $f_X(x)$ should assign zero probability density to negative heights (which are physically/definitionally impossible) and extremely large heights (which are biologically implausible).
So does it make sense to think of the random variable $X$ as a combination/pairing/specification of the abstract variable $x$ with an associated probability density function $f_X(x)$? Or am I misunderstanding or missing important aspects?