What does it mean to generate a random number/variable from a probability distribution? Suppose I have a geometric distribution given which looks like this

Here p = 0.4 and x is from 0 to inf. Now what does it mean when one says generate a random number/variable using this distribution?
 A: In general, generating a random number from a probability distribution means transforming random numbers so that the numbers fit the distribution.
Perhaps the most generic way to do so is called inverse transform sampling:

*

*Generate a uniform random number in [0, 1].

*Run the quantile function (also known as the inverse CDF or the PPF) on the uniform random number.

*The result is a random number that fits the distribution.

However, this technique can't be used in practice for all distributions. The main reason is that the quantile function is either unavailable or hard to calculate. Thus, for many distributions, other techniques are used. They include rejection sampling, direct transformations, etc.
In the case of the geometric distribution, there are at least two ways to generate numbers that follow it. One way is a direct transformation:

*

*Set x to 0.

*With probability p, return x.

*Add 1 to x and go to step 2.

A geometric random number can also be found by inverse transform sampling, described below.

*

*Generate a uniform random number in [0, 1], call it u.

*Run the quantile function, which is floor(log((u - 1)/(p-1))/log(1-p)).

*The result is a geometric random number.

Other ways to generate geometric random numbers are available. The choice of algorithm depends on many things, including efficiency, simplicity, and accuracy. (Note that the geometric distribution is defined differently in different works.) The same applies to other probability distributions.
The 1986 book Non-Uniform Random Variate Generation by Luc Devroye goes into random generation from various distributions in detail. See also my article on randomization and sampling methods.
A: This is a deep question, covered quite nicely in Sivia & Skilling’s textbook.
Briefly, a draw from a distribution $p(x)$ means that a procedure returns a number for which $p(x)$ describes to the best of our knowledge what that number might be. In other words, we cannot do better than using $p(x)$ for predicting $x$ with the knowledge that we have.
Knowledge here is crucial. If you know e.g., the seed and algorithm that a random number generator uses, the draws are completely predictable and you can do better than $p(x)$. Similarly, if you’ve tested the random number generator extensively, you may know better what it might return.
