These functions are named after Carl Friedrich Gauss (1777-1855) who applied them to areas such as:
astronomy (e.g., describing conic sections in space)
physics (e.g., Gauss’s Law which relates electric charge to the resulting electric field)
Gaussian Analysis has a number of Machine Learning applications, including:
in statistics to describe normal distributions
in signal processing to define Gaussian filters
in image processing where two-dimensional Gaussians are used for Gaussian blurs
Python Example
To download the code below, click here.
""" normal_gaussian_distribution.py displays a normal (gaussian) distribution """ # Import needed libraries. import numpy as np import matplotlib.pyplot as plotlib # Define parameters. mean = 0 standard_deviation = .1 number_of_bars = 30 number_of_values = 200 # Get normally distributed random values for input to the histogram. values = np.random.normal(mean, standard_deviation, number_of_values) print("Values:") print(values) # Plot the histogram bars. y_axis_counts, x_axis_bins, ignored = plotlib.hist(values, number_of_bars, density=True) print("Y axis counts: ") print(y_axis_counts) print("X axis bins: ") print(x_axis_bins) # Define the predictive gaussian curve equation. curve_equation = 1/(standard_deviation * np.sqrt(2 * np.pi)) * \ np.exp(-(x_axis_bins - mean)**2 / (2 * standard_deviation**2)) # Plot the curve. plotlib.plot(x_axis_bins, curve_equation, linewidth=2, color='r') # Display the plot. plotlib.xlabel('X') plotlib.ylabel('Y') plotlib.show()
The output is shown below:
Values:
[ 0.10474705 -0.30987932 -0.0377035 -0.12976679 0.03038214 0.02884987
0.06735474 0.02050336 0.10587408 0.0791276 0.03052759 0.21124234
0.12064312 0.10327687 0.14145668 -0.09847649 0.09387778 -0.11535636
0.07428888 0.09126191 0.02139157 0.12499734 0.08815726 0.04669107
0.11204913 -0.00150977 -0.17304188 -0.05482239 -0.12933726 -0.17945018
-0.09856835 -0.062865 0.06568228 -0.01367314 -0.16178722 0.20493866
0.14503332 -0.14496856 0.03617333 -0.18822113 -0.06582592 -0.17168639
-0.0391193 -0.01552944 0.10939517 0.08769728 0.07535222 0.11443495
0.04564379 -0.19244263 -0.10538806 0.01349989 -0.07703975 -0.17040789
-0.31217889 0.06574343 0.00646494 0.2068757 0.2335022 -0.01168252
0.05205067 -0.02333681 -0.03391463 0.02957848 -0.03660433 -0.05374718
-0.15526708 0.05358534 0.00534359 -0.03919433 -0.12330592 -0.16946084
0.00989148 0.04596242 -0.05949043 0.01114637 0.03046224 0.17880669
0.05638037 0.11397048 -0.03805841 0.07311613 0.15061437 0.08709982
0.08485248 0.0721531 0.00141072 0.08259899 -0.11273119 -0.1687727
-0.05965978 -0.12921086 -0.13001872 -0.0482734 -0.11063765 -0.07264496
0.14480709 -0.01091887 -0.06735846 0.0097877 -0.09959458 -0.00281473
0.11152834 0.07634176 -0.06880425 -0.06444 -0.08786654 0.27057934
0.00130303 0.1040938 -0.04027242 -0.09381493 0.16435642 -0.06778927
-0.06378324 0.02909034 -0.08235546 0.00622552 0.16772477 -0.01604748
-0.05742619 0.07295698 -0.16177074 0.15175463 0.0111284 0.01002375
0.1121463 0.04910416 0.03420192 -0.23352333 0.02109191 0.00578421
0.18632515 -0.04966773 0.051996 -0.04810638 -0.05649257 -0.01946372
-0.06099288 -0.16894184 -0.19070416 -0.06760437 0.03209812 -0.10352239
-0.06656983 -0.05270806 -0.0106319 -0.05207719 0.07823332 0.13054697
-0.1449979 -0.03860409 -0.10919588 -0.03190828 0.047055 0.10942066
-0.07273786 0.19440813 0.0173874 0.04903521 -0.02009606 0.0572564
0.13853029 0.09609025 0.00606739 0.10157311 0.09431825 0.02695916
-0.09729319 0.07581314 0.04807245 -0.05871703 -0.13058004 -0.17450026
0.21163954 0.06790068 -0.06012134 0.02367296 0.09584136 0.27604811
-0.14405045 -0.09499542 -0.00078646 -0.13857509 0.05205091 0.05981628
0.06830568 0.17722134 0.01685421 -0.18746567 0.01508161 0.10049187
-0.06885735 0.08311225 -0.01847542 -0.07042699 0.18187776 0.17013984
0.13434615 -0.0960767 ]
Y axis counts:
[0.51000719 0. 0. 0. 0.2550036 0.
1.27501798 2.29503237 1.27501798 1.53002158 2.55003597 1.53002158
4.84506834 3.57005035 1.78502518 2.80503956 4.08005755 3.06004316
3.57005035 3.57005035 2.80503956 3.31504676 1.27501798 1.27501798
1.02001439 1.02001439 1.02001439 0.2550036 0. 0.51000719]
X axis bins:
[-0.31217889 -0.29257132 -0.27296376 -0.25335619 -0.23374862 -0.21414106
-0.19453349 -0.17492592 -0.15531836 -0.13571079 -0.11610322 -0.09649566
-0.07688809 -0.05728052 -0.03767296 -0.01806539 0.00154218 0.02114974
0.04075731 0.06036488 0.07997244 0.09958001 0.11918758 0.13879514
0.15840271 0.17801028 0.19761784 0.21722541 0.23683298 0.25644054
0.27604811]