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

Poisson Distribution 

Using the Poisson distribution, this program calculates the probability of an event occurring a given number of times. You must know the expected frequency of the event.

No special instruction or statistical toolboxes are used, so you can adapt the code to any other programming language...
 



This is the code in Matlab:


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

% Asks the user for input
f = input('Calculated Frequency: ');
x = input(
'Test Frequency: '); 

% Computes probability
a = log(factorial(x));
a = exp(-f + x*log(f) - a); 

% Displays result
str = ['Probability of ' num2str(x) ' occurrences = ' num2str(a)];
disp(str)


The instruction 'num2str' (number-to-string) transforms a number into a string, to be used along with the rest of the output message, launched by instruction 'disp'.

 Example  1:


Some programs are downloaded into 2000 computers. The probability of any one computer getting infected by a virus is 0.001 (nothing to do with reality, ok?) Thus we can expect 2 computers will suffer a bad reaction (0.001 x 2000 = 2). What is the probability that 4 computers will get infected?

We launch our code above and enter known data as input:

Calculated Frequency: 2
Test Frequency: 4

Matlab answer is

Probability of 4 occurrences = 0.090224

Example 2:


What is the probability that only one computer will get infected?

We re-launch our code and enter data:

Calculated Frequency: 2
Test Frequency: 1

Matlab answer is

Probability of 1 occurrences = 0.27067


 From 'Poisson Distribution' to home

 From 'Poisson Distribution' to 'Probability and Statistics'
 
Top

Online Poisson Calculator

Normal distribution

F-distribution

t-distribution

Chi-square

Random numbers




footer for poisson distribution page