![]() |
Python_2
1.0
|
How to Make a Bell Curve in Python? More...
Functions | |
def | pdf (x) |
A custom function to calculate the probability distribution function. More... | |
def | plot (x, xlabel="", ylabel="") |
Plot the curve by using matplotlib. More... | |
def | plot2 (x, title="") |
Plot the curve by using seaborn. More... | |
def | plot3 (x, title="", xlabel="", ylabel="", fig=None, ax=None) |
Plot the histogram by using matplotlib. More... | |
def | showPlot (show=True, file_name="bell.png") |
Draw the graphics. More... | |
def | main (argv=None) |
Main program for plotting the curve. More... | |
How to Make a Bell Curve in Python?
A bell-shaped curve in statistics corresponds to a normal distribution or a Gaussian distribution which has been named after German mathematician Carl Friedrich Gauss.
In a normal distribution, the points are concentrated on the mean values and most of the points lie near the mean.
The orientation of the bell-curve depends on the mean and standard deviation values of a given set of input points.
By changing the value of the mean we can shift the location of the curve on the axis and the shape of the curve can be manipulated by changing the standard deviation values.
In a normal distribution, mean, median, and mode are all equal and the bell-shaped curve is symmetric about the mean i.e., the y-axis.
The probability density function for a normal distribution is calculated using the formula:
\(f(x,\mu,\sigma) = {{1} \over {\sigma \sqrt{2\pi}}} \exp^{{{-1} \over{2}} \times {\left({{x-\mu} \over {\sigma}}\right)}^{2}},\ -\infty < x < \infty\)
Packages required: macOS:
Ubuntu:
def bell.main | ( | argv = None | ) |
Main program for plotting the curve.
argv | commnad line arguments.
|
References plot(), plot2(), and showPlot().
def bell.pdf | ( | x | ) |
A custom function to calculate the probability distribution function.
x | list of values. |
Referenced by plot().
def bell.plot | ( | x, | |
xlabel = "" , |
|||
ylabel = "" |
|||
) |
Plot the curve by using matplotlib.
x | list of values. |
xlabel | x axis label. |
ylabel | y axis label. |
References pdf().
Referenced by main(), and data.main().
def bell.plot2 | ( | x, | |
title = "" |
|||
) |
Plot the curve by using seaborn.
x | list of values (pandas.DataFrame, numpy.ndarray, mapping, or sequence). |
title | curve title. |
Referenced by main(), and data.main().
def bell.plot3 | ( | x, | |
title = "" , |
|||
xlabel = "" , |
|||
ylabel = "" , |
|||
fig = None , |
|||
ax = None |
|||
) |
Plot the histogram by using matplotlib.
x | list of values. |
title | curve title. |
xlabel | x axis label. |
ylabel | y axis label. |
fig | figure containing subplots. |
ax | axis for drawing. |
Referenced by data.main().
def bell.showPlot | ( | show = True , |
|
file_name = "bell.png" |
|||
) |
Draw the graphics.
show | whether draw or save the graphics. |
file_name | name of the file to save the figure. |
Referenced by main(), and data.main().