logo for matrixlab-examples.com
[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Welcome Matrixmania Blog
-> Sitemap / Search <-
-> Books <-
Forums and Help
Contact
Basics Quick Matlab Guide
Matlab Tutorial
Matlab Examples
Matlab Flow Control
Boolean Logic
Plots and GUI Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Applications Calculus
Linear Algebra
Matlab Cookbook I
Matlab Cookbook II
Electrical Calculations
Probability and Stats
Finance Apps
Other Relevant Links
Notes on Computing
Online Calculators
Fun!
Your own Website?
Terms/Policies
leftimage for matrixlab-examples.com

Normal Distribution

This algorithm (program in Matlab) calculates the probability and frequency of given values on a standard normal distribution curve (Gauss’ bell). 

You have to enter the mean, the standard deviation and the value of interest. No special toolboxes or strange instructions are used.


 
Gauss' bell to show a standard normal distribution
Standard Normal distribution

The shaded area represents the probability of ‘x’, and its frequency is ‘y’.
The normal probability is approximated using the following formula: 

probability = 1 – r(a1t + a2t2 + a3t3) + eps

where:
                             a1 = 0.4361836
                             a2 = -0.1201676
                             a3 = 0.9372980
                             auxiliary formula for Normal Distribution code

                             t = 1/(1 + 0.33267x)
                            
eps < 10-5

 This is the Matlab code to accomplish the task,


 % Clears screen and deletes all the variables in the workspace
clc; clear; 

% Asks the user for input
m = input('Mean: ');
s = input(
'Std. Dev: ');
y = input(
'x = '); 

% Calculates the frequency (y coordinate)
y = abs((y - m)/s);
r = exp(-y^2/2)/sqrt(2*pi);
str = [
'Frequency: ' num2str(r)];
disp(str) 

z = y;
% Approximates probability (area under curve)
y = 1/(1 + 0.33267*abs(y));
a1 = 0.4361836;
a2 = -0.1201676;
a3 = 0.9372980;
t = 1 - r*(a1*y + a2*y^2 + a3*y^3);

if z < 0
    t = 1 - t;

end

str = ['Probability: ' num2str(t)];
disp(str)


Example 1:

The mean instructions per millisecond (IPMS) of a certain type of modern computers is 150. The standard deviation is 15 IPMS. If the IPMS are normally distributed, what is the probability that a computer executes between 150 and 180 instructions per millisecond?

Easy. Run the Matlab code above and enter...

Mean: 150
Std. Dev: 15
x = 180 

The handy Matlab response is 

Frequency: 0.053991
Probability: 0.97724

 


Example 2: 

What if we need to know the probability of an execution of 130 and 150 instructions per milliseconds for the same type of modern computers?

Don’t worry, Matlab is here... 

Mean: 150
Std. Dev: 15
x = 130

Again, the handy response is 

Frequency: 0.16401
Probability: 0.9088

 From 'Normal Distribution' to home

 From 'Normal Distribution to 'Probability and Statistics' Menu



Top

Online Calculator

Gauss Bell

Binomial distribution




footer for normal distribution page