leftimage for poohprod.ru

Gaussian distribution – how to plot it in Matlab



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.


The Probability Density Function (PDF) in this case can be defined as:


Gaussian distribution formula

where

relevant values in bell curve


The formula above can me coded in Matlab easily, like this:

function f = gauss_distribution(x, mu, s)
p1 = -.5 * ((x - mu)/s) .^ 2;
p2 = (s * sqrt(2*pi));
f = exp(p1) ./ p2;

Now, let’s use it in an example.

We produce 500 random numbers between -100 and 100, with mean m = 0 and standard deviation s = 30. The code is:

a = -100; b = 100;
x = a + (b-a) * rand(1, 500);
m = (a + b)/2;
s = 30;

Then, we plot this information using our bell curve:

f = gauss_distribution(x, m, s);
plot(x,f,
'.')
grid
on
title('Bell Curve')
xlabel(
'Randomly produced numbers')
ylabel(
'Gauss Distribution')

The produced shape is:

Gaussian distribution after random numbers

An important property of this bell-shaped curve is that the values less than one standard deviation from the mean (between green lines below) represent approximately 68.2% of the area under the curve, while two standard deviations from the mean (between red lines below) take about 95.4%, and three standard deviations account for about 99.7% of the area.

standard deviation values in a bell curve

From 'Gaussian distribution' to home

From 'Gaussian distribution' to Matlab 2D plots

Probability and Statistics

Statistics: Normal Distribution

Top



footer for gaussian distribution page









Related pages


matlab bookshow to solve quadratic equations in matlabbernoulli distribution matlabbernoulli distribution matlabpolar coordinates conversionsum of harmonic serieshexadecimal to octal conversion methodmatlab axis squarescilab commandspoisson distribution calculator onlinetriangle sum theorem calculatorisnan matlabdouble interpolation formulamatlab guide examplesmatlab movie plotpythagoras theorem solverbisection method algorithmpythag calcsolids of revolution examplesquadratic function online calculatorhow to calculate pnrloan repayment equationresistor number code calculatorbinomial distribution calcmatlab finding rootsbell curve plottermatlab rotate figurefibonacci sequence examplessolve linear equations matlabquadratic function online calculatornodal analysis circuitsbabylonian algorithmkeyascii tableslope intercept form from two points calculatorpiecewise calculator onlinematlab normal distribution plotcomet animationsawtooth wave functionmagic square matrixcall function in matlabmatlab deal functionscilab helppythagoras calculator online5 band resistance color code calculatorconversion binary to hexadecimalsimultaneous equation examplegray code to binary conversion methodmatlab beginnersformulas for half lifenet salvage value formulaammoritization tablevswr charthow to calculate your body mass index manuallymatlab gui animationdraw circle matlabmatlab formulascilab plotcircuitbuilding do it yourself for dummiesohms law caculatortrapzpascals trianglepiecewise functions calculatorcalculate permutations and combinationshexadecimal to octal conversion methodcontinuous compound calculatormatlab graphics tutorialsimple interest investment calculatorcalculating half life decaymatrix inverse in matlabcftool matlabformula for salvage valuerc circuits equationssquare feet in inches calculatorsolving matrices in matlab3d rotation matrix matlabhow to convert from cartesian to polardefine functions in matlabmagic square matrix