Rudresh Rudresh - 1 year ago 135
Python Question

plotting conditional distribution in python

I'm new to python and trying to plot a gaussian distribution having the function defined as

enter image description here

I plotted normal distribution P(x,y) and it's giving correct output. code and output are below.

Code :
enter image description here

Output :
enter image description here

Now I need to plot a conditional distribution enter image description here and the output should like enter image description here. to do this I need to define a boundary condition for the equation. I tried to define a boundary condition but it's not working. the code which I tried is enter image description here but it's giving wrong output
enter image description here please help me how to plot the same.


Answer Source

You used the boundary condition on the wrong parameter, try to do it after creating the grid points.

R = np.arange(-4, 4, 0.1)
X, Y = np.meshgrid(R, R)

then validate X and Y based on the condition

valid_xy = np.sqrt(X**2+Y**2) >= 1

X = X[valid_xy]
Y = Y[valid_xy]

Then continue with the rest of the code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download