If I want to generate a random number from 0 to 1, for example, if I wanted a uniform distribution, I would give the function $y=1$. If I want a simulated normal bell distribution, I could try something like $\frac{\sin\left(\pi\left(2x-\frac{1}{2}\right)\right)-1}{2}$. If I wanted more high numbers to appear, I could do $y=x$, or if lower numbers should appear more frequently, $y=1-x$.
2026-02-22 21:38:30.1771796310
On
Can I generate a random number with the probability distribution of the area under any arbitrary function?
149 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
0
On
From the Caratheodory's Existence Theorem you can deduce that
Given a non-decreasing, right continuous function $F : \mathbb{R} \to \mathbb{R}$, there exists a measure $\mu_F$ on $(\mathbb{R}, \mathscr{B}(\mathbb{R}))$, s.t. $\mu_F((a,b]) = F(b) - F(a)$.
So you need to take care $\lim\limits_{x \to \infty}F(x) = 1$. And you are done.
I assume by "arbitrary function" you mean a pdf or something proportional to it. We can sample any continuous distribution of cdf $F(x)$ by computing $F^{-1}(y)$ for $y\sim U(0,\,1)$, provided $F$ is injective, i.e. the pdf is everywhere non-zero. Even if there are regions where $F'$ vanishes, we can still make it work by computing the least $x$ for which $F(x)=y$.