Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting of 1-dimensional Gaussian distribution function

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!

like image 285
pythonnewbie Avatar asked Feb 14 '13 10:02

pythonnewbie


People also ask

How do you plot a Gaussian distribution function?

In statistics and probability theory, the Gaussian distribution is a continuous distribution that gives a good description of data that cluster around a mean. The graph or plot of the associated probability density has a peak at the mean, and is known as the Gaussian function or bell curve. p1 = -. 5 * ((x - mu)/s) .

How do you represent a Gaussian distribution?

The Gaussian distribution is also commonly called the "normal distribution" and is often described as a "bell-shaped curve". If the probability of a single event is p = and there are n = events, then the value of the Gaussian distribution function at value x = is x 10^ .


1 Answers

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.)))  x_values = np.linspace(-3, 3, 120) for mu, sig in [(-1, 1), (0, 2), (2, 3)]:     mp.plot(x_values, gaussian(x_values, mu, sig))  mp.show() 

will produce something like plot showing one-dimensional gaussians produced by matplotlib

like image 181
danodonovan Avatar answered Sep 28 '22 16:09

danodonovan