Python_2  1.0
Functions
bell Namespace Reference

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

Detailed Description

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:

Author
Paulo Roma
Since
24/03/2022
See also
https://www.geeksforgeeks.org/how-to-make-a-bell-curve-in-python/
https://www.statology.org/bell-curve-google-sheets/
https://trumpexcel.com/bell-curve/
https://www.automateexcel.com/charts/bell-curve-plot-template/

Function Documentation

◆ main()

def bell.main (   argv = None)

Main program for plotting the curve.

Parameters
argvcommnad line arguments.
  • argv[0]: script path.
  • argv[1]: number of random values.

References plot(), plot2(), and showPlot().

◆ pdf()

def bell.pdf (   x)

A custom function to calculate the probability distribution function.

Parameters
xlist of values.
Returns
function to calculate the y coordinate for each x in the list of values.

Referenced by plot().

◆ plot()

def bell.plot (   x,
  xlabel = "",
  ylabel = "" 
)

Plot the curve by using matplotlib.

Parameters
xlist of values.
xlabelx axis label.
ylabely axis label.
See also
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.plot.html
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.scatter.html
https://numpy.org/doc/stable/reference/generated/numpy.sort.html

References pdf().

Referenced by main(), and data.main().

◆ plot2()

def bell.plot2 (   x,
  title = "" 
)

Plot the curve by using seaborn.

Parameters
xlist of values (pandas.DataFrame, numpy.ndarray, mapping, or sequence).
titlecurve title.
See also
https://seaborn.pydata.org/generated/seaborn.histplot.html
https://seaborn.pydata.org/generated/seaborn.boxplot.html
https://seaborn.pydata.org/generated/seaborn.distplot.html

Referenced by main(), and data.main().

◆ plot3()

def bell.plot3 (   x,
  title = "",
  xlabel = "",
  ylabel = "",
  fig = None,
  ax = None 
)

Plot the histogram by using matplotlib.

Parameters
xlist of values.
titlecurve title.
xlabelx axis label.
ylabely axis label.
figfigure containing subplots.
axaxis for drawing.
See also
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.hist.html

Referenced by data.main().

◆ showPlot()

def bell.showPlot (   show = True,
  file_name = "bell.png" 
)

Draw the graphics.

Parameters
showwhether draw or save the graphics.
file_namename of the file to save the figure.
See also
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.show.html
https://matplotlib.org/3.5.1/api/figure_api.html#matplotlib.figure.Figure.savefig

Referenced by main(), and data.main().