I have two random variables, x
is beta-distributed on the interval [2, 6]
and y
is uniformly distributed on the interval [0, 1]
. For every x
I would like to find y
such that CDF_x(x) = CDF_x(y)
and plot the graph. In other words I would like to get CDF_y_inverse(CDF_x(x))
.
So far I have the following code which only plots the pdf of x
.
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from scipy.stats import beta, uniform
a, b = 2, 5
fig, ax = plt.subplots(1, 1)
x = np.linspace(2+4*beta.ppf(0, a, b), 2+4*beta.ppf(1, a, b), 1000)
ax.plot(x, beta.pdf((x-2)/4, a, b), lw=2, color='green', alpha=0.5, label='beta pdf')
plt.show()
Edit: Assume instead of uniform distribution y
has truncated normal distribution, otherwise the problem is trivial.