# Connexions

You are here: Home » Content » Applied Probability » MATLAB and Independent Classes

• Preface to Pfeiffer Applied Probability

### Lenses

What is a lens?

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

#### Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
• Rice Digital Scholarship

This collection is included in aLens by: Digital Scholarship at Rice University

Click the "Rice Digital Scholarship" link to see all content affiliated with them.

#### Also in these lenses

• UniqU content

This collection is included inLens: UniqU's lens
By: UniqU, LLC

Click the "UniqU content" link to see all content selected in this lens.

### Recently Viewed

This feature requires Javascript to be enabled.

Inside Collection:

Collection by: Paul E Pfeiffer. E-mail the author

# MATLAB and Independent Classes

Module by: Paul E Pfeiffer. E-mail the author

Summary: In the independent case, we may calculate all minterm probabilities from the probabilities of the basic events. These calculations are straightforward, but may be tedious and subject to errors. An m-function minprob calculates all minterm probabilities from the probabilities of the basic or generating sets. To arrange these as on a minterm map, m-function minmap reshapes the row matrix pm. When minterm probabilities are available, m-function ikn(P,k) calculates individual probabilities and ckn(P,k) calculates the probabilities that k or more occur. These provide the basis of a variety of useful calculations. The m-function imintest checks a vector of minterm probabilities for feasible size, determines the number of variables, and performs a check for independence. As in the nonindependent case, we may utilize the minterm expansion and the minterm probabilities to calculate the probabilities of Boolean combinations of events. However, it is frequently more efficient to manipulate the expressions for the Boolean combination to be a disjoint union of intersections. Various Matlab calculations on independent Boolean combinations are readily performed.

## MATLAB and Independent Classes

In the unit on Minterms, we show how to use minterm probabilities and minterm vectors to calculate probabilities of Boolean combinations of events. In Independence of Events we show that in the independent case, we may calculate all minterm probabilities from the probabilities of the basic events. While these calculations are straightforward, they may be tedious and subject to errors. Fortunately, in this case we have an m-function minprob which calculates all minterm probabilities from the probabilities of the basic or generating sets. This function uses the m-function mintable to set up the patterns of p's and q's for the various minterms and then takes the products to obtain the set of minterm probabilities.

### Example 1

>> pm = minprob(0.1*[4 7 6])
pm = 0.0720  0.1080  0.1680  0.2520  0.0480  0.0720  0.1120  0.1680


It may be desirable to arrange these as on a minterm map. For this we have an m-function minmap which reshapes the row matrix pmpm, as follows:

>> t = minmap(pm)
t = 0.0720    0.1680    0.0480    0.1120
0.1080    0.2520    0.0720    0.1680


Probability of occurrence of k of n independent events

In Example 2, we show how to use the m-functions mintable and csort to obtain the probability of the occurrence of k of n events, when minterm probabilities are available. In the case of an independent class, the minterm probabilities are calculated easily by minprob, It is only necessary to specify the probabilities for the n basic events and the numbers k of events. The size of the class, hence the mintable, is determined, and the minterm probabilities are calculated by minprob. We have two useful m-functions. If P is a matrix of the n individual event probabilities, and k is a matrix of integers less than or equal to n, then

function y = ikn ( P , k ) function y=ikn(P,k) calculates individual probabilities that k k of n n occur

function y = ckn ( P , k ) functiony=ckn(P,k) calculates the probabilities that kk or more occur

### Example 2

>> p = 0.01*[13 37 12 56 33 71 22 43 57 31];
>> k = [2 5 7];
>> P = ikn(p,k)
P =    0.1401    0.1845    0.0225       % individual probabilities
>> Pc = ckn(p,k)
Pc =   0.9516    0.2921    0.0266       % cumulative probabilities


Reliability of systems with independent components

Suppose a system has n components which fail independently. Let Ei be the event the ith component survives the designated time period. Then Ri=P(Ei)Ri=P(Ei) is defined to be the reliability of that component. The reliability R of the complete system is a function of the component reliabilities. There are three basic configurations. General systems may be decomposed into subsystems of these types. The subsystems become components in the larger configuration. The three fundamental configurations are:

1. Series. The system operates iff all n components operate: R=i=1nRiR=i=1nRi
2. Parallel. The system operates iff not all components fail: R=1-i=1n(1-Ri)R=1-i=1n(1-Ri)
3. k of n. The system operates iff k or more components operate. R may be calculated with the m-function ckn. If the component probabilities are all the same, it is more efficient to use the m-function cbinom (see Bernoulli trials and the binomial distribution, below).

MATLAB solution. Put the component reliabilities in matrix RC=[R1R2Rn]RC=[R1R2Rn]

1. Series Configuration
  >> R = prod(RC)     % prod is a built in MATLAB function

2. Parallel Configuration
  >> R = parallel(RC) % parallel is a user defined function

3. k of n Configuration
  >> R = ckn(RC,k)    % ckn is a user defined function (in file ckn.m).


### Example 3

There are eight components, numbered 1 through 8. Component 1 is in series with a parallel combination of components 2 and 3, followed by a 3 of 5 combination of components 4 through 8 (see Figure 1 for a schematic representation). Probabilities of the components in order are

0 . 95 0 . 90 0 . 92 0 . 80 0 . 83 0 . 91 0 . 85 0 . 85 0 . 95 0 . 90 0 . 92 0 . 80 0 . 83 0 . 91 0 . 85 0 . 85
(1)

The second and third probabilities are for the parallel pair, and the last five probabilities are for the 3 of 5 combination.

>> RC = 0.01*[95 90 92 80 83 91 85 85];        % Component reliabilities
>> Ra = RC(1)*parallel(RC(2:3))*ckn(RC(4:8),3) % Solution
Ra = 0.9172


### Example 4

>> RC = 0.01*[95 90 92 80 83 91 85 85];    % Component reliabilities 1--8
>> Rb = prod(RC(1:2))*parallel([RC(3),ckn(RC(4:8),3)])     % Solution
Rb = 0.8532


A test for independence

It is difficult to look at a list of minterm probabilities and determine whether or not the generating events form an independent class. The m-function imintest has as argument a vector of minterm probabilities. It checks for feasible size, determines the number of variables, and performs a check for independence.

### Example 5

>> pm = 0.01*[15 5 2 18 25 5 18 12];   % An arbitrary class
>> disp(imintest(pm))
The class is NOT independent
Minterms for which the product rule fails
1     1     1     0
1     1     1     0



### Example 6


>> pm = [0.10 0.15 0.20 0.25 0.30]: %An improper number of probabilities
>> disp(imintest(pm))
The number of minterm probabilities incorrect


### Example 7


>> pm = minprob([0.5 0.3 0.7]);
>> disp(imintest(pm))
The class is independent


## Probabilities of Boolean combinations

As in the nonindependent case, we may utilize the minterm expansion and the minterm probabilities to calculate the probabilities of Boolean combinations of events. However, it is frequently more efficient to manipulate the expressions for the Boolean combination to be a disjoint union of intersections.

### Example 8: A simple Boolean combination

Suppose the class {A,B,C}{A,B,C} is independent, with respective probabilities 0.4, 0.6, 0.8. Determine P(ABC)P(ABC). The minterm expansion is

A B C = M ( 3 , 4 , 5 , 6 , 7 ) , so that P ( A B C ) = p ( 3 , 4 , 5 , 6 , 7 ) A B C = M ( 3 , 4 , 5 , 6 , 7 ) , so that P ( A B C ) = p ( 3 , 4 , 5 , 6 , 7 )
(2)

It is not difficult to use the product rule and the replacement theorem to calculate the needed minterm probabilities. Thus p(3)=P(Ac)P(B)P(C)=0.60.60.8=0.2280p(3)=P(Ac)P(B)P(C)=0.60.60.8=0.2280. Similarly p(4)=0.0320,p(5)=0.1280,p(6)=0.0480,p(7)=0.1920p(4)=0.0320,p(5)=0.1280,p(6)=0.0480,p(7)=0.1920 . The desired probability is the sum of these, 0.6880.

As an alternate approach, we write

A B C = A A c B C , so that P ( A B C ) = 0 . 4 + 0 . 6 0 . 6 0 . 8 = 0 . 6880 A B C = A A c B C , so that P ( A B C ) = 0 . 4 + 0 . 6 0 . 6 0 . 8 = 0 . 6880
(3)

Considerbly fewer arithmetic operations are required in this calculation.

In larger problems, or in situations where probabilities of several Boolean combinations are to be determined, it may be desirable to calculate all minterm probabilities then use the minterm vector techniques introduced earlier to calculate probabilities for various Boolean combinations. As a larger example for which computational aid is highly desirable, consider again the class and the probabilities utilized in Example 2, above.

### Example 9

Consider again the independent class {E1,E2,,E10}{E1,E2,,E10} with respective probabilities {0.130.370.120.560.330.710.220.430.570.31}{0.130.370.120.560.330.710.220.430.570.31}. We wish to calculate

P ( F ) = P E 1 E 3 ( E 4 E 7 c ) E 2 ( E 5 c E 6 E 8 ) E 9 E 10 c P ( F ) = P E 1 E 3 ( E 4 E 7 c ) E 2 ( E 5 c E 6 E 8 ) E 9 E 10 c
(4)

There are 210=1024210=1024 minterm probabilities to be calculated. Each requires the multiplication of ten numbers. The solution with MATLAB is easy, as follows:

>> P = 0.01*[13 37 12 56 33 71 22 43 57 31];
>> minvec10
Vectors are A1 thru A10 and A1c thru A10c
They may be renamed, if desired.
>> F = (A1|(A3&(A4|A7c)))|(A2&(A5c|(A6&A8)))|(A9&A10c);
>> pm = minprob(P);
>> PF = F*pm'
PF =  0.6636


Writing out the expression for F is tedious and error prone. We could simplify as follows:

>> A = A1|(A3&(A4|A7c));
>> B = A2&(A5c|(A6&A8));
>> C = A9&A10c;
>> F = A|B|C;               % This minterm vector is the same as for F above


This decomposition of the problem indicates that it may be solved as a series of smaller problems. First, we need some central facts about independence of Boolean combinations.

## Independent Boolean combinations

Suppose we have a Boolean combination of the events in the class {Ai:1in}{Ai:1in} and a second combination the events in the class {Bj:1jm}{Bj:1jm}. If the combined class {Ai,Bj:1in,1jm}{Ai,Bj:1in,1jm} is independent, we would expect the combinations of the subclasses to be independent. It is important to see that this is in fact a consequence of the product rule, for it is further evidence that the product rule has captured the essence of the intuitive notion of independence. In the following discussion, we exhibit the essential structure which provides the basis for the following general proposition.

Proposition. Consider n distinct subclasses of an independent class of events. If for each i the event Ai is a Boolean (logical) combination of members of the ith subclass, then the class {A1,A2,,An}{A1,A2,,An} is an independent class.

Verification of this far reaching result rests on the minterm expansion and two elementary facts about the disjoint subclasses of an independent class. We state these facts and consider in each case an example which exhibits the essential structure. Formulation of the general result, in each case, is simply a matter of careful use of notation.

1. A class each of whose members is a minterm formed by members of a distinct subclass of an independent class is itself an independent class.

### Example 10

Consider the independent class {A1,A2,A3,B1,B2,B3,B4}{A1,A2,A3,B1,B2,B3,B4}, with respective probabilities 0.4, 0.7, 0.3, 0.5, 0.8, 0.3, 0.6. Consider M3, minterm three for the class {A1,A2,A3}{A1,A2,A3}, and N5, minterm five for the class {B1,B2,B3,B4}{B1,B2,B3,B4}. Then

P ( M 3 ) = P ( A 1 c A 2 A 3 ) = 0 . 6 0 . 7 0 . 3 = 0 . 126 and P ( N 5 ) = P ( B 1 c B 2 B 3 c B 4 ) = 0 . 5 0 . 8 0 . 7 0 . 6 = 0 . 168 P ( M 3 ) = P ( A 1 c A 2 A 3 ) = 0 . 6 0 . 7 0 . 3 = 0 . 126 and P ( N 5 ) = P ( B 1 c B 2 B 3 c B 4 ) = 0 . 5 0 . 8 0 . 7 0 . 6 = 0 . 168
(5)

Also

P ( M 3 N 5 ) = P ( A 1 c A 2 A 3 B 1 c B 2 B 3 c B 4 ) = 0 . 6 0 . 7 0 . 3 0 . 5 0 . 8 0 . 7 0 . 6 = ( 0 . 6 0 . 7 0 . 3 ) ( 0 . 5 0 . 8 0 . 7 0 . 6 ) = P ( M 3 ) P ( N 5 ) = 0 . 0212 P ( M 3 N 5 ) = P ( A 1 c A 2 A 3 B 1 c B 2 B 3 c B 4 ) = 0 . 6 0 . 7 0 . 3 0 . 5 0 . 8 0 . 7 0 . 6 = ( 0 . 6 0 . 7 0 . 3 ) ( 0 . 5 0 . 8 0 . 7 0 . 6 ) = P ( M 3 ) P ( N 5 ) = 0 . 0212
(6)

The product rule shows the desired independence.

Again, it should be apparent that the result holds for any number of Ai and Bj; and it can be extended to any number of distinct subclasses of an independent class.

2. Suppose each member of a class can be expressed as a disjoint union. If each auxiliary class formed by taking one member from each of the disjoint unions is an independent class, then the original class is independent.

### Example 11

Suppose A=A1A2A3A=A1A2A3 and B=B1B2B=B1B2, with {Ai,Bj}{Ai,Bj} independent for each pair i,ji,j. Suppose

P ( A 1 ) = 0 . 3 , P ( A 2 ) = 0 . 4 , P ( A 3 ) = 0 . 1 , P ( B 1 ) = 0 . 2 , P ( B 2 ) = 0 . 5 P ( A 1 ) = 0 . 3 , P ( A 2 ) = 0 . 4 , P ( A 3 ) = 0 . 1 , P ( B 1 ) = 0 . 2 , P ( B 2 ) = 0 . 5
(7)

We wish to show that the pair {A,B}{A,B} is independent; i.e., the product rule P(AB)=P(A)P(B)P(AB)=P(A)P(B) holds.

COMPUTATION

P ( A ) = P ( A 1 ) + P ( A 2 ) + P ( A 3 ) = 0 . 3 + 0 . 4 + 0 . 1 = 0 . 8 and P ( B ) = P ( B 1 ) + P ( B 2 ) = 0 . 2 + 0 . 5 = 0 . 7 P ( A ) = P ( A 1 ) + P ( A 2 ) + P ( A 3 ) = 0 . 3 + 0 . 4 + 0 . 1 = 0 . 8 and P ( B ) = P ( B 1 ) + P ( B 2 ) = 0 . 2 + 0 . 5 = 0 . 7
(8)

Now

A B = ( A 1 A 2 A 3 ) ( B 1 B 2 ) = A 1 B 1 A 1 B 2 A 2 B 1 A 2 B 2 A 3 B 1 A 3 B 2 A B = ( A 1 A 2 A 3 ) ( B 1 B 2 ) = A 1 B 1 A 1 B 2 A 2 B 1 A 2 B 2 A 3 B 1 A 3 B 2
(9)

By additivity and pairwise independence, we have

P ( A B ) = P ( A 1 ) P ( B 1 ) + P ( A 1 ) P ( B 2 ) + P ( A 2 ) P ( B 1 ) + P ( A 2 ) P ( B 2 ) + P ( A 3 ) P ( B 1 ) + P ( A 3 ) P ( B 2 ) = 0 . 3 0 . 2 + 0 . 3 0 . 5 + 0 . 4 0 . 2 + 0 . 4 0 . 5 + 0 . 1 0 . 2 + 0 . 1 0 . 5 = 0 . 56 = P ( A ) P ( B ) P ( A B ) = P ( A 1 ) P ( B 1 ) + P ( A 1 ) P ( B 2 ) + P ( A 2 ) P ( B 1 ) + P ( A 2 ) P ( B 2 ) + P ( A 3 ) P ( B 1 ) + P ( A 3 ) P ( B 2 ) = 0 . 3 0 . 2 + 0 . 3 0 . 5 + 0 . 4 0 . 2 + 0 . 4 0 . 5 + 0 . 1 0 . 2 + 0 . 1 0 . 5 = 0 . 56 = P ( A ) P ( B )
(10)

The product rule can also be established algebraically from the expression for P(AB)P(AB), as follows:

P ( A B ) = P ( A 1 ) [ P ( B 1 ) + P ( B 2 ) ] + P ( A 2 ) [ P ( B 1 ) + P ( B 2 ) ] + P ( A 3 ) [ P ( B 1 ) + P ( B 2 ) ] = [ P ( A 1 ) + P ( A 2 ) + P ( A 3 ) ] [ P ( B 1 ) + P ( B 2 ) ] = P ( A ) P ( B ) P ( A B ) = P ( A 1 ) [ P ( B 1 ) + P ( B 2 ) ] + P ( A 2 ) [ P ( B 1 ) + P ( B 2 ) ] + P ( A 3 ) [ P ( B 1 ) + P ( B 2 ) ] = [ P ( A 1 ) + P ( A 2 ) + P ( A 3 ) ] [ P ( B 1 ) + P ( B 2 ) ] = P ( A ) P ( B )
(11)

It should be clear that the pattern just illustrated can be extended to the general case. If

A = i = 1 n A i and B = j = 1 m B j , with each pair { A i , B j } independent A = i = 1 n A i and B = j = 1 m B j , with each pair { A i , B j } independent
(12)

then the pair {A,B}{A,B} is independent. Also, we may extend this rule to the triple {A,B,C}{A,B,C}

A = i = 1 n A i , B = j = 1 m B j , and C = k = 1 r C k , with each class { A i , B j , C k } independent A = i = 1 n A i , B = j = 1 m B j , and C = k = 1 r C k , with each class { A i , B j , C k } independent
(13)

and similarly for any finite number of such combinations, so that the second proposition holds.

3. Begin with an independent class EE of n events. Select m distinct subclasses and form Boolean combinations for each of these. Use of the minterm expansion for each of these Boolean combinations and the two propositions just illustrated shows that the class of Boolean combinations is independent

To illustrate, we return to Example 9, which involves an independent class of ten events.

### Example 12: A hybrid approach

Consider again the independent class {E1,E2,,E10}{E1,E2,,E10} with respective probabilities {0.130.370.120.560.330.710.220.430.570.31}{0.130.370.120.560.330.710.220.430.570.31}. We wish to calculate

P ( F ) = P E 1 E 3 ( E 4 E 7 c ) E 2 ( E 5 c E 6 E 8 ) E 9 E 10 c P ( F ) = P E 1 E 3 ( E 4 E 7 c ) E 2 ( E 5 c E 6 E 8 ) E 9 E 10 c
(14)

In the previous solution, we use minprob to calculate the 210=1024210=1024 minterms for all ten of the Ei and determine the minterm vector for F. As we note in the alternate expansion of F,

F = A B C , where A = E 1 E 3 ( E 4 E 7 c ) B = E 2 ( E 5 c E 6 E 8 ) C = E 9 E 10 c F = A B C , where A = E 1 E 3 ( E 4 E 7 c ) B = E 2 ( E 5 c E 6 E 8 ) C = E 9 E 10 c
(15)

We may calculate directly P(C)=0.570.69=0.3933P(C)=0.570.69=0.3933. Now A is a Boolean combination of {E1,E3,E4,E7}{E1,E3,E4,E7} and B is a combination of {E2,E5,E6,E8}{E2,E5,E6,E8}. By the result on independence of Boolean combinations, the class {A,B,C}{A,B,C} is independent. We use the m-procedures to calculate P(A)P(A) and P(B)P(B). Then we deal with the independent class {A,B,C}{A,B,C} to obtain the probability of F.

>> p  = 0.01*[13 37 12 56 33 71 22 43 57 31];
>> pa = p([1 3 4 7]);     % Selection of probabilities for A
>> pb = p([2 5 6 8]);     % Selection of probabilities for B
>> pma = minprob(pa);     % Minterm probabilities for calculating P(A)
>> pmb = minprob(pb);     % Minterm probabilities for calculating P(B)
>> minvec4;
>> a = A|(B&(C|Dc));      % A corresponds to E1, B to E3, C to E4, D to E7
>> PA = a*pma'
PA = 0.2243
>> b = A&(Bc|(C&D));      % A corresponds to E2, B to E5, C to E6, D to E8
>> PB = b*pmb'
PB = 0.2852
>> PC = p(9)*(1 - p(10))
PC = 0.3933
>> pm = minprob([PA PB PC]);
>> minvec3                % The problem becomes a three variable problem
>> F = A|B|C;             % with {A,B,C} an independent class
>> PF = F*pm'
PF = 0.6636               % Agrees with the result of Example 7


## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

#### Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

#### Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks