Rudresh - 1 year ago 135

Python Question

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

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

Code :

Output :

Now I need to plot a conditional distribution and the output should like . 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 but it's giving wrong output

please help me how to plot the same.

Thanks,

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

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**