pythonnewbie - 1 year ago 131

Python Question

How do I make plots of a 1-dimensional Gaussian distribution function using the mean and standard deviation parameter values (μ, σ) = (−1, 1), (0, 2), and (2, 3)?

I'm new to programming, using Python.

Thank you in advance!

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

Answer Source

With the excellent `matplotlib`

and `numpy`

packages

```
from matplotlib import pyplot as mp
import numpy as np
def gaussian(x, mu, sig):
return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.)))
for mu, sig in [(-1, 1), (0, 2), (2, 3)]:
mp.plot(gaussian(np.linspace(-3, 3, 120), mu, sig))
mp.show()
```

will produce something like

Also - www.whathaveyoutried.com sometimes I feel like such a homework mug.

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