Rudresh - 1 month ago 16

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,

Answer

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.