Visualizing PDFs

The plots I’ve included are the typical way to visualize PDFs, but I much prefer to visualize them as the number lines below. Implementation-wise, I’ve just sampled 300 values from each distribution and plotted each as a red dot with opacity 0.12.

Transforming variables

If I know the PDF of 𝑋, how can I find the PDF of 2𝑋?

Using our number line visual, let’s animate the transform from some random variable 𝑋 to 2𝑋:

Observe two things:

  1. A point originally at π‘₯ moves to 2π‘₯.
  2. The density at every point is halved.

Therefore,

𝑓𝑋(π‘₯)β‹…12=𝑓2𝑋(2π‘₯).

(Typically, we rearrange this as 𝑓2𝑋(π‘₯)=12⋅𝑓𝑋(π‘₯2), but I find the first expression more enlightening.)

Let’s tackle a slightly more challenging transform, 𝑋→𝑋2.

Note that the density is no longer uniformly stretched by a factor of 2; instead, the density at point π‘₯ will get stretched by |(π‘₯2)β€²|=2|π‘₯|. Therefore for π‘₯β‰₯0,

(𝑓𝑋(π‘₯)+𝑓𝑋(βˆ’π‘₯))β‹…12π‘₯=𝑓𝑋2(π‘₯2).

Exercise

In general, what is the PDF of 𝑔(𝑋) in terms of 𝑓𝑋 and 𝑔?