Module - 3
Module - 3
Module - 3
1
Sequential Numbers
A sequence is a collection of elements in a particular order. Elements of a
sequence can be related to each other, and are often defined using recursion.
Sequences can be finite or infinite.
Geometric Sequences
A sequence in which every term is obtained by multiplying or dividing a
definite number with the preceding number is known as a geometric
sequence.
Sequential Numbers
Harmonic Sequences
A series of numbers is said to be in harmonic sequence if the reciprocals of
all the elements of the sequence form an arithmetic sequence.
𝟏 𝟏 𝟏 𝟏
Harmonic Sequences = 𝟓 , 𝟏𝟎, 𝟏𝟓, 𝟐𝟎,….
Fibonacci Numbers
Fibonacci numbers form an interesting sequence of numbers in which each
element is obtained by adding two preceding elements and the sequence starts
with 0 and 1. Sequence is defined as, F0 = 0 and F1 = 1 and Fn = Fn-1 + Fn-2
Probability
Sample Space: In probability, the set of all possible outcomes is called the Sample
Space. We will use S to represent the sample space. In terms of the language of sets, a
sample space is a universal set and an outcome is an element of the universal set.
𝑛
𝑃 𝐴 = lim
𝑚→∞ 𝑚
Probability
Example 1: One card is drawn from a deck of 52 cards, well-shuffled.
Calculate the probability that the card will (i) be a king, (ii) not be a
king.
Well-shuffling ensures equally likely outcomes.
(i) There are 4 kings in a deck.
Let E be the event the card drawn is ace.
The number of favourable outcomes to the event E = 4
The number of possible outcomes = 52
Therefore, P(E) = 4/52 = 1/13
Let P(C)= p; since B is twice as likely to win as C, P(B) = 2p; and since A is
twice as likely to win as B,
P(A)= 2P(B)= 2(2p) = 4p. Now the sum of the probabilities must be 1;
hence
1
p+2p+4p = 1 or 7p = 1 or p = 7
𝟒 𝟐 𝟏
Accordingly, P(A) = 4p = 𝟕, P(B) = 2p = 𝟕, P(C) = p = 𝟕
Probability
Example 3: A coin is tossed, and a die is rolled. What is the probability that
the coin shows the head and the die shows 3?
When a coin is tossed, the outcome is either a head or a tail. Similarly, when
a die is rolled, the outcomes will be 1, 2, 3, 4, 5, 6.
The probability to get the head = ½
The probability of getting 3 = 1/6
Hence, the required probability = (1/2) (1/6) = 1/12.
Random Numbers
A random number is a number chosen as if by chance from some specified
distribution. Such numbers are independent, having no correlations between
successive numbers.
Impossible to know the next value using any program. However, we can
generate random numbers using some function.
pseudo-random number
Random Numbers
A pseudo-random number is a number generated with the help of a deterministic
algorithm, however, it shows a behavior as if it were random.
A random number generator will have to comply with the following criteria
x1 x2 x3 .. xn
𝒙𝒊 1 2 3 4 5 6
𝑓(𝑥𝑖 ) 1 3 5 7 9 11
36 36 36 36 36 36
𝒚𝒊 2 3 4 5 6 7 8 9 10 11 12
g(𝑦𝑖 ) 1 2 3 4 5 6 5 4 3 2 1
36 36 36 36 36 36 36 36 36 36 36
The charts that follow graphically describe the above distributions: Observe
that the vertical lines drawn above the numbers on the horizontal axis are
proportional to their probabilities
Random Variable
Some of the important theorems regarding the mean of random
variables.
𝝈𝒙 = 𝑽𝒂𝒓(𝑿)
Random Variable
The theorem below gives us an alternate and sometimes more useful formula
for calculating the variance of the random variable X.
𝑛
Theorem 3: 𝑉𝑎𝑟 𝑋 = 𝑥𝑖2 𝑓 𝑥𝑖 − 𝜇2 = 𝐸(𝑋 2 ) − 𝜇2
𝑖=1
Proof: 𝑥𝑖 𝑓 𝑥𝑖 = 𝜇 and 𝑓(𝑥𝑖 ) = 1
𝒚𝒊 2 3 4 5 6 7 8 9 10 11 12
g(𝑦𝑖 ) 1 2 3 4 5 6 5 4 3 2 1
36 36 36 36 36 36 36 36 36 36 36
Random Variable
The mean was 7.0 for random variable Y.
¯
Central Tendencies and Dispersion
Measures that indicate the approximate center of a distribution are called
measures of central tendency. Measures that describe the spread of the data
are measures of dispersion. These measures include the mean, median, mode,
range, upper and lower quartiles, variance, and standard deviation.
𝑛
1 𝑎1 + 𝑎2 + 𝑎3 … … . . +𝑎𝑛
𝐴= 𝑎𝑖 = Arithmetic mean
𝑛 𝑛
𝑖=1
Example: Consider the data set: 17, 10, 9, 14, 13, 17, 12, 20, 14
𝑎𝑖 17 + 10 + 9 + 14 + 13 + 17 + 12 + 20 + 14 126
𝑚𝑒𝑎𝑛 = = = = 14
𝑛 9 9
The mean of the data set is 14.
Central Tendencies and Dispersion
Weighted arithmetic mean: When some quantities are more important than the
others and do not contribute equally to the final result thus multiplying them to a
coefficient is called weighted average
𝑛
𝑖=1 𝑤𝑖 𝑥𝑖
𝐴= 𝑛
𝑖=1 𝑤𝑖
Real-life Example: For appointing a person for a job, the interviewer looks at
his personality, working capabilities, educational qualifications, and team
working skills. Based on the job profile, these criteria are given different levels
of importance(weights) and then the final selection is done.
Central Tendencies and Dispersion
Numerical Problem: The table below presents the weights of different decision
features of an automobile. With the help of this information, we need to calculate
the weighted average.
Central Tendencies and Dispersion
Median: The median of a set of data is the “middle element” when the data is
arranged in ascending order.
1, 3, 6, 6, 6, 6, 7, 8, 12, 15, 17
Q3 = 14, 16, 16, 19, 24. The médian value for the upper half is 16. Q3 = 16
Central Tendencies and Dispersion
Variance: It is a measurement of the spread between numbers in any particular
data set.
Standard deviation: It measures the dispersion of a data set relative to its mean.
¯
Home work: In the case of the sample, we have used n-1 in the denominator
than n. Explain the reason behind it.
Frequency Distribution
Probability density function: It is a function that provides the relative
likelihood of the random variable at that given point.
The uniform distribution (continuous) is one
Continuous uniform of the simplest probability distributions in
distribution statistics. It is a continuous distribution,
which means that it takes values within a
specified range, e.g. between 0 and 1.
1
𝑓 𝑥 = 𝑏 − 𝑎 𝑖𝑓 𝑎 ≤ 𝑥 ≤ 𝑏
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
The expected value of a uniform The variance of a uniform distribution
distribution is: is:
𝑏 𝑏
𝑥 𝑉𝑎𝑟 𝑋 = 𝐸 𝑋 2 − 𝐸 2 𝑋
𝐸 𝑋 = 𝑥𝑓 𝑥 𝑑𝑥 = 𝑑𝑥 𝑏 2
𝑎 𝑎 (𝑏 − 𝑎) 𝑥2 𝑎+𝑏 (𝑏 − 𝑎)2
= 𝑑𝑥 − =
𝑎+𝑏 𝑎 𝑏 − 𝑎 2 12
=
2
Frequency Distribution
Exponential Distribution: In probability theory and statistics, the exponential
distribution is a continuous probability distribution. The continuous random
variable, say X is said to have an exponential distribution, if it has the following
probability density function:
λ𝑒 −λ𝑥 𝑓𝑜𝑟 𝑥 > 0
𝑓 𝑥 =
0 𝑓𝑜𝑟 𝑥 ≤ 0
1
𝑀𝑒𝑎𝑛 =
λ
1
𝜎2 = 2
λ
Exponential distribution
Frequency Distribution
Binomial distribution: We consider repeated and independent trials of an
experiment with two outcomes; we call one of the outcomes success and the
other outcome failure. Let p be the probability of success, so that q = 1-p is the
probability of failure. If we are interested in the number of successes and not in
the order in which they occur, then we say.
The probability of exactly k successes in n repeated trials is denoted and given
by 𝑛 𝑘 𝑛−𝑘 𝑛
𝑏 𝑘; 𝑛, 𝑝 = 𝑝 𝑞 Here is the binomial coefficient.
𝑘 𝑘
Example: A fair coin is tossed 6 times or, equivalently, six fair coins are tossed;
1
call heads a success. Then n = 6 and p = q = 2.
(i) The probability that exactly two heads occur (i.e. k = 2) is
1 6 1 2 1 4 15
𝑏 2; 6, = ( ) ( ) =
2 2 2 2 64
Frequency Distribution
(ii) The probability of getting at least four heads (i.e. k = 4, 6, 1/2) is
1 1
(iii) The probability of no heads (i.e. all failures) is q6 = (2)6 = 64, and so the
1 63
probability of at least one head is 1-q6 = 1-63 = 64
Frequency Distribution
If we say, n and p as constant, then the above function P(k) = b(k,n,p) is a
discrete probability distribution.
Geometric distribution
•A phenomenon that has a series of
trials
•Each trial has only two possible
outcomes – either success or failure
•The probability of success is
the same for each trial
Bell curve
when x= μ
Frequency Distribution
The properties of normal distribution
If μ = 0 and σ =1 then
1 1
−2𝑥 2
𝑓 𝑥 = 𝑒
2𝜋
Frequency Distribution
Frequency Distribution
Central Limit Theorem: The normal approximation to the binomial
distribution:
The binomial distribution P(k) = b(k;n,p) is closely approximated by the
normal distribution providing n is large and neither p nor q is close to zero.
λ𝑘 𝑒 −λ
𝑝 𝑘; λ =
𝑘!
Random Errors: Random errors are errors that fluctuate from one
measurement to the next. They yield results distributed about some mean
value. They can occur for a variety of reasons, namely, lack of sensitivity,
noise, unpredictable fluctuations, and human errors.
Maximum Error: The maximum and minimum values of the data set,
𝑥𝑚𝑎𝑥 𝑎𝑛𝑑 𝑥𝑚𝑖𝑛. Then the maximum error is
𝑥𝑚𝑎𝑥 − 𝑥𝑚𝑖𝑛
∆𝑥𝑚𝑎𝑥 =
2
And, virtually no measurements should ever fall outside 𝜇 ± ∆𝑥𝑚𝑎𝑥
𝑥3 𝑥5
sin 𝑥 = 𝑥 − + 5! …………………….(approximate up to n = 2)
3!
𝜋 𝜋
𝑥 = 2 , 𝑡ℎ𝑒𝑛, sin = 1 (𝑤ℎ𝑖𝑐ℎ 𝑖𝑠 𝑡𝑟𝑢𝑒/𝑎𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑣𝑎𝑙𝑢𝑒)
2
𝜋3 𝜋5
𝜋 2 2
Now , due to approximation, the value will be = 2 − + = 1.004
3! 5!
1
= 0.3333333333
3
The difference between an approximation of a number used in
computation and its correct (true) value is called round-off error.
𝑦 = 3𝑥 2 − 5
3𝑥 2 = 𝑦 + 5 The square root function will be defined for non-
2
𝑦+5 negative values. This is possible when y is greater
𝑥 =
3 than y ≥ -5. Hence, the range of f(x) is [-5, ∞].
𝒚+𝟓
𝒙=
𝟑
Simple Functions
Homework: Find the domain and range of the functions
𝟏
𝒚= −𝟓
𝒙−𝟑
𝒙𝟐 − 𝟑𝒙 − 𝟒
𝒚=
𝒙+𝟏
Derivative
The derivative of a function in the calculus of variable standards the
sensitivity to change the output value with respect to a change in its input
value. The derivative of a function f(x) is defined as
𝑑 𝑑𝑓(𝑥) 𝑑𝑔(𝑥)
(4) Sum Rule: 𝑓 𝑥 + 𝑔(𝑥) = +
𝑑𝑥 𝑑𝑥 𝑑𝑥
𝑑 𝑑𝑓(𝑥) 𝑑𝑔 𝑥
(5) Difference Rule: 𝑓 𝑥 − 𝑔(𝑥) = −
𝑑𝑥 𝑑𝑥 𝑑𝑥
𝑑 𝑑𝑔 𝑥 𝑑𝑓(𝑥)
(6) Product rule: 𝑓 𝑥 𝑔(𝑥) = 𝑓(𝑥) + 𝑔(𝑥)
𝑑𝑥 𝑑𝑥 𝑑𝑥
𝑑𝑔 𝑥 𝑑𝑓(𝑥)
𝑑 𝑓 𝑥 𝑓 𝑥 𝑑𝑥
−𝑔(𝑥) 𝑑𝑥
(7) Quotient rule: =
𝑑𝑥 𝑔 𝑥 𝑔(𝑥)2
Derivative
The derivatives of
trigonometric functions Higher-order Derivatives
We can find the successive derivatives of
a function and obtain the higher-order
derivatives.
If y is a function, then its first derivative
is dy/dx.
Further, we can find the second-order partial derivatives also like ∂2f/∂x2,
∂2f/∂y2.
Derivative
Problem 1: Prove the following rules of derivative: (1) power rule, (2) product
rule, and (3) quotient rule
1
2
𝑥𝑑𝑥 = ≈ 0.6667
0 3
Hence, integration of any function
means: the estimation of the area
under that curve.
Integral
There are two types of integrals, (1) definite integral and (2) indefinite
integral.
Definite Integral: An integral that contains the upper and lower limits then
it is a definite integral. Riemann Integral is the other name of the Definite
Integral.
𝑏
𝑓 𝑥 𝑑𝑥
𝑎
Indefinite Integrals: They are defined without upper and lower limits, and
are represented as follows.
𝑓 𝑥 𝑑𝑥 = 𝐹 𝑥 + 𝐶
Where C is any constant and the function f(x) is called the integrand.
Integral
Some Important Integration Formulas:
1 𝑑𝑥 = 𝑥 + 𝐶 1
𝑑𝑥 = ln 𝑥 + 𝐶
𝑥
𝑎 𝑑𝑥 = 𝑎𝑥 + 𝐶
𝑒 𝑥 𝑑𝑥 = 𝑒 𝑥 + 𝐶
𝑥 𝑛+1 𝑥
𝑥 𝑛 𝑑𝑥 = + 𝐶; 𝑛 ≠ −1 𝑎
𝑛+1 𝑎 𝑥 𝑑𝑥 = + 𝐶; 𝑎 > 0, 𝑎 ≠ 1
𝑙𝑛𝑎
𝑠𝑖𝑛𝑥 𝑑𝑥 = −𝑐𝑜𝑠𝑥 + 𝐶
1
𝑑𝑥 = 𝑠𝑖𝑛−1 𝑥 + 𝐶
1 − 𝑥2
𝑐𝑜𝑠𝑥 𝑑𝑥 = 𝑠𝑖𝑛𝑥 + 𝐶 1
𝑑𝑥 = 𝑡𝑎𝑛−1 𝑥 + 𝐶
1 + 𝑥2
𝑠𝑒𝑐 2 𝑥 𝑑𝑥 = 𝑡𝑎𝑛𝑥 + 𝐶
Integral
Home work: Integrate the following function.
𝑥 2 − 1 4 + 3𝑥 𝑑𝑥
𝑑𝑥
1 + tan(𝑥)
𝑠𝑖𝑛3 𝑥 𝑐𝑜𝑠 2 𝑥 𝑑𝑥
Numerical differentiation
f (x+ h)− f (x) Forward difference
f ' (x )= lim
h →0 h
f (x)− f (x− h)
f ' (x )= lim Backward difference
h →0 h
-0.88956192323
f’_direct(pi) = -sin(pi/3) = 30.5/2 = -0.86602540378
b) 0.01
c) 0.001
d) 0.0001
1 10
1 10
∫ f (x) d x = w ∗ ∑ f (x i )=w∗((f (a)+f (a+w ))/2+(f (a+w )+f (a+2 w))/2+(f (a+2 w)+f (a+3 w))/2+...)
a i= 1
n−1
x = np.linspace(-2, 2, 100)
y = x ** 2
x = np.linspace(-6, 6, 50)
y = np.cos(x)
plt.plot(x, y, 'b', label ='cos(x)')
plt.xlabel('x-axis')
plt.ylabel('y-axis')
Functions - Python
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 1, 1000)
y = np.exp(x)
plt.plot(x, y, 'b', label ='exp(x)')
plt.xlabel('x-axis')
plt.ylabel('y-axis')
Functions - Python
import matplotlib.pyplot as plt
import numpy as np
data1 = [1, 3, 4, 5, 7, 9, 2]
x = statistics.mean(data1)
print("Mean is :", x)
Central tendencies - Python
import numpy as np
import statistics
from statistics import mean
data1 = [1, 3, 4, 5, 7, 9, 2]
data1 = [1, 3, 4, 5, 7, 9, 2]
set1 =[1, 2, 3, 3, 4, 4, 4, 5, 5, 6]
sample = [1, 2, 3, 4, 5]
l=[]
for i in range(10):
l.append(rand())
print(l)
plt.plot(l)
plt.show()
Random Numbers
Binomial Distribution: We consider repeated and independent trials of an
experiment with two outcomes; we call one of the outcomes success and the
other outcome failure. Let p be the probability of success, so that q = 1-p is
the probability of failure. If we are interested in the number of successes and
not in the order in which they occur, then the following theorem applies
n
Random Numbers
Central Limit Theorem: The central limit theorem states that whenever a
random sample of size n is taken from any distribution with mean and variance,
then the sample mean will be approximately a normal distribution with mean
and variance. The larger the value of the sample size, the better the
approximation of the normal.
n
Central limit theorem
Let X1, X2, X3, .........., Xn are the n random samples with mean μ and variance σ 2
∑ Xi−μ
Z n= i= 1
√n σ2
tends to be normal.