Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

python - CDF of two continuous random variables from PDF function

So let's say we have a random variable M and it's continuous. Its PDF function is (4x^3)/81 for 0≤x≤3 and 0 for outside of this interval. And let's say we also have another continuous random variable N that depends on M like N = M^2 + 3. How can I plot the joint CDF of M and N?

question from:https://stackoverflow.com/questions/65646794/cdf-of-two-continuous-random-variables-from-pdf-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Stackoverflow won't let me type this joint CDF derivation in because it thinks it is improperly formatted code, but here is an image of it. CDF Derivation

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm

m = np.linspace(0,3,100)
n = np.linspace(3,12,100)
m_mesh,n_mesh = np.meshgrid(m,n)
joint_cdf = np.minimum(m_mesh,np.sqrt(n_mesh-3))**4/81
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(m_mesh, n_mesh, joint_cdf, cmap=cm.coolwarm,linewidth=0, antialiased=False)

Joint CDF Plot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...