0% found this document useful (0 votes)
5 views3 pages

MATLAB Probability Calculations Guide

The document describes how to calculate probabilities in MATLAB by indexing data points that fall within defined boundaries using 1s and 0s. It defines boundaries for variables A and B, counts the number of hits for each using sum, and calculates the probabilities of events A, B, and A and B occurring using the counts and total number of data points. The probability of A given B is then calculated using the probabilities of A and B and their intersection.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

MATLAB Probability Calculations Guide

The document describes how to calculate probabilities in MATLAB by indexing data points that fall within defined boundaries using 1s and 0s. It defines boundaries for variables A and B, counts the number of hits for each using sum, and calculates the probabilities of events A, B, and A and B occurring using the counts and total number of data points. The probability of A given B is then calculated using the probabilities of A and B and their intersection.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

2)c)ii)

To calculate probabilities in MATLAB, the number of points within each boundary must be indexed
in the following way (1 represents a hit, so the point is within the boundary):

>> A = 2430 < density & density < 2450 >> B = 55 < strength & strength < 65 >> Atotal = 2410 < density & density < 2489 >> Btotal = 48 < strength & strength < 71
A= B= Atotal = Btotal =

1 1 1 1
1 1 1 1
0 1 1 1
0 0 1 1
0 1 1 1
1 0 1 1
0 0 1 1
1 0 1 1
1 1 1 1
1 1 1 1
1 1 1 1
0 0 1 1
1 1 1 1
1 1 1 1
1 1 1 1
0 0 1 1
1 0 1 1
0 0 1 1
0 1 1 1
1 1 1 1
1 1 1 1
0 1 1 1
0 1 1 1
1 1 1 1
1 1 1 1
0 1 1 1
1 1 1 1
1 0 1 1
0 1 1 1
0 0 1 1
1 1 1 1
1 1 1 1
1 0 1 1
0 0 1 1
0 1 1 1
0 1 1 1
0 0 1 1
0 1 1 1
0 0 1 1
0 1 1 1

Also as P(AandB) will need to be found, the following boundary, which includes both the
density and strength, must be defined: >> AandB = A & B
This simply indexes the points which fit both criteria, A and B.
Then, these indexed “hits” must be counted, which involves a simple sum of all the 1’s
above.
>> sum(Atotal)

ans =

40

>> sum(Btotal)

ans =

40

>> sum(A)

ans =

20

>> sum(B)

ans =

26

>> sum(AandB)

ans =

15

=================================================================================================================
====

Then, the probabilities are found simply by inputting the different formulae, using the
basic
>> ProbA = sum(A)/sum(Atotal)
ProbA =

0.5000
>> ProbB = sum(B)/sum(Btotal)
ProbB =

0.6500
In this case, ProbAandB had to be done slightly differently, as it involved boundaries
within two variables.
>> >> ProbAandB = sum(AandB)/sum(Atotal)
ProbAandB =

0.3750
Then, we can use this to find P(A|B)
>> ProbAgivenB = ProbAandB/ProbB
ProbAgivenB =

0.5769

You might also like