Counting: 1 1 2 2 N N 1 2 N 1 2 N

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Counting

Counting is the process of determining the number of elements of a finite set of objects. In
mathematics, the essence of counting a set and finding a result n, is that it establishes a one-to-
one correspondence (or bijection) of the set with the set of numbers {1, 2, ..., n}. A fundamental
fact, which can be proved by mathematical induction, is that no bijection can exist between {1, 2,
..., n} and {1, 2, ..., m} unless n = m; this fact ensures that counting the same set in different
ways can never result in different numbers.

Addition Principle: If event A can occur in a ways and event B can occur in b other ways, then
the event of either A or B can occur in a + b ways.
This idea can easily be applied to more events. We can put the addition principle into the
language of sets. Let S be a set. If A1, A2, ... , An is a partition of S, then
|S| = |A1| + |A2| + … + |An| [1]
where |X| denotes the number of elements in the set X.

Multiplication Principle: If event A1 can occur in a1 different ways, and event A2 can occur in
a2 different ways, ... , and event An can occur in an different ways, then the total number of ways
that event A1 followed by event A2 , ... , followed by event An can occur is a1a2 … an.
We can also put the multiplication principle into the language of sets; that is, if
|S| = {(s1, s2, …, sn) | si ∈ Si , 1 ≤ i ≤ n},then
|S| = |S1|· |S2| … |Sn|· [2]

Strings: A string over a finite set S is a sequence of elements of S. For example, there are 8
binary strings of length 3:
000, 001, 010, 011, 100, 101, 110, 111
We sometimes call a string of length k a k-string.

Permutations: A permutation of a finite set S is an ordered sequence of all the elements of S,


with each element appearing exactly once.
For example, if S = {a, b, c} then S has 6 permutations: {a, b, c}, {a, c, b}, {b, a, c}, {b, c, a}, {c,
a, b}, {c, b, a}.
There are n! permutations of a set of n elements, since we can choose the first element of the
sequence in n ways, the second in (n-1) ways, the third in (n-2) ways, and so on.
A k-permutation of S is an ordered sequence of k elements of S, with no element appearing more
than once in the sequence. The twelve 2-permutations of the set {a, b, c, d} are {a, b}, {a, c}, {a,
d}, {b, a}, {b, c}, {b, d}, {c, a}, {c, b}, {c, d}, {d, a}, {d, b}, {d, c}.
The number of k-permutations of an n-set is
𝒏!
𝒏 (𝒏 − 𝟏)(𝒏 − 𝟐) … (𝒏 − 𝒌) = (𝒏−𝒌)!
[3]

since we have n ways to choose the first element, (n–1) ways to choose the second element, and
so on, until we have selected k elements, the last being a selection from the remaining (n - k + 1).

Combinations: A k-combination of an n-set S is simply a k-subset of S.


For example, the 4-set {a, b, c, d} has six 2-combinations: {a, b}, {a, c}, {a, d}, {b, c}, {b, d},
{c, d}.
We can construct a k-combination of an n-set by choosing k distinct (different) elements from
the n-set. The order in which we select the elements does not matter.
We can express the number of k-combinations of an n-set in terms of the number of k
permutations of an n-set. Every k-combination has exactly k! permutations of its elements, each
of which is a distinct k-permutation of the n-set. Thus, the number of k-combinations of an n-set
is the number of k-permutations divided by k!; from equation [3], this quantity is
𝒏!
[4]
𝒌!(𝒏−𝟏)!
For k = 0, this formula tells us that the number of ways to choose 0 elements from an n-set is 1
(not 0), since 0! = 1.

Binomial coefficients: The notation (𝑛𝑘) (read “n choose k”) denotes the number of k-
combinations of an n-set. From equation [4], we have
𝒏!
(𝒏𝒌) = [5]
𝒌!(𝒏−𝟏)!
𝒏 𝒏
This formula is symmetric in k and (n – k): (𝒌) = (𝒏−𝒌 )
These numbers are also known as binomial coefficients.
Probability

 probability is defined as : P(x)=number of favorable outcomes / total number of


outcomes
 Here, P(x) is the probability of occurrence of an event x, and the event x here is a discrete
and independent event.
 The definition of probability in general can be for continuous events, dependent events,
conditional events and so on.
 In probability theory, we perform or consider the experiments in which all possible
outcomes are known in advance.
 P(x)+P(x')=1 ;that is, sum of probability of an event occurring and the probability of the
same event not occurring is one.
 Compound Events are formed by combining two or more simple events:
o A∩B:
o A∪B :
o P(A∪B)=P(A)+P(B)-P(A∩B)
 Two events A and B are said to be Mutually Exclusive Events if P(A∩B)=0, that is, if
both A and B can NEVER happen simultaneously.
 Two events are said to be Independent, if P(A|B)=P(A), or the conditional probability of
event A occurring given event B has occurred is equal to the probability of event A, or
that event A is unaffected by event B
 Conditional Probability: P(A|B)=P(A∩B)P(B)
 If A and B are independent then, P(A∩B)=P(A)P(B)
 An experiment can be single stage or multi-stage, depending upon if an experiment can
be further broken down into stages.
 In case of a multi-stage experiment, we can have conditional probabilities between events
A and B such that either :
o A and B are in the same stage. In this case we use: P(AB)=n(A∩B)n(B)
o A is in the stage that has occurred, and B is in a stage that will occur (experiment
is not yet over).
o A is in a previous stage, and B is in a later stage, and the experiment is over.
o In the second and third case, we make use of Bayes’ theorem
Application of Probability:

 Probability finds its application in a wide variety of areas. Be it Artificial Intelligence,


communication, statistical analysis, quantum mechanics and many more.

 One way of using probability is introducing Random variables. If S is the sample space,
and w is an element in sample space, then a real valued function X which assigns a
unique real number X(w) to each w in S is called a random variable X.

Examples of probability:
Question: What is the probability of a leap year having 53 Saturdays or 53 Sundays?
Solution: A leap year has 52 weeks 2 days. Those 2 days can be Monday and Tuesday OR
Tuesday and Wednesday, and so on till Sunday and Monday.
P(53 sat U 53 Sun)=P(53 Sat)+P(53 Sun)-P(53 Sat and 53 Sun) [NOTE: UNIOIN STANDS
FOR “OR”,INTERSECTION FOR “AND”]
=2/7+2/7-1/7=3/7

Question: A box contains 10 good articles and 6 defective articles. One item is drawn at
random. What is the probability that it is either good or has a defect?
Solution: The answer is one! Because the article could be either good or defective as per the
question

Question: If the probability of A failing in an exam is 0.2 and of B failing is 0.3, then what is
the
probability of either A failing, or B failing?
Solution: P(A fails or B fails)=P(A fails)+P(B fails)-P(A and B fail).
Now, P(A fails and B fails)=P(A fails) X P(B fails) as A and B are independent because clearly, there
is no relation of A failing with B failing.
Thus, P(A or B fails)=0.3+0.2-0.2X0.3=0.44
Question: Three integers are chosen at random from first twenty integers. The probability that
their product is even is?
Solution: Total ways to choose three integers is 20X19X18.
To choose three numbers such that their product is even, we are supposed to choose any two numbers
and one even number.
We can either choose an even number then choose any two numbers, or we can choose an odd
number
then an even number and then any number, or we can choose two odd numbers then an even number.
Correspondingly there are 10X19X18,10X10X18,10X9X10.

10X19X18+10X10X18+10X9X10
Thus, probability = =17/19
20X19X18

Question: A bag contains x white and y black balls. Two players A and B alternately draw a
ball from the bag and then replace it every time after the draw. A begins the game. If the
probability of A winning (A player wins when he draws a white ball) is twice the probability of
B winning, then find x:y.

Solution: Here, clearly, P(drawing a white ball)=P(W)=x/(x+y).


Similarly, P(B)=y/(x+y).
P(A wins)=2(P(B wins))
or, P(A wins)=2(P(A loses))
or, P(A wins)=2(1-P(A wins))
or, P(A wins)=2/3.
Now, A starts the game, so for A to win, either he draws white ball the first time, or he draws
a black
ball and then B draws a black ball and then A draws a white ball, or he draws a black ball
then B draws
black then he again draws black then B draws black and then he draws white and so on.

x y y x y y y y x
Thus, P(A wins) = x+y + x+y X x+y X x+y + x+Y X x+y X x+y X x+y X x+y + ⋯
x
x+y
= y y
1− X
x+y x+y

Using sum of an infinite Geometric Progression.


Thus we get,
𝑥 2 + 𝑥𝑦 2
=
𝑥 2 + 2𝑥𝑦 3
Solving, we get, x=y or x:y=1:1
Expected Value

Theory:
Mathematical Expectation is an important concept in Probability Theory. Mathematically, for a
discrete variable X with probability function P(X), the expected value E[X] is given by Σ xiP(xi)
the summation runs over all the distinct values xi that the variable can take. For example, for a
dice-throw experiment, the set of discrete outcomes is { 1,2,3,4,5,6} and each of this outcome
has the same probability 1/6. Hence, the expected value of this experiment will be
1/6*(1+2+3+4+5+6) = 21/6 = 3.5. For a continuous variable X with probability density function
P(x) , the expected value E[X] is given by ∫ xP(x)dx. It is important to understand that "expected
value" is not same as "most probable value" - rather, it need not even be one of the probable
values. For example, in a dice-throw experiment, the expected value, 3.5 is not one of the
possible outcomes at all.
The rule of "linearity of the expectation" says that E[x1+x2] = E[x1] + E[x2].

Examples
Question: What is the expected number of coin flips for getting a head?

Answer: Let the expected number of coin flips be x. Then we can write an equation for it -
a. If the first flip is the head, then we are done. The probability of this event is 1/2 and the
number of coin flips for this event is 1.
b. If the first flip is the tails, then we have wasted one flip. Since consecutive flips are
independent events, the solution in this case can be recursively framed in terms of x - The
probability of this event is 1/2 and the expected number of coins flips now onwards is x. But
we have already wasted one flip, so the total number of flips is x+1.

The expected value x is the sum of the expected values of these two cases. Using the rule of
linearity of the expectation and the definition of Expected value, we get,
x = (1/2)(1) + (1/2) (1+x)
Solving, we get x = 2.
Thus the expected number of coin flips for getting a head is 2.
Question: What is the expected number of coin flips for getting two consecutive heads?

Answer: Let the expected number of coin flips be x. The case analysis goes as follows:
a. If the first flip is a tails, then we have wasted one flip. The probability of this event is 1/2
and the total number of flips required is x+1
b. If the first flip is a heads and second flip is a tails, then we have wasted two flips. The
probability of this event is 1/4 and the total number of flips required is x+2
c. If the first flip is a heads and second flip is also heads, then we are done. The probability of
this event is 1/4 and the total number of flips required is 2.
Adding, the equation that we get is -
x = (1/2)(x+1) + (1/4)(x+2) + (1/4)2
Solving, we get x = 6.
Thus, the expected number of coin flips for getting two consecutive heads is 6.

Question: (Generalization) What is the expected number of coin flips for getting N
consecutive heads, given N?
Answer: Let the expected number of coin flips be x. Based on previous exercises, we can
wind up the whole case analysis in two basic parts:
a) If we get 1st, 2nd, 3rd,...,n'th tail as the first tail in the experiment, then we have to start all
over again.
b) Else we are done.
For the 1st flip as tail, the part of the equation is (1/2)(x+1)
For the 2nd flip as tail, the part of the equation is (1/4)(x+2)
...
For the k'th flip as tail, the part of the equation is (1/(2k))(x+k)
...
For the N'th flip as tail, the part of the equation is (1/(2N))(x+N)
The part of equation corresponding to case (b) is (1/(2N))(N)
Adding,
x = (1/2)(x+1) + (1/4)(x+2) + ... + (1/(2^k))(x+k) + .. + (1/(2^N))(x+N) + (1/(2^N))(N)

Solving this equation is left as an exercise to the reader. The entire equation can be very
easily reduced to the following form:

x = 2N+1-2

Thus, the expected number of coin flips for getting N consecutive heads is (2N+1 - 2).
Question: What is the expected number of dice throws required to get a "four"?

Answer: Let the expected number of throws be x. The desirable event (getting 'four') has
probability 1/6 (as each face is equiprobable). There are 5 other undesirable events (K=5).
Note that the value of the final answer does not depend on K.

The answer is thus 1/(1/6) i.e. 6.

Question: (Bernoulli Trials) n students are asked to choose a number from 1 to 100
inclusive. What is the expected number of students that would choose a single digit
number?

Answer::This question is based on the concept of Bernoulli trials. An experiment is called a


Bernoulli trial if it has exactly two outcomes, one of which is desired. For example - flipping
a coin, selecting a number from 1 to 100 to get a prime, rolling a dice to get 4 etc. The result
of a Bernoulli trial can typically be represented as "yes/no" or "success/failure". We have
seen in Q5 above that if the probability of success of a Bernoulli trial is p then the expected
number of trials to get a success is 1/p. is

This question is based on yet another result related to Bernoulli trials - If the probability of a
success in a Bernoulli trial is p then the expected number of successes in n trials is n*p. The
proof is simple -

The number of successes in n trials = (if 1st trial is success then 1 else 0) + ... + (if nth trial is
success then 1 else 0)
The expected value of each bracket is 1*p + 0*(1-p) = p. Thus the expected number of
successes in n trials is n*p.

In the current case, "success" is defined as the experiment that chooses a single digit number.
Since all choices are equiprobable, the probability of success is 9/100. (There are 9 single
digit numbers in 1 to 100). Since there are n students, the expected number of students that
would contribute to success (i.e. the expected number of successes) is n*9/100

You might also like