1 / 18

Pattern recognition lab 3

Pattern recognition lab 3. TA : Nouf Al-Harbi :: nouf200@hotmail.com. Lab objective:. Illustrate the normal distribution of a random variable Draw two normal functions using the Gaussian formula. Part 1. Theoretical Concept. What’s Normal distribution ..?.

len
Download Presentation

Pattern recognition lab 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pattern recognition lab 3 TA : Nouf Al-Harbi :: nouf200@hotmail.com

  2. Lab objective: • Illustrate the normal distribution of a random variable • Draw two normal functions using the Gaussian formula

  3. Part 1 Theoretical Concept

  4. What’s Normal distribution ..? • A normal distribution is a very important statistical data distribution pattern occurring in many natural phenomena • Height, weight , people age

  5. Normal distribution • Certain data, when graphed as a histogram (data on the horizontal axis, amount of data on the vertical axis), creates a bell-shaped curve known as a normal curve, or normal distribution.

  6. Normal distribution A normal distribution of data means that most of the examples in a set of data are close to the "average," while relatively few examples tend to one extreme or the other.

  7. Normal distribution • Normal distributions are symmetrical • a single central peak at the mean (average), (μ) of the data.  •   50% of the distribution lies to the left of the mean • 50% lies to the right of the mean. • The spread of a normal distribution is controlled by the standard deviation, (σ) .  • The smaller the standard deviation the more concentrated the data.

  8. Normal Distribution form

  9. Part 2 Practical Applying Using randn function

  10. Normal distribution using randn • Generate N random values normally distributed where mu=20 , sigma=2 • Find the frequency distribution of each outcome (i.e. how many times each outcome occur?) • Find the probability density function p(x)

  11. randn • generates random numbers drawn from the normal distribution N(0,1), i.e., with mean (μ) = 0 and standard deviation (σ) =1 • Write the following in Matlab & see the result: • r = randn(1,6) • generates 1-D array of one row and 6columns • To change the normal parameters we can use fix function 

  12. fix • x=fix(σ * r + μ ) • x = fix( 2* r + 20); • Writing the previous line convert r into random values normally distributed with • mean (μ) = 20 • standard deviation (σ) =2

  13. Full code N=1000000; mu = 20; % mean. sigma = 2; % standard deviation. r = randn(1,N); x = fix( sigma * r + mu ); xmax = max(x); f=zeros(1,xmax); for i=1:N j = x(i); f(j) = f(j)+1; end plot(f) p = f / N; figure, plot(p)

  14. Part 2 Practical Applying Using Gaussian(normal) formula

  15. Using Gaussian(normal) formula • Instead of generating random values normally distributed (using randn), we can use: • Gaussian formula :

  16. Draw 2 normal functions using Gaussian formula • For first normal function : N(20,2) • Mu1=20 sigma1=2 • X=1:40 • Apply Gaussian Formula • For second normal function :N(15,1.5) • Mu2=15 sigma2=1.5 • X=1:40 • Apply Gaussian Formula • Plot the normal functions

  17. Full code mu1 = 20; sigma1 = 2; p1 = zeros(1,40); for x = 1:40 p1(x) = (1/sqrt(2*pi*sigma1))*exp(-(x-mu1)^2/(2*sigma1)); End mu2 = 30; sigma2 = 1.5; p2 = zeros(1,40); for x = 1:40 p2(x) = (1/sqrt(2*pi*sigma2))*exp(-(x-mu2)^2/(2*sigma2)); end x=1:40; plot(x,p1,'r-',x,p2,'b-') 1 2 3

  18. H.W 2 Write a Matlab function that compute the value of the Gaussian distribution for a given x. That is a function that accept the values of x, mu, and sigma, then return the value of N(mu,sigma) at the value of x. For example: call the function normalfn(x,mu,sigma). Then use it by issuing the command >>normalfn(15, 20,3). %this should return the values of this pdf at x =15. Then, use this function to write another function to draw the normal distribution N(20,2), i.e., with normal distribution with mean = 20 and standard deviation = 2.

More Related