What are the advanatages of CDFs for RNG over simple random sampling?

72 Views Asked by At

If I understand Cumulative Distribution Functions (CDFs) correctly, they can be used for random number generation from a given dataset as follows:

Build a CDF that maps data points to an ordinal probability of any particular data point being <= the given data point. Then use inverse sampling on the CDF by generating a pseudorandom number in the interval of [0, 1), find the probability from the codomain of the CDF that is closest, and then return the data point from the domain that corresponds to that probability.

What are the advantages of this approach over building a list that contains all of the data points, with duplicates, and then generating a random number r such that r ∈ ℕ and 1 <= r <= n (where n is the number of data points, including duplicates) and selecting the r-th data point from the list?

It seems like both approaches yield the same outcome, unless I am mistaken.