# Intelligent Systems II — all public teaching content

Exact source JSON: https://deep-learning-study-room.vercel.app/exports/is2.json


---

## M2 · Start here: your IS2 M2 study order

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/m2-start--how-to-use/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/m2-start/how-to-use

M2 scope and pattern confirmed in your 8 October class update.

Learn **Fuzzy Logic → Genetic Algorithms → Particle Swarm Optimization**, with the required maths explained just before it is used. The answers stay below the questions.

## The confirmed 10-mark pattern

| Question | Marks | Attempt rule | Prepare for |
| --- | --- | --- | --- |
| Q1(a) | 2 | Compulsory | A short numerical or theory question |
| Q1(b) | 2 | Compulsory | A short numerical or theory question, including swarm intelligence |
| Q2, Q3, Q4 | 3 each | Attempt any two | GA, PSO and fuzzy logic; the mix can include theory and numericals |

Your class update specifically highlights fuzzy union/intersection/difference/complement, GA with supplied operators, two-particle PSO minimisation, fuzzy rules, architecture, advantages and disadvantages. Work GA and PSO through **iteration 2**. The mock question numbering is a practice arrangement; the actual exam can rearrange the topics.

## Read in this order

1. [Essential maths](https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--reading-formulas/): candidate versus score, fractions, min/max, binary and two-coordinate movement.
2. [Fuzzy logic](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--membership-meaning/): membership meaning → graphs → set operations → rule base → Mamdani → defuzzification. Then the complete 32°C / 7-person fan example.
3. [Genetic algorithms](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--meaning/): terms → encoding → selection → crossover/mutation → complete two-generation solutions.
4. [PSO](https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--meaning/): position, velocity and memory → single updates → two particles → two dimensions → class photograph example.
5. [Three 10-mark mocks](https://deep-learning-study-room.vercel.app/read/is2/m2/index/mocks/), followed by [last-day revision](https://deep-learning-study-room.vercel.app/read/is2/m2/index/revision/).

Fuzzy relation matrices are kept as additional Unit 2 practice after the three main topics. ACO and GA-for-TSP are in the TEE route; they are not mixed into this M2 reading path.

## How to write a numerical

**Full question → Given → To find → Formula and why → numbered calculation steps → final answer.** Read one worked example, then write the same calculation in your notebook. Keep its intermediate table: in GA and PSO that table is the input to the next iteration.

## If the exam is tomorrow

First complete fuzzy operations, triangle membership and the Mamdani architecture. Next finish one GA two-generation solution and one PSO two-iteration solution. Then do the remaining variants, theory answers and mocks. Use the formula page for revision after learning the symbols; it is not a substitute for the worked explanations.

**Yaad rakho:** Fuzzy = degree aur rules. GA = select, cross, mutate. PSO = velocity, position, best memories.

---

## M2 · Symbols, brackets and iteration labels: how to read a formula

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--reading-formulas/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/reading-formulas

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Read a formula as a calculation instruction

A **variable** is a name for a number that can change. In **f(x)=x²+1**, x is the input, f is the name of the scoring rule, and f(x) is its result. An **equation** says that the expressions on both sides have the same value. A formula tells you how to calculate a quantity.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| x² | x multiplied by itself | 3² = 3 × 3 = 9 |
| 2x or 2(x) | 2 multiplied by x | For x=3: 2x=6, while x²=9 |
| f(3) | Apply the rule named f to input 3 | If f(x)=x²+1, then f(3)=10 |
| x₁ and x₂ | First and second named entries; the small lower number is a label | If a position is (3,7), x₁=3 and x₂=7 |
| x at time t | A version of x at a particular iteration | Old x=3; after a move x=2. The time label is not squaring. |
| = and ≈ | Exactly equal; approximately equal after rounding | 1/3 ≈ 0.333333 |
| ∈ and { } | Belongs to; a collection of values | x ∈ {2,5} means x may be 2 or 5 |

**Evaluate f(x)=2x²+1 at x=−3.** [2 marks · Worked example]

#### Given

The rule is f(x)=2x²+1. The supplied input is x=−3.

#### To find

f(−3): the output of this rule for input −3.

#### Formula and why it applies



$$
f(x)=2x^2+1
$$



The question supplies the rule. Replace x by −3, square that whole input, multiply the square by 2, and add 1. Parentheses keep the negative input together.

#### Solution

##### Step 1. Substitute with parentheses



$$
f(-3)=2(-3)^2+1
$$



##### Step 2. Do the square first



$$
(-3)^2=(-3)\times(-3)=9
$$



##### Step 3. Multiply by 2



$$
2\times9=18
$$



##### Step 4. Add 1



$$
f(-3)=18+1=19
$$



**Final answer.** f(−3)=19.

**Evaluate g(x)=(x−2)/4 at x=10.** [2 marks · Worked example]

#### Given

The rule is g(x)=(x−2)/4. The supplied input is x=10.

#### To find

g(10): the output of this rule for input 10.

#### Formula and why it applies



$$
g(x)=\frac{x-2}{4}
$$



The fraction bar groups the numerator x−2. Subtract 2 from the input first, then divide the entire difference by 4.

#### Solution

##### Step 1. Replace the input



$$
g(10)=\frac{10-2}{4}
$$



##### Step 2. Finish the numerator



$$
10-2=8
$$



##### Step 3. Divide



$$
g(10)=8/4=2
$$



**Final answer.** g(10)=2.

**At iteration 0, x=4. The rule is new x = old x − 1. Find x after two iterations.** [2 marks · Worked example]

#### Given

Initial value x=4 at iteration 0. Every update subtracts 1 from the current value. Perform two updates.

#### To find

The value after update 1 and after update 2.

#### Formula and why it applies



$$
x^{(t+1)}=x^{(t)}-1
$$



t labels the current iteration, and t+1 labels the next. The parenthesised upper label records the step; it is not a power. Apply the supplied rule once, then use that new answer as the input to the second update.

#### Solution

##### Step 1. Iteration 1 uses the initial value



$$
x^{(1)}=4-1=3
$$



##### Step 2. Iteration 2 uses the updated value



$$
x^{(2)}=3-1=2
$$



##### Step 3. Distinguish a label from a power

x at iteration 2 is 2. Squaring the initial value would give 4²=16; that is a different operation.

**Final answer.** After update 1: x=3. After update 2: x=2. The sequence is 4 → 3 → 2.

**Yaad rakho:** Symbol sirf naam hai. Pehle bolo kaunsa number chahiye, phir uski jagah value likho.

---

## M2 · Position, score, minimisation and maximisation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--objective/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/objective

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## What are we trying to do in IS2?

**An intelligent system** uses information and a decision procedure to choose an output or an action. In M2, you study three different procedures.

| Topic | Input | What the procedure does | Output |
| --- | --- | --- | --- |
| Fuzzy logic | Temperature and occupancy | Applies rules such as IF hot AND crowded THEN fast | A fan-speed setting |
| Genetic algorithm (GA) | A population of candidate answers | Selects, combines and changes candidate answers | A good solution and its fitness |
| Particle swarm optimization (PSO) | Positions and velocities of particles | Moves candidate answers using individual and shared experience | A best position and its objective value |

## Candidate answer and score are different

An **objective function** is the calculation used to score an answer. In **minimisation**, a smaller score is better; in **maximisation**, a larger score is better. The letter **x** names a candidate answer. The notation **f(x)**, read “f of x”, means its score. Parentheses here do not mean f multiplied by x.

**For the minimisation problem 

$$
f(x)=(x-3)^2
$$

, find the score at 

$$
x=2
$$

.** [2 marks · Practice]

#### Given



$$
x=2
$$

, 

$$
f(x)=(x-3)^2
$$



#### To find

The objective value f(x).

#### Formula and why it applies

Replace x by the supplied number. Square means multiply the result by itself.

#### Solution

##### Step 1. Subtract 3



$$
x-3=2-3=-1
$$



##### Step 2. Square the difference



$$
f(2)=(-1)^2=(-1)\times(-1)=1
$$



**Final answer.** The position is x = 2; its score is 1. These are two different numbers.

**For the minimisation problem 

$$
f(x)=(x-3)^2
$$

, find the score at 

$$
x=5
$$

.** [2 marks · Practice]

#### Given



$$
x=5
$$

, 

$$
f(x)=(x-3)^2
$$



#### To find

The objective value f(x).

#### Formula and why it applies

Replace x by the supplied number. Square means multiply the result by itself.

#### Solution

##### Step 1. Subtract 3



$$
x-3=5-3=2
$$



##### Step 2. Square the difference



$$
f(5)=(2)^2=(2)\times(2)=4
$$



**Final answer.** The position is x = 5; its score is 4. These are two different numbers.

**For the minimisation problem 

$$
f(x)=(x-3)^2
$$

, find the score at 

$$
x=-1
$$

.** [2 marks · Practice]

#### Given



$$
x=-1
$$

, 

$$
f(x)=(x-3)^2
$$



#### To find

The objective value f(x).

#### Formula and why it applies

Replace x by the supplied number. Square means multiply the result by itself.

#### Solution

##### Step 1. Subtract 3



$$
x-3=(-1)-3=-4
$$



##### Step 2. Square the difference



$$
f(-1)=(-4)^2=(-4)\times(-4)=16
$$



**Final answer.** The position is x = -1; its score is 16. These are two different numbers.

Comparing these candidates: x = 2 has score 1, x = 5 has score 4, and x = −1 has score 16. For minimisation, x = 2 is the best of these three. A negative position is allowed unless the question gives a restriction; a low score, not a low coordinate, decides the winner.

**Yaad rakho:** x = answer ki jagah; f(x) = us answer ka score. Min mein chhota score jeetega.

---

## M2 · Fractions, brackets, minimum and maximum

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--arithmetic/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/arithmetic

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Fractions, min and max

A fraction means division: the top number is the **numerator**, and the bottom is the **denominator**. Calculate each bracket first. **min** selects the smallest listed number; **max** selects the largest. Neither word means addition.

**Evaluate 

$$
\frac{32-25}{35-25}
$$

.** [2 marks · Practice]

#### Given

Top: 32 − 25; bottom: 35 − 25.

#### To find

The quotient.

#### Formula and why it applies

Subtract separately in the numerator and denominator, then divide.

#### Solution

##### Step 1. Calculate the numerator



$$
32-25=7
$$



##### Step 2. Calculate the denominator



$$
35-25=10
$$



##### Step 3. Divide



$$
\frac{7}{10}=0.7
$$



**Final answer.** 0.7

**Evaluate 

$$
\frac{35-32}{35-25}
$$

.** [2 marks · Practice]

#### Given

Top: 35 − 32; bottom: 35 − 25.

#### To find

The quotient.

#### Formula and why it applies

Subtract separately in the numerator and denominator, then divide.

#### Solution

##### Step 1. Calculate the numerator



$$
35-32=3
$$



##### Step 2. Calculate the denominator



$$
35-25=10
$$



##### Step 3. Divide



$$
\frac{3}{10}=0.3
$$



**Final answer.** 0.3

**Evaluate 

$$
\frac{7-6}{8-6}
$$

.** [2 marks · Practice]

#### Given

Top: 7 − 6; bottom: 8 − 6.

#### To find

The quotient.

#### Formula and why it applies

Subtract separately in the numerator and denominator, then divide.

#### Solution

##### Step 1. Calculate the numerator



$$
7-6=1
$$



##### Step 2. Calculate the denominator



$$
8-6=2
$$



##### Step 3. Divide



$$
\frac{1}{2}=0.5
$$



**Final answer.** 0.5

**Find 

$$
\max\{\min(0.7,0.2),\min(0.4,0.8)\}
$$

.** [2 marks · Practice]

#### Given

Two inner min operations followed by one outer max.

#### To find

One number.

#### Formula and why it applies

Work from the innermost brackets outward. This exact pattern occurs in fuzzy relation composition.

#### Solution

##### Step 1. First pair



$$
\min(0.7,0.2)=0.2
$$



##### Step 2. Second pair



$$
\min(0.4,0.8)=0.4
$$



##### Step 3. Choose the larger result



$$
\max(0.2,0.4)=0.4
$$



**Final answer.** 0.4.

**Yaad rakho:** Pehle bracket, phir divide. AND ka min; OR ka max.

---

## M2 · Percentages, probabilities and cumulative intervals

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--probability/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/probability

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Probability is a share of a specified total

A probability is a number between 0 and 1. In these finite examples, 0 means an event has no probability mass and 1 means it occurs with certainty under the model. In a continuous distribution, a single exact value can have probability zero without being logically impossible; probabilities then describe intervals. 25% means 25 out of 100, so it equals 25÷100=0.25. For equally likely outcomes, probability is favourable outcomes divided by all possible outcomes. For GA selection, it is the candidate’s weight divided by the sum of weights.



$$
P(\text{event})=\frac{\text{favourable count}}{\text{total count}}
$$



**A bag contains 3 red balls and 7 blue balls. One ball is drawn uniformly at random. Find the probability of red and of blue.** [2 marks · Worked example]

#### Given

Red=3; blue=7. Each ball is equally likely.

#### To find

Both probabilities and their percentages.

#### Formula and why it applies



$$
P(\text{colour})=\frac{\text{balls of that colour}}{\text{all balls}}
$$



All balls are equally likely, so counting them gives probability. The denominator counts all balls; the numerator counts the requested colour.

#### Solution

##### Step 1. Find the total



$$
3+7=10
$$



##### Step 2. Red probability



$$
P(R)=3/10=0.3=30\%
$$



##### Step 3. Blue probability



$$
P(B)=7/10=0.7=70\%
$$



**Final answer.** Red 0.3; blue 0.7. Their sum is 1.

## From weights to probabilities to cumulative probabilities

A **weight** need not itself be a probability. Weights 1, 2, 3, 4 add to 10. Dividing every weight by 10 makes their total 1: this is **normalisation**. **Cumulative** means “total accumulated so far”. It turns separate shares into boundaries along a line from 0 to 1.

**Candidates A, B, C and D have weights 1, 2, 3 and 4. Find probabilities and cumulative probabilities. Which candidate is selected by random draw r=0.55?** [2 marks · Worked example]

#### Given

Weights [1,2,3,4], draw 0.55. Use intervals including their lower endpoint and excluding their upper endpoint.

#### To find

Four probabilities, their running totals and the selected candidate.

#### Formula and why it applies



$$
P_i=F_i/(F_A+F_B+F_C+F_D)
$$



F is weight. P is its share. Add P values in row order for the cumulative boundary.

#### Solution

##### Step 1. Add all weights



$$
1+2+3+4=10
$$



##### Step 2. Divide each weight by that same total

| Candidate | Division | Probability |
| --- | --- | --- |
| A | 1÷10 | 0.1 |
| B | 2÷10 | 0.2 |
| C | 3÷10 | 0.3 |
| D | 4÷10 | 0.4 |

##### Step 3. Build the running totals

| Candidate | Running addition | Interval |
| --- | --- | --- |
| A | 0+0.1=0.1 | 0 ≤ r < 0.1 |
| B | 0.1+0.2=0.3 | 0.1 ≤ r < 0.3 |
| C | 0.3+0.3=0.6 | 0.3 ≤ r < 0.6 |
| D | 0.6+0.4=1 | 0.6 ≤ r ≤ 1 |

##### Step 4. Locate the draw

0.55 is at least 0.3 and less than 0.6. It lies in C’s interval. The draw is not compared with C’s weight 3.

**Final answer.** Candidate C is selected.

Swipe across the diagram to read its labels ↔

![Each interval width equals its probability. Running totals mark the ends.](https://deep-learning-study-room.vercel.app/is2/fig/depth_roulette.12804497d2.svg)

Diagram: Each interval width equals its probability. Running totals mark the ends.. Labels: Probabilities become intervals on the same 0–1 line | A | 0.1 | 0 | B | 0.2 | 0.1 | C | 0.3 | 0.3 | D | 0.4 | 0.6 | 1 | r = 0.55 selects C

Each interval width equals its probability. Running totals mark the ends.

**Two unnormalised class scores are 0.12 and 0.08. Convert them to probabilities.** [2 marks · Worked example]

#### Given

Scores A=0.12 and B=0.08; they describe the only two alternatives.

#### To find

Normalised probabilities.

#### Formula and why it applies

Divide each score by the sum, preserving their ratio.

#### Solution

##### Step 1. Sum the scores



$$
0.12+0.08=0.20
$$



##### Step 2. Normalise A



$$
P(A)=0.12/0.20=0.6
$$



##### Step 3. Normalise B



$$
P(B)=0.08/0.20=0.4
$$



**Final answer.** A=0.6 and B=0.4. The original score 0.12 was not the final probability.

**Yaad rakho:** Probability = apna hissa ÷ sabka total. Cumulative = ab tak ke saare hisse jodna.

---

## M2 · Binary from the beginning: positions, place values and bits

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--binary/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/binary

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## 1. Position means the digit's place

**A position is simply a place occupied by one digit in a number.** A digit is the symbol written there. The **place value** tells us how much one unit in that position is worth.

Start with an ordinary number you already know: **23**. Its two digits are 2 and 3. They do not contribute the same kind of unit.

|  | LEFT: tens place | RIGHT: ones place |
| --- | --- | --- |
| Value of this place | 10 | 1 |
| Digit written here | 2 | 3 |
| Contribution | 2 × 10 = 20 | 3 × 1 = 3 |



$$
23=(2\times 10)+(3\times 1)=20+3
$$



The **2** means two tens because of where it sits. In **32**, the same digit 2 sits on the right and means only two ones. Changing a digit’s position can change its contribution.

**Yaad rakho:** Position = digit ki jagah. Place value = us jagah par likhe ONE ki keemat. 23 mein 2 ka contribution 20 hai, kyunki woh tens ki jagah par hai.

## 2. Binary changes the size of the groups

Our ordinary number system is **decimal**: it has ten possible digits, 0 to 9. Its places are ones, tens, hundreds, and so on. Moving one place left multiplies the place value by 10.

**Binary** has only two possible digits: **0 and 1**. One binary digit is called a **bit**. Therefore, a **4-bit number means four digit boxes**, each holding either 0 or 1.

In binary, grouping happens in **twos**. The rightmost box counts single units. After one single, a second single cannot be written as digit “2”, because binary has no digit 2. Instead, the two singles become **one group of two** in the next box on the left.

**Binary 10 means one group of two and zero single units.**

It represents the ordinary number 2. Read its digits as “one-zero” when discussing binary, so you do not accidentally read it as decimal ten.

Two groups of two make **4**, so the next box to the left is the fours place. Two groups of four make **8**, so the next box is the eights place. This is why the values double.

| Ordinary number | Binary digits | Meaning |
| --- | --- | --- |
| 0 | 0 | No single units |
| 1 | 1 | One single unit |
| 2 | 10 | One two + zero ones = 2 |
| 3 | 11 | One two + one one = 3 |
| 4 | 100 | One four + zero twos + zero ones = 4 |

**Yaad rakho:** Decimal mein 10 ka group; binary mein 2 ka group. Do singles = ek pair; do pairs = ek group of four.

## 3. Build the places from the RIGHT

First draw four empty boxes. **Start with the box furthest to the right.** Give that place the value 1. Move left one box at a time, doubling the previous value.

1. **1st box from the right:** value 1.
2. **2nd box from the right:** 1 × 2 = 2.
3. **3rd box from the right:** 2 × 2 = 4.
4. **4th box from the right:** 4 × 2 = 8.

Place value: what ONE in this box is worth

4th from right**8**

3rd from right**4**

2nd from right**2**

1st from right**1**

← Double each time you move one box LEFT

Start at the RIGHT with 1. Then 1 × 2 = 2, 2 × 2 = 4, and 4 × 2 = 8.

We built the values by moving right to left: **1 → 2 → 4 → 8**. Once the boxes are on paper, reading them in the usual left-to-right direction shows **8, 4, 2, 1**. These are the same four places, viewed in the opposite direction.

**Position number is not place value.** The third box from the right has position number 3, but its place value is 4. “Third” tells you where the box is; “4” tells you what a 1 in it contributes.

If you add a fifth box on the left, its value is 8 × 2 = **16**. The rightmost place stays 1; adding a box on the left does not change the existing places.

**Yaad rakho:** Sabse RIGHT se 1 likho. LEFT jaate jaate double karo: 1, 2, 4, 8, 16. Question ke digits baad mein in boxes mein rakho.

## 4. The place value stays fixed; the digit chooses it

Keep the digit **1** the same and move it into a different place. Put 0 in every other box. Watch how its position changes the number it represents:

| Binary digits | Where the 1 sits | Decimal value |
| --- | --- | --- |
| 0001 | 1st place from the right: ones | 1 × 1 = 1 |
| 0010 | 2nd place from the right: twos | 1 × 2 = 2 |
| 0100 | 3rd place from the right: fours | 1 × 4 = 4 |
| 1000 | 4th place from the right: eights | 1 × 8 = 8 |

In all four rows, the written digit is still 1. Its **position** decides whether that 1 contributes one, two, four or eight.

Now put **1 0 1 1** in the four boxes. The values 8, 4, 2 and 1 are labels for the boxes. The written digits tell us which values to include:

- **Digit 1:** take one of this place value.
- **Digit 0:** take zero of this place value.

Place value: what ONE in this box is worth

4th from right**8**

3rd from right**4**

2nd from right**2**

1st from right**1**

Digits written in those boxes

**1**include

**0**skip

**1**include

**1**include

Each box contributes

1 × 8**8**

0 × 4**0**

1 × 2**2**

1 × 1**1**

Add the contributions: 8 + 0 + 2 + 1 = 11 in ordinary decimal notation.

The 0 above does **not** mean the place value changes from 4 to 0. The place is still worth 4 per unit; the digit says to take zero units of it. Its contribution is therefore 0 × 4 = 0.

The three 1s are the same digit, but they sit in different places. They contribute **8, 2 and 1**. Therefore, binary 1011 represents decimal 11.

**Yaad rakho:** Box ki value fixed. Andar 1 hai toh value lo; 0 hai toh skip karo. Phir li hui values jodo.

## 5. Binary to decimal: four complete examples

**Decode** means convert the binary digits into an ordinary decimal number. In exam notation, a small 2 below a number means binary; a small 10 means decimal. These small labels identify the number system. They are not multipliers.



$$
(1011)_2=(11)_{10}
$$



This line says: “one-zero-one-one in binary and eleven in decimal represent the same quantity.”

**Convert the binary number 

$$
(1011)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 1011, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Binary digit | 1 | 0 | 1 | 1 |

##### Step 2. Calculate the contribution of the 8-place

The digit is 1, so include the value of this place.



$$
1\times 8=8
$$



##### Step 3. Calculate the contribution of the 4-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 4=0
$$



##### Step 4. Calculate the contribution of the 2-place

The digit is 1, so include the value of this place.



$$
1\times 2=2
$$



##### Step 5. Calculate the contribution of the 1-place

The digit is 1, so include the value of this place.



$$
1\times 1=1
$$



##### Step 6. Add the contributions



$$
8+0+2+1=11
$$



**Final answer.** 

$$
(1011)_2=(11)_{10}
$$

.

**Convert the binary number 

$$
(0110)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 0110, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Binary digit | 0 | 1 | 1 | 0 |

##### Step 2. Calculate the contribution of the 8-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 8=0
$$



##### Step 3. Calculate the contribution of the 4-place

The digit is 1, so include the value of this place.



$$
1\times 4=4
$$



##### Step 4. Calculate the contribution of the 2-place

The digit is 1, so include the value of this place.



$$
1\times 2=2
$$



##### Step 5. Calculate the contribution of the 1-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 1=0
$$



##### Step 6. Add the contributions



$$
0+4+2+0=6
$$



**Final answer.** 

$$
(0110)_2=(6)_{10}
$$

.

**Convert the binary number 

$$
(1001)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 1001, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Binary digit | 1 | 0 | 0 | 1 |

##### Step 2. Calculate the contribution of the 8-place

The digit is 1, so include the value of this place.



$$
1\times 8=8
$$



##### Step 3. Calculate the contribution of the 4-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 4=0
$$



##### Step 4. Calculate the contribution of the 2-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 2=0
$$



##### Step 5. Calculate the contribution of the 1-place

The digit is 1, so include the value of this place.



$$
1\times 1=1
$$



##### Step 6. Add the contributions



$$
8+0+0+1=9
$$



**Final answer.** 

$$
(1001)_2=(9)_{10}
$$

.

**Convert the binary number 

$$
(10011)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 10011, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 16 | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- | --- |
| Binary digit | 1 | 0 | 0 | 1 | 1 |

##### Step 2. Calculate the contribution of the 16-place

The digit is 1, so include the value of this place.



$$
1\times 16=16
$$



##### Step 3. Calculate the contribution of the 8-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 8=0
$$



##### Step 4. Calculate the contribution of the 4-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 4=0
$$



##### Step 5. Calculate the contribution of the 2-place

The digit is 1, so include the value of this place.



$$
1\times 2=2
$$



##### Step 6. Calculate the contribution of the 1-place

The digit is 1, so include the value of this place.



$$
1\times 1=1
$$



##### Step 7. Add the contributions



$$
16+0+0+2+1=19
$$



**Final answer.** 

$$
(10011)_2=(19)_{10}
$$

.

## 6. Decimal to binary: choose each digit

**Encode** means write an ordinary number using binary digits. The direction of the task is now reversed: the number is known, and you have to choose the 0s and 1s.

For four bits, write the places 8, 4, 2, 1. Start with the largest place on the left. Use it only if it does not exceed the amount still needed. Whenever you use a place, subtract it before moving to the next one.

**Yaad rakho:** Number banana hai. Badi value se start: jitna bacha hai usmein value fit ho toh 1 aur subtract; fit nahi ho toh 0.

**Write the decimal number 6 as an unsigned 4-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 6. Required length: 4 bits, meaning exactly 4 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 4 boxes and label their values

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ |

Start with the whole number 6 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 8-place

We still need 6. Taking 8 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **6**.

##### Step 3. Choose the digit in the 4-place

We still need 6. This is at least 4, so take one 4. Write **1** in this box.



$$
\text{Remaining}=6-4=2
$$



##### Step 4. Choose the digit in the 2-place

We still need 2. This is at least 2, so take one 2. Write **1** in this box.



$$
\text{Remaining}=2-2=0
$$



##### Step 5. Choose the digit in the 1-place

We still need 0. Taking 1 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 6. Read the digits from LEFT to RIGHT

The boxes now contain **0 1 1 0**. Join them in the same order: **0110**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 7. Check by converting back



$$
0\times 8+1\times 4+1\times 2+0\times 1=6
$$



**Final answer.** 

$$
(6)_{10}=(0110)_2
$$

. The answer has 4 bits.

**Write the decimal number 11 as an unsigned 4-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 11. Required length: 4 bits, meaning exactly 4 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 4 boxes and label their values

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ |

Start with the whole number 11 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 8-place

We still need 11. This is at least 8, so take one 8. Write **1** in this box.



$$
\text{Remaining}=11-8=3
$$



##### Step 3. Choose the digit in the 4-place

We still need 3. Taking 4 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **3**.

##### Step 4. Choose the digit in the 2-place

We still need 3. This is at least 2, so take one 2. Write **1** in this box.



$$
\text{Remaining}=3-2=1
$$



##### Step 5. Choose the digit in the 1-place

We still need 1. This is at least 1, so take one 1. Write **1** in this box.



$$
\text{Remaining}=1-1=0
$$



##### Step 6. Read the digits from LEFT to RIGHT

The boxes now contain **1 0 1 1**. Join them in the same order: **1011**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 7. Check by converting back



$$
1\times 8+0\times 4+1\times 2+1\times 1=11
$$



**Final answer.** 

$$
(11)_{10}=(1011)_2
$$

. The answer has 4 bits.

**Write the decimal number 19 as an unsigned 5-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 19. Required length: 5 bits, meaning exactly 5 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 5 boxes and label their values

| Place value | 16 | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ | □ |

Start with the whole number 19 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 16-place

We still need 19. This is at least 16, so take one 16. Write **1** in this box.



$$
\text{Remaining}=19-16=3
$$



##### Step 3. Choose the digit in the 8-place

We still need 3. Taking 8 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **3**.

##### Step 4. Choose the digit in the 4-place

We still need 3. Taking 4 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **3**.

##### Step 5. Choose the digit in the 2-place

We still need 3. This is at least 2, so take one 2. Write **1** in this box.



$$
\text{Remaining}=3-2=1
$$



##### Step 6. Choose the digit in the 1-place

We still need 1. This is at least 1, so take one 1. Write **1** in this box.



$$
\text{Remaining}=1-1=0
$$



##### Step 7. Read the digits from LEFT to RIGHT

The boxes now contain **1 0 0 1 1**. Join them in the same order: **10011**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 8. Check by converting back



$$
1\times 16+0\times 8+0\times 4+1\times 2+1\times 1=19
$$



**Final answer.** 

$$
(19)_{10}=(10011)_2
$$

. The answer has 5 bits.

**Write the decimal number 0 as an unsigned 4-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 0. Required length: 4 bits, meaning exactly 4 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 4 boxes and label their values

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ |

Start with the whole number 0 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 8-place

We still need 0. Taking 8 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 3. Choose the digit in the 4-place

We still need 0. Taking 4 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 4. Choose the digit in the 2-place

We still need 0. Taking 2 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 5. Choose the digit in the 1-place

We still need 0. Taking 1 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 6. Read the digits from LEFT to RIGHT

The boxes now contain **0 0 0 0**. Join them in the same order: **0000**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 7. Check by converting back



$$
0\times 8+0\times 4+0\times 2+0\times 1=0
$$



**Final answer.** 

$$
(0)_{10}=(0000)_2
$$

. The answer has 4 bits.

## 7. A zero at the start can keep the required length

**Leading zeros** are zeros at the beginning, on the left. Binary 110 and 0110 both represent decimal 6:



$$
(110)_2=(1\times4)+(1\times2)+(0\times1)=6
$$





$$
(0110)_2=(0\times8)+(1\times4)+(1\times2)+(0\times1)=6
$$



The added leftmost place contributes zero. It changes the length from three bits to four bits, but not the value. If a GA question requires four bits, write **0110**.

This rule is specifically about zeros on the **left**. Appending a zero on the right shifts the existing digits into places worth twice as much. For example, binary 1100 is 8 + 4 = 12, not 6.

## 8. How many bits are enough?

For these GA conversions, **unsigned** means the bits represent zero or a positive whole number, with no negative sign. The smallest 4-bit value is 0000. The largest is 1111 because all four places are included.

**Find the largest unsigned integer that can be represented using 4 bits. Can decimal 19 fit in 4 bits?** [2 marks · Practice]

#### Given

Four places with values 8, 4, 2 and 1. Each digit is either 0 or 1.

#### To find

The largest possible value and whether 19 can be represented.

#### Formula and why it applies

A digit contributes the most when it is 1. Set every digit to 1 and add all the place values.

#### Solution

##### Step 1. Use all four places

The largest 4-bit string is **1111**.

##### Step 2. Add their values



$$
8+4+2+1=15
$$



##### Step 3. Compare with 19

19 is greater than 15, so four bits are insufficient. Add the 16-place on the left. Then 19 = 16 + 2 + 1, giving **10011** in five bits.

**Final answer.** The maximum is 15. Decimal 19 needs at least 5 bits.

The general rule is 

$$
\text{largest unsigned value}=2^n-1
$$

. Here n means the number of bits. The power 

$$
2^n
$$

 means multiplying n copies of 2; for four bits, 

$$
2^4=2\times2\times2\times2=16
$$

, so the maximum is 16 − 1 = 15. There are 16 different values, from 0 through 15, because zero is also one value.

| Bits | Place values from left to right | Unsigned values |
| --- | --- | --- |
| 3 | 4, 2, 1 | 0 to 7 |
| 4 | 8, 4, 2, 1 | 0 to 15 |
| 5 | 16, 8, 4, 2, 1 | 0 to 31 |

If an exam gives a number outside the capacity of the stated bit length, state that inconsistency. Do not silently cut off a digit: removing the 16-place from 10011 would change 19 into 3. Also retain any separate allowed range stated in the question.

## 9. Where this fits in a genetic algorithm

A **chromosome** is the representation of one candidate solution in a genetic algorithm. With the direct unsigned binary encoding used here, decimal 6 is represented by the four-bit chromosome **0110**.

During crossover or mutation, the algorithm changes these bits. Afterwards, **decode the resulting chromosome** to find its new value of x. Then use that x in the given objective or fitness function. The binary string, its decimal value, and its fitness score are different things.

**Yaad rakho:** Encode: number se bits. Decode: bits se number. GA mein bits badle toh x dobara decode karo, phir uska score nikalo.

---

## M2 · Vectors, coordinates, matrices and transpose from the first entry

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--coordinates/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/coordinates

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## A vector is an ordered list of numbers

A **scalar** is one number, such as 5. A **vector** is an ordered list, such as (3,7). Order matters: the first number may be horizontal position and the second vertical position. A **matrix** is a rectangular table of numbers. These words describe how numbers are arranged, not a new kind of arithmetic.

| Arrangement | Example | How to read it |
| --- | --- | --- |
| Scalar | 5 | One value |
| Row vector | [3,7] | One row, two entries |
| Column vector | 

$$
\begin{bmatrix}3\\7\end{bmatrix}
$$

 | Two rows, one entry |
| Matrix | 

$$
\begin{bmatrix}3&7\\4&2\end{bmatrix}
$$

 | Two rows, two columns |

## Rows go across; columns go down

For a matrix A, **A₂₁** means the entry in **row 2, column 1**. The first lower label is the row; the second is the column. Matrix size is written **number of rows × number of columns**. A 2×3 matrix has two rows containing three entries each.

Swipe across the diagram to read its labels ↔

![Read an entry by finding its row first and its column second.](https://deep-learning-study-room.vercel.app/is2/fig/depth_matrix.a8870f4ab6.svg)

Diagram: Read an entry by finding its row first and its column second.. Labels: Rows across. Columns down. Entry A₂₃ = 7. | Column 1 | Column 2 | Column 3 | Row 1 | 2 | 5 | 8 | Row 2 | 1 | 4 | 7 | Two rows × three columns = 2 × 3 matrix

Read an entry by finding its row first and its column second.

**Let A have first row [2,5,8] and second row [1,4,7]. State its size and find A₂₃ and A₁₂.** [2 marks · Worked example]

#### Given



$$
A=\begin{bmatrix}2&5&8\\1&4&7\end{bmatrix}
$$



#### To find

Matrix dimensions and two entries.

#### Formula and why it applies

Read the lower labels in row–column order.

#### Solution

##### Step 1. Count the arrangement

There are 2 horizontal rows and 3 vertical columns. Size=2×3.

##### Step 2. Find A₂₃

Row 2 is [1,4,7]. Its third entry is 7.

##### Step 3. Find A₁₂

Row 1 is [2,5,8]. Its second entry is 5.

**Final answer.** Size 2×3; A₂₃=7; A₁₂=5.

**A particle has position x=(3,7), velocity v=(−1,2), and best position p=(1,8). Find p−x, half of that difference, and x+v.** [2 marks · Worked example]

#### Given

Position x=(3,7); velocity v=(−1,2); personal-best position p=(1,8). First and second coordinates stay in the same order.

#### To find

The difference p−x, the scaled difference 0.5(p−x), and the updated position x+v.

#### Formula and why it applies

Match first with first and second with second. A scalar multiplies every coordinate.

#### Solution

##### Step 1. Subtract corresponding coordinates



$$
p-x=(1-3,\;8-7)=(-2,1)
$$



##### Step 2. Multiply both coordinates by 0.5



$$
0.5(p-x)=(0.5(-2),\;0.5(1))=(-1,0.5)
$$



##### Step 3. Add the velocity to the position



$$
x+v=(3+(-1),\;7+2)=(2,9)
$$



**Final answer.** Difference (−2,1); scaled difference (−1,0.5); new position (2,9).

## Transpose exchanges rows and columns

The superscript **T** in Aᵀ means **transpose**. It does not mean multiply or raise A to a power. Row 1 of A becomes column 1 of Aᵀ; row 2 becomes column 2. An m×n arrangement becomes n×m.

**Find the transpose of A = [[2,5,8],[1,4,7]].** [2 marks · Worked example]

#### Given



$$
A=\begin{bmatrix}2&5&8\\1&4&7\end{bmatrix}
$$



#### To find

Aᵀ.

#### Formula and why it applies

Turn each old row into a new column, keeping its order.

#### Solution

##### Step 1. Move the first row

[2,5,8] becomes the first column from top to bottom.

##### Step 2. Move the second row

[1,4,7] becomes the second column from top to bottom.

##### Step 3. Write the new arrangement



$$
A^T=\begin{bmatrix}2&1\\5&4\\8&7\end{bmatrix}
$$



**Final answer.** Aᵀ has 3 rows and 2 columns. No number changed.

**Calculate the dot product of [2,3] and [4,5].** [2 marks · Worked example]

#### Given

First vector a=[2,3]; second vector b=[4,5]. Each has two entries.

#### To find

The dot product a·b, a single number obtained by adding the two matching products.

#### Formula and why it applies



$$
a\cdot b=a_1b_1+a_2b_2
$$



Multiply corresponding entries, then add the products. Markov matrix multiplication later repeats this for each destination column.

#### Solution

##### Step 1. First product



$$
2\times4=8
$$



##### Step 2. Second product



$$
3\times5=15
$$



##### Step 3. Add



$$
8+15=23
$$



**Final answer.** The dot product is 23. It is not the vector [8,15].

**Yaad rakho:** Vector = order wali list. Matrix = rows-columns ka table. Entry padhte waqt pehle row, phir column.

---

## M2 · Graph axes, intervals and the fractions inside membership functions

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--graphs/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/graphs

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Read a graph one input at a time

The **horizontal axis** runs left to right and shows input x. The **vertical axis** runs bottom to top and shows the output. A point (3,0.4) means: input 3 gives output 0.4. In a membership graph, the vertical output is a degree between 0 and 1.

To read the graph at x=3, start at 3 on the bottom axis, move vertically until you reach the line, then move horizontally to the vertical axis. The height you read is the membership.

Swipe across the diagram to read its labels ↔

![Halfway along a straight rise from height 0 to height 1 gives height 0.5.](https://deep-learning-study-room.vercel.app/is2/fig/depth_slope.c91a1030aa.svg)

Diagram: Halfway along a straight rise from height 0 to height 1 gives height 0.5.. Labels: Read x = 4: halfway from 2 to 6, so height = 0.5 | 0 | 0.25 | 0.5 | 1 | 0 | 2 | 3 | 4 | 6 | 8 | μ | Input x | Straight rising membership | x = 4

Halfway along a straight rise from height 0 to height 1 gives height 0.5.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| x < 5 | Strictly less than 5 | 4.9 qualifies; 5 does not |
| x ≤ 5 | Less than or equal to 5 | Both 4.9 and 5 qualify |
| 2 ≤ x ≤ 8 | x is between 2 and 8 including both ends | The interval is [2,8] |
| [2,8) | Include 2; exclude 8 | Useful for roulette interval boundaries |
| Piecewise formula | Choose one calculation according to where x lies | Rising branch, falling branch or outside |

**A straight membership line rises from (2,0) to (6,1). Find its height at x=3.** [2 marks · Worked example]

#### Given

Left input=2; peak input=6; required input=3.

#### To find

Membership height.

#### Formula and why it applies



$$
\text{height}=\frac{\text{distance from left}}{\text{total rising width}}
$$



A straight line changes by the same proportion of its height as the proportion travelled along its width.

#### Solution

##### Step 1. Find distance travelled



$$
3-2=1
$$



##### Step 2. Find total width



$$
6-2=4
$$



##### Step 3. Divide distance by width



$$
\mu(3)=\frac{1}{4}=0.25
$$



**Final answer.** Membership=0.25.

**A straight membership line rises from (2,0) to (6,1). Find its height at x=4.** [2 marks · Worked example]

#### Given

Left input=2; peak input=6; required input=4.

#### To find

Membership height.

#### Formula and why it applies



$$
\text{height}=\frac{\text{distance from left}}{\text{total rising width}}
$$



A straight line changes by the same proportion of its height as the proportion travelled along its width.

#### Solution

##### Step 1. Find distance travelled



$$
4-2=2
$$



##### Step 2. Find total width



$$
6-2=4
$$



##### Step 3. Divide distance by width



$$
\mu(4)=\frac{2}{4}=0.5
$$



**Final answer.** Membership=0.5.

**A straight membership line rises from (10,0) to (30,1). Find its height at x=25.** [2 marks · Worked example]

#### Given

Left input=10; peak input=30; required input=25.

#### To find

Membership height.

#### Formula and why it applies



$$
\text{height}=\frac{\text{distance from left}}{\text{total rising width}}
$$



A straight line changes by the same proportion of its height as the proportion travelled along its width.

#### Solution

##### Step 1. Find distance travelled



$$
25-10=15
$$



##### Step 2. Find total width



$$
30-10=20
$$



##### Step 3. Divide distance by width



$$
\mu(25)=\frac{15}{20}=0.75
$$



**Final answer.** Membership=0.75.

**A membership line falls from (5,1) to (8,0). Find its height at x=7.** [2 marks · Worked example]

#### Given

Peak=5; right zero=8; x=7.

#### To find

Membership.

#### Formula and why it applies



$$
\mu(x)=\frac{\text{distance still remaining to right zero}}{\text{total falling width}}
$$



#### Solution

##### Step 1. Remaining distance



$$
8-7=1
$$



##### Step 2. Total falling width



$$
8-5=3
$$



##### Step 3. Divide



$$
\mu(7)=1/3\approx0.333333
$$



**Final answer.** Membership≈0.333333. Using distance already travelled would reverse the falling line.

**Yaad rakho:** Chadhti line: left se kitna aage? Utarti line: right tak kitna baaki? Dono mein poori width se divide.

---

## M2 · Sum notation, ordinary averages and weighted averages

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--sums-averages/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/sums-averages

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Σ means add a list of terms

The capital Greek letter **Σ** is read “sum”. The lower label says where to start and the upper label where to stop. The small index i is just a counter: first item, second item, third item.



$$
\sum_{i=1}^{3}a_i=a_1+a_2+a_3
$$



**For a₁=2, a₂=5 and a₃=8, calculate Σaᵢ and their mean.** [2 marks · Worked example]

#### Given

Three numbers: 2,5,8.

#### To find

Sum and ordinary average.

#### Formula and why it applies



$$
\bar a=\frac{a_1+a_2+a_3}{3}
$$



The bar means average. Each number has equal weight.

#### Solution

##### Step 1. Expand the sum symbol



$$
\sum_{i=1}^3 a_i=2+5+8
$$



##### Step 2. Add



$$
2+5=7\quad7+8=15
$$



##### Step 3. Divide by the count of numbers



$$
\bar a=15/3=5
$$



**Final answer.** Sum=15; mean=5.

## A weighted average gives unequal influence

If values 20 and 80 have weights 3 and 1, this is equivalent to averaging [20,20,20,80]. Therefore you divide by the **sum of weights**, not by the number of distinct values. Weights may also be decimals. Their total need not initially be 1.



$$
\bar z=\frac{w_1z_1+w_2z_2+\cdots}{w_1+w_2+\cdots}
$$



**Find the weighted average of [20, 80] with corresponding weights [3, 1].** [2 marks · Worked example]

#### Given

| Value | Its weight |
| --- | --- |
| 20 | 3 |
| 80 | 1 |

#### To find

The weighted average of the listed values.

#### Formula and why it applies



$$
\bar z=\frac{\sum_i w_i z_i}{\sum_i w_i}
$$



zᵢ is a value and wᵢ is its corresponding weight. Multiply each value by its own weight, add, then divide by total weight. Here all weights are nonnegative and their total is positive.

#### Solution

##### Step 1. Multiply value 1 by its weight



$$
20\times3=60
$$



##### Step 2. Multiply value 2 by its weight



$$
80\times1=80
$$



##### Step 3. Add the weighted products



$$
60+80=140
$$



##### Step 4. Add the weights



$$
3+1=4
$$



##### Step 5. Divide the two totals



$$
\bar z=\frac{140}{4}=35
$$



**Final answer.** 35.

**Find the weighted average of [20, 50, 80] with corresponding weights [0.2, 0.6, 0.2].** [2 marks · Worked example]

#### Given

| Value | Its weight |
| --- | --- |
| 20 | 0.2 |
| 50 | 0.6 |
| 80 | 0.2 |

#### To find

The weighted average of the listed values.

#### Formula and why it applies



$$
\bar z=\frac{\sum_i w_i z_i}{\sum_i w_i}
$$



zᵢ is a value and wᵢ is its corresponding weight. Multiply each value by its own weight, add, then divide by total weight. Here all weights are nonnegative and their total is positive.

#### Solution

##### Step 1. Multiply value 1 by its weight



$$
20\times0.2=4
$$



##### Step 2. Multiply value 2 by its weight



$$
50\times0.6=30
$$



##### Step 3. Multiply value 3 by its weight



$$
80\times0.2=16
$$



##### Step 4. Add the weighted products



$$
4+30+16=50
$$



##### Step 5. Add the weights



$$
0.2+0.6+0.2=1
$$



##### Step 6. Divide the two totals



$$
\bar z=\frac{50}{1}=50
$$



**Final answer.** 50.

**Find the weighted average of [65, 85] with corresponding weights [0.3, 0.5].** [2 marks · Worked example]

#### Given

| Value | Its weight |
| --- | --- |
| 65 | 0.3 |
| 85 | 0.5 |

#### To find

The weighted average of the listed values.

#### Formula and why it applies



$$
\bar z=\frac{\sum_i w_i z_i}{\sum_i w_i}
$$



zᵢ is a value and wᵢ is its corresponding weight. Multiply each value by its own weight, add, then divide by total weight. Here all weights are nonnegative and their total is positive.

#### Solution

##### Step 1. Multiply value 1 by its weight



$$
65\times0.3=19.5
$$



##### Step 2. Multiply value 2 by its weight



$$
85\times0.5=42.5
$$



##### Step 3. Add the weighted products



$$
19.5+42.5=62
$$



##### Step 4. Add the weights



$$
0.3+0.5=0.8
$$



##### Step 5. Divide the two totals



$$
\bar z=\frac{62}{0.8}=77.5
$$



**Final answer.** 77.5.

## Π means multiply a list of terms



$$
\prod_{i=1}^{3}a_i=a_1a_2a_3
$$



For [0.5,0.2,0.4], first 0.5×0.2=0.1, then 0.1×0.4=0.04. Σ would instead give 1.1. Naive Bayes multiplies likelihood factors; it does not add them.

**Yaad rakho:** Sigma = sab jodo. Product Pi = sab multiply. Weighted mean = value×weight ke total ko weights ke total se divide.

---

## M2 · Powers, roots, absolute values and exp on the calculator

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--powers-exponentials/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/core-maths/powers-exponentials

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Powers, roots and exponentials used later

A positive integer power repeats multiplication. 2³=2×2×2=8; it does not mean 2×3. A nonzero number raised to power 0 equals 1. A negative power means a reciprocal: 2⁻²=1/(2²)=1/4. A square root reverses a square for a nonnegative result: √9=3.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| 2⁰, 2¹, 2², 2³ | Binary place values | 1,2,4,8 |
| |x| | Absolute value: distance from zero | |−3|=3 and |3|=3 |
| e ≈ 2.71828 | A fixed mathematical constant | e⁰=1 |
| exp(u) | Another way of writing eᵘ | exp(−2)=e⁻²≈0.135335 |
| ln(x) | The natural logarithm; the exponent giving x from e | ln(e²)=2; ln(1)=0 |

**Calculate exp(−x²/2) at x=-2.** [2 marks · Worked example]

#### Given

x=-2; exp means e raised to the bracketed exponent.

#### To find

The exponential value.

#### Formula and why it applies

Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.

#### Solution

##### Step 1. Square x



$$
(-2)^2=4
$$



##### Step 2. Negate and divide by 2



$$
u=-\frac{4}{2}=-2
$$



##### Step 3. Evaluate the exponential



$$
e^u=e^{-2}\approx 0.135335283
$$



**Final answer.** 0.135335283.

**Calculate exp(−x²/2) at x=0.** [2 marks · Worked example]

#### Given

x=0; exp means e raised to the bracketed exponent.

#### To find

The exponential value.

#### Formula and why it applies

Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.

#### Solution

##### Step 1. Square x



$$
(0)^2=0
$$



##### Step 2. Negate and divide by 2



$$
u=-\frac{0}{2}=0
$$



##### Step 3. Evaluate the exponential



$$
e^u=e^{0}\approx 1
$$



**Final answer.** 1.

**Calculate exp(−x²/2) at x=2.** [2 marks · Worked example]

#### Given

x=2; exp means e raised to the bracketed exponent.

#### To find

The exponential value.

#### Formula and why it applies

Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.

#### Solution

##### Step 1. Square x



$$
(2)^2=4
$$



##### Step 2. Negate and divide by 2



$$
u=-\frac{4}{2}=-2
$$



##### Step 3. Evaluate the exponential



$$
e^u=e^{-2}\approx 0.135335283
$$



**Final answer.** 0.135335283.

On an fx-991ES-style calculator, eˣ is normally the shifted function above ln. Enter the complete exponent in brackets. Use the negative-number key for −2 where required. Confirm against e⁰=1 before a longer calculation. The exact key labels depend on the model.

**Yaad rakho:** exp ka matlab e ki power. Pehle exponent ka poora hisaab, phir eˣ.

---

## M2 · Fuzzy sets: what membership actually means

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--membership-meaning/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/membership-meaning

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Start with an input and a label

Suppose the input is **temperature 32°C** and the fuzzy label is **Hot**. A membership function is the rule that converts that temperature into a degree of matching the label. If μHot(32)=0.7, read it aloud as “the membership of 32 degrees in Hot is 0.7”. The lower word Hot names the set; 32 is the input; 0.7 is the output.

The same temperature can have membership 0.3 in Medium and 0.7 in Hot. These are two descriptions of one input. Fuzzy memberships do not generally have to sum to 1. By contrast, probabilities of mutually exclusive, exhaustive outcomes do.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Universe U | All input values being considered | Temperatures from 0 to 40°C |
| Crisp value | One definite measured number | 32°C |
| Linguistic term | A word naming a fuzzy category | Low, Medium, High |
| μA(x) | Degree to which input x fits category A | μHot(32)=0.7 |

**Yaad rakho:** 32 temperature hai; 0.7 us temperature ka Hot label mein degree hai. Dono ko mix mat karo.

## Why “true or false” is sometimes too rigid

Suppose a controller says a room is hot only when its temperature is at least 30°C. At 29.9°C it says “not hot”; at 30°C it says “hot”. That sharp boundary is a **crisp** rule. Fuzzy logic allows a gradual degree of belonging to the category “Hot”.

**Definition.** A fuzzy set A on a universe U assigns every element x a membership degree μA(x) between 0 and 1. The symbol μ is the Greek letter “mu”; read μA(x) as “the degree to which x belongs to set A”.



$$
\mu_A:U\rightarrow[0,1]
$$



| Term | Meaning | Temperature example |
| --- | --- | --- |
| Universe U | All allowed input values | Temperatures from 0°C to 40°C |
| Element x | The particular input being considered | 32°C |
| Fuzzy set A | A category described by a membership function | Hot |
| Membership μA(x) | How strongly x fits that category | μHot(32) = 0.7 |

## Read membership correctly

Membership 0 means no belonging; 1 means full belonging; 0.7 means partial belonging under the chosen definition. **It does not mean a 70% chance that the measured temperature is 32°C.** Nor is it a 70% chance that the sensor is correct. Fuzziness concerns the gradual meaning of “Hot”; probability concerns uncertainty about which event occurs.

| Input | Warm membership | Hot membership | Interpretation |
| --- | --- | --- | --- |
| 28 | 0.8 | 0.1 | Fits Warm strongly and Hot weakly |
| 32 | 0.3 | 0.7 | Fits Hot more than Warm |
| 35 | 0 | 1 | Fully Hot in this chosen model |

These memberships need not add to 1. Overlapping categories are allowed. A crisp set is the special case in which membership can only be 0 or 1. A crisp set can also contain infinitely many elements; “crisp” does not mean “finite”.

**On U = {20, 25, 30, 35}, the Hot memberships are [0, 0.2, 0.6, 1]. Write the fuzzy set Hot and identify the fully and partly belonging inputs.** [2 marks · Practice]

#### Given

Ordered inputs [20, 25, 30, 35]; memberships [0, 0.2, 0.6, 1].

#### To find

The set notation and interpretation.

#### Formula and why it applies

In the common fuzzy-set notation μ/x, the slash separates membership from element; it is not division.

#### Solution

##### Step 1. Pair each input with its membership

| x | μHot(x) |
| --- | --- |
| 20 | 0 |
| 25 | 0.2 |
| 30 | 0.6 |
| 35 | 1 |

##### Step 2. Write the set



$$
Hot=\{0/20,\;0.2/25,\;0.6/30,\;1/35\}
$$



##### Step 3. Interpret

35 fully belongs; 25 and 30 partly belong; 20 does not belong.

**Final answer.** Hot = {0/20, 0.2/25, 0.6/30, 1/35}.

**Distinguish crisp and fuzzy sets.** [2 marks · Practice]

#### Answer

| Crisp set | Fuzzy set |
| --- | --- |
| Membership is 0 or 1 | Membership is any value in [0,1] |
| A sharp boundary separates members | A membership function permits gradual boundaries |
| Example: temperature ≥ 30°C | Example: degree of being Hot increases gradually |

**Yaad rakho:** μ ka matlab: is category mein kitna fit hota hai. Chance nahi.

---

## M2 · Triangular membership: choose the side, then calculate

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--triangle/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/triangle

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Why the triangle has two different fractions

Tri(2,5,8) means membership starts at zero at x=2, rises to 1 at x=5, then falls to zero at x=8. The first three numbers are **input positions**, not three membership degrees.

| Where is x? | Meaning | Calculation |
| --- | --- | --- |
| x≤2 or x≥8 | Outside, or at a zero-height endpoint | 0 |
| 2<x<5 | Part-way up the rising edge | (x−2)/(5−2) |
| x=5 | At the peak | 1 |
| 5<x<8 | Part-way down the falling edge | (8−x)/(8−5) |

For x=3: distance travelled is 3−2=1; total rising width is 5−2=3; the height is 1÷3. For x=7: distance still remaining is 8−7=1; total falling width is 8−5=3; again the height is 1÷3. Use the branch containing the input before doing any division.

**Yaad rakho:** a = start, b = peak, c = end. x kahan pada hai, wahi fraction decide karega.

## A graph is a rule for assigning membership

The horizontal axis gives the input x. The vertical axis gives membership μ. To read μ at an input, go vertically up from that x to the line, then horizontally to the membership axis.

A triangle has three parameters: **a** is the left zero, **b** is the peak with membership 1, and **c** is the right zero. We assume a < b < c.

Swipe across the diagram to read its labels ↔

![Rising side: use distance from the left end. Falling side: use distance from the right end.](https://deep-learning-study-room.vercel.app/is2/fig/v2_triangle.4eb0b27c9d.svg)

Diagram: Rising side: use distance from the left end. Falling side: use distance from the right end.. Labels: Triangle: left end 2, peak 5, right end 8 | 0 | 0.5 | 1 | 0 | 2 | 3 | 5 | 7 | 8 | 10 | μ | Input x | A | x = 3 | x = 7

Rising side: use distance from the left end. Falling side: use distance from the right end.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



## Why the two fractions have these forms

On the rising side, x − a is how far you have climbed across the horizontal base; b − a is the full rising width. Their ratio goes from 0 to 1. On the falling side, c − x is the remaining horizontal distance to the right zero; c − b is the full falling width. That ratio goes from 1 to 0.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 3.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 3.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

2 < 3 ≤ 5, so membership increases as x moves toward the peak.

##### Step 2. Choose the correct expression

Rising side



$$
\mu_A(3)=\frac{3-2}{5-2}=\frac{1}{3}=0.333333333
$$



##### Step 3. Interpret the value

The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.

**Final answer.** μA(3) = 0.333333333.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 7.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 7.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

5 < 7 < 8, so membership decreases as x moves away from the peak.

##### Step 2. Choose the correct expression

Falling side



$$
\mu_A(7)=\frac{8-7}{8-5}=\frac{1}{3}=0.333333333
$$



##### Step 3. Interpret the value

The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.

**Final answer.** μA(7) = 0.333333333.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 5.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 5.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

2 < 5 ≤ 5, so membership increases as x moves toward the peak.

##### Step 2. Choose the correct expression

Rising side



$$
\mu_A(5)=\frac{5-2}{5-2}=\frac{3}{3}=1
$$



##### Step 3. Interpret the value

The degree of belonging to A is 1. This is full membership at the peak.

**Final answer.** μA(5) = 1.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 9.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 9.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

9 is outside the open support (2, 8) or at an endpoint.

##### Step 2. Choose the correct expression

Outside the triangle



$$
\mu_A(9)=0
$$



##### Step 3. Interpret the value

The degree of belonging to A is 0. It is a membership degree, not a probability.

**Final answer.** μA(9) = 0.

**Yaad rakho:** Peak se left: x − a. Peak se right: c − x. Neeche usi side ki poori width.

---

## M2 · Trapezoids, shoulders and intuition-based fuzzification

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--trapezoid-intuition/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/trapezoid-intuition

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## The middle is a flat top, not another slope

Trap(a,b,c,d) has four input positions: start rising at a, reach height 1 at b, stay at height 1 until c, and fall to zero at d. For Trap(0,2,6,8), any input between 2 and 6 has full membership. The rising width is 2−0=2; the falling width is 8−6=2.

| Input | Locate it | Numerator | Denominator | Membership |
| --- | --- | --- | --- | --- |
| 1 | Rising: 0<1<2 | 1−0=1 | 2−0=2 | 1/2=0.5 |
| 4 | Flat top: 2≤4≤6 | No division | No division | 1 |
| 7 | Falling: 6<7<8 | 8−7=1 | 8−6=2 | 1/2=0.5 |
| 9 | Beyond right endpoint | No division | No division | 0 |

A **left shoulder** can stay at height 1 for all sufficiently small inputs, then fall. A right shoulder does the reverse. If a diagram uses a vertical edge, read its stated endpoint convention; do not divide by a zero-width edge.

## Trapezoidal membership

A trapezoid has four parameters a < b ≤ c < d: rise from a to b, stay at 1 between b and c, then fall from c to d. The flat top means a whole interval fully belongs.

Swipe across the diagram to read its labels ↔

![From 20 to 30, the membership is exactly 1.](https://deep-learning-study-room.vercel.app/is2/fig/v2_trapezoid.dbfff598ea.svg)

Diagram: From 20 to 30, the membership is exactly 1.. Labels: A trapezoid has a fully belonging interval | 0 | 0.5 | 1 | 0 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 50 | μ | Input x | Comfortable

From 20 to 30, the membership is exactly 1.



$$
\mu(x)=\begin{cases}0,&x\le a\text{ or }x\ge d\\(x-a)/(b-a),&a<x<b\\1,&b\le x\le c\\(d-x)/(d-c),&c<x<d\end{cases}
$$



**For Trap(10,20,30,40), calculate μ(15).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=15.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 15 lies on the rising side.

##### Step 2. Apply that branch



$$
\mu(15)=(15-10)/(20-10)=5/10=0.5
$$



**Final answer.** μ(15) = 0.5.

**For Trap(10,20,30,40), calculate μ(25).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=25.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 25 lies on the flat top.

##### Step 2. Apply that branch



$$
\mu(25)=1
$$



**Final answer.** μ(25) = 1.

**For Trap(10,20,30,40), calculate μ(35).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=35.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 35 lies on the falling side.

##### Step 2. Apply that branch



$$
\mu(35)=(40-35)/(40-30)=5/10=0.5
$$



**Final answer.** μ(35) = 0.5.

**For Trap(10,20,30,40), calculate μ(45).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=45.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 45 lies on the outside support.

##### Step 2. Apply that branch



$$
\mu(45)=0
$$



**Final answer.** μ(45) = 0.

## Other membership shapes

A left shoulder remains fully true at the low end; a right shoulder remains fully true at the high end. A Gaussian has a smooth rounded peak. In a numerical, use the supplied graph or expression: do not invent breakpoints from a label such as “High”.

## Fuzzification by the intuition method

**Fuzzification** converts a measured crisp input into its membership degrees. In the **intuition method**, a domain expert defines useful linguistic categories and membership functions from experience. For example, the designer chooses the Warm triangle (15,25,35); after that choice, μWarm(32) = (35−32)/(35−25) = 0.3 is a calculation, not another guess.

1. Specify the variable and its allowed range.
2. Choose linguistic labels such as Low, Medium and High.
3. Specify each shape and every breakpoint.
4. Evaluate the functions at the actual input.
5. Validate the controller on representative inputs and adjust the design if needed.

**Yaad rakho:** Shape banana design choice; shape milne ke baad membership calculate karni hai.

---

## M2 · Union, intersection, complement and difference

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--set-operations/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/set-operations

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Work on one element before working on a whole set

If A assigns element u₁ a degree 0.7 and B assigns the same element degree 0.4, every operation compares these two degrees. Do not compare u₁ from A with u₂ from B. ∪ means union (“A OR B”); ∩ means intersection (“A AND B”); superscript c means complement (“NOT”).

**At one element u, μA(u)=0.7 and μB(u)=0.4. Find union, intersection, complement of B and A\B.** [2 marks · Worked example]

#### Given

At the same element u, A assigns membership 0.7 and B assigns membership 0.4.

#### To find

The membership at u in A∪B, A∩B, Bᶜ and A minus B.

#### Formula and why it applies

Use max for OR, min for AND, and 1 minus membership for NOT. Difference is A AND NOT B.

#### Solution

##### Step 1. Union: choose the larger



$$
\max(0.7,0.4)=0.7
$$



##### Step 2. Intersection: choose the smaller



$$
\min(0.7,0.4)=0.4
$$



##### Step 3. Complement B first



$$
1-0.4=0.6
$$



##### Step 4. Intersect A with complement B



$$
\min(0.7,0.6)=0.6
$$



**Final answer.** Union 0.7; intersection 0.4; Bᶜ 0.6; A\B 0.6. Ordinary subtraction 0.7−0.4=0.3 would be the wrong difference operation.

## The four operations used in Q1

Use the **standard max–min convention** unless the question specifies another t-norm or t-conorm. “T-norm” simply names a fuzzy AND operator; here it is min. “T-conorm” names a fuzzy OR operator; here it is max.

| Operation | Meaning | Rule |
| --- | --- | --- |
| Union A ∪ B | A OR B | Take the larger membership |
| Intersection A ∩ B | A AND B | Take the smaller membership |
| Complement Aᶜ | NOT A | 1 − membership of A |
| Difference A ∖ B | A AND NOT B | min(μA, 1 − μB) |

**On U = {u1, u2, u3}, A has memberships [0.2, 0.8, 0.6] and B has memberships [0.7, 0.3, 0.5]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [3 marks · Practice]

#### Given

| Element | u1 | u2 | u3 |
| --- | --- | --- | --- |
| A | 0.2 | 0.8 | 0.6 |
| B | 0.7 | 0.3 | 0.5 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-0.7=0.3
$$





$$
\mu_{A\setminus B}(u_1)=\min(0.2,0.3)=0.2
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0.2 | 0.7 | max(0.2, 0.7) = 0.7 | min(0.2, 0.7) = 0.2 | 1 − 0.7 = 0.3 | min(0.2, 0.3) = 0.2 |
| u2 | 0.8 | 0.3 | max(0.8, 0.3) = 0.8 | min(0.8, 0.3) = 0.3 | 1 − 0.3 = 0.7 | min(0.8, 0.7) = 0.7 |
| u3 | 0.6 | 0.5 | max(0.6, 0.5) = 0.6 | min(0.6, 0.5) = 0.5 | 1 − 0.5 = 0.5 | min(0.6, 0.5) = 0.5 |

**Final answer.** A ∪ B = [0.7, 0.8, 0.6]; A ∩ B = [0.2, 0.3, 0.5]; Bᶜ = [0.3, 0.7, 0.5]; A ∖ B = [0.2, 0.7, 0.5].

**On U = {u1, u2, u3}, A has memberships [0, 1, 0.4] and B has memberships [1, 0, 0.4]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [3 marks · Practice]

#### Given

| Element | u1 | u2 | u3 |
| --- | --- | --- | --- |
| A | 0 | 1 | 0.4 |
| B | 1 | 0 | 0.4 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-1=0
$$





$$
\mu_{A\setminus B}(u_1)=\min(0,0)=0
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0 | 1 | max(0, 1) = 1 | min(0, 1) = 0 | 1 − 1 = 0 | min(0, 0) = 0 |
| u2 | 1 | 0 | max(1, 0) = 1 | min(1, 0) = 0 | 1 − 0 = 1 | min(1, 1) = 1 |
| u3 | 0.4 | 0.4 | max(0.4, 0.4) = 0.4 | min(0.4, 0.4) = 0.4 | 1 − 0.4 = 0.6 | min(0.4, 0.6) = 0.4 |

**Final answer.** A ∪ B = [1.0, 1.0, 0.4]; A ∩ B = [0.0, 0.0, 0.4]; Bᶜ = [0.0, 1.0, 0.6]; A ∖ B = [0.0, 1.0, 0.4].

**On U = {u1, u2, u3, u4}, A has memberships [0.9, 0.2, 0.5, 0.7] and B has memberships [0.6, 0.8, 0.1, 0.7]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [3 marks · Practice]

#### Given

| Element | u1 | u2 | u3 | u4 |
| --- | --- | --- | --- | --- |
| A | 0.9 | 0.2 | 0.5 | 0.7 |
| B | 0.6 | 0.8 | 0.1 | 0.7 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-0.6=0.4
$$





$$
\mu_{A\setminus B}(u_1)=\min(0.9,0.4)=0.4
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0.9 | 0.6 | max(0.9, 0.6) = 0.9 | min(0.9, 0.6) = 0.6 | 1 − 0.6 = 0.4 | min(0.9, 0.4) = 0.4 |
| u2 | 0.2 | 0.8 | max(0.2, 0.8) = 0.8 | min(0.2, 0.8) = 0.2 | 1 − 0.8 = 0.2 | min(0.2, 0.2) = 0.2 |
| u3 | 0.5 | 0.1 | max(0.5, 0.1) = 0.5 | min(0.5, 0.1) = 0.1 | 1 − 0.1 = 0.9 | min(0.5, 0.9) = 0.5 |
| u4 | 0.7 | 0.7 | max(0.7, 0.7) = 0.7 | min(0.7, 0.7) = 0.7 | 1 − 0.7 = 0.3 | min(0.7, 0.3) = 0.3 |

**Final answer.** A ∪ B = [0.9, 0.8, 0.5, 0.7]; A ∩ B = [0.6, 0.2, 0.1, 0.7]; Bᶜ = [0.4, 0.2, 0.9, 0.3]; A ∖ B = [0.4, 0.2, 0.5, 0.3].

**Why not subtract A − B?** With A=0.2 and B=0.7, raw subtraction gives −0.5, which is not a membership degree. Under this convention, A ∖ B = min(0.2, 0.3) = 0.2. Some alternative fuzzy algebras define other difference operators; always identify the specified convention.

**Yaad rakho:** Union bada; intersection chhota; complement 1 se ghata; difference = pehle B ka complement, phir min.

---

## M2 · Fuzzy properties, De Morgan laws and α-cuts

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--properties/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/properties

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Translate the property names

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Commutative | Changing order changes nothing | max(0.3,0.8)=max(0.8,0.3)=0.8 |
| Associative | Regroup the same operation | max(max(0.2,0.7),0.4)=max(0.2,max(0.7,0.4))=0.7 |
| Idempotent | Combining a membership with itself keeps it | min(0.6,0.6)=0.6 |
| Involution | Complement twice returns the original | 1−(1−0.4)=1−0.6=0.4 |
| De Morgan | NOT swaps AND and OR while complementing each operand | 1−max(a,b)=min(1−a,1−b) |

## Properties that remain valid

| Property | Statement for max–min operations |
| --- | --- |
| Commutative | A ∪ B = B ∪ A; A ∩ B = B ∩ A |
| Associative | (A ∪ B) ∪ C = A ∪ (B ∪ C); likewise for intersection |
| Idempotent | A ∪ A = A; A ∩ A = A |
| Distributive | A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C); and its dual |
| Involution | (Aᶜ)ᶜ = A |
| De Morgan | (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ; (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ |

## Two crisp identities do not generally hold

For fuzzy sets, A ∪ Aᶜ need not equal the entire universe at membership 1; A ∩ Aᶜ need not be the empty set at membership 0.

**At an element x, μA(x)=0.4. Calculate μ(A ∪ Aᶜ) and μ(A ∩ Aᶜ).** [2 marks · Practice]

#### Given

μA(x)=0.4; standard complement/max/min.

#### To find

Whether excluded middle and non-contradiction hold at this element.

#### Formula and why it applies

Complement first, then use max or min.

#### Solution

##### Step 1. Complement



$$
\mu_{A^c}(x)=1-0.4=0.6
$$



##### Step 2. Union



$$
\max(0.4,0.6)=0.6\ne1
$$



##### Step 3. Intersection



$$
\min(0.4,0.6)=0.4\ne0
$$



**Final answer.** The union is 0.6 and the intersection is 0.4; the crisp identities fail here.

**Verify the first De Morgan law for μA=0.3 and μB=0.8.** [2 marks · Practice]

#### Given

A=0.3, B=0.8 at the same element.

#### To find

Both sides of (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ.

#### Formula and why it applies

Evaluate the operations independently on each side.

#### Solution

##### Step 1. Left side



$$
1-\max(0.3,0.8)=1-0.8=0.2
$$



##### Step 2. Right side



$$
\min(1-0.3,1-0.8)=\min(0.7,0.2)=0.2
$$



**Final answer.** Both sides equal 0.2.

**For U={a,b,c,d} and memberships A=[0,0.3,1,0.7], find support, core, boundary, height and the 0.7-cut.** [2 marks · Worked example]

#### Given

Universe U={a,b,c,d}. Memberships: A(a)=0, A(b)=0.3, A(c)=1, A(d)=0.7. Cut level α=0.7.

#### To find

The support, core, boundary and 0.7-cut as sets of elements, and the height as one membership value.

#### Formula and why it applies

Support: degree>0; core: degree=1; boundary: 0<degree<1; height: largest degree; α-cut: degree≥α.

#### Solution

##### Step 1. Inspect each element

| Element | Degree | Positive? | Exactly 1? | At least 0.7? |
| --- | --- | --- | --- | --- |
| a | 0 | No | No | No |
| b | 0.3 | Yes | No | No |
| c | 1 | Yes | Yes | Yes |
| d | 0.7 | Yes | No | Yes |

##### Step 2. Collect the requested elements

Support={b,c,d}. Core={c}. Boundary={b,d}. The 0.7-cut={c,d}.

##### Step 3. Read the height

The maximum degree is 1, so the height is 1 and the set is normal.

**Final answer.** Support {b,c,d}; core {c}; boundary {b,d}; height 1; 0.7-cut {c,d}.

**Find the 0.5-cut of the triangular fuzzy set Tri(2,5,8).** [2 marks · Worked example]

#### Given

Triangle start a=2, peak b=5, end c=8; cut level α=0.5. Retain all inputs whose membership is at least 0.5.

#### To find

Left and right endpoints of the retained interval.

#### Formula and why it applies

The triangle rises past 0.5, remains above it, then falls through 0.5. Solve height=0.5 on both slopes.

#### Solution

##### Step 1. Left slope: multiply both sides by 3



$$
(x-2)/3=0.5
$$





$$
x-2=0.5\times3=1.5
$$



##### Step 2. Isolate the left input



$$
x=1.5+2=3.5
$$



##### Step 3. Right slope: multiply both sides by 3



$$
(8-x)/3=0.5
$$





$$
8-x=1.5
$$



##### Step 4. Isolate the right input



$$
x=8-1.5=6.5
$$



##### Step 5. Include all inputs between them

The graph is at or above 0.5 for 3.5≤x≤6.5. Include the endpoints because the condition is ≥.

**Final answer.** The 0.5-cut is [3.5,6.5].

## Describing a fuzzy set

**Support:** inputs with μ > 0. **Core:** inputs with μ = 1. **Boundary:** inputs with 0 < μ < 1. **Height:** largest membership (more generally the supremum). A set is normal when its height is 1; it is subnormal when its height is below 1. A crossover point has membership 0.5. An α-cut contains inputs with μ ≥ α.

For Tri(2,5,8), support is (2,8), core is {5}, height is 1, and the 0.5-cut is [3.5,6.5]. Solve (x−2)/3=0.5 → x=3.5 and (8−x)/3=0.5 → x=6.5.

A one-dimensional fuzzy set is **convex** if every α-cut is an interval (or empty). The membership between two inputs must not dip below the smaller endpoint membership. A single triangle is convex; two separated peaks with a lower valley may not be.

**Yaad rakho:** Fuzzy A aur NOT A dono partial ho sakte hain. Isliye crisp waali 1 aur 0 identities blindly nahi lagani.

---

## M2 · Mamdani architecture: what every block does

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--mamdani-architecture/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/mamdani-architecture

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Follow one measurement through the controller

A **controller** turns measurements into an action setting. Consider temperature 32°C and occupancy 7 people. The input numbers first become membership degrees. The rules then combine those degrees. Only the final defuzzification returns one fan-speed number.

| Stage | What goes in | Operation | What comes out |
| --- | --- | --- | --- |
| Fuzzifier | 32°C and 7 people | Use the supplied membership graphs | Temperature Medium=.3, High=.7; occupancy High=.5 |
| Knowledge base | Chosen labels and their shapes | Store graphs and IF–THEN rules | A reusable definition of how the controller works |
| Inference | Medium=.3 AND High=.5 | Rule strength=min(.3,.5)=.3 | “Fan High” fires at .3 |
| Aggregation | All clipped output sets | Take the largest output degree at each speed | One combined fuzzy output shape |
| Defuzzifier | Combined shape | Apply the specified MoM, centroid or representative method | One numerical speed |

The **antecedent** is the IF part (“temperature is Medium AND occupancy is High”). The **consequent** is the THEN part (“fan speed is High”). A rule strength of 0.3 is a membership height; it does not mean the fan runs at 30%.

## Definition: a fuzzy inference system

A **fuzzy inference system (FIS)** maps inputs to an output by evaluating fuzzy IF–THEN rules. A **Mamdani FIS** uses fuzzy sets in the rule consequents, combines their inferred output sets, and defuzzifies the result.

Crisp inputs32°C; 7 people

→

Fuzzificationdegrees of Warm/Hot etc.

→

Rules + inferencerule strengths and clipped outputs

→

Aggregationone combined output shape

→

Defuzzificationone fan-speed number

## Architecture: what each block contributes

| Block | What it stores or calculates | Concrete meaning |
| --- | --- | --- |
| Fuzzifier | Membership values of the measured inputs | 32°C may be Medium to degree 0.3 and High to degree 0.7 |
| Knowledge base: database | Ranges and membership functions | Medium = Tri(15,25,35) |
| Knowledge base: rule base | IF–THEN rules | IF temperature High AND occupancy High THEN fan Very High |
| Inference engine | Combines conditions and applies consequents | min for AND; clips the output triangle at the rule strength |
| Aggregator | Combines all rule outputs | At every output location, take the maximum clipped membership |
| Defuzzifier | Converts the aggregate to one crisp value | Use centroid or mean of maxima, as requested |

## Parts of an IF–THEN rule

In “IF temperature is High AND occupancy is High THEN fan speed is Very High”, the IF part is the **antecedent** (condition), and the THEN part is the **consequent** (output category). The input variable temperature, the label High, and the numerical membership μHigh(32) are different things.

## Why a rule strength is not yet the fan speed

A strength such as 0.3 says how strongly a rule fires. It is on the membership scale 0–1. Fan speed might be on a 0–100% scale. Defuzzification is the step that produces a number on that output scale.

**Explain the architecture of a Mamdani fuzzy inference system.** [3 marks · Practice]

#### Answer

A Mamdani FIS contains a fuzzifier, knowledge base, inference engine and defuzzifier. The database specifies membership functions and the rule base stores IF–THEN rules. Crisp inputs are fuzzified. The inference engine calculates rule firing strengths and constructs output fuzzy sets. These sets are aggregated, then defuzzified into a crisp action. For a fan controller, temperature and occupancy are inputs and fan speed is the output.

**Yaad rakho:** Input ka degree → rule ka strength → output ka shape → final number.

---

## M2 · Rule firing, clipping and aggregation: four solved cases

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--rules-clipping/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/rules-clipping

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Clipping means limiting a height

A rule firing at strength 0.3 cannot give its consequent a membership above 0.3. At every candidate speed z, keep the smaller of 0.3 and the original output-set membership. The speed axis is unchanged.

**At speeds 40, 60 and 80, output set A has memberships [0.1,0.8,0.2] and set B has [0,0.4,1]. Rule A fires at 0.3 and rule B at 0.5. Clip and max-aggregate the sets.** [2 marks · Worked example]

#### Given

| Speed | Original A membership | Original B membership |
| --- | --- | --- |
| 40 | 0.1 | 0 |
| 60 | 0.8 | 0.4 |
| 80 | 0.2 | 1 |

Rule A strength=0.3; rule B strength=0.5. Compare memberships at the same speed.

#### To find

The combined membership at each speed.

#### Formula and why it applies



$$
\mu_{out}(z)=\max(\min(0.3,\mu_A(z)),\min(0.5,\mu_B(z)))
$$



Inner min limits a rule’s height; outer max keeps the stronger support at that speed.

#### Solution

##### Step 1. Clip A

At 40: min(.3,.1)=.1. At 60: min(.3,.8)=.3. At 80: min(.3,.2)=.2.

##### Step 2. Clip B

At 40: min(.5,0)=0. At 60: min(.5,.4)=.4. At 80: min(.5,1)=.5.

##### Step 3. Aggregate at each speed

| Speed | Clipped A | Clipped B | max(A,B) |
| --- | --- | --- | --- |
| 40 | 0.1 | 0 | 0.1 |
| 60 | 0.3 | 0.4 | 0.4 |
| 80 | 0.2 | 0.5 | 0.5 |

**Final answer.** Combined degrees [0.1,0.4,0.5] at speeds [40,60,80]. A separate defuzzification step is still required.

**Yaad rakho:** Clip = height ki ceiling. Aggregate = har same x par sabse upar wala height.

## Four different calculations happen in inference

**AND/OR** combine conditions within a rule. **Implication** uses the resulting strength to modify that rule’s output membership function. **Aggregation** merges different rule outputs. Here we use min-AND, max-OR, min-implication and max-aggregation.



$$
\alpha_{AND}=\min(a,b)\qquad\alpha_{OR}=\max(a,b)
$$





$$
\mu_{\mathrm{rule}}(z)=\min(\alpha,\mu_{\mathrm{consequent}}(z))
$$





$$
\mu_{\mathrm{aggregate}}(z)=\max_r\mu_{\mathrm{rule}\ r}(z)
$$



α (“alpha”) is the rule firing strength. z names a possible output value. The subscript r labels a rule, not a multiplication.

**A rule has two condition degrees 0.7 and 0.5, joined by AND. Find its firing strength.** [2 marks · Practice]

#### Given

a=0.7; b=0.5; connective=AND.

#### To find

The strength α.

#### Formula and why it applies

Use the smaller degree because both conditions must hold.

#### Solution

##### Step 1. Select the operator



$$
\alpha=\min(0.7,0.5)
$$



##### Step 2. Evaluate



$$
\alpha=0.5
$$



**Final answer.** 0.5.

**A rule has two condition degrees 0.3 and 0, joined by AND. Find its firing strength.** [2 marks · Practice]

#### Given

a=0.3; b=0; connective=AND.

#### To find

The strength α.

#### Formula and why it applies

Use the smaller degree because both conditions must hold.

#### Solution

##### Step 1. Select the operator



$$
\alpha=\min(0.3,0)
$$



##### Step 2. Evaluate



$$
\alpha=0
$$



**Final answer.** 0.

**A rule has two condition degrees 0.2 and 0.8, joined by OR. Find its firing strength.** [2 marks · Practice]

#### Given

a=0.2; b=0.8; connective=OR.

#### To find

The strength α.

#### Formula and why it applies

Use the larger degree because either condition is sufficient.

#### Solution

##### Step 1. Select the operator



$$
\alpha=\max(0.2,0.8)
$$



##### Step 2. Evaluate



$$
\alpha=0.8
$$



**Final answer.** 0.8.

**Rule 1 fires at 0.3 and its original output membership at z=60 is 0.8. Rule 2 fires at 0.6 and its original membership at z=60 is 0.2. Find the aggregate membership at z=60 using min-implication and max-aggregation.** [3 marks · Practice]

#### Given

Rule 1: α₁=0.3, μ₁(60)=0.8. Rule 2: α₂=0.6, μ₂(60)=0.2.

#### To find

Membership at the single output location z=60 after implication and aggregation.

#### Formula and why it applies

Clip each original degree at its rule strength; then take the larger clipped degree.

#### Solution

##### Step 1. Clip rule 1



$$
\mu_{R1}(60)=\min(0.3,0.8)=0.3
$$



##### Step 2. Clip rule 2



$$
\mu_{R2}(60)=\min(0.6,0.2)=0.2
$$



##### Step 3. Aggregate at this output location



$$
\mu_{out}(60)=\max(0.3,0.2)=0.3
$$



**Final answer.** The aggregate membership at z=60 is 0.3. This is not a crisp fan-speed answer.

Swipe across the diagram to read its labels ↔

![Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.](https://deep-learning-study-room.vercel.app/is2/fig/v2_clip.f101b5cfa9.svg)

Diagram: Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.. Labels: Min-implication clips the triangle at strength 0.3 | 0 | 0.3 | 1 | 50 | 54.5 | 65 | 75.5 | 80 | μ | Output z | Original High | clip 0.3

Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.

**Yaad rakho:** AND ke liye min; output clip karne ke liye bhi min; rules ko jodne ke liye max. Har min ka role alag hai.

---

## M2 · Mean of maxima: discrete peaks and clipped plateaus

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--mom/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/mom

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

**Maximum membership** is a height. **Mean of maxima** averages the horizontal locations attaining that height. If heights at speeds [20,50,80] are [.2,.6,.6], the maximum height is .6 and the qualifying speeds are 50 and 80; MoM=(50+80)/2=65. Do not average [.6,.6], which would return a degree rather than a speed. A continuous flat maximum from 50 to 80 also has midpoint 65.

## Mean of maxima (MoM)

**Defuzzification** converts the aggregate membership function into one crisp output. For MoM, first find the largest membership height, then average the output locations attaining that height. Do not average the membership values themselves.



$$
z^*_{MoM}=\frac{z_1+\cdots+z_m}{m}
$$



For a continuous flat maximum from a to b, the mean is its midpoint:



$$
z^*_{MoM}=\frac{a+b}{2}
$$



**For the following discrete aggregate, find the mean-of-maxima output.** [2 marks · Practice]

#### Given

| Output z | Membership μ |
| --- | --- |
| 10 | 0.2 |
| 20 | 0.8 |
| 30 | 0.8 |
| 40 | 0.3 |

#### To find

MoM crisp output.

#### Formula and why it applies

Find all locations at the largest height, then average only those locations.

#### Solution

##### Step 1. Find the maximum height



$$
\mu_{max}=0.8
$$



##### Step 2. List the locations attaining it

20, 30

##### Step 3. Average these locations



$$
z^*=\frac{20+30}{2}=25
$$



**Final answer.** 25.

**For the following discrete aggregate, find the mean-of-maxima output.** [2 marks · Practice]

#### Given

| Output z | Membership μ |
| --- | --- |
| 1 | 0.1 |
| 2 | 0.4 |
| 3 | 0.9 |
| 4 | 0.2 |

#### To find

MoM crisp output.

#### Formula and why it applies

Find all locations at the largest height, then average only those locations.

#### Solution

##### Step 1. Find the maximum height



$$
\mu_{max}=0.9
$$



##### Step 2. List the locations attaining it

3

##### Step 3. Average these locations



$$
z^*=\frac{3}{1}=3
$$



**Final answer.** 3.

**A single triangular output Tri(50,65,80) is clipped at α=0.3. Find its crisp value by mean of maxima.** [3 marks · Practice]

#### Given

a=50, b=65, c=80; clip height α=0.3.

#### To find

Both plateau endpoints and their mean.

#### Formula and why it applies

Set the rising and falling membership fractions equal to 0.3. Every point between those intersections has the maximum height.

#### Solution

##### Step 1. Find the left endpoint



$$
\frac{z_L-50}{65-50}=0.3
$$





$$
z_L-50=0.3\times15=4.5
$$





$$
z_L=54.5
$$



##### Step 2. Find the right endpoint



$$
\frac{80-z_R}{80-65}=0.3
$$





$$
80-z_R=4.5
$$





$$
z_R=75.5
$$



##### Step 3. Average endpoints



$$
z^*=(54.5+75.5)/2=65
$$



**Final answer.** MoM = 65.

Swipe across the diagram to read its labels ↔

![The maximum extends over [54.5,75.5], whose midpoint is 65.](https://deep-learning-study-room.vercel.app/is2/fig/v2_clip.f101b5cfa9.svg)

Diagram: The maximum extends over [54.5,75.5], whose midpoint is 65.. Labels: Min-implication clips the triangle at strength 0.3 | 0 | 0.3 | 1 | 50 | 54.5 | 65 | 75.5 | 80 | μ | Output z | Original High | clip 0.3

The maximum extends over [54.5,75.5], whose midpoint is 65.

For several disjoint continuous maximum plateaus, a continuous MoM uses a length-weighted mean over all maximum intervals; simply averaging two outside endpoints is not generally valid. In tabulated questions, average the listed locations at the maximum.

**Yaad rakho:** Sabse upar ka level dekho; us level par x-values ka mean lo.

---

## M2 · Centroid: three table sums and one area calculation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--centroid/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/centroid

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Centroid means the balance point of the whole shape

Imagine the area under the output graph as a thin sheet of uniform material. The centroid is its horizontal balance point. More area on one side pulls the answer toward that side. In a discrete problem, each membership is a weight. In a continuous problem, the entire area supplies the weights.

The integral sign ∫ means adding very thin strips across a continuous interval. The denominator ∫μ(z)dz is the total area. The numerator ∫zμ(z)dz is the **first moment**: position multiplied by area, accumulated across the shape. Their ratio has units of the output, such as fan-speed percent.

**A non-overlapping aggregate consists of a rectangle of width 4 and height 0.5 centred at z=2, plus a triangle of base 4 and height 0.5 centred horizontally at z=6. Find the area centroid.** [2 marks · Worked example]

#### Given

Rectangle: width 4, height 0.5, horizontal centre 2. Triangle: base 4, height 0.5, horizontal centroid 6. Their areas do not overlap.

#### To find

The combined horizontal centroid.

#### Formula and why it applies



$$
z^*=\frac{A_1c_1+A_2c_2}{A_1+A_2}
$$



Each piece contributes area times its own centre. Use this only for a valid decomposition of the aggregate.

#### Solution

##### Step 1. Rectangle area



$$
A_1=4\times0.5=2
$$



##### Step 2. Triangle area



$$
A_2=\tfrac12\times4\times0.5=1
$$



##### Step 3. First moments



$$
A_1c_1=2\times2=4
$$





$$
A_2c_2=1\times6=6
$$



##### Step 4. Totals



$$
A=2+1=3\qquad M=4+6=10
$$



##### Step 5. Divide



$$
z^*=10/3\approx3.333333
$$



**Final answer.** Centroid≈3.333333, closer to the larger-area piece.

For overlapping clipped sets, first form their max-aggregate. Adding the areas of the original overlapping sets would count the overlap twice.

## Centroid: the balance point of the output

The centroid uses the whole aggregate membership distribution. For a discrete output table, multiply each output location by its membership, add the products, then divide by total membership.



$$
z^*=\frac{\sum_i z_i\mu(z_i)}{\sum_i\mu(z_i)}
$$



The index i simply numbers table entries. Σ (“sigma”) means add all listed terms. The denominator must be nonzero.

**Find the discrete centroid of the aggregate membership table.** [3 marks · Practice]

#### Given

| z | μ(z) |
| --- | --- |
| 10 | 0.2 |
| 20 | 0.6 |
| 30 | 0.4 |

#### To find

One centroid value on the output scale.

#### Formula and why it applies

This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.



$$
z^*=\frac{\sum z_i\mu_i}{\sum\mu_i}
$$



#### Solution

##### Step 1. Multiply every location by its membership

| z | μ | z × μ |
| --- | --- | --- |
| 10 | 0.2 | 2 |
| 20 | 0.6 | 12 |
| 30 | 0.4 | 12 |

##### Step 2. Add the numerator



$$
2+12+12=26
$$



##### Step 3. Add the denominator



$$
0.2+0.6+0.4=1.2
$$



##### Step 4. Divide



$$
z^*=\frac{26}{1.2}=21.666666667
$$



**Final answer.** 21.666666667.

**Find the discrete centroid of the aggregate membership table.** [3 marks · Practice]

#### Given

| z | μ(z) |
| --- | --- |
| 0 | 0.5 |
| 5 | 1 |
| 10 | 0.5 |

#### To find

One centroid value on the output scale.

#### Formula and why it applies

This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.



$$
z^*=\frac{\sum z_i\mu_i}{\sum\mu_i}
$$



#### Solution

##### Step 1. Multiply every location by its membership

| z | μ | z × μ |
| --- | --- | --- |
| 0 | 0.5 | 0 |
| 5 | 1 | 5 |
| 10 | 0.5 | 5 |

##### Step 2. Add the numerator



$$
0+5+5=10
$$



##### Step 3. Add the denominator



$$
0.5+1+0.5=2
$$



##### Step 4. Divide



$$
z^*=\frac{10}{2}=5
$$



**Final answer.** 5.

**Find the discrete centroid of the aggregate membership table.** [3 marks · Practice]

#### Given

| z | μ(z) |
| --- | --- |
| 20 | 0 |
| 40 | 0.3 |
| 60 | 0.6 |
| 80 | 0.1 |

#### To find

One centroid value on the output scale.

#### Formula and why it applies

This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.



$$
z^*=\frac{\sum z_i\mu_i}{\sum\mu_i}
$$



#### Solution

##### Step 1. Multiply every location by its membership

| z | μ | z × μ |
| --- | --- | --- |
| 20 | 0 | 0 |
| 40 | 0.3 | 12 |
| 60 | 0.6 | 36 |
| 80 | 0.1 | 8 |

##### Step 2. Add the numerator



$$
0+12+36+8=56
$$



##### Step 3. Add the denominator



$$
0+0.3+0.6+0.1=1
$$



##### Step 4. Divide



$$
z^*=\frac{56}{1}=56
$$



**Final answer.** 56.

## For a continuous shape, integrate the area



$$
z^*=\frac{\int z\mu(z)\,dz}{\int\mu(z)\,dz}
$$



The denominator is the area under the aggregate. The numerator is its first moment about zero: area weighted by horizontal location. For a shape made of non-overlapping rectangles and triangles, compute each part’s area A and its own centroid c, then use 

$$
z^*=(\sum A_jc_j)/(\sum A_j)
$$

. Overlapping regions of a max-aggregate must not be counted twice.

**An aggregate is a rectangle of height 0.5 from z=0 to z=4, followed by a right triangle decreasing from height 0.5 at z=4 to 0 at z=6. Find its area centroid.** [3 marks · Practice]

#### Given

Rectangle [0,4], height 0.5; triangle with vertices (4,0),(4,0.5),(6,0).

#### To find

Centroid of the combined area.

#### Formula and why it applies

The parts do not overlap except at their boundary. Weight each part’s horizontal centroid by its area.

#### Solution

##### Step 1. Rectangle area and centre



$$
A_1=4\times0.5=2\qquad c_1=(0+4)/2=2
$$



##### Step 2. Triangle area and centre



$$
A_2=\tfrac12\times2\times0.5=0.5
$$





$$
c_2=(4+4+6)/3=14/3
$$



##### Step 3. Add first moments



$$
A_1c_1+A_2c_2=2(2)+0.5(14/3)=19/3
$$



##### Step 4. Divide by total area



$$
z^*=(19/3)/(2+0.5)=38/15\approx2.533333
$$



**Final answer.** Centroid ≈ 2.533333. The plateau MoM would be 2, so different methods can legitimately give different results.

**Yaad rakho:** Centroid = har location × uska weight, total karke total weight se divide.

---

## M2 · Weighted average and centroid are not automatically the same

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--weighted-average/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/weighted-average

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

This is the same weighted-average calculation taught in Essential maths. Here a representative output value c is weighted by a rule strength α. Keep the pair together: strength .3 belonging to speed 65 contributes .3×65. The denominator is the total strength. It is not automatically the number of rules, and the representative is not automatically the area-centre of a clipped set.

## Weighted average of output representatives

Some classroom solutions use one representative (often the peak) per output label and weight it by the firing strength. That is a **weighted-average or height-based calculation**. It is exact for a specified weighted combination of singleton outputs, but is not generally the centroid of a max-aggregated, clipped Mamdani shape.

Always name the method. A table of memberships at actual output locations supports the discrete centroid. A list of category peaks and strengths supports the specified representative-weighted calculation. Full continuous output shapes support area centroid.

**Using the weighted-average method, combine output representatives [25, 75] mph with respective strengths [0.1, 0.7].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 25 | 0.1 |
| 75 | 0.7 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0.1 × 25 | 2.5 |
| 0.7 × 75 | 52.5 |

##### Step 2. Add the products



$$
2.5+52.5=55
$$



##### Step 3. Add the strengths



$$
0.1+0.7=0.8
$$



##### Step 4. Divide



$$
z^*=\frac{55}{0.8}=68.75
$$



**Final answer.** 68.75 mph.

**Using the weighted-average method, combine output representatives [40, 65, 85] % fan speed with respective strengths [0, 0.3, 0.5].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 40 | 0 |
| 65 | 0.3 |
| 85 | 0.5 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0 × 40 | 0 |
| 0.3 × 65 | 19.5 |
| 0.5 × 85 | 42.5 |

##### Step 2. Add the products



$$
0+19.5+42.5=62
$$



##### Step 3. Add the strengths



$$
0+0.3+0.5=0.8
$$



##### Step 4. Divide



$$
z^*=\frac{62}{0.8}=77.5
$$



**Final answer.** 77.5 % fan speed.

**Using the weighted-average method, combine output representatives [25, 40, 60] minutes with respective strengths [0.6, 0.4, 0.2].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 25 | 0.6 |
| 40 | 0.4 |
| 60 | 0.2 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0.6 × 25 | 15 |
| 0.4 × 40 | 16 |
| 0.2 × 60 | 12 |

##### Step 2. Add the products



$$
15+16+12=43
$$



##### Step 3. Add the strengths



$$
0.6+0.4+0.2=1.2
$$



##### Step 4. Divide



$$
z^*=\frac{43}{1.2}=35.833333333
$$



**Final answer.** 35.833333333 minutes.

| Method | What it uses | Limitation |
| --- | --- | --- |
| MoM | Locations at maximum membership | Ignores lower portions of the shape; can change abruptly |
| Area centroid | Entire aggregated output area | Needs an area/moment calculation or numerical integration |
| Representative weighted average | Supplied representative values and strengths | Not interchangeable with a clipped Mamdani area centroid |

No method is universally “most accurate”. The correct exam calculation is the method specified by the question. If all memberships or all weights are zero, division by zero is undefined; a controller needs an explicit fallback rule.

**Yaad rakho:** Formula similar dikhega, par weight kya hai? Membership, area, ya rule strength—pehle woh identify karo.

## Faculty slide example: one temperature input

This is a different example from the two-input fan design. With Warm=Tri(20,30,40) and Hot=Tri(30,40,50), temperature 32 gives Warm=(40−32)/10=0.8 and Hot=(32−30)/10=0.2. The slide uses output representatives 50 and 80.

**Using the weighted-average method, combine output representatives [50, 80] % fan speed with respective strengths [0.8, 0.2].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 50 | 0.8 |
| 80 | 0.2 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0.8 × 50 | 40 |
| 0.2 × 80 | 16 |

##### Step 2. Add the products



$$
40+16=56
$$



##### Step 3. Add the strengths



$$
0.8+0.2=1
$$



##### Step 4. Divide



$$
z^*=\frac{56}{1}=56
$$



**Final answer.** 56 % fan speed.

---

## M2 · Class fan question: 32°C, 7 people, every rule and step

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--class-fan/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/class-fan

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

There are 3 temperature labels and 3 occupancy labels. Pair each temperature label with each occupancy label: 3×3=9 possible AND rules. At the specified input, any rule containing a zero input membership has strength min(0,other)=0 and contributes no output. The rules with nonzero strength remain; their output labels come from the supplied rule table, not from the magnitude of the strength.

This is the fan-controller design question shared in class: temperature 32°C and occupancy 7. The photos contain inconsistent graph breakpoints and arithmetic. A design question permits a stated design; below, every membership function is specified explicitly. These choices make the solution reproducible and should not be read as a uniquely recoverable answer from the photos.

**Design a Mamdani fan controller for temperature 0–40°C and occupancy 0–10, with three input labels each and five fan-speed labels on 0–100%. For T=32°C and occupancy=7, use the membership functions and nine rules below. Calculate all memberships, firing strengths, and active output sets. Find fan speed by (a) mean of maxima and (b) the specified representative-weighted average.** [10 marks · Class-question adaptation; full design]

#### Given

| Variable | Low / Very Low | Medium / Low | High / Medium | High output | Very High output |
| --- | --- | --- | --- | --- | --- |
| Temperature | Tri(0,10,20) | Tri(15,25,35) | Tri(25,35,40) | — | — |
| Occupancy | Tri(0,2,4) | Tri(3,5,7) | Tri(6,8,10) | — | — |
| Fan speed | Tri(0,10,20) | Tri(10,25,40) | Tri(20,40,60) | Tri(50,65,80) | Tri(70,85,100) |

Input T=32°C; occupancy=7. Use min-AND, min-clipping and max-aggregation.

| Temperature | Occupancy | Fan output |
| --- | --- | --- |
| Low | Low | Very Low |
| Low | Medium | Low |
| Low | High | Medium |
| Medium | Low | Low |
| Medium | Medium | Medium |
| Medium | High | High |
| High | Low | Medium |
| High | Medium | High |
| High | High | Very High |

#### To find

Input memberships → nine rule strengths → clipped output → two named crisp outputs.

#### Formula and why it applies

Use the appropriate triangle branch for membership. AND takes the smaller degree. Each output is clipped at that strength; rules with the same consequent combine by max. MoM uses only the highest plateau. The requested representative weighted average uses category peaks and strengths.



$$
\alpha_r=\min(\mu_{T,r},\mu_{O,r})\quad\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



#### Solution

##### Step 1. Read the temperature graph

Swipe across the diagram to read its labels ↔

![At 32, Medium is on its falling side; High is on its rising side.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fan_temp.434c9b6635.svg)

Diagram: At 32, Medium is on its falling side; High is on its rising side.. Labels: Chosen temperature membership functions | 0 | 0.5 | 1 | 0 | 10 | 15 | 20 | 25 | 32 | 35 | 40 | μ | Temperature in °C | Low | Medium | High | 32°C

At 32, Medium is on its falling side; High is on its rising side.



$$
\mu_L(32)=0
$$





$$
\mu_M(32)=\frac{35-32}{35-25}=\frac3{10}=0.3
$$





$$
\mu_H(32)=\frac{32-25}{35-25}=\frac7{10}=0.7
$$



##### Step 2. Read the occupancy graph

Swipe across the diagram to read its labels ↔

![At 7, Medium reaches its right zero and High is halfway up its rising edge.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fan_people.1861531dd1.svg)

Diagram: At 7, Medium reaches its right zero and High is halfway up its rising edge.. Labels: Chosen occupancy membership functions | 0 | 0.5 | 1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | μ | Number of people | Low | Medium | High | 7 people

At 7, Medium reaches its right zero and High is halfway up its rising edge.



$$
\mu_L(7)=0\qquad\mu_M(7)=0
$$





$$
\mu_H(7)=\frac{7-6}{8-6}=\frac12=0.5
$$



##### Step 3. Evaluate all nine rules

| T label / degree | O label / degree | min = strength | Output |
| --- | --- | --- | --- |
| Low / 0 | Low / 0 | 0 | Very Low |
| Low / 0 | Medium / 0 | 0 | Low |
| Low / 0 | High / 0.5 | 0 | Medium |
| Medium / 0.3 | Low / 0 | 0 | Low |
| Medium / 0.3 | Medium / 0 | 0 | Medium |
| Medium / 0.3 | High / 0.5 | 0.3 | High |
| High / 0.7 | Low / 0 | 0 | Medium |
| High / 0.7 | Medium / 0 | 0 | High |
| High / 0.7 | High / 0.5 | 0.5 | Very High |

##### Step 4. Clip and aggregate



$$
\mu_{out}(z)=\max\{\min(0.3,\mu_H(z)),\min(0.5,\mu_{VH}(z))\}
$$



Swipe across the diagram to read its labels ↔

![High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fan_output.8708d0ea77.svg)

Diagram: High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.. Labels: Two active output sets | 0 | 0.5 | 1 | 50 | 54.5 | 65 | 70 | 75 | 77.5 | 85 | 92.5 | 100 | μ | Fan speed (%) | High | Very High | clip 0.3 | clip 0.5

High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.

##### Step 5. Find the highest plateau for MoM

The maximum is 0.5, belonging to Very High. Its triangle is (70,85,100).



$$
\frac{z_L-70}{15}=0.5\Rightarrow z_L=77.5
$$





$$
\frac{100-z_R}{15}=0.5\Rightarrow z_R=92.5
$$





$$
z^*_{MoM}=\frac{77.5+92.5}{2}=85
$$



##### Step 6. Multiply the representatives by strengths



$$
0.3\times65=19.5
$$





$$
0.5\times85=42.5
$$



##### Step 7. Add, then divide for the weighted average



$$
z^*_{WA}=\frac{19.5+42.5}{0.3+0.5}=\frac{62}{0.8}=77.5
$$



**Final answer.** For this explicitly stated design: MoM = 85%; representative-weighted output = 77.5%. These are different methods. 77.5% is not claimed to be the true continuous Mamdani area centroid.

**How to adapt it in the exam:** if breakpoints or output representatives differ, recompute the memberships from those data. The sequence of operations stays unchanged. If the question explicitly asks for the area centroid, integrate the max-aggregated shape; do not silently substitute the weighted average above.

**Yaad rakho:** Temperature aur people ka degree nikalo → 9 min → active outputs clip → jo method poocha hai woh lagao.

## Why the Very High plateau has midpoint 85

For the stated Very High triangle (70,85,100) clipped at height 0.5, solve the rising edge: (z−70)/(85−70)=0.5, so z−70=0.5×15=7.5 and z=77.5. On the falling edge, (100−z)/(100−85)=0.5, so 100−z=7.5 and z=92.5. Thus the highest flat interval is [77.5,92.5]. Its midpoint is (77.5+92.5)/2=170/2=85.

Continue with the [complete area-centroid calculation for this same fan design](https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--centroid-comparison/): 77.086956522%, with all overlap breakpoints and area/moment arithmetic shown.

---

## M2 · The same fan controller: true area centroid versus MoM and weighted average

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--centroid-comparison/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/centroid-comparison

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

The preceding class-fan lesson makes the input shapes and nine rules explicit because the photographs do not specify one internally consistent design. Keep that exact stated design here: temperature 32°C, occupancy 7, High output Tri(50,65,80) firing at 0.3 and Very High output Tri(70,85,100) firing at 0.5. This continuation calculates the actual area centroid of their max-aggregate. It does not reinterpret 77.5 as a centroid.

**For the stated two-input class fan controller at T=32°C and occupancy=7, calculate the true continuous Mamdani area centroid of High=Tri(50,65,80) clipped at 0.3 and Very High=Tri(70,85,100) clipped at 0.5. Compare it with mean of maxima and the specified representative-weighted average.** [6 marks]

Worked teaching continuation of the class-design adaptation; the mark allocation here is for practice.

#### Given

All other output rules have strength zero. Use min for implication, max for aggregation and speed z on 0–100%. The two active rule strengths were calculated from input memberships: min(0.3,0.5)=0.3 and min(0.7,0.5)=0.5.

#### To find

Every visible segment of the aggregate, its area and first moment, the centroid, and the differences between the three crisp answers.

#### Formula and why it applies



$$
\mu_{out}(z)=\max\{\min(0.3,\mu_H(z)),\min(0.5,\mu_{VH}(z))\}
$$





$$
z^*_{COA}=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



Centroid balances all the area under the upper envelope. A straight strip with endpoints (a,u) and (b,v) has the following area A and first moment M; adding only disjoint strips counts overlap once.



$$
A=\frac{(b-a)(u+v)}2,\qquad M=\frac{b-a}{6}[(2a+b)u+(a+2b)v]
$$



#### Solution

##### Step 1. Locate the two clipped plateaus



$$
H:\quad z_L=50+0.3(65-50)=54.5,\quad z_R=80-0.3(80-65)=75.5
$$





$$
VH:\quad z_L=70+0.5(85-70)=77.5,\quad z_R=100-0.5(100-85)=92.5
$$



High has a 0.3 plateau from 54.5 to 75.5. Very High has a 0.5 plateau from 77.5 to 92.5.

##### Step 2. Find where the upper envelope changes owner

Very High rises through the High plateau at height 0.3. Solve its rising equation:



$$
(z-70)/15=0.3\quad\Rightarrow\quad z=74.5
$$



Before 74.5, clipped High supplies the upper envelope. After 74.5, Very High is above it. The descending High edge from 75.5 to 80 lies underneath and contributes no extra aggregate area.

##### Step 3. Trace the aggregate graph

Swipe across the diagram to read its labels ↔

![Fan output: trace the upper envelope before finding its centroid](https://deep-learning-study-room.vercel.app/is2/fig/deep_fan_centroid.98bf1c217d.svg)

Diagram: Fan output: trace the upper envelope before finding its centroid. Labels: Fan output: trace the upper envelope before finding its centroid | High clipped at 0.3; Very High clipped at 0.5. Hidden overlap is counted once. | 0 | 0.3 | 0.5 | 50 | 54.5 | 74.5 | 77.5 | 92.5 | 100 | Centroid ≈77.087% | Fan speed z (%) | Area = 17.25; first moment = 1329.75; centroid = moment ÷ area.

Read left to right: (50,0) → (54.5,0.3) → (74.5,0.3) → (77.5,0.5) → (92.5,0.5) → (100,0). Membership is zero outside this support. Each adjacent pair is one straight strip in the table.

##### Step 4. Work the rising first strip explicitly



$$
A_1=(54.5-50)(0+0.3)/2=0.675
$$





$$
M_1=\frac{4.5}{6}[(100+54.5)0+(50+109)0.3]=35.775
$$



The first moment has units of speed multiplied by area. Dividing total moment by total area returns speed.

##### Step 5. Calculate all disjoint strips

| a | b | u | v | Area A | First moment M |
| --- | --- | --- | --- | --- | --- |
| 50 | 54.5 | 0 | 0.3 | 0.675 | 35.775 |
| 54.5 | 74.5 | 0.3 | 0.3 | 6 | 387 |
| 74.5 | 77.5 | 0.3 | 0.5 | 1.2 | 91.35 |
| 77.5 | 92.5 | 0.5 | 0.5 | 7.5 | 637.5 |
| 92.5 | 100 | 0.5 | 0 | 1.875 | 178.125 |



$$
\sum A=0.675+6+1.2+7.5+1.875=17.25
$$





$$
\sum M=35.775+387+91.35+637.5+178.125=1329.75
$$



##### Step 6. Divide for the actual centroid



$$
z^*_{COA}=1329.75/17.25=1773/23\approx77.086956522\%
$$



##### Step 7. Compare methods on the same aggregate

| Method | Calculation | Answer |
| --- | --- | --- |
| Area centroid | 1329.75 ÷ 17.25 | 77.086956522% |
| Mean of maxima | (77.5+92.5) ÷ 2 | 85% |
| Specified representative weighted average | (0.3×65+0.5×85) ÷ (0.3+0.5) | 77.5% |

MoM uses only the highest plateau. The representative method uses two chosen peaks and two rule strengths. The area centroid uses the full max-aggregate, so these are three legitimate but different calculations.

**Final answer.** Area centroid ≈77.086956522%; MoM=85%; representative-weighted output=77.5%. Report the method with the value. The centroid is inside the support [50,100], as a balance point must be.

**Boundary coverage of this teaching design.** With the ordinary triangles stated in the class adaptation, every temperature degree is zero at T=0 or T=40, and every occupancy degree is zero at occupancy=0 or 10. Then no rule fires and an area centroid is undefined. To make a controller cover the entire declared input range, explicitly redesign outer sets as shoulders or specify an out-of-coverage rule; do not silently divide by zero. The worked T=32, occupancy=7 case has positive area and is unaffected.

**Yaad rakho:** Centroid mein poore shaded area ka balance chahiye. Peak × strength wala shortcut same calculation nahi hai.

---

## M2 · Fuzzy theory: definitions, architecture, advantages and applications

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--exam-theory/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/exam-theory

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

**Explain fuzzy logic with one application.** [2 marks · Practice]

#### Answer

Fuzzy logic represents gradual truth or category membership using values between 0 and 1. A temperature controller can use Low, Medium and High temperature sets. It evaluates rules such as IF temperature is High THEN fan speed is High, combines the rule outputs and defuzzifies them into a numerical fan speed. This permits gradual control around category boundaries.

**Give the advantages and limitations of a Mamdani fuzzy controller.** [3 marks · Practice]

#### Answer

| Advantages | Limitations |
| --- | --- |
| Human-readable rules express expert knowledge | Membership functions and rules require careful design |
| Can model gradual boundaries without an exact analytic plant model | Rule count can grow rapidly with more inputs and categories |
| Handles overlapping linguistic descriptions | A poorly chosen rule base can produce poor or uncovered outputs |
| Suitable for many control applications | Does not automatically learn or guarantee optimal control |

**Describe the design of a fuzzy fan controller.** [3 marks · Practice]

#### Answer

Choose temperature and occupancy as inputs and fan speed as output. Define their ranges and Low/Medium/High membership functions. Construct a rule table linking input labels to output labels. Fuzzify measured inputs, use min to obtain AND-rule strengths, clip the consequent sets and max-aggregate them. Apply the specified defuzzification method to obtain a fan speed. Test the design at normal inputs and range boundaries.

## Other applications you can explain

| Application | Inputs | Example rule | Output |
| --- | --- | --- | --- |
| Washing machine | Dirtiness, load | IF dirt High AND load High THEN wash time Long | Wash duration |
| Loan decision support | Income, credit score | IF income High AND credit Good THEN approval suitability High | Suitability score (not an automatic legal lending decision) |
| Fire warning | Temperature, smoke | IF temperature High OR smoke High THEN risk High | Alarm-risk score |
| Vehicle control | Distance, relative speed | IF distance Small AND closing speed High THEN braking Strong | Braking command |

**Yaad rakho:** Theory answer mein definition → blocks/steps → ek concrete example. Sirf headings se marks nahi milte.

---

## M2 · Gaussian, singleton and bell memberships

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--smooth-memberships/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-core/smooth-memberships

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

For a Gaussian membership, c is the input at the centre and σ controls the width. Compute x−c, square it, divide by 2σ², put a minus sign in front, and apply eˣ. The maximum membership is 1 at x=c because the exponent becomes 0. Increasing σ makes the same distance from the centre count as a smaller relative distance, so the curve becomes wider. A Gaussian membership is not the same formula as a normal probability density: there is no 1/(√(2π)σ) multiplier here.

## A smooth membership function

A Gaussian membership function reaches 1 at its centre c and decreases smoothly on both sides. Its width σ must be positive. This is a fuzzy membership curve, not a normalised probability density: there is no 1/(√(2π)σ) factor.



$$
\mu(x)=\exp\left(-\frac{(x-c)^2}{2\sigma^2}\right)
$$



exp(u) means eᵘ. The calculator evaluates it using eˣ; calculate the entire negative exponent first. A squared distance treats equal left and right offsets equally.

**For Gaussian membership with c=10 and σ=2, find μ(10).** [2 marks · Practice]

#### Given

x=10; centre c=10; width σ=2.

#### To find

Membership degree.

#### Formula and why it applies

Use squared distance from the centre in the Gaussian membership formula.

#### Solution

##### Step 1. Distance from the centre



$$
10-10=0
$$



##### Step 2. Square the distance and width



$$
(0)^2=0\qquad2\sigma^2=2(2^2)=8
$$



##### Step 3. Exponent



$$
-0/8=0
$$



##### Step 4. Evaluate e to this power



$$
\mu(10)=e^{0}\approx1
$$



**Final answer.** 1.

**For Gaussian membership with c=10 and σ=2, find μ(12).** [2 marks · Practice]

#### Given

x=12; centre c=10; width σ=2.

#### To find

Membership degree.

#### Formula and why it applies

Use squared distance from the centre in the Gaussian membership formula.

#### Solution

##### Step 1. Distance from the centre



$$
12-10=2
$$



##### Step 2. Square the distance and width



$$
(2)^2=4\qquad2\sigma^2=2(2^2)=8
$$



##### Step 3. Exponent



$$
-4/8=-0.5
$$



##### Step 4. Evaluate e to this power



$$
\mu(12)=e^{-0.5}\approx0.60653066
$$



**Final answer.** 0.60653066.

**For Gaussian membership with c=10 and σ=2, find μ(14).** [2 marks · Practice]

#### Given

x=14; centre c=10; width σ=2.

#### To find

Membership degree.

#### Formula and why it applies

Use squared distance from the centre in the Gaussian membership formula.

#### Solution

##### Step 1. Distance from the centre



$$
14-10=4
$$



##### Step 2. Square the distance and width



$$
(4)^2=16\qquad2\sigma^2=2(2^2)=8
$$



##### Step 3. Exponent



$$
-16/8=-2
$$



##### Step 4. Evaluate e to this power



$$
\mu(14)=e^{-2}\approx0.135335283
$$



**Final answer.** 0.135335283.

## Singleton

A singleton fuzzy set has membership 1 at exactly one specified point and 0 elsewhere. For a singleton at c=50: μ(50)=1, μ(49)=0 and μ(51)=0. A singleton consequent is represented by one numerical output; this is why a specified weighted average of singleton outputs is a legitimate calculation.

## Generalised bell (when its formula is supplied)



$$
\mu(x)=\frac1{1+\left|\frac{x-c}{a}\right|^{2b}}
$$



c is the centre, a>0 controls width and b>0 controls the slope. Absolute value |u| is the nonnegative magnitude: |−2|=2. At x=c membership is 1; at x=c±a membership is 1/2.

**For a=2, b=1 and c=10, find generalised-bell membership at x=14.** [2 marks · Practice]

#### Given

a=2, b=1, c=10; x=14.

#### To find

μ(14).

#### Formula and why it applies

Subtract the centre, divide by a, take the absolute value, raise to 2b, then use the reciprocal.

#### Solution

##### Step 1. Scaled distance



$$
|(14-10)/2|=|2|=2
$$



##### Step 2. Power



$$
2^{2(1)}=4
$$



##### Step 3. Final reciprocal



$$
\mu(14)=1/(1+4)=0.2
$$



**Final answer.** 0.2.

**Yaad rakho:** Gaussian MF ka centre 1 hota hai. GMM density ke normalising factor ko yahan mat lagao.

---

## M2 · GA meaning, biological idea and every basic term

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--meaning/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/meaning

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

| Object | Concrete value | Do not confuse it with |
| --- | --- | --- |
| Individual number | Row 2 | The candidate’s value x |
| Candidate value x | 11 | Its chromosome 1011 |
| Chromosome | 1011 | Its fitness |
| Fitness when maximising x² | 11×11=121 | Its row number or bit string |

In this guide, “gene 3” counts the third bit from the **left** starting at 1. Binary place values were built from the **right** starting with weight 1. These are two labelling conventions, not contradictory place-value rules. Read the end specified in an exam.

## What a genetic algorithm does

A **genetic algorithm (GA)** is a population-based optimisation method inspired by biological evolution. It maintains candidate solutions, evaluates their fitness, selects parents, generates children through crossover and mutation, and repeats the process.

In biology, genes carry inherited information. In a GA, an encoding plays the role of inherited information. The analogy motivates the operators; it does not mean that a computer chromosome is literally DNA.

| Term | Meaning | Four-bit example |
| --- | --- | --- |
| Individual | One candidate solution | x=11 |
| Chromosome | The complete encoded candidate | 1011 |
| Gene | One component of an encoding | The third bit |
| Allele | The value at a gene | 0 or 1 for binary encoding |
| Population | The collection of current individuals | [3,5,10,12] |
| Fitness | A score used to favour useful candidates | For max x², fitness of 11 is 121 |
| Generation | One cycle producing a new population | Select → cross → mutate → replace |
| Search space | All candidate solutions permitted | 4-bit integers: 0–15 |
| Elitism | Preserving best individuals unchanged | Copy the best into the next population |

An objective describes what the problem wants. Fitness describes what the selection mechanism favours. For maximising a nonnegative objective, they may be the same. For minimising cost, directly selecting in proportion to cost would favour bad candidates; use a specified transformation or a comparison-based selection method.

**For a maximisation GA with objective f(x)=x², find the fitness of x=3.** [2 marks · Practice]

#### Given

x=3; fitness equals the nonnegative objective x².

#### To find

Fitness, not the encoded chromosome.

#### Formula and why it applies

Square x to evaluate its objective; binary encoding is a separate representation step.

#### Solution

##### Step 1. Substitute x



$$
f(3)=3^2
$$



##### Step 2. Multiply



$$
3\times3=9
$$



**Final answer.** Fitness = 9.

**For a maximisation GA with objective f(x)=x², find the fitness of x=7.** [2 marks · Practice]

#### Given

x=7; fitness equals the nonnegative objective x².

#### To find

Fitness, not the encoded chromosome.

#### Formula and why it applies

Square x to evaluate its objective; binary encoding is a separate representation step.

#### Solution

##### Step 1. Substitute x



$$
f(7)=7^2
$$



##### Step 2. Multiply



$$
7\times7=49
$$



**Final answer.** Fitness = 49.

**For a maximisation GA with objective f(x)=x², find the fitness of x=12.** [2 marks · Practice]

#### Given

x=12; fitness equals the nonnegative objective x².

#### To find

Fitness, not the encoded chromosome.

#### Formula and why it applies

Square x to evaluate its objective; binary encoding is a separate representation step.

#### Solution

##### Step 1. Substitute x



$$
f(12)=12^2
$$



##### Step 2. Multiply



$$
12\times12=144
$$



**Final answer.** Fitness = 144.

**Yaad rakho:** Chromosome answer ka code; fitness us code wale answer ka score.

---

## M2 · Encoding: binary, real values and permutations

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--encoding/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/encoding

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

## Expand the compact decoding formula before using it



$$
x=b_1 2^3+b_2 2^2+b_3 2^1+b_4 2^0
$$



For four bits, b₁ is the leftmost bit and receives weight 8; b₄ is the rightmost and receives weight 1. In general n−i gives the power belonging to bit i. For 1011, the four terms are 1×8, 0×4, 1×2, 1×1. Add 8+0+2+1=11.

For real-range mapping, d/(2ⁿ−1) is the fraction of the way through the possible codes. Multiplying by U−L travels that fraction of the physical range. Adding L shifts the result to start at the lower limit.

| 3-bit code | Decoded d | Fraction d/7 | Mapped to [−2,5] |
| --- | --- | --- | --- |
| 000 | 0 | 0/7=0 | −2+0×7=−2 |
| 011 | 3 | 3/7 | −2+(3/7)×7=1 |
| 111 | 7 | 7/7=1 | −2+1×7=5 |

## Choose an encoding that can express legal solutions

**Binary encoding** uses bit strings; **real-valued encoding** stores real numbers directly; **permutation encoding** stores an order, such as a TSP city tour. An operator valid for bits may create invalid city tours, so encoding and operators must fit the problem.

| Representation | Candidate | Appropriate use |
| --- | --- | --- |
| Binary | 1011 | An unsigned integer or a coded real value |
| Real-valued | [0.2, 1.7] | Continuous parameters |
| Permutation | [A,C,B,D] | Visit order in TSP |

## Decode an n-bit integer



$$
x=b_1 2^{n-1}+b_2 2^{n-2}+\cdots+b_n2^0
$$



b₁ is the leftmost bit, not a coefficient you have to learn. In four bits the weights are 8,4,2,1. The maximum is 

$$
2^n-1
$$

.

**Decode the 4-bit chromosome 0011.** [2 marks · Practice]

#### Given

Bits 0011; place values 8,4,2,1.

#### To find

Integer x.

#### Formula and why it applies

Multiply each bit by its matching place value, then add.

#### Solution

##### Step 1. List contributions

| Bit | Place value | Contribution |
| --- | --- | --- |
| 0 | 8 | 0 |
| 0 | 4 | 0 |
| 1 | 2 | 2 |
| 1 | 1 | 1 |

##### Step 2. Add



$$
0+0+2+1=3
$$



**Final answer.** x=3.

**Decode the 4-bit chromosome 1010.** [2 marks · Practice]

#### Given

Bits 1010; place values 8,4,2,1.

#### To find

Integer x.

#### Formula and why it applies

Multiply each bit by its matching place value, then add.

#### Solution

##### Step 1. List contributions

| Bit | Place value | Contribution |
| --- | --- | --- |
| 1 | 8 | 8 |
| 0 | 4 | 0 |
| 1 | 2 | 2 |
| 0 | 1 | 0 |

##### Step 2. Add



$$
8+0+2+0=10
$$



**Final answer.** x=10.

**Decode the 4-bit chromosome 1111.** [2 marks · Practice]

#### Given

Bits 1111; place values 8,4,2,1.

#### To find

Integer x.

#### Formula and why it applies

Multiply each bit by its matching place value, then add.

#### Solution

##### Step 1. List contributions

| Bit | Place value | Contribution |
| --- | --- | --- |
| 1 | 8 | 8 |
| 1 | 4 | 4 |
| 1 | 2 | 2 |
| 1 | 1 | 1 |

##### Step 2. Add



$$
8+4+2+1=15
$$



**Final answer.** x=15.

## Encoding a real interval

If the question maps an n-bit integer d to a real interval [L,U], first decode d, then use:



$$
x=L+\frac{d}{2^n-1}(U-L)
$$



**Map the 3-bit string 101 to the real interval [−2,5] using linear binary decoding.** [3 marks · Practice]

#### Given

n=3, L=−2, U=5; string 101.

#### To find

Real x.

#### Formula and why it applies

The smallest bit code maps to L and the largest to U; the remaining codes are equally spaced.



$$
x=L+\frac d{2^n-1}(U-L)
$$



#### Solution

##### Step 1. Decode integer d



$$
d=1(4)+0(2)+1(1)=5
$$



##### Step 2. Calculate interval width and maximum code



$$
U-L=5-(-2)=7\qquad2^3-1=7
$$



##### Step 3. Map to the interval



$$
x=-2+(5/7)(7)=3
$$



**Final answer.** x=3.

**Yaad rakho:** Pehle bits se integer. Real range mapping explicitly diya ho tabhi next formula lagao.

---

## M2 · Roulette selection, cumulative intervals and alternatives

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--selection/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/selection

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

Before the three complete sums below, read the running-total example in [Percentages, probabilities and cumulative intervals](https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--probability/). For weights [1,2,3,4], candidate C’s own probability is 0.3, but its interval is [0.3,0.6). A draw of 0.55 selects C because it lies inside that interval; it is not required to be less than C’s individual probability.

## Selection chooses parents, usually with replacement

**Roulette-wheel selection** gives each candidate a probability proportional to a nonnegative fitness weight. A high weight occupies a larger interval on [0,1]. A supplied random number selects the interval containing it.



$$
P_i=F_i/\sum_jF_j
$$



Fᵢ is the fitness weight of individual i. The sum must be positive. Probabilities add to 1. Cumulative probability is the running sum and supplies the interval boundaries.

**Fitness weights of successive individuals are [1, 2, 3, 4]. Select parents using random numbers [0.05, 0.25, 0.55, 0.9].** [3 marks · Practice]

#### Given

Fitness weights [1, 2, 3, 4]; draws [0.05, 0.25, 0.55, 0.9].

#### To find

Parent row number for each draw.

#### Formula and why it applies

Divide by the fitness sum, form cumulative intervals, then locate each random draw. Use half-open intervals [lower,upper); the final upper endpoint 1 is included.

#### Solution

##### Step 1. Sum fitness



$$
\sum F=1+2+3+4=10
$$



##### Step 2. Find probabilities and cumulative bounds

| Individual | Fitness | Probability | Cumulative |
| --- | --- | --- | --- |
| 1 | 1 | 0.1 | 0.1 |
| 2 | 2 | 0.2 | 0.3 |
| 3 | 3 | 0.3 | 0.6 |
| 4 | 4 | 0.4 | 1 |

##### Step 3. Locate each draw

| Draw | Selected individual |
| --- | --- |
| 0.05 | 1 |
| 0.25 | 2 |
| 0.55 | 3 |
| 0.9 | 4 |

**Final answer.** Selected row numbers: [1, 2, 3, 4]. Repeated selection is permitted.

**Fitness weights of successive individuals are [4, 4, 2]. Select parents using random numbers [0.2, 0.6, 0.85].** [3 marks · Practice]

#### Given

Fitness weights [4, 4, 2]; draws [0.2, 0.6, 0.85].

#### To find

Parent row number for each draw.

#### Formula and why it applies

Divide by the fitness sum, form cumulative intervals, then locate each random draw. Use half-open intervals [lower,upper); the final upper endpoint 1 is included.

#### Solution

##### Step 1. Sum fitness



$$
\sum F=4+4+2=10
$$



##### Step 2. Find probabilities and cumulative bounds

| Individual | Fitness | Probability | Cumulative |
| --- | --- | --- | --- |
| 1 | 4 | 0.4 | 0.4 |
| 2 | 4 | 0.4 | 0.8 |
| 3 | 2 | 0.2 | 1 |

##### Step 3. Locate each draw

| Draw | Selected individual |
| --- | --- |
| 0.2 | 1 |
| 0.6 | 2 |
| 0.85 | 3 |

**Final answer.** Selected row numbers: [1, 2, 3]. Repeated selection is permitted.

**Fitness weights of successive individuals are [0, 3, 1]. Select parents using random numbers [0.2, 0.8].** [3 marks · Practice]

#### Given

Fitness weights [0, 3, 1]; draws [0.2, 0.8].

#### To find

Parent row number for each draw.

#### Formula and why it applies

Divide by the fitness sum, form cumulative intervals, then locate each random draw. Use half-open intervals [lower,upper); the final upper endpoint 1 is included.

#### Solution

##### Step 1. Sum fitness



$$
\sum F=0+3+1=4
$$



##### Step 2. Find probabilities and cumulative bounds

| Individual | Fitness | Probability | Cumulative |
| --- | --- | --- | --- |
| 1 | 0 | 0 | 0 |
| 2 | 3 | 0.75 | 0.75 |
| 3 | 1 | 0.25 | 1 |

##### Step 3. Locate each draw

| Draw | Selected individual |
| --- | --- |
| 0.2 | 2 |
| 0.8 | 3 |

**Final answer.** Selected row numbers: [2, 3]. Repeated selection is permitted.

## Other selection methods

| Method | Procedure | Why it is used |
| --- | --- | --- |
| Tournament | Sample a group and take its best candidate | Only objective comparisons are needed |
| Rank | Sort candidates; assign weights based on rank | Reduces sensitivity to a single huge raw fitness |
| Elitist survival | Preserve top individuals unchanged into the next population | Protects good solutions from destructive variation |

Selection is not automatically “replace the weakest with the fittest”. That is one possible classroom reproduction rule. If a problem gives selected parents, a rank rule, tournament contestants or roulette draws, follow that exact instruction.

**Yaad rakho:** Probability nikalo → cumulative banao → random number ka interval dekho.

---

## M2 · Crossover and mutation: four complete worked variants

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--operators/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/operators

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

## Cutting means splitting the written string

The **prefix** is the part before the cut; the **suffix** is the part after it. “10 joined with 00 gives 1000” means writing strings next to each other. It is not the arithmetic addition 10+00.

| Operation | Parents / instruction | Construction | Children |
| --- | --- | --- | --- |
| One-point crossover | 10|11 and 01|00 | First prefix + second tail; second prefix + first tail | 1000 and 0111 |
| Two-point crossover | 1|01|10 and 0|10|01 | Exchange only the middle blocks | 11010 and 00101 |
| Uniform crossover | A=1010, B=0101, mask=1100 | Child 1 takes A where mask=1 and B where mask=0; child 2 reverses this | 1001 and 0110 |
| Mutation | 1000; flip position 3 from left | The third bit is 0; replace it by 1; keep every other bit | 1010 |

These crossover operators are alternatives. Apply the operator stated in the question; do not apply all three in one generation. Mutation is a separate step after crossover in the worked exam workflow.

## Crossover combines; mutation changes

In **single-point crossover**, cut both parents after the specified bit. Child 1 keeps parent 1’s prefix and takes parent 2’s suffix; child 2 does the reverse. A cut after bit 2 in a four-bit string looks like 10|11.

**Cross parents 1011 and 0100 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 1011, 0100; cut after bit 2; mutation bit 4.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

10 | 11 and 01 | 00

##### Step 2. Exchange tails

10 + 00 → 1000  
01 + 11 → 0111

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 1000 | 0 | 1 | 1001 |
| 0111 | 1 | 0 | 0110 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 1001 | 8 + 0 + 0 + 1 | 9 |
| 0110 | 0 + 4 + 2 + 0 | 6 |

**Final answer.** Final children 1001 (9) and 0110 (6).

**Cross parents 0011 and 1100 after bit 1. Then flip bit 2 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 0011, 1100; cut after bit 1; mutation bit 2.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

0 | 011 and 1 | 100

##### Step 2. Exchange tails

0 + 100 → 0100  
1 + 011 → 1011

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 0100 | 1 | 0 | 0000 |
| 1011 | 0 | 1 | 1111 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 0000 | 0 + 0 + 0 + 0 | 0 |
| 1111 | 8 + 4 + 2 + 1 | 15 |

**Final answer.** Final children 0000 (0) and 1111 (15).

**Cross parents 1110 and 0001 after bit 3. Then flip bit 1 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 1110, 0001; cut after bit 3; mutation bit 1.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

111 | 0 and 000 | 1

##### Step 2. Exchange tails

111 + 1 → 1111  
000 + 0 → 0000

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 1111 | 1 | 0 | 0111 |
| 0000 | 0 | 1 | 1000 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 0111 | 0 + 4 + 2 + 1 | 7 |
| 1000 | 8 + 0 + 0 + 0 | 8 |

**Final answer.** Final children 0111 (7) and 1000 (8).

**Cross parents 1010 and 1010 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 1010, 1010; cut after bit 2; mutation bit 4.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

10 | 10 and 10 | 10

##### Step 2. Exchange tails

10 + 10 → 1010  
10 + 10 → 1010

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 1010 | 0 | 1 | 1011 |
| 1010 | 0 | 1 | 1011 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 1011 | 8 + 0 + 2 + 1 | 11 |
| 1011 | 8 + 0 + 2 + 1 | 11 |

**Final answer.** Final children 1011 (11) and 1011 (11).

**Two-point crossover** exchanges the segment between two cuts. **Uniform crossover** uses a given mask to choose, at each position, which parent contributes a gene. Mutation may flip a bit, perturb a real value, or swap two positions in a permutation. These are different operators; apply the one named in the question.

**Yaad rakho:** Crossover = tail exchange. Mutation = specified bit flip. Flip ka matlab 1 bhi 0 banega.

---

## M2 · GA architecture, two-generation flow, constraints and theory

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--algorithm/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/algorithm

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Feasible | Obeys every stated constraint | x≤10: x=9 qualifies; x=12 does not |
| Penalty | A deduction for violating a constraint | For maximisation, subtract 100×excess |
| Elitism | Explicitly preserve a best old individual | Only apply if the question specifies it |
| Replacement | Choose what population the next generation uses | Our full-replacement examples use the new children |
| Stopping condition | A rule ending the repeated process | Stop after two complete generations |

## A complete GA generation

Encode + evaluate

→

Select parents

→

Crossover

→

Mutation

→

Evaluate childrenreplace and repeat

A **simple generational GA** replaces the population in generations using a chosen encoding, selection rule and variation operators. A more general GA may use steady-state replacement, different encodings, adaptive operators or explicit elitism. Always state the choices used in your worked answer.

## What “iteration 2” means here

Initial population → first generation’s selection/crossover/mutation → new population → second generation’s selection/crossover/mutation → final population. Stopping after the first children and labelling them iteration 2 is not two full generations.

## Stopping conditions

Stop after a fixed generation budget, after reaching a specified acceptable objective, or after little improvement for a stated number of generations. A finite run does not prove the global optimum.

## Constraints

A **constraint** restricts allowed solutions, such as 0≤x≤15 or “visit every city once”. Common approaches are valid-by-design encoding, repairing an invalid child, rejecting it, or using a penalty. A penalty must reduce attractiveness: subtract it in maximisation or add it to a minimised cost. Do not silently remove the original constraint because you used more bits.

**A maximisation problem has objective f(x)=x² and constraint x≤10. The given penalised fitness is F(x)=x²−100 max(0,x−10). Compare x=9 and x=12.** [3 marks · Practice]

#### Given

Penalty coefficient 100; bound 10; candidates 9 and 12.

#### To find

Penalised fitness of both candidates.

#### Formula and why it applies

Only excess above the bound receives a penalty.

#### Solution

##### Step 1. Feasible candidate 9



$$
\max(0,9-10)=0
$$





$$
F(9)=81-100(0)=81
$$



##### Step 2. Infeasible candidate 12



$$
\max(0,12-10)=2
$$





$$
F(12)=144-100(2)=-56
$$



##### Step 3. Compare

For this maximisation fitness, 81 > −56, so x=9 is preferred. Raw objective alone would misleadingly favour 12.

**Final answer.** F(9)=81; F(12)=−56.

| Advantages | Limitations |
| --- | --- |
| Derivative-free; supports many encodings | Many objective evaluations may be costly |
| Population explores several candidates | Premature convergence is possible |
| Crossover and mutation can create new candidates | Parameter and encoding choices affect results |
| Applicable to discontinuous or combinatorial searches | No guaranteed global optimum; variation can worsen fitness |

**Yaad rakho:** Do generation = do baar poora cycle. Sirf children banana aur decode karna do alag iterations nahi.

---

## M2 · Two generations with given selection, cut and mutation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--two-generations/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/two-generations

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

Swipe across the diagram to read its labels ↔

![This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.](https://deep-learning-study-room.vercel.app/is2/fig/v2_ga_generation.fa7bf86c05.svg)

Diagram: This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.. Labels: One complete GA generation: read from top to bottom | Selected parents | 1010 × 1100 | Cut after bit 2 | Mark the cut | 10 | 10 11 | 00 | Keep prefix, exchange suffix | After crossover | 1000 1110 | Children are 8 and 14 | Flip the last bit | 1001 1111 | 0 becomes 1 in each child | Decode and evaluate | 9² = 81 15² = 225 | These are the children’s fitness values

This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.

**Maximise 

$$
f(x)=x^2
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [3, 5, 10, 12]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [1, 2, 3, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Current individual row numbers [3, 4, 4, 3] |
| 2 | Current individual row numbers [2, 3, 2, 3] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 3 | 0011 | 3 × 3 = 9 |
| 2 | 5 | 0101 | 5 × 5 = 25 |
| 3 | 10 | 1010 | 10 × 10 = 100 |
| 4 | 12 | 1100 | 12 × 12 = 144 |

##### Step 2. Generation 1: apply the supplied selection order

The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 3 | 10 | 1010 |
| 2 | 4 | 12 | 1100 |
| 3 | 4 | 12 | 1100 |
| 4 | 3 | 10 | 1010 |

##### Step 3. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 10 | 10 | 11 | 00 | 1000 | 1110 |
| 3 & 4 | 11 | 00 | 10 | 10 | 1110 | 1000 |

##### Step 4. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1000 | Flip bit 4 | 1001 |
| 2 | 1110 | Flip bit 4 | 1111 |
| 3 | 1110 | Flip bit 4 | 1111 |
| 4 | 1000 | Flip bit 4 | 1001 |

##### Step 5. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1001 | 8 + 0 + 0 + 1 = 9 | 9² = 81 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1001 | 8 + 0 + 0 + 1 = 9 | 9² = 81 |

##### Step 6. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{9+25+100+144}{4}=\frac{278}{4}=69.5
$$





$$
\overline f_{new}=\frac{81+225+225+81}{4}=\frac{612}{4}=153
$$



Best objective: 144 → 225. Higher is better. The next population is [9, 15, 15, 9]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 7. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 9 | 1001 | 9 × 9 = 81 |
| 2 | 15 | 1111 | 15 × 15 = 225 |
| 3 | 15 | 1111 | 15 × 15 = 225 |
| 4 | 9 | 1001 | 9 × 9 = 81 |

##### Step 8. Generation 2: apply the supplied selection order

The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 2 | 15 | 1111 |
| 2 | 3 | 15 | 1111 |
| 3 | 2 | 15 | 1111 |
| 4 | 3 | 15 | 1111 |

##### Step 9. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 11 | 11 | 11 | 11 | 1111 | 1111 |
| 3 & 4 | 11 | 11 | 11 | 11 | 1111 | 1111 |

##### Step 10. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1111 | Flip bit 4 | 1110 |
| 2 | 1111 | Flip bit 4 | 1110 |
| 3 | 1111 | Flip bit 4 | 1110 |
| 4 | 1111 | Flip bit 4 | 1110 |

##### Step 11. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |

##### Step 12. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{81+225+225+81}{4}=\frac{612}{4}=153
$$





$$
\overline f_{new}=\frac{196+196+196+196}{4}=\frac{784}{4}=196
$$



Best objective: 225 → 196. Higher is better. The next population is [14, 14, 14, 14]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [14, 14, 14, 14]. Best final objective = 196 at x = [14].

---

## M2 · Two generations including roulette selection

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--roulette-generations/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/roulette-generations

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

**Maximise 

$$
f(x)=x(15-x)+1
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [2, 5, 9, 12]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [2, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Random draws [0.1, 0.4, 0.65, 0.9] |
| 2 | Random draws [0.2, 0.4, 0.6, 0.95] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 2 | 0010 | 2 × (15 − 2) + 1 = 27 |
| 2 | 5 | 0101 | 5 × (15 − 5) + 1 = 51 |
| 3 | 9 | 1001 | 9 × (15 − 9) + 1 = 55 |
| 4 | 12 | 1100 | 12 × (15 − 12) + 1 = 37 |

##### Step 2. Generation 1: calculate roulette intervals

Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.



$$
\sum F=27+51+55+37\approx170
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 27 ÷ 170 ≈ 0.158823529 | 0 + 0.158823529 ≈ 0.158823529 |
| 2 | 51 ÷ 170 ≈ 0.3 | 0.158823529 + 0.3 ≈ 0.458823529 |
| 3 | 55 ÷ 170 ≈ 0.323529412 | 0.458823529 + 0.323529412 ≈ 0.782352941 |
| 4 | 37 ÷ 170 ≈ 0.217647059 | 0.782352941 + 0.217647059 ≈ 1 |

##### Step 3. Generation 1: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.1 | 0 ≤ 0.1 < 0.158823529 | 1 | 2 |
| 0.4 | 0.158823529 ≤ 0.4 < 0.458823529 | 2 | 5 |
| 0.65 | 0.458823529 ≤ 0.65 < 0.782352941 | 3 | 9 |
| 0.9 | 0.782352941 ≤ 0.9 < 1 | 4 | 12 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 4. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 00 | 10 | 01 | 01 | 0001 | 0110 |
| 3 & 4 | 10 | 01 | 11 | 00 | 1000 | 1101 |

##### Step 5. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 0001 | No mutation | 0001 |
| 2 | 0110 | Flip bit 4 | 0111 |
| 3 | 1000 | No mutation | 1000 |
| 4 | 1101 | Flip bit 4 | 1100 |

##### Step 6. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 0001 | 0 + 0 + 0 + 1 = 1 | 1(15−1)+1 = 15 |
| 0111 | 0 + 4 + 2 + 1 = 7 | 7(15−7)+1 = 57 |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8(15−8)+1 = 57 |
| 1100 | 8 + 4 + 0 + 0 = 12 | 12(15−12)+1 = 37 |

##### Step 7. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{27+51+55+37}{4}=\frac{170}{4}=42.5
$$





$$
\overline f_{new}=\frac{15+57+57+37}{4}=\frac{166}{4}=41.5
$$



Best objective: 55 → 57. Higher is better. The next population is [1, 7, 8, 12]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 8. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 1 | 0001 | 1 × (15 − 1) + 1 = 15 |
| 2 | 7 | 0111 | 7 × (15 − 7) + 1 = 57 |
| 3 | 8 | 1000 | 8 × (15 − 8) + 1 = 57 |
| 4 | 12 | 1100 | 12 × (15 − 12) + 1 = 37 |

##### Step 9. Generation 2: calculate roulette intervals

Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.



$$
\sum F=15+57+57+37\approx166
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 15 ÷ 166 ≈ 0.090361446 | 0 + 0.090361446 ≈ 0.090361446 |
| 2 | 57 ÷ 166 ≈ 0.343373494 | 0.090361446 + 0.343373494 ≈ 0.43373494 |
| 3 | 57 ÷ 166 ≈ 0.343373494 | 0.43373494 + 0.343373494 ≈ 0.777108434 |
| 4 | 37 ÷ 166 ≈ 0.222891566 | 0.777108434 + 0.222891566 ≈ 1 |

##### Step 10. Generation 2: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.2 | 0.090361446 ≤ 0.2 < 0.43373494 | 2 | 7 |
| 0.4 | 0.090361446 ≤ 0.4 < 0.43373494 | 2 | 7 |
| 0.6 | 0.43373494 ≤ 0.6 < 0.777108434 | 3 | 8 |
| 0.95 | 0.777108434 ≤ 0.95 < 1 | 4 | 12 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 11. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 01 | 11 | 01 | 11 | 0111 | 0111 |
| 3 & 4 | 10 | 00 | 11 | 00 | 1000 | 1100 |

##### Step 12. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 0111 | No mutation | 0111 |
| 2 | 0111 | Flip bit 4 | 0110 |
| 3 | 1000 | No mutation | 1000 |
| 4 | 1100 | Flip bit 4 | 1101 |

##### Step 13. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 0111 | 0 + 4 + 2 + 1 = 7 | 7(15−7)+1 = 57 |
| 0110 | 0 + 4 + 2 + 0 = 6 | 6(15−6)+1 = 55 |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8(15−8)+1 = 57 |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13(15−13)+1 = 27 |

##### Step 14. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{15+57+57+37}{4}=\frac{166}{4}=41.5
$$





$$
\overline f_{new}=\frac{57+55+57+27}{4}=\frac{196}{4}=49
$$



Best objective: 57 → 57. Higher is better. The next population is [7, 6, 8, 13]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [7, 6, 8, 13]. Best final objective = 57 at x = [7, 8].

---

## M2 · GA minimisation: transform cost before roulette selection

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--minimisation/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/ga-core/minimisation

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

Roulette favours a larger weight. A minimisation objective instead favours a smaller cost. The stated transformation F=1/(1+cost) reverses their order for nonnegative costs: cost 0 → weight 1/1=1; cost 3 → 1/4=.25; cost 24 → 1/25=.04. The +1 prevents division by zero. This is one specified transformation, not a universal rule for every minimisation problem.

**Minimise 

$$
f(x)=(x-7)^2
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [2, 4, 8, 12]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [2, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Random draws [0.1, 0.4, 0.65, 0.9] |
| 2 | Random draws [0.2, 0.4, 0.6, 0.95] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Roulette uses Fᵢ/ΣF. For minimisation here, use Fᵢ=1/(1+f(xᵢ)); do not directly favour large costs.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 2 | 0010 | (2 − 7)² = 25 |
| 2 | 4 | 0100 | (4 − 7)² = 9 |
| 3 | 8 | 1000 | (8 − 7)² = 1 |
| 4 | 12 | 1100 | (12 − 7)² = 25 |

##### Step 2. Generation 1: calculate roulette intervals

Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.

| Individual | Cost | Fitness calculation |
| --- | --- | --- |
| 1 | 25 | 1 / (1 + 25) = 1 / 26 ≈ 0.038461538 |
| 2 | 9 | 1 / (1 + 9) = 1 / 10 ≈ 0.1 |
| 3 | 1 | 1 / (1 + 1) = 1 / 2 ≈ 0.5 |
| 4 | 25 | 1 / (1 + 25) = 1 / 26 ≈ 0.038461538 |



$$
\sum F=0.038461538+0.1+0.5+0.038461538\approx0.676923077
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 0.038461538 ÷ 0.676923077 ≈ 0.056818182 | 0 + 0.056818182 ≈ 0.056818182 |
| 2 | 0.1 ÷ 0.676923077 ≈ 0.147727273 | 0.056818182 + 0.147727273 ≈ 0.204545455 |
| 3 | 0.5 ÷ 0.676923077 ≈ 0.738636364 | 0.204545455 + 0.738636364 ≈ 0.943181818 |
| 4 | 0.038461538 ÷ 0.676923077 ≈ 0.056818182 | 0.943181818 + 0.056818182 ≈ 1 |

##### Step 3. Generation 1: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.1 | 0.056818182 ≤ 0.1 < 0.204545455 | 2 | 4 |
| 0.4 | 0.204545455 ≤ 0.4 < 0.943181818 | 3 | 8 |
| 0.65 | 0.204545455 ≤ 0.65 < 0.943181818 | 3 | 8 |
| 0.9 | 0.204545455 ≤ 0.9 < 0.943181818 | 3 | 8 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 4. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 01 | 00 | 10 | 00 | 0100 | 1000 |
| 3 & 4 | 10 | 00 | 10 | 00 | 1000 | 1000 |

##### Step 5. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 0100 | No mutation | 0100 |
| 2 | 1000 | Flip bit 4 | 1001 |
| 3 | 1000 | No mutation | 1000 |
| 4 | 1000 | Flip bit 4 | 1001 |

##### Step 6. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 0100 | 0 + 4 + 0 + 0 = 4 | (4−7)² = 9 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |
| 1000 | 8 + 0 + 0 + 0 = 8 | (8−7)² = 1 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |

##### Step 7. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{25+9+1+25}{4}=\frac{60}{4}=15
$$





$$
\overline f_{new}=\frac{9+4+1+4}{4}=\frac{18}{4}=4.5
$$



Best objective: 1 → 1. Lower is better. The next population is [4, 9, 8, 9]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 8. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 4 | 0100 | (4 − 7)² = 9 |
| 2 | 9 | 1001 | (9 − 7)² = 4 |
| 3 | 8 | 1000 | (8 − 7)² = 1 |
| 4 | 9 | 1001 | (9 − 7)² = 4 |

##### Step 9. Generation 2: calculate roulette intervals

Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.

| Individual | Cost | Fitness calculation |
| --- | --- | --- |
| 1 | 9 | 1 / (1 + 9) = 1 / 10 ≈ 0.1 |
| 2 | 4 | 1 / (1 + 4) = 1 / 5 ≈ 0.2 |
| 3 | 1 | 1 / (1 + 1) = 1 / 2 ≈ 0.5 |
| 4 | 4 | 1 / (1 + 4) = 1 / 5 ≈ 0.2 |



$$
\sum F=0.1+0.2+0.5+0.2\approx1
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 0.1 ÷ 1 ≈ 0.1 | 0 + 0.1 ≈ 0.1 |
| 2 | 0.2 ÷ 1 ≈ 0.2 | 0.1 + 0.2 ≈ 0.3 |
| 3 | 0.5 ÷ 1 ≈ 0.5 | 0.3 + 0.5 ≈ 0.8 |
| 4 | 0.2 ÷ 1 ≈ 0.2 | 0.8 + 0.2 ≈ 1 |

##### Step 10. Generation 2: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.2 | 0.1 ≤ 0.2 < 0.3 | 2 | 9 |
| 0.4 | 0.3 ≤ 0.4 < 0.8 | 3 | 8 |
| 0.6 | 0.3 ≤ 0.6 < 0.8 | 3 | 8 |
| 0.95 | 0.8 ≤ 0.95 < 1 | 4 | 9 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 11. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 10 | 01 | 10 | 00 | 1000 | 1001 |
| 3 & 4 | 10 | 00 | 10 | 01 | 1001 | 1000 |

##### Step 12. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1000 | No mutation | 1000 |
| 2 | 1001 | Flip bit 4 | 1000 |
| 3 | 1001 | No mutation | 1001 |
| 4 | 1000 | Flip bit 4 | 1001 |

##### Step 13. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1000 | 8 + 0 + 0 + 0 = 8 | (8−7)² = 1 |
| 1000 | 8 + 0 + 0 + 0 = 8 | (8−7)² = 1 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |

##### Step 14. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{9+4+1+4}{4}=\frac{18}{4}=4.5
$$





$$
\overline f_{new}=\frac{1+1+4+4}{4}=\frac{10}{4}=2.5
$$



Best objective: 1 → 1. Lower is better. The next population is [8, 8, 9, 9]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [8, 8, 9, 9]. Best final objective = 1 at x = [8].

---

## M2 · Swarm intelligence, particles, velocity, pbest and gbest

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--meaning/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/pso-core/meaning

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

## Swarm intelligence

**Swarm intelligence** is collective problem-solving behaviour that emerges from interactions among many relatively simple agents and their environment. It is inspired by systems such as bird flocks, fish schools and ant colonies.

**Particle swarm optimization (PSO)** is a population-based search method inspired by social movement. Each particle represents a candidate solution. It moves through the search space using a velocity influenced by its own best previous position and the best position known to the swarm.

## Translate every PSO word into a concrete object

| Term | Meaning | Example |
| --- | --- | --- |
| Particle | One candidate solution | Particle A |
| Position x | The candidate’s coordinates | xA = 3 |
| Objective f(x) | The problem’s score for that candidate | f(3) = 3² = 9 |
| Velocity v | Proposed change of position | vA = −1 means move left by 1 |
| pbest | Best position that this particle has visited | A once visited x=1 with score 1 |
| gbest | Best position found by any particle | Among all personal bests, x=0.5 scores 0.25 |

Swipe across the diagram to read its labels ↔

![A best memory changes only when the new score improves.](https://deep-learning-study-room.vercel.app/is2/fig/v2_pso_memory.fcc9783a95.svg)

Diagram: A best memory changes only when the new score improves.. Labels: Best memory survives a worse move | Visit 1 | Position x = 3 | Score x² = 9 | Remember pbest = 3 | Visit 2 | Position x = 1 | Score x² = 1 | Remember pbest = 1 | Visit 3 | Position x = 2 | Score x² = 4 | Remember pbest = 1 | Minimise x²: after visiting x = 2, the best past position is still x = 1. | Current position and remembered best position are separate records.

A best memory changes only when the new score improves.

## Current position is not necessarily personal best

For minimising x², suppose a particle visits x=3, then x=1, then x=2. Its current position is 2, but its personal best stays 1 because 1² is less than 2². The particle remembers a better past result even after a bad move.

**A particle visits x=3, x=1, x=2 in that order while minimising f(x)=x². Find pbest after each visit.** [2 marks · Practice]

#### Given

Positions in chronological order: 3 → 1 → 2.

#### To find

The best-so-far position and score.

#### Formula and why it applies

Keep the location with the lowest objective encountered so far.

#### Solution

##### Step 1. First visit



$$
f(3)=9
$$



No history: pbest=3, best score=9.

##### Step 2. Second visit



$$
f(1)=1<9
$$



Replace pbest by 1.

##### Step 3. Third visit



$$
f(2)=4>1
$$



Keep pbest=1 even though the current position is 2.

**Final answer.** Final current position=2; pbest=1; personal-best score=1.

**Define swarm intelligence and briefly explain one nature-inspired algorithm.** [2 marks · Practice]

#### Answer

Swarm intelligence is collective problem-solving that emerges from interactions among simple agents. Particle swarm optimization is inspired by flocking behaviour. Each particle is a candidate solution with a position and velocity. It remembers its own best position and uses the swarm’s best position to guide movement. Repeated evaluation and movement search for a low-cost or high-fitness solution.

**Yaad rakho:** Position abhi kahan ho; pbest apna best past; gbest sabka best past.

---

## M2 · Read the PSO equation and work three individual updates

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--equation/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/pso-core/equation

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

## First read the update in words

**New velocity = retained old velocity + pull toward personal best + pull toward the group best.** After finding that velocity, add it to the old position. You are calculating a movement, then applying it.

Swipe across the diagram to read its labels ↔

![A negative difference pulls toward a best position on the left.](https://deep-learning-study-room.vercel.app/is2/fig/depth_pso.88e9c2a672.svg)

Diagram: A negative difference pulls toward a best position on the left.. Labels: Read the direction before multiplying the pull | Best = 1 | Current = 4 | difference = 1 − 4 = −3 | coefficient 0.5 → pull 0.5 × (−3) = −1.5 (left)

A negative difference pulls toward a best position on the left.

Example: current x=4 and personal best=1 gives the difference 1−4=−3. A coefficient of .5 gives personal pull .5×(−3)=−1.5. The negative sign says “move left”; it does not mean a negative probability. If current x=−2 and best=1, the difference is 1−(−2)=1+2=3, which pulls right.

In vi,jt, i chooses the particle, j chooses its coordinate, and t chooses the recorded iteration. For particle B, coordinate 2, iteration 0, look at row B and the second velocity entry in the initial table. The letters identify a stored number; they are not extra multiplication factors.

## The velocity equation is three contributions added together



$$
v_{i,j}^{t+1}=w v_{i,j}^{t}+c_1r_1(pbest_{i,j}^{t}-x_{i,j}^{t})+c_2r_2(gbest_j^{t}-x_{i,j}^{t})
$$





$$
x_{i,j}^{t+1}=x_{i,j}^{t}+v_{i,j}^{t+1}
$$



| Symbol | Meaning |
| --- | --- |
| i | Which particle |
| j | Which coordinate of that particle |
| t / t+1 | Before / after this iteration; these are labels, not powers |
| w | Inertia weight: how much old velocity is kept |
| c₁r₁ | Combined strength of the pull to personal best |
| c₂r₂ | Combined strength of the pull to global best |
| r₁,r₂ | Random factors, normally in [0,1]; use the values supplied in an exam |

A best position to the left gives a negative difference and pulls left; a best position to the right gives a positive difference and pulls right. The multiplication sets the strength of each pull.

**For one coordinate, x=4, v=0, pbest=4, gbest=2. With w=0.5, c₁=c₂=1 and r₁=r₂=0.5, find the next velocity and position.** [3 marks · Practice]

#### Given

x=4, v=0, pbest=4, gbest=2; w=.5; c₁r₁=.5; c₂r₂=.5.

#### To find

New velocity followed by new position.

#### Formula and why it applies

Use the three-term velocity equation, then add the new velocity to x.



$$
v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)
$$



#### Solution

##### Step 1. Inertia



$$
0.5\times0=0
$$



##### Step 2. Personal pull



$$
0.5(4-(4))=0
$$



##### Step 3. Social pull



$$
0.5(2-(4))=-1
$$



##### Step 4. New velocity



$$
v_{new}=0+0+(-1)=-1
$$



##### Step 5. New position



$$
x_{new}=4+(-1)=3
$$



**Final answer.** vnew=-1; xnew=3.

**For one coordinate, x=4, v=-2, pbest=3, gbest=1. With w=0.5, c₁=c₂=1 and r₁=r₂=0.5, find the next velocity and position.** [3 marks · Practice]

#### Given

x=4, v=-2, pbest=3, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.

#### To find

New velocity followed by new position.

#### Formula and why it applies

Use the three-term velocity equation, then add the new velocity to x.



$$
v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)
$$



#### Solution

##### Step 1. Inertia



$$
0.5\times(-2)=-1
$$



##### Step 2. Personal pull



$$
0.5(3-(4))=-0.5
$$



##### Step 3. Social pull



$$
0.5(1-(4))=-1.5
$$



##### Step 4. New velocity



$$
v_{new}=(-1)+(-0.5)+(-1.5)=-3
$$



##### Step 5. New position



$$
x_{new}=4+(-3)=1
$$



**Final answer.** vnew=-3; xnew=1.

**For one coordinate, x=-2, v=1, pbest=-1, gbest=1. With w=0.5, c₁=c₂=1 and r₁=r₂=0.5, find the next velocity and position.** [3 marks · Practice]

#### Given

x=-2, v=1, pbest=-1, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.

#### To find

New velocity followed by new position.

#### Formula and why it applies

Use the three-term velocity equation, then add the new velocity to x.



$$
v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)
$$



#### Solution

##### Step 1. Inertia



$$
0.5\times1=0.5
$$



##### Step 2. Personal pull



$$
0.5(-1-(-2))=0.5
$$



##### Step 3. Social pull



$$
0.5(1-(-2))=1.5
$$



##### Step 4. New velocity



$$
v_{new}=0.5+0.5+1.5=2.5
$$



##### Step 5. New position



$$
x_{new}=(-2)+2.5=0.5
$$



**Final answer.** vnew=2.5; xnew=0.5.

**First-iteration shortcut:** if pbest was just initialised to x, the personal difference is zero. This follows from the initialisation; it is not a permanent property of PSO. A gbest particle can still move because its inertia term can be nonzero.

**Yaad rakho:** Old speed ka hissa + apne best ki pull + group best ki pull; phir new speed ko position mein add.

---

## M2 · Two particles, two iterations: start with the simplest minimisation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--two-particles/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/pso-core/two-particles

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

A synchronous iteration is a class photograph of the old swarm: every particle uses that same snapshot of gbest. First calculate all new positions, then compare all new scores and update memories. If particle A discovers a better position halfway through the calculations, B still uses the previous snapshot during this iteration. B can use the improved gbest in the next iteration.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

**Minimise 

$$
f(x)=x^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (-2) | (0) |
| B | (4) | (0) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(-2)=(-2)^2=4=4
$$



**Particle B**



$$
f(4)=4^2=16=16
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(-2)
$$



Its score is 4. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (-2). pbest values are A: (-2), B: (4).

##### Step 4. Iteration 1: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=-2-(-2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-2-(-2)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=(-2)+0=-2
$$



##### Step 5. Iteration 1: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=4-(4)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-2-(4)=-6
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-6)=-3
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-3)=-3
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=4+(-3)=1
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(-2)=(-2)^2=4=4
$$



**Particle B**



$$
f(1)=1^2=1=1
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 4 | 4 | Keep old: tie | (-2) |
| B | 16 | 1 | Replace: new score is lower | (1) |

Compare the retained pbest scores. gbest = **(1)**, with objective **1**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (-2) | (0) | (-2) |
| B | (1) | (-3) | (1) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (-2), B: (1).

##### Step 10. Iteration 2: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=-2-(-2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(-2)=3
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(3)=1.5
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+1.5=1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=(-2)+1.5=-0.5
$$



##### Step 11. Iteration 2: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-3)=-1.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=(-1.5)+0+0=-1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1+(-1.5)=-0.5
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(-0.5)=(-0.5)^2=0.25=0.25
$$



**Particle B**



$$
f(-0.5)=(-0.5)^2=0.25=0.25
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 4 | 0.25 | Replace: new score is lower | (-0.5) |
| B | 1 | 0.25 | Replace: new score is lower | (-0.5) |

Compare the retained pbest scores. gbest = **(-0.5)**, with objective **0.25**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (-0.5) | (1.5) | (-0.5) |
| B | (-0.5) | (-1.5) | (-0.5) |

**Final answer.** After iteration 2, gbest = (-0.5), objective = 0.25. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

---

## M2 · A worse move: pbest stays in the past

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--memory-matters/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/pso-core/memory-matters

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

**Minimise 

$$
f(x)=x^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (1) | (4) |
| B | (3) | (-1) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(1)=1^2=1=1
$$



**Particle B**



$$
f(3)=3^2=9=9
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(1)
$$



Its score is 1. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (1), B: (3).

##### Step 4. Iteration 1: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times4=2
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=2+0+0=2
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=1+2=3
$$



##### Step 5. Iteration 1: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1)=-0.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3-(3)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(3)=-2
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-2)=-1
$$



Add the three velocity contributions.



$$
v^{(1)}=(-0.5)+0+(-1)=-1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=3+(-1.5)=1.5
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(3)=3^2=9=9
$$



**Particle B**



$$
f(1.5)=1.5^2=2.25=2.25
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 9 | Keep old: new score is worse | (1) |
| B | 9 | 2.25 | Replace: new score is lower | (1.5) |

Compare the retained pbest scores. gbest = **(1)**, with objective **1**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (3) | (2) | (1) |
| B | (1.5) | (-1.5) | (1.5) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (1), B: (1.5).

##### Step 10. Iteration 2: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times2=1
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(3)=-2
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(-2)=-1
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(3)=-2
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-2)=-1
$$



Add the three velocity contributions.



$$
v^{(2)}=1+(-1)+(-1)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=3+(-1)=2
$$



##### Step 11. Iteration 2: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1.5)=-0.75
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1.5-(1.5)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1.5)=-0.5
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-0.5)=-0.25
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.75)+0+(-0.25)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1.5+(-1)=0.5
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(2)=2^2=4=4
$$



**Particle B**



$$
f(0.5)=0.5^2=0.25=0.25
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 4 | Keep old: new score is worse | (1) |
| B | 2.25 | 0.25 | Replace: new score is lower | (0.5) |

Compare the retained pbest scores. gbest = **(0.5)**, with objective **0.25**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (2) | (-1) | (1) |
| B | (0.5) | (-1) | (0.5) |

**Final answer.** After iteration 2, gbest = (0.5), objective = 0.25. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

**Yaad rakho:** Naya result kharab ho toh position toh badlegi, pbest nahi.

---

## M2 · Two-dimensional PSO: keep the coordinates separate

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--two-coordinates/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/pso-core/two-coordinates

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

A two-dimensional particle has two entries in its position and two in its velocity. Apply the scalar velocity calculation once to coordinate 1 and once to coordinate 2. Keep them in the same order to form the new pair. Only after both entries are ready do you insert the pair into f(x₁,x₂). Adding x₁ and x₂ into a single position would lose information.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

**Minimise 

$$
f(x)=x_1^2+x_2^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (1, 1) | (0, 0) |
| B | (3, 2) | (0, 0) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



**Particle B**



$$
f(3, 2)=3^2+2^2=9+4=13
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(1, 1)
$$



Its score is 2. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (3, 2).

##### Step 4. Iteration 1: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=1+0=1
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=1+0=1
$$



##### Step 5. Iteration 1: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3-(3)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(3)=-2
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-2)=-1
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-1)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=3+(-1)=2
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=2-(2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(2)=-1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-1)=-0.5
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-0.5)=-0.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=2+(-0.5)=1.5
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



**Particle B**



$$
f(2, 1.5)=2^2+1.5^2=4+2.25=6.25
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 2 | 2 | Keep old: tie | (1, 1) |
| B | 13 | 6.25 | Replace: new score is lower | (2, 1.5) |

Compare the retained pbest scores. gbest = **(1, 1)**, with objective **2**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (1, 1) | (0, 0) | (1, 1) |
| B | (2, 1.5) | (-1, -0.5) | (2, 1.5) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (2, 1.5).

##### Step 10. Iteration 2: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1+0=1
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1+0=1
$$



##### Step 11. Iteration 2: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1)=-0.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=2-(2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(2)=-1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-1)=-0.5
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.5)+0+(-0.5)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=2+(-1)=1
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-0.5)=-0.25
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1.5-(1.5)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1.5)=-0.5
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-0.5)=-0.25
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.25)+0+(-0.25)=-0.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1.5+(-0.5)=1
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



**Particle B**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 2 | 2 | Keep old: tie | (1, 1) |
| B | 6.25 | 2 | Replace: new score is lower | (1, 1) |

Compare the retained pbest scores. gbest = **(1, 1)**, with objective **2**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (1, 1) | (0, 0) | (1, 1) |
| B | (1, 1) | (-1, -0.5) | (1, 1) |

**Final answer.** After iteration 2, gbest = (1, 1), objective = 2. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

---

## M2 · Class PSO photograph: all three particles through iteration 2

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--class-three-particles/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/pso-core/class-three-particles

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

The positions, velocities and coefficients are transcribed from the class photo. We use f(x₁,x₂)=x₁²+x₂²−x₁x₂, minimisation, initial pbest=x, fixed supplied random factors and synchronous updates. The photo does not itself specify all these conventions; they are stated here to make the two-iteration extension unambiguous.

**Minimise 

$$
f(x)=x_1^2+x_2^2-x_1x_2
$$

 using 3 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [10 marks · Class data; two-iteration minimisation extension]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (3.14, 7.21) | (0.1, 0.3) |
| B | (4.15, 7.31) | (0.5, 0.1) |
| C | (6.17, 8.27) | (0.2, 0) |

w=0.5, c₁=1.2, c₂=1.2, r₁=0.5, r₂=0.1. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(3.14, 7.21)=3.14^2+7.21^2-(3.14)(7.21)
$$





$$
=9.8596+51.9841-22.6394=39.2043
$$



**Particle B**



$$
f(4.15, 7.31)=4.15^2+7.31^2-(4.15)(7.31)
$$





$$
=17.2225+53.4361-30.3365=40.3221
$$



**Particle C**



$$
f(6.17, 8.27)=6.17^2+8.27^2-(6.17)(8.27)
$$





$$
=38.0689+68.3929-51.0259=55.4359
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(3.14, 7.21)
$$



Its score is 39.2043. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (3.14, 7.21). pbest values are A: (3.14, 7.21), B: (4.15, 7.31), C: (6.17, 8.27).

##### Step 4. Iteration 1: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.1=0.05
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3.14-(3.14)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(3.14)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0.05+0+0=0.05
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=3.14+0.05=3.19
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.3=0.15
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.21-(7.21)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.21)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0.15+0+0=0.15
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=7.21+0.15=7.36
$$



##### Step 5. Iteration 1: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.5=0.25
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=4.15-(4.15)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(4.15)=-1.01
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-1.01)=-0.1212
$$



Add the three velocity contributions.



$$
v^{(1)}=0.25+0+(-0.1212)=0.1288
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=4.15+0.1288=4.2788
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.1=0.05
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.31-(7.31)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.31)=-0.1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.1)=-0.012
$$



Add the three velocity contributions.



$$
v^{(1)}=0.05+0+(-0.012)=0.038
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=7.31+0.038=7.348
$$



##### Step 6. Iteration 1: update particle C

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.2=0.1
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=6.17-(6.17)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(6.17)=-3.03
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-3.03)=-0.3636
$$



Add the three velocity contributions.



$$
v^{(1)}=0.1+0+(-0.3636)=-0.2636
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=6.17+(-0.2636)=5.9064
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=8.27-(8.27)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(8.27)=-1.06
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-1.06)=-0.1272
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-0.1272)=-0.1272
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=8.27+(-0.1272)=8.1428
$$



##### Step 7. Iteration 1: evaluate the new positions

**Particle A**



$$
f(3.19, 7.36)=3.19^2+7.36^2-(3.19)(7.36)
$$





$$
=10.1761+54.1696-23.4784=40.8673
$$



**Particle B**



$$
f(4.2788, 7.348)=4.2788^2+7.348^2-(4.2788)(7.348)
$$





$$
=18.30812944+53.993104-31.4406224=40.86061104
$$



**Particle C**



$$
f(5.9064, 8.1428)=5.9064^2+8.1428^2-(5.9064)(8.1428)
$$





$$
=34.88556096+66.30519184-48.09463392=53.09611888
$$



##### Step 8. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 39.2043 | 40.8673 | Keep old: new score is worse | (3.14, 7.21) |
| B | 40.3221 | 40.86061104 | Keep old: new score is worse | (4.15, 7.31) |
| C | 55.4359 | 53.09611888 | Replace: new score is lower | (5.9064, 8.1428) |

Compare the retained pbest scores. gbest = **(3.14, 7.21)**, with objective **39.2043**.

##### Step 9. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (3.19, 7.36) | (0.05, 0.15) | (3.14, 7.21) |
| B | (4.2788, 7.348) | (0.1288, 0.038) | (4.15, 7.31) |
| C | (5.9064, 8.1428) | (-0.2636, -0.1272) | (5.9064, 8.1428) |

##### Step 10. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (3.14, 7.21). pbest values are A: (3.14, 7.21), B: (4.15, 7.31), C: (5.9064, 8.1428).

##### Step 11. Iteration 2: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.05=0.025
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3.14-(3.19)=-0.05
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.05)=-0.03
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(3.19)=-0.05
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.05)=-0.006
$$



Add the three velocity contributions.



$$
v^{(2)}=0.025+(-0.03)+(-0.006)=-0.011
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=3.19+(-0.011)=3.179
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.15=0.075
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.21-(7.36)=-0.15
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.15)=-0.09
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.36)=-0.15
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.15)=-0.018
$$



Add the three velocity contributions.



$$
v^{(2)}=0.075+(-0.09)+(-0.018)=-0.033
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=7.36+(-0.033)=7.327
$$



##### Step 12. Iteration 2: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.1288=0.0644
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=4.15-(4.2788)=-0.1288
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.1288)=-0.07728
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(4.2788)=-1.1388
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-1.1388)=-0.136656
$$



Add the three velocity contributions.



$$
v^{(2)}=0.0644+(-0.07728)+(-0.136656)=-0.149536
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=4.2788+(-0.149536)=4.129264
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.038=0.019
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.31-(7.348)=-0.038
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.038)=-0.0228
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.348)=-0.138
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.138)=-0.01656
$$



Add the three velocity contributions.



$$
v^{(2)}=0.019+(-0.0228)+(-0.01656)=-0.02036
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=7.348+(-0.02036)=7.32764
$$



##### Step 13. Iteration 2: update particle C

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-0.2636)=-0.1318
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=5.9064-(5.9064)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(5.9064)=-2.7664
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-2.7664)=-0.331968
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.1318)+0+(-0.331968)=-0.463768
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=5.9064+(-0.463768)=5.442632
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-0.1272)=-0.0636
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=8.1428-(8.1428)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(8.1428)=-0.9328
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.9328)=-0.111936
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.0636)+0+(-0.111936)=-0.175536
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=8.1428+(-0.175536)=7.967264
$$



##### Step 14. Iteration 2: evaluate the new positions

**Particle A**



$$
f(3.179, 7.327)=3.179^2+7.327^2-(3.179)(7.327)
$$





$$
=10.106041+53.684929-23.292533=40.498437
$$



**Particle B**



$$
f(4.129264, 7.32764)=4.129264^2+7.32764^2-(4.129264)(7.32764)
$$





$$
=17.050821182+53.69430797-30.257760057=40.487369094
$$



**Particle C**



$$
f(5.442632, 7.967264)=5.442632^2+7.967264^2-(5.442632)(7.967264)
$$





$$
=29.622243087+63.477295646-43.362885999=49.736652734
$$



##### Step 15. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 39.2043 | 40.498437 | Keep old: new score is worse | (3.14, 7.21) |
| B | 40.3221 | 40.487369094 | Keep old: new score is worse | (4.15, 7.31) |
| C | 53.09611888 | 49.736652734 | Replace: new score is lower | (5.442632, 7.967264) |

Compare the retained pbest scores. gbest = **(3.14, 7.21)**, with objective **39.2043**.

##### Step 16. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (3.179, 7.327) | (-0.011, -0.033) | (3.14, 7.21) |
| B | (4.129264, 7.32764) | (-0.149536, -0.02036) | (4.15, 7.31) |
| C | (5.442632, 7.967264) | (-0.463768, -0.175536) | (5.442632, 7.967264) |

**Final answer.** After iteration 2, gbest = (3.14, 7.21), objective = 39.2043. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

Swipe across the diagram to read its labels ↔

![Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.](https://deep-learning-study-room.vercel.app/is2/fig/v2_pso_class_paths.961831cda1.svg)

Diagram: Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.. Labels: 3 | 3.5 | 4 | 4.5 | 5 | 5.5 | 6 | 6.5 | 7 | 7.5 | 8 | 8.5 | Class PSO: positions after each iteration | 0 = initial, 1 = iteration 1, 2 = iteration 2 | A0 | A1 | A2 | B0 | B1 | B2 | C0 | C1 | C2 | First coordinate x₁ | The best-so-far location remains A0 = (3.14, 7.21) after both iterations.

Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.

---

## M2 · PSO algorithm, architecture, advantages and limitations

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--theory/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/pso-core/theory

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

## Algorithm you can write in an exam

1. Define the objective and whether to minimise or maximise it. Initialise particle positions and velocities.
2. Evaluate every particle. Set each pbest to its initial position and gbest to the best among them.
3. Use the previous state to calculate each new velocity.
4. Update each position using that new velocity. Apply bounds or a velocity limit only according to the stated policy.
5. Evaluate the new positions. Update a pbest only when the new objective is better; choose gbest from the personal bests.
6. Repeat until the iteration budget or another stopping criterion is reached.

Initialise

→

Evaluate + memories

→

Velocity

→

Position

→

Evaluate + update memoriesrepeat until stopping

| Advantages | Limitations |
| --- | --- |
| Simple position/velocity updates; does not require objective derivatives | Can converge prematurely to a local region |
| Uses both individual and shared experience | Results depend on coefficients, initialisation and random factors |
| Useful for many continuous optimisation problems | Constraints and discrete encodings need suitable handling |
| Keeps best-so-far memories | Does not guarantee the global optimum in a finite run |

**Explain one application of PSO.** [3 marks · Practice]

#### Answer

In controller tuning, a particle can represent the gain values of a controller. The objective is a performance cost, such as tracking error plus an overshoot penalty. Each proposed gain vector is evaluated in the model. PSO updates candidate gains using individual and swarm bests. The best feasible gains found are selected and then validated on the actual system. A lower training cost alone does not prove safe real-world behaviour.

| Exam situation | Action |
| --- | --- |
| Minimisation | Lower f is better |
| Maximisation | Higher f is better; do not reverse velocity differences |
| Tie in best score | Keep the previous best unless a tie rule is supplied |
| Different random factors each iteration | Read the relevant row; do not reuse old factors |
| Synchronous update | Freeze gbest for all particles within one iteration |
| Position/velocity outside a limit | Use the limit-handling rule explicitly supplied; state an assumption if absent |

**Yaad rakho:** Velocity → position → score → pbest → gbest. Ye order har iteration mein same.

---

## M2 · Cartesian product: every cell explained

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-relations--cartesian/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-relations/cartesian

Longer Unit 2 numerical practice, also useful for TEE.

## How a row membership and a column membership meet

Let A₁=.6 and A₂=.2 label two rows. Let B₁=.3, B₂=.8 and B₃=.5 label three columns. Cell R₂₃ belongs to row 2 and column 3, so use A₂=.2 and B₃=.5. Their min is .2. You do not multiply 2×3; those subscripts only locate the cell.



$$
R_{23}=\min(A_2,B_3)=\min(0.2,0.5)=0.2
$$



There are two choices of row and three of column, so fill six cells in a 2×3 rectangle. Keep the row and column labels when reporting a relation.

## What is a fuzzy relation?

A fuzzy set gives a membership to one element. A **fuzzy relation** gives a degree to an ordered pair. A matrix is a convenient table: rows name the first element and columns name the second.

For the standard min-based Cartesian product R=A×B, put the A memberships down the rows and the B memberships across the columns. Each cell is the smaller of its row and column memberships.



$$
R_{ij}=\min(\mu_A(a_i),\mu_B(b_j))
$$



**Find the fuzzy Cartesian product A×B for memberships A=[0.6, 0.2] and B=[0.3, 0.8, 0.5].** [3 marks · Practice]

#### Given

Ordered A memberships [0.6, 0.2]; B memberships [0.3, 0.8, 0.5].

#### To find

A 2×3 relation matrix.

#### Formula and why it applies

Every row corresponds to an A element and every column to a B element; apply min in every cell.



$$
R_{ij}=\min(A_i,B_j)
$$



#### Solution

##### Step 1. Determine dimensions

2 row elements × 3 column elements.

##### Step 2. Compute each cell

| A ↓ / B → | 0.3 | 0.8 | 0.5 |
| --- | --- | --- | --- |
| 0.6 | min(0.6,0.3) = 0.3 | min(0.6,0.8) = 0.6 | min(0.6,0.5) = 0.5 |
| 0.2 | min(0.2,0.3) = 0.2 | min(0.2,0.8) = 0.2 | min(0.2,0.5) = 0.2 |

##### Step 3. Write the matrix



$$
R=\begin{bmatrix}0.3&0.6&0.5\\0.2&0.2&0.2\end{bmatrix}
$$



**Final answer.** R is the matrix in Step 3.

**Find the fuzzy Cartesian product A×B for memberships A=[1, 0.4] and B=[0.7, 0].** [3 marks · Practice]

#### Given

Ordered A memberships [1, 0.4]; B memberships [0.7, 0].

#### To find

A 2×2 relation matrix.

#### Formula and why it applies

Every row corresponds to an A element and every column to a B element; apply min in every cell.



$$
R_{ij}=\min(A_i,B_j)
$$



#### Solution

##### Step 1. Determine dimensions

2 row elements × 2 column elements.

##### Step 2. Compute each cell

| A ↓ / B → | 0.7 | 0 |
| --- | --- | --- |
| 1 | min(1,0.7) = 0.7 | min(1,0) = 0 |
| 0.4 | min(0.4,0.7) = 0.4 | min(0.4,0) = 0 |

##### Step 3. Write the matrix



$$
R=\begin{bmatrix}0.7&0\\0.4&0\end{bmatrix}
$$



**Final answer.** R is the matrix in Step 3.

**Find the fuzzy Cartesian product A×B for memberships A=[0.2, 0.9, 0.5] and B=[0.6, 0.1].** [3 marks · Practice]

#### Given

Ordered A memberships [0.2, 0.9, 0.5]; B memberships [0.6, 0.1].

#### To find

A 3×2 relation matrix.

#### Formula and why it applies

Every row corresponds to an A element and every column to a B element; apply min in every cell.



$$
R_{ij}=\min(A_i,B_j)
$$



#### Solution

##### Step 1. Determine dimensions

3 row elements × 2 column elements.

##### Step 2. Compute each cell

| A ↓ / B → | 0.6 | 0.1 |
| --- | --- | --- |
| 0.2 | min(0.2,0.6) = 0.2 | min(0.2,0.1) = 0.1 |
| 0.9 | min(0.9,0.6) = 0.6 | min(0.9,0.1) = 0.1 |
| 0.5 | min(0.5,0.6) = 0.5 | min(0.5,0.1) = 0.1 |

##### Step 3. Write the matrix



$$
R=\begin{bmatrix}0.2&0.1\\0.6&0.1\\0.5&0.1\end{bmatrix}
$$



**Final answer.** R is the matrix in Step 3.

**Yaad rakho:** Row ka degree aur column ka degree—dono ka min us cell mein.

---

## M2 · Max–min composition: three complete matrix examples

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-relations--composition/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/read/fuzzy-relations/composition

Longer Unit 2 numerical practice, also useful for TEE.

## One result cell combines alternative two-link paths

For T₁₁, start at u₁ and end at w₁. If the middle domain has v₁ and v₂, there are two candidate paths. Their strengths come from matching row 1 of R with column 1 of S.

| Path | First link from R | Second link from S | Path strength |
| --- | --- | --- | --- |
| u₁ → v₁ → w₁ | .2 | .5 | min(.2,.5)=.2 |
| u₁ → v₂ → w₁ | .8 | .7 | min(.8,.7)=.7 |

Choose the stronger path: max(.2,.7)=.7, so T₁₁=.7. The middle label j runs through v₁ and v₂. The labels i and k stay fixed at 1 while this one cell is calculated. Then move to the next result cell.

**Yaad rakho:** Ek path mein dono links chahiye, isliye min. Alag paths mein best chalega, isliye max.

## Composition connects through a middle element

Suppose R relates U to V and S relates V to W. To find how strongly u connects to w through each middle v, take min of the two links. Then choose the strongest such path using max.



$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$



We call this matrix operation R composed with S here. Some books write the symbolic order in reverse. State the formula and row/column labels, especially when a question says S∘R. Composition requires the intermediate domains and their ordering to match; having two 3×3 matrices alone does not prove their labels match.

**Calculate the max–min composition using 

$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$

.** [3 marks · Practice]

#### Given



$$
R=\begin{bmatrix}0.2&0.8\\0.6&0.3\end{bmatrix}
$$





$$
S=\begin{bmatrix}0.5&0.9\\0.7&0.1\end{bmatrix}
$$



#### To find

Every entry of T.

#### Formula and why it applies

Pair each row entry with the corresponding column entry; min for a two-link path, max across the possible middle elements. This is not ordinary matrix multiplication.

#### Solution

##### Step 1. Cell (1,1): row 1 of R with column 1 of S



$$
T_{11}=\max\{\min(0.2,0.5),\min(0.8,0.7)\}
$$





$$
=\max\{0.2,0.7\}=0.7
$$



##### Step 2. Cell (1,2): row 1 of R with column 2 of S



$$
T_{12}=\max\{\min(0.2,0.9),\min(0.8,0.1)\}
$$





$$
=\max\{0.2,0.1\}=0.2
$$



##### Step 3. Cell (2,1): row 2 of R with column 1 of S



$$
T_{21}=\max\{\min(0.6,0.5),\min(0.3,0.7)\}
$$





$$
=\max\{0.5,0.3\}=0.5
$$



##### Step 4. Cell (2,2): row 2 of R with column 2 of S



$$
T_{22}=\max\{\min(0.6,0.9),\min(0.3,0.1)\}
$$





$$
=\max\{0.6,0.1\}=0.6
$$



**Final answer.** 

$$
T=\begin{bmatrix}0.7&0.2\\0.5&0.6\end{bmatrix}
$$

.

**Calculate the max–min composition using 

$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$

.** [3 marks · Practice]

#### Given



$$
R=\begin{bmatrix}1&0\\0.4&0.7\end{bmatrix}
$$





$$
S=\begin{bmatrix}0.2&0.6\\0.8&0.3\end{bmatrix}
$$



#### To find

Every entry of T.

#### Formula and why it applies

Pair each row entry with the corresponding column entry; min for a two-link path, max across the possible middle elements. This is not ordinary matrix multiplication.

#### Solution

##### Step 1. Cell (1,1): row 1 of R with column 1 of S



$$
T_{11}=\max\{\min(1,0.2),\min(0,0.8)\}
$$





$$
=\max\{0.2,0\}=0.2
$$



##### Step 2. Cell (1,2): row 1 of R with column 2 of S



$$
T_{12}=\max\{\min(1,0.6),\min(0,0.3)\}
$$





$$
=\max\{0.6,0\}=0.6
$$



##### Step 3. Cell (2,1): row 2 of R with column 1 of S



$$
T_{21}=\max\{\min(0.4,0.2),\min(0.7,0.8)\}
$$





$$
=\max\{0.2,0.7\}=0.7
$$



##### Step 4. Cell (2,2): row 2 of R with column 2 of S



$$
T_{22}=\max\{\min(0.4,0.6),\min(0.7,0.3)\}
$$





$$
=\max\{0.4,0.3\}=0.4
$$



**Final answer.** 

$$
T=\begin{bmatrix}0.2&0.6\\0.7&0.4\end{bmatrix}
$$

.

**Calculate the max–min composition using 

$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$

.** [3 marks · Practice]

#### Given



$$
R=\begin{bmatrix}0.3&0.6&0.9\end{bmatrix}
$$





$$
S=\begin{bmatrix}0.8&0.1\\0.2&0.7\\0.5&0.4\end{bmatrix}
$$



#### To find

Every entry of T.

#### Formula and why it applies

Pair each row entry with the corresponding column entry; min for a two-link path, max across the possible middle elements. This is not ordinary matrix multiplication.

#### Solution

##### Step 1. Cell (1,1): row 1 of R with column 1 of S



$$
T_{11}=\max\{\min(0.3,0.8),\min(0.6,0.2),\min(0.9,0.5)\}
$$





$$
=\max\{0.3,0.2,0.5\}=0.5
$$



##### Step 2. Cell (1,2): row 1 of R with column 2 of S



$$
T_{12}=\max\{\min(0.3,0.1),\min(0.6,0.7),\min(0.9,0.4)\}
$$





$$
=\max\{0.1,0.6,0.4\}=0.6
$$



**Final answer.** 

$$
T=\begin{bmatrix}0.5&0.6\end{bmatrix}
$$

.

**Yaad rakho:** Har path mein min, phir saare paths mein max. Multiply-and-add nahi.

---

## M2 · Fuzzy formulas, with meanings and worked-example links

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/formulas/m2-formulas-v2--fuzzy/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/formulas/m2-formulas-v2/fuzzy

One place for the formulas, meanings, conditions and links to full worked examples.

## Fuzzy formulas

### Triangular membership



$$
\mu(x)=\max\left(0,\min\left(\frac{x-a}{b-a},\frac{c-x}{c-b}\right)\right)
$$



a=left zero, b=peak, c=right zero, with a<b<c. Locate x before choosing the rising/falling branch.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--triangle/)

### Union and intersection



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\quad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$



Compare memberships at the same element. These formulas use standard max–min operations.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--set-operations/)

### Complement and difference



$$
\mu_{A^c}=1-\mu_A\quad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



A difference means A AND NOT B; it is not ordinary subtraction.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--set-operations/)

### Rule strength, clipping and aggregation



$$
\alpha_r=\min(a_r,b_r)\quad\mu_r(z)=\min(\alpha_r,\mu_{C_r}(z))\quad\mu_{out}(z)=\max_r\mu_r(z)
$$



a,b are input degrees; α is the strength; z is a candidate output value. OR conditions use max instead.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--rules-clipping/)

### Mean of maxima



$$
z^*=\frac{\sum_{z_i\in M}z_i}{|M|}\quad\text{one plateau }[a,b]:\ z^*=(a+b)/2
$$



M is the set of discrete output locations attaining maximum membership. The plateau shortcut is for one continuous maximum interval.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--mom/)

### Discrete / continuous centroid



$$
z^*=\frac{\sum_i z_i\mu_i}{\sum_i\mu_i}\qquad z^*=\frac{\int z\mu(z)\,dz}{\int\mu(z)\,dz}
$$



Use actual discrete memberships or the full continuous aggregate. Denominator must be positive.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--centroid/)

### Specified representative-weighted output



$$
z^*=\frac{\sum_r\alpha_r c_r}{\sum_r\alpha_r}
$$



c is a supplied representative such as a peak. Do not call this the exact area centroid of a clipped Mamdani aggregate without justification.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--weighted-average/)

### Cartesian product and max–min composition



$$
R_{ij}=\min(A_i,B_j)\quad T_{ik}=\max_j\min(R_{ij},S_{jk})
$$



Relations must have a common middle domain in the same order. Min along a path, max across paths.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-relations--composition/)

## Other membership formulas from the reading lessons

### Trapezoid with distinct breakpoints



$$
\mu(x)=\max\left(0,\min\left(\frac{x-a}{b-a},1,\frac{d-x}{d-c}\right)\right)
$$



For a<b≤c<d: a is the left zero, b the start of the height-1 plateau, c its end and d the right zero. Vertical shoulder edges need the specified piecewise definition. [Branch examples →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--trapezoid-intuition/)

### Gaussian membership



$$
\mu(x)=e^{-(x-c)^2/(2\sigma^2)}
$$



c is the centre and σ>0 sets the width. At x=c the exponent is zero and membership is 1. [Worked exponential calculations →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--smooth-memberships/)

### Generalised bell membership



$$
\mu(x)=\frac{1}{1+|(x-c)/a|^{2b}}
$$



a>0 controls width; b>0 controls steepness; c is the centre. First subtract c, divide by a, take absolute value, apply the power, add 1, then take its reciprocal.

### Alpha-cut



$$
A_\alpha=\{x:\mu_A(x)\ge\alpha\}
$$



α is the chosen membership threshold. For 0<α≤1 keep inputs meeting or exceeding it, including threshold-equality endpoints. [Discrete and triangular examples →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--properties/)

---

## M2 · GA and PSO formulas, symbols and memory rules

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/formulas/m2-formulas-v2--ga-pso/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/formulas/m2-formulas-v2/ga-pso

One place for the formulas, meanings, conditions and links to full worked examples.

### Binary decoding



$$
x=\sum_{i=1}^{n}b_i2^{n-i}
$$



bᵢ is a bit; the maximum n-bit unsigned integer is 2ⁿ−1.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--encoding/)

### Roulette selection



$$
P_i=F_i/\sum_jF_j\quad C_i=\sum_{j=1}^iP_j
$$



Fitness weights must be nonnegative with a positive total. For minimisation use the specified transformation or selection method. C is cumulative probability.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--selection/)

### Population average



$$
\bar f=\frac{f_1+\cdots+f_N}{N}
$$



N is the number of individuals. Compare both best and average; mutation need not improve either.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--two-generations/)

### PSO velocity



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$



w weights inertia; c₁r₁ weights personal pull; c₂r₂ weights social pull. Apply the same equation separately to each coordinate.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--equation/)

### PSO position



$$
x^{t+1}=x^t+v^{t+1}
$$



Use the new velocity, not the old one. Then reevaluate the objective.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--two-particles/)

**Memory updates:** minimise → replace a pbest only for a lower score; maximise → only for a higher score. gbest is a position selected from the personal bests. Store the corresponding objective score alongside it. Keep previous best on ties unless instructed otherwise.

**Yaad rakho:** Formula ke pehle objective direction aur old state likho. Iteration 2 mein fresh positions aur retained memories use karo.

## Encoding and minimisation conventions



$$
x=L+\frac{d}{2^n-1}(U-L)
$$



For the specified uniform real-range encoding: decode n bits into unsigned integer d first. L and U are the physical limits. [Endpoint examples →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--encoding/)



$$
F=\frac{1}{1+f(x)}
$$



This is the stated roulette transformation in our nonnegative-cost minimisation example. It is not required for every GA. It converts a smaller cost into a larger selection weight. [Complete minimisation example →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--minimisation/)

---

## M2 · Q1(c) Fuzzy set operations [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-final-2025--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-final-2025/q1c

Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.

**Question. Consider two fuzzy sets X = {(c1, 0.6), (c2, 0.8), (c3, 0.3), (c4, 0.5), (c5, 0.7)} and Y = {(c1, 0.4), (c2, 0.5), (c3, 0.9), (c4, 0.6), (c5, 0.2)}. Find 1) X ∪ Y 2) X ∩ Y 3) ¬X ∪ ¬Y 4) ¬X ∩ ¬Y.** [5 marks]

### Answer

#### Given

The aligned X and Y memberships printed in this question.

#### To find

The four requested membership lists in the original element order.

#### Formula and why it applies

Use max for OR, min for AND, and 1−μ for NOT.



$$
\mu_{X\cup Y}=\max(\mu_X,\mu_Y),\quad\mu_{X\cap Y}=\min(\mu_X,\mu_Y)
$$



Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.

#### Solution

##### Step 1. Complements

¬X = {0.4, 0.2, 0.7, 0.5, 0.3}; ¬Y = {0.6, 0.5, 0.1, 0.4, 0.8}.

##### Step 2. Table

|  | c1 | c2 | c3 | c4 | c5 |
| --- | --- | --- | --- | --- | --- |
| X | 0.6 | 0.8 | 0.3 | 0.5 | 0.7 |
| Y | 0.4 | 0.5 | 0.9 | 0.6 | 0.2 |
| **X ∪ Y = max** | 0.6 | 0.8 | 0.9 | 0.6 | 0.7 |
| **X ∩ Y = min** | 0.4 | 0.5 | 0.3 | 0.5 | 0.2 |
| **¬X ∪ ¬Y** | 0.6 | 0.5 | 0.7 | 0.5 | 0.8 |
| **¬X ∩ ¬Y** | 0.4 | 0.2 | 0.1 | 0.4 | 0.3 |

##### Step 3. Check with De Morgan's law

¬X ∪ ¬Y must equal 1 − (X ∩ Y) = {0.6, 0.5, 0.7, 0.5, 0.8} ✓, and ¬X ∩ ¬Y must equal 1 − (X ∪ Y) = {0.4, 0.2, 0.1, 0.4, 0.3} ✓.

**Final answer.** X ∪ Y = {(c1,0.6),(c2,0.8),(c3,0.9),(c4,0.6),(c5,0.7)}; X ∩ Y = {(c1,0.4),(c2,0.5),(c3,0.3),(c4,0.5),(c5,0.2)}; ¬X ∪ ¬Y = {(c1,0.6),(c2,0.5),(c3,0.7),(c4,0.5),(c5,0.8)}; ¬X ∩ ¬Y = {(c1,0.4),(c2,0.2),(c3,0.1),(c4,0.4),(c5,0.3)}.

Official marking: 1 + 1 + 1.5 + 1.5.

## Calculate every element separately

### Element c1



$$
\neg X:1-0.6=0.4\qquad\neg Y:1-0.4=0.6
$$





$$
X\cup Y:\max(0.6,0.4)=0.6
$$





$$
X\cap Y:\min(0.6,0.4)=0.4
$$





$$
\neg X\cup\neg Y:\max(0.4,0.6)=0.6
$$





$$
\neg X\cap\neg Y:\min(0.4,0.6)=0.4
$$



### Element c2



$$
\neg X:1-0.8=0.2\qquad\neg Y:1-0.5=0.5
$$





$$
X\cup Y:\max(0.8,0.5)=0.8
$$





$$
X\cap Y:\min(0.8,0.5)=0.5
$$





$$
\neg X\cup\neg Y:\max(0.2,0.5)=0.5
$$





$$
\neg X\cap\neg Y:\min(0.2,0.5)=0.2
$$



### Element c3



$$
\neg X:1-0.3=0.7\qquad\neg Y:1-0.9=0.1
$$





$$
X\cup Y:\max(0.3,0.9)=0.9
$$





$$
X\cap Y:\min(0.3,0.9)=0.3
$$





$$
\neg X\cup\neg Y:\max(0.7,0.1)=0.7
$$





$$
\neg X\cap\neg Y:\min(0.7,0.1)=0.1
$$



### Element c4



$$
\neg X:1-0.5=0.5\qquad\neg Y:1-0.6=0.4
$$





$$
X\cup Y:\max(0.5,0.6)=0.6
$$





$$
X\cap Y:\min(0.5,0.6)=0.5
$$





$$
\neg X\cup\neg Y:\max(0.5,0.4)=0.5
$$





$$
\neg X\cap\neg Y:\min(0.5,0.4)=0.4
$$



### Element c5



$$
\neg X:1-0.7=0.3\qquad\neg Y:1-0.2=0.8
$$





$$
X\cup Y:\max(0.7,0.2)=0.7
$$





$$
X\cap Y:\min(0.7,0.2)=0.2
$$





$$
\neg X\cup\neg Y:\max(0.3,0.8)=0.8
$$





$$
\neg X\cap\neg Y:\min(0.3,0.8)=0.3
$$



---

## M2 · Q2(a) PSO, one iteration [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-final-2025--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-final-2025/q2a

Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.

**Question. Maximize 

$$
F(x_1,x_2)=2x_1^2-3x_1x_2+x_2^2+5x_1+2x_2+7
$$

 using Particle Swarm Optimization. 

$$
X=\begin{bmatrix}2.5&-3.0\\3.5&-1.5\end{bmatrix},\;V=\begin{bmatrix}0.2&0.3\\0.1&0.25\end{bmatrix}
$$

. Take 

$$
W=0.9,\;c_1=c_2=1.5,\;r_1=0.5949,\;r_2=0.0855
$$

. Optimize and give the solution after 1 iteration showing the step-by-step process.** [10 marks]

### Answer

#### Given

Particle 1: 

$$
x=(2.5,\,-3.0)
$$

, 

$$
v=(0.2,\,0.3)
$$

. Particle 2: 

$$
x=(3.5,\,-1.5)
$$

, 

$$
v=(0.1,\,0.25)
$$

.



$$
c_1r_1=1.5\times0.5949=0.89235,\qquad c_2r_2=1.5\times0.0855=0.12825
$$



#### To find

Fitness, pbest, gbest; new velocities and positions; updated pbest and gbest.

#### Formula and why it applies



$$
v_{ij}\leftarrow wv_{ij}+c_1r_1(p^b_{ij}-x_{ij})+c_2r_2(p^g_j-x_{ij}),\qquad x_{ij}\leftarrow x_{ij}+v_{ij}
$$



Each particle is pulled by its own memory and by the swarm's best; we maximise, so the larger 

$$
F
$$

 is better.

#### Solution

##### Step 1. Fitness of particle 1



$$
F(2.5,-3)=2(6.25)-3(2.5)(-3)+9+5(2.5)+2(-3)+7=12.5+22.5+9+12.5-6+7=57.5
$$



##### Step 2. Fitness of particle 2



$$
F(3.5,-1.5)=2(12.25)-3(3.5)(-1.5)+2.25+17.5-3+7=24.5+15.75+2.25+17.5-3+7=64
$$



##### Step 3. pbest and gbest

| Particle | Position | F | pbest |
| --- | --- | --- | --- |
| 1 | (2.5, −3.0) | 57.5 | (2.5, −3.0) |
| 2 | (3.5, −1.5) | 64 | (3.5, −1.5) |

No previous iteration, so pbest = current position. Largest fitness is 64, so **gbest = (3.5, −1.5)**.

##### Step 4. Velocity and position of particle 1



$$
v_{11}=0.9(0.2)+0.89235(2.5-2.5)+0.12825(3.5-2.5)=0.18+0+0.12825=0.30825
$$





$$
x_{11}=2.5+0.30825=2.80825
$$





$$
v_{12}=0.9(0.3)+0.89235(0)+0.12825(-1.5-(-3.0))=0.27+0.192375=0.462375
$$





$$
x_{12}=-3.0+0.462375=-2.537625
$$



##### Step 5. Velocity and position of particle 2 (it is gbest, so both pull terms are 0)



$$
v_{21}=0.9(0.1)+0+0=0.09,\qquad x_{21}=3.5+0.09=3.59
$$





$$
v_{22}=0.9(0.25)+0+0=0.225,\qquad x_{22}=-1.5+0.225=-1.275
$$



##### Step 6. New fitness



$$
F(2.80825,-2.537625)=15.772536+21.378856+6.439541+14.04125-5.07525+7=59.5569
$$





$$
F(3.59,-1.275)=25.7762+13.73175+1.625625+17.95-2.55+7=63.5336
$$



##### Step 7. Update pbest and gbest

| Particle | New position | New F | Old pbest F | pbest after iteration |
| --- | --- | --- | --- | --- |
| 1 | (2.80825, −2.537625) | 59.5569 | 57.5 | (2.80825, −2.537625) — improved |
| 2 | (3.59, −1.275) | 63.5336 | 64 | (3.5, −1.5) — kept |

The best pbest fitness is still 64, so gbest stays (3.5, −1.5).

**Final answer.** 

$$
V=\begin{bmatrix}0.30825&0.462375\\0.09&0.225\end{bmatrix}
$$

, 

$$
X=\begin{bmatrix}2.80825&-2.537625\\3.59&-1.275\end{bmatrix}
$$

. After one iteration particle 1 improved to F = 59.5569; the best solution so far is gbest = (3.5, −1.5) with F = 64.

Official key: fitness and gbest (5 marks), velocity and position updates (5 marks). The calculations above use the question data. The key's summary matrix writes 0.462 in place of 2.808 for 

$$
x_{11}
$$

; that is a copying slip.

---

## M2 · Q3(b) Fuzzy loan-approval system [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-final-2025--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-final-2025/q3b

Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.

**A bank uses fuzzy decision support with Credit Score and Income Stability, both on 1–100. Loan Approval is a score on 1–100 with labels Reject, Consider and Approve. Define triangular membership functions, construct nine rules, explain Mamdani inference and defuzzify for Credit Score=55 and Income Stability=35.** [10 marks]

### Answer

#### Given

| Variable | Crisp value |
| --- | --- |
| Credit Score | 55 |
| Income Stability | 35 |

The question asks us to design the membership functions. This solution chooses Low=Tri(1,25,50), Medium=Tri(25,50,75), High=Tri(50,75,100) for both inputs. Output labels use the same triangles in their respective order. These are explicit design choices, not additional printed givens.

#### To find

A complete stated design and its continuous Mamdani centroid.

#### Formula and why it applies

Use min for AND and implication, max for aggregation and the true area centroid of the resulting shape. A peak-only weighted average is a different defuzzifier.



$$
z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

##### Step 1. Specify the membership functions

| Input / output position | Triangle | Peak |
| --- | --- | --- |
| Low / Reject | (1,25,50) | 25 |
| Medium / Consider | (25,50,75) | 50 |
| High / Approve | (50,75,100) | 75 |

Use 0 outside each triangle, the rising fraction before the peak and the falling fraction after it. This design is evaluated at the requested input; a deployed controller would also need coverage/fallback at all boundary values.

##### Step 2. Write all nine rules

| Credit Score / Income Stability | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Reject | Reject | Consider |
| Medium | Reject | Consider | Approve |
| High | Consider | Approve | Approve |

Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.

##### Step 3. Fuzzify Credit Score = 55



$$
\mu_{Low}(55)=0
$$





$$
\mu_{Medium}(55)=\frac{75-55}{75-50}=0.8
$$





$$
\mu_{High}(55)=\frac{55-50}{75-50}=0.2
$$



##### Step 4. Fuzzify Income Stability = 35



$$
\mu_{Low}(35)=\frac{50-35}{50-25}=0.6
$$





$$
\mu_{Medium}(35)=\frac{35-25}{50-25}=0.4
$$





$$
\mu_{High}(35)=0
$$



##### Step 5. Evaluate all rules and aggregate matching consequents

| Credit Score | Income Stability | Firing strength | Consequent |
| --- | --- | --- | --- |
| Low | Low | min(0,0.6) = 0 | Reject |
| Low | Medium | min(0,0.4) = 0 | Reject |
| Low | High | min(0,0) = 0 | Consider |
| Medium | Low | min(0.8,0.6) = 0.6 | Reject |
| Medium | Medium | min(0.8,0.4) = 0.4 | Consider |
| Medium | High | min(0.8,0) = 0 | Approve |
| High | Low | min(0.2,0.6) = 0.2 | Consider |
| High | Medium | min(0.2,0.4) = 0.2 | Approve |
| High | High | min(0.2,0) = 0 | Approve |

Aggregated label strengths: Reject = 0.6, Consider = 0.4, Approve = 0.2.



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



##### Step 6. Draw the aggregated output

Swipe across the diagram to read its labels ↔

![The shaded upper envelope counts any overlap only once.](https://deep-learning-study-room.vercel.app/is2/fig/v2_loan_aggregate.2c5ffa32a7.svg)

Diagram: The shaded upper envelope counts any overlap only once.. Labels: Chosen triangular output sets and their max-aggregate | 0 | 0.5 | 1 | 1 | 25 | 50 | 75 | 100 | μ | Output score | Reject | Consider | Approve | centroid ≈ 42.78

The shaded upper envelope counts any overlap only once.

##### Step 7. Calculate area and moment of each straight-line strip

For a strip from a to b with endpoint heights u and v, its trapezoid area is A. Its first moment M is the integral of z times the line height.



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}\big[(2a+b)u+(a+2b)v\big]
$$



| a | b | u | v | Area A | Moment M |
| --- | --- | --- | --- | --- | --- |
| 1 | 15.4 | 0 | 0.6 | 4.32 | 45.792 |
| 15.4 | 25 | 0.6 | 0.6 | 5.76 | 116.352 |
| 25 | 35 | 0.6 | 0.6 | 6 | 180 |
| 35 | 40 | 0.6 | 0.4 | 2.5 | 93.333333333 |
| 40 | 50 | 0.4 | 0.4 | 4 | 180 |
| 50 | 55 | 0.4 | 0.4 | 2 | 105 |
| 55 | 65 | 0.4 | 0.4 | 4 | 240 |
| 65 | 70 | 0.4 | 0.2 | 1.5 | 100.833333333 |
| 70 | 75 | 0.2 | 0.2 | 1 | 72.5 |
| 75 | 95 | 0.2 | 0.2 | 4 | 340 |
| 95 | 100 | 0.2 | 0 | 0.5 | 48.333333333 |

##### Step 8. Divide total moment by total area



$$
\sum A=35.58
$$





$$
\sum M=1522.144
$$





$$
z^*=\frac{1522.144}{35.58}\approx42.780888139
$$



**Final answer.** For these stated triangles and rules, the centroid is 42.780888139. This is a fuzzy suitability score; the category memberships can be evaluated at this score. The model alone is not a complete loan-decision policy.

Because the paper asks for a design, a different explicitly specified membership/rule system can yield a different numerical output. Explain the choices and use the chosen defuzzification method consistently; no particular examiner mark outcome is promised.

## How the centroid table’s breakpoints are obtained

For each output triangle, solve “line height = clip height”. Reject is clipped at .6: rising endpoint 1+.6(25−1)=15.4 and falling endpoint 50−.6(50−25)=35. Consider is clipped at .4: endpoints 25+.4(50−25)=35 and 75−.4(75−50)=65. Approve is clipped at .2: endpoints 50+.2(75−50)=55 and 100−.2(100−75)=95.

Now take the maximum of the three clipped curves. The declining Reject edge reaches the Consider height .4 at (50−z)/25=.4, hence z=40. The declining Consider edge reaches the Approve height .2 at (75−z)/25=.2, hence z=70. These crossover locations must be included when splitting the aggregate. Original peaks and other clip endpoints may add extra splits without changing the total area.

**For the first aggregate strip from a=1 to b=15.4, endpoint heights are u=0 and v=0.6. Find its area and first moment.** [3 marks · Worked example]

#### Given

Strip endpoints a=1 and b=15.4; left height u=0 and right height v=0.6. This is a straight rising edge of the clipped Reject set.

#### To find

A and M for one table row.

#### Formula and why it applies



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}[(2a+b)u+(a+2b)v]
$$



A is trapezoid area. M weights every small area by its horizontal position; this formula integrates a straight line.

#### Solution

##### Step 1. Width and height sum



$$
b-a=15.4-1=14.4\qquad u+v=0.6
$$



##### Step 2. Area



$$
A=14.4\times0.6/2=8.64/2=4.32
$$



##### Step 3. First bracket term



$$
(2a+b)u=(2+15.4)\times0=0
$$



##### Step 4. Second bracket term



$$
(a+2b)v=(1+30.8)\times0.6=31.8\times0.6=19.08
$$



##### Step 5. Moment



$$
M=(14.4/6)(0+19.08)=2.4\times19.08=45.792
$$



**Final answer.** Area=4.32; moment=45.792. Repeat the same arithmetic for each row, then sum the areas and moments separately.

### Interpret the loan result using an explicit decision rule

Choose the output label having the greatest membership at the centroid; this is an additional stated interpretation rule. At z=42.780888139:



$$
\mu_{Reject}=(50-z)/25\approx0.288764474,\quad\mu_{Consider}=(z-25)/25\approx0.711235526,\quad\mu_{Approve}=0
$$



The resulting recommendation is **Consider / manual review**; this design does not recommend automatic approval. If a binary approve/reject answer is required, the question must supply a threshold or you must state the threshold you adopt. A different decision threshold is separate from defuzzification.

---

## M2 · Q4(a) Cartesian product and max–min composition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-final-2025--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-final-2025/q4a

Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.

**Question. Consider fuzzy sets A = {0.4/small + 0.3/medium + 0.1/large} and B = {0.2/slow + 0.7/moderate + 0.3/fast}. 1. Find R = A × B. 2. Given C = {0.3/small + 0.1/medium + 0.4/large}, find S = C × B. 3. Calculate the max–min composition S ∘ R.** [10 marks]

### Answer

#### Given

The fuzzy sets or relation matrices and their listed row/column order.

#### To find

The relation matrix/matrices and the composition specified in the question.

#### Formula and why it applies

For Cartesian products take min of row and column membership. For the ordered matrix composition shown here:



$$
T_{ik}=\max_j\min(S_{ij},R_{jk})
$$



If max–product is asked instead, replace the inner min by multiplication.

#### Solution

##### Step 1. R = A × B (rows small, medium, large; columns slow, moderate, fast)



$$
R=\begin{bmatrix}\min(.4,.2)&\min(.4,.7)&\min(.4,.3)\\\min(.3,.2)&\min(.3,.7)&\min(.3,.3)\\\min(.1,.2)&\min(.1,.7)&\min(.1,.3)\end{bmatrix}=\begin{bmatrix}0.2&0.4&0.3\\0.2&0.3&0.3\\0.1&0.1&0.1\end{bmatrix}
$$



##### Step 2. S = C × B



$$
S=\begin{bmatrix}0.2&0.3&0.3\\0.1&0.1&0.1\\0.2&0.4&0.3\end{bmatrix}
$$



##### Step 3. S ∘ R by max–min (row of S with column of R)

The printed relation domains do not directly compose: both relate size to speed. For the numerical exercise, explicitly assume positional alignment and compute row of S with column of R. Equal dimensions alone are not a justification for semantic relation composition.



$$
(1,1)=\max[\min(.2,.2),\min(.3,.2),\min(.3,.1)]=\max(.2,.2,.1)=0.2
$$





$$
(1,2)=\max[\min(.2,.4),\min(.3,.3),\min(.3,.1)]=\max(.2,.3,.1)=0.3
$$





$$
(1,3)=\max[\min(.2,.3),\min(.3,.3),\min(.3,.1)]=0.3
$$



Row 2 of S is all 0.1, so every entry of row 2 is 0.1.



$$
(3,1)=\max[\min(.2,.2),\min(.4,.2),\min(.3,.1)]=0.2,\;(3,2)=\max[.2,.3,.1]=0.3,\;(3,3)=\max[.2,.3,.1]=0.3
$$



**Final answer.** 

$$
S\circ R=\begin{bmatrix}0.2&0.3&0.3\\0.1&0.1&0.1\\0.2&0.3&0.3\end{bmatrix}
$$

.

**Official key note.** The key first printed a wrong matrix with row 2 = (0.2, 0.3, 0.3), then corrected it by hand to (0.1, 0.1, 0.1). The corrected matrix above is right. Marking: R 3, S 3, composition 4.

**A careful remark you can add.** Strictly, composition needs S: X → Y and R: Y → Z, while here both relate size to speed. The numerical matrix calculation above assumes positional identification of the three middle labels; that is a declared repair, not a valid size-to-speed relation composition without an extra mapping.

## Every cell without the row shortcuts

Both printed relations run from size to speed; their middle labels do not match for genuine relation composition. The numerical working below follows the question’s intended row-of-S with column-of-R operation using explicitly assumed positional alignment of the three middle entries.

### R: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| R11 | 0.4 | 0.2 | 0.2 |
| R12 | 0.4 | 0.7 | 0.4 |
| R13 | 0.4 | 0.3 | 0.3 |
| R21 | 0.3 | 0.2 | 0.2 |
| R22 | 0.3 | 0.7 | 0.3 |
| R23 | 0.3 | 0.3 | 0.3 |
| R31 | 0.1 | 0.2 | 0.1 |
| R32 | 0.1 | 0.7 | 0.1 |
| R33 | 0.1 | 0.3 | 0.1 |

### S: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| S11 | 0.3 | 0.2 | 0.2 |
| S12 | 0.3 | 0.7 | 0.3 |
| S13 | 0.3 | 0.3 | 0.3 |
| S21 | 0.1 | 0.2 | 0.1 |
| S22 | 0.1 | 0.7 | 0.1 |
| S23 | 0.1 | 0.3 | 0.1 |
| S31 | 0.4 | 0.2 | 0.2 |
| S32 | 0.4 | 0.7 | 0.4 |
| S33 | 0.4 | 0.3 | 0.3 |

**Result cell (1,1)**



$$
\max\{\min(0.2,0.2),\min(0.3,0.2),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (1,2)**



$$
\max\{\min(0.2,0.4),\min(0.3,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (1,3)**



$$
\max\{\min(0.2,0.3),\min(0.3,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (2,1)**



$$
\max\{\min(0.1,0.2),\min(0.1,0.2),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (2,2)**



$$
\max\{\min(0.1,0.4),\min(0.1,0.3),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (2,3)**



$$
\max\{\min(0.1,0.3),\min(0.1,0.3),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (3,1)**



$$
\max\{\min(0.2,0.2),\min(0.4,0.2),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (3,2)**



$$
\max\{\min(0.2,0.4),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (3,3)**



$$
\max\{\min(0.2,0.3),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



---

## M2 · Q5(b) Genetic algorithm [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-final-2025--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-final-2025/q5b

Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.

**Implement a GA to maximise 

$$
f(x)=2x^3-5x^2+7x
$$

 for x in [0,15]. Take 4-bit representations of 13, 22, 18, 23. Crossover after the second bit and mutate by flipping any one bit. Produce two offspring and comment on fitness.** [10 marks]

### Answer

**The printed data are inconsistent.** 22, 18 and 23 are outside 0–15 and cannot fit into four bits. Increasing the bit count would encode the numbers but would still violate the stated range. There is no single exact solution satisfying all printed conditions.

The complete worked variant below explicitly changes the invalid parents to their last four bits (values modulo 16), producing [13,6,2,7]. This is one declared repair, not a silent interpretation of the printed question. If the instructor clarifies different corrected data, follow those data.

#### Given

Printed parents: [13, 22, 18, 23]. Worked variant: [13, 6, 2, 7] with 4 bits. For the unspecified selection step, select the two highest-fitness candidates. For the unspecified mutation location, flip the last bit of each child. Crossover is after bit 2.

#### To find

Two valid children under the declared assumptions and their fitness.

#### Formula and why it applies

Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.



$$
f(x)=2x^3-5x^2+7x
$$



#### Solution

##### Step 1. Encode and evaluate the declared parent population

| x | Binary | Fitness substitution |
| --- | --- | --- |
| 13 | 1101 | 2(13³) − 5(13²) + 7(13) = 3640 |
| 6 | 0110 | 2(6³) − 5(6²) + 7(6) = 294 |
| 2 | 0010 | 2(2³) − 5(2²) + 7(2) = 10 |
| 7 | 0111 | 2(7³) − 5(7²) + 7(7) = 490 |

##### Step 2. Select the two fittest under the stated assumption

[13, 7] with fitness [3640, 490].

##### Step 3. Cut after bit 2 and exchange tails

| Parent 1 | Parent 2 | Child 1 | Child 2 |
| --- | --- | --- | --- |
| 11 | 01 | 01 | 11 | 1111 | 0101 |

##### Step 4. Flip the last bit of each child

| Before | After | Decoded x |
| --- | --- | --- |
| 1111 | 1110 | 14 |
| 0101 | 0100 | 4 |

##### Step 5. Evaluate both children

| x | Fitness calculation |
| --- | --- |
| 14 | 2(2744) − 5(196) + 7(14) = 4606 |
| 4 | 2(64) − 5(16) + 7(4) = 76 |

##### Step 6. Compare with the selected parents

Best parent score = 3640; best child score = 4606. Parent average = 2065; child average = 2341. Both the best score and the average score increased in this worked variant. An individual child can still be worse than a parent; GA does not guarantee improvement after every random operator.

**Final answer.** Under these declared repairs and operator choices, children are [14, 4] with fitness [4606, 76]. These are not unique answers to the inconsistent and under-specified original question.

The printed wording about “two offspring” is not an explicit requirement for two complete generations. The M2 examples separately work two full generations because your class update asks for iteration 2.

## Evaluate the polynomial without skipping the powers

Calculate x²=x×x, then x³=x²×x. Multiply each by its coefficient and combine with the written signs. A bit-string repair in the worked answer is an explicitly stated response to inconsistent printed givens; it is not a new instruction in the original paper.

### x=13



$$
x^2=13\times13=169\qquad x^3=169\times13=2197
$$





$$
2x^3=4394\quad 5x^2=845\quad 7x=91
$$





$$
f(13)=4394-845+91=3640
$$



### x=6



$$
x^2=6\times6=36\qquad x^3=36\times6=216
$$





$$
2x^3=432\quad 5x^2=180\quad 7x=42
$$





$$
f(6)=432-180+42=294
$$



### x=2



$$
x^2=2\times2=4\qquad x^3=4\times2=8
$$





$$
2x^3=16\quad 5x^2=20\quad 7x=14
$$





$$
f(2)=16-20+14=10
$$



### x=7



$$
x^2=7\times7=49\qquad x^3=49\times7=343
$$





$$
2x^3=686\quad 5x^2=245\quad 7x=49
$$





$$
f(7)=686-245+49=490
$$



### x=15



$$
x^2=15\times15=225\qquad x^3=225\times15=3375
$$





$$
2x^3=6750\quad 5x^2=1125\quad 7x=105
$$





$$
f(15)=6750-1125+105=5730
$$



### x=5



$$
x^2=5\times5=25\qquad x^3=25\times5=125
$$





$$
2x^3=250\quad 5x^2=125\quad 7x=35
$$





$$
f(5)=250-125+35=160
$$



### x=14



$$
x^2=14\times14=196\qquad x^3=196\times14=2744
$$





$$
2x^3=5488\quad 5x^2=980\quad 7x=98
$$





$$
f(14)=5488-980+98=4606
$$



### x=4



$$
x^2=4\times4=16\qquad x^3=16\times4=64
$$





$$
2x^3=128\quad 5x^2=80\quad 7x=28
$$





$$
f(4)=128-80+28=76
$$



“Modulo 16” means keep the remainder after dividing by 16: 22=1×16+6, so its remainder is 6; 18=1×16+2; 23=1×16+7. This is only the declared repair used here, not an unspoken general encoding rule.

---

## M2 · Q6(a) Applications of fuzzy logic [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-final-2025--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-final-2025/q6a

Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.

**List the applications of fuzzy logic. Explain any one application in detail.** [10 marks]

### Answer

### Definition

Fuzzy logic is a multi-valued logic, introduced by Lotfi Zadeh (1965), in which truth values range over [0, 1]; it lets machines reason with vague, human-like terms such as “slightly dirty” or “very hot”.

### Applications

| Area | Examples |
| --- | --- |
| Home appliances | Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners |
| Automotive | Automatic transmission, anti-lock braking (ABS), cruise control, engine control |
| Transportation | Traffic-signal control, Sendai subway train control (smooth braking and acceleration) |
| Consumer electronics | Camera autofocus and auto-exposure, image stabilisation |
| Industrial control | Cement kilns, pH, temperature and distillation control in chemical plants |
| Aerospace | Satellite and spacecraft attitude control |
| Medicine | Diagnosis support, anaesthesia dosage control |
| Finance and decisions | Loan approval, credit and fire-risk scoring, stock trading rules |
| AI and robotics | Robot navigation, natural-language interfaces, expert systems |

### One application in detail: fuzzy washing machine

1. **Problem.** Wash time depends on how dirty and how greasy the clothes are. These are vague (“a bit dirty”), and a fixed timer wastes water and power.
2. **Inputs and outputs.** Sensors measure dirt (turbidity of water) and grease; the output is wash time. Each is described by fuzzy sets: dirt Small/Medium/High, grease Small/Medium/High, time Very Short … Very Long.
3. **Fuzzification.** Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.
4. **Rule base.** 9 expert rules, e.g. IF dirt is High AND grease is High THEN time is Very Long; IF dirt is Small AND grease is Small THEN time is Very Short.
5. **Inference.** Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.
6. **Defuzzification.** Use the specified defuzzifier. For a separate representative-weighted illustration, strengths [.6,.4,.2] at times [25,40,60] give (.6×25+.4×40+.2×60)/(.6+.4+.2)=(15+16+12)/1.2≈35.833 minutes. These illustrative strengths are supplied here, not derived from unspecified input graphs. A Mamdani area centroid requires the full aggregate shape.
7. **Benefits.** Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.

### Advantages and disadvantages (bonus)

**Advantages:** handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. **Disadvantages:** rules and membership functions depend on expert judgement; results are hard to verify formally; tuning can take time; not suited where very high precision is required.

**Yaad rakho:** Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.

---

## M2 · Q7(a) Applications of PSO [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-final-2025--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-final-2025/q7a

Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.

**List the applications of Particle Swarm Optimization and explain any one application in detail.** [10 marks]

### Answer

### Definition (1 line)

Particle Swarm Optimization is a population-based metaheuristic, inspired by bird flocking and fish schooling, in which particles move through the search space using their own best position (pbest) and the swarm's best position (gbest) to find optimal or near-optimal solutions.

### Applications

1. **Function optimisation**: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.
2. **Neural-network training**: optimising weights and biases (your Lab 8 uses the pyswarms library for this).
3. **Hyper-parameter tuning** of ML models (learning rate, number of hidden units, SVM C and γ).
4. **Feature selection**: choosing the most useful subset of features (binary PSO).
5. **Image processing**: threshold selection for segmentation, edge detection, image enhancement.
6. **Path planning** for robots and drones: shortest collision-free path.
7. **Power systems**: economic load dispatch, optimal placement of capacitors.
8. **Control engineering**: tuning PID controller gains.
9. **Scheduling and wireless sensor networks**: job scheduling, sensor node placement and clustering.

### One application in detail: training a neural network with PSO

Training data

→

Neural network with weights = particle position

→

Error (fitness)

→

PSO moves the weights

→

Best weights = gbest

1. **Encoding.** Flatten all weights and biases of the network into one vector. Each particle is one complete set of weights; a network with 50 weights gives a 50-dimensional search space.
2. **Fitness.** Run the training data through the network with that particle's weights and compute the error (for example mean squared error or cross-entropy). Lower error = better particle (minimisation).
3. **Search.** Apply the velocity and position updates. Each particle is pulled towards the weight set that gave its own lowest error (pbest) and towards the lowest-error weights found by the swarm (gbest).
4. **Stop** after a fixed number of iterations or when the error stops improving; gbest is the trained network.
5. **Why PSO here:** it needs no gradients, so it works with non-differentiable activations and can explore candidate weights without differentiating the objective. It can still stagnate; comparison with gradient methods depends on the problem. **Limitation:** large networks create a high-dimensional search space, and evaluating many complete candidate networks can be computationally expensive. Gradient-based training is often more efficient when useful gradients are available; there is no universal speed ordering for every problem and implementation.

### Advantages and disadvantages (add for 10 marks)

| Advantages | Disadvantages |
| --- | --- |
| Simple to implement; few parameters (w, c₁, c₂) | Can converge prematurely to a local optimum |
| No derivatives needed | Sensitive to parameter choice |
| Fast convergence in early iterations; memory (pbest, gbest) | No guarantee of the global optimum |
| Objective evaluations can be parallel; particles share information through gbest | Less suited to discrete problems without modification |

Marking pattern used for ACO in the same paper: listing 3 marks + explanation 2 marks (5-mark version); listing 5 + explanation 5 (10-mark version).

**Yaad rakho:** Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.

---

## M2 · Q1(b) Applications of PSO [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-reexam-2026--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-reexam-2026/q1b

Longer past-paper practice restricted to Fuzzy, GA and PSO.

**List the applications of Particle Swarm Optimization and explain any one application in detail.** [5 marks]

### Answer

### Definition (1 line)

Particle Swarm Optimization is a population-based metaheuristic, inspired by bird flocking and fish schooling, in which particles move through the search space using their own best position (pbest) and the swarm's best position (gbest) to find optimal or near-optimal solutions.

### Applications

1. **Function optimisation**: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.
2. **Neural-network training**: optimising weights and biases (your Lab 8 uses the pyswarms library for this).
3. **Hyper-parameter tuning** of ML models (learning rate, number of hidden units, SVM C and γ).
4. **Feature selection**: choosing the most useful subset of features (binary PSO).
5. **Image processing**: threshold selection for segmentation, edge detection, image enhancement.
6. **Path planning** for robots and drones: shortest collision-free path.
7. **Power systems**: economic load dispatch, optimal placement of capacitors.
8. **Control engineering**: tuning PID controller gains.
9. **Scheduling and wireless sensor networks**: job scheduling, sensor node placement and clustering.

### One application in detail: training a neural network with PSO

Training data

→

Neural network with weights = particle position

→

Error (fitness)

→

PSO moves the weights

→

Best weights = gbest

1. **Encoding.** Flatten all weights and biases of the network into one vector. Each particle is one complete set of weights; a network with 50 weights gives a 50-dimensional search space.
2. **Fitness.** Run the training data through the network with that particle's weights and compute the error (for example mean squared error or cross-entropy). Lower error = better particle (minimisation).
3. **Search.** Apply the velocity and position updates. Each particle is pulled towards the weight set that gave its own lowest error (pbest) and towards the lowest-error weights found by the swarm (gbest).
4. **Stop** after a fixed number of iterations or when the error stops improving; gbest is the trained network.
5. **Why PSO here:** it needs no gradients, so it works with non-differentiable activations and can explore candidate weights without differentiating the objective. It can still stagnate; comparison with gradient methods depends on the problem. **Limitation:** large networks create a high-dimensional search space, and evaluating many complete candidate networks can be computationally expensive. Gradient-based training is often more efficient when useful gradients are available; there is no universal speed ordering for every problem and implementation.

### Advantages and disadvantages (add for 10 marks)

| Advantages | Disadvantages |
| --- | --- |
| Simple to implement; few parameters (w, c₁, c₂) | Can converge prematurely to a local optimum |
| No derivatives needed | Sensitive to parameter choice |
| Fast convergence in early iterations; memory (pbest, gbest) | No guarantee of the global optimum |
| Objective evaluations can be parallel; particles share information through gbest | Less suited to discrete problems without modification |

Marking pattern used for ACO in the same paper: listing 3 marks + explanation 2 marks (5-mark version); listing 5 + explanation 5 (10-mark version).

**Yaad rakho:** Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.

---

## M2 · Q1(c) Fuzzy set operations [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-reexam-2026--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-reexam-2026/q1c

Longer past-paper practice restricted to Fuzzy, GA and PSO.

**Question. X = {(c1, 0.7), (c2, 0.9), (c3, 0.2), (c4, 0.4), (c5, 0.9)}, Y = {(c1, 0.6), (c2, 0.3), (c3, 0.8), (c4, 0.7), (c5, 0.1)}. Find X ∪ Y, X ∩ Y, ¬X ∪ ¬Y, ¬X ∩ ¬Y.** [5 marks]

### Answer

#### Given

The aligned X and Y memberships printed in this question.

#### To find

The four requested membership lists in the original element order.

#### Formula and why it applies

Use max for OR, min for AND, and 1−μ for NOT.



$$
\mu_{X\cup Y}=\max(\mu_X,\mu_Y),\quad\mu_{X\cap Y}=\min(\mu_X,\mu_Y)
$$



Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.

#### Solution

|  | c1 | c2 | c3 | c4 | c5 |
| --- | --- | --- | --- | --- | --- |
| ¬X | 0.3 | 0.1 | 0.8 | 0.6 | 0.1 |
| ¬Y | 0.4 | 0.7 | 0.2 | 0.3 | 0.9 |
| **X ∪ Y** | 0.7 | 0.9 | 0.8 | 0.7 | 0.9 |
| **X ∩ Y** | 0.6 | 0.3 | 0.2 | 0.4 | 0.1 |
| **¬X ∪ ¬Y** | 0.4 | 0.7 | 0.8 | 0.6 | 0.9 |
| **¬X ∩ ¬Y** | 0.3 | 0.1 | 0.2 | 0.3 | 0.1 |

**Final answer.** As in the last four rows. De Morgan check: ¬X ∪ ¬Y = 1 − (X ∩ Y) and ¬X ∩ ¬Y = 1 − (X ∪ Y) ✓.

## Calculate every element separately

### Element c1



$$
\neg X:1-0.7=0.3\qquad\neg Y:1-0.6=0.4
$$





$$
X\cup Y:\max(0.7,0.6)=0.7
$$





$$
X\cap Y:\min(0.7,0.6)=0.6
$$





$$
\neg X\cup\neg Y:\max(0.3,0.4)=0.4
$$





$$
\neg X\cap\neg Y:\min(0.3,0.4)=0.3
$$



### Element c2



$$
\neg X:1-0.9=0.1\qquad\neg Y:1-0.3=0.7
$$





$$
X\cup Y:\max(0.9,0.3)=0.9
$$





$$
X\cap Y:\min(0.9,0.3)=0.3
$$





$$
\neg X\cup\neg Y:\max(0.1,0.7)=0.7
$$





$$
\neg X\cap\neg Y:\min(0.1,0.7)=0.1
$$



### Element c3



$$
\neg X:1-0.2=0.8\qquad\neg Y:1-0.8=0.2
$$





$$
X\cup Y:\max(0.2,0.8)=0.8
$$





$$
X\cap Y:\min(0.2,0.8)=0.2
$$





$$
\neg X\cup\neg Y:\max(0.8,0.2)=0.8
$$





$$
\neg X\cap\neg Y:\min(0.8,0.2)=0.2
$$



### Element c4



$$
\neg X:1-0.4=0.6\qquad\neg Y:1-0.7=0.3
$$





$$
X\cup Y:\max(0.4,0.7)=0.7
$$





$$
X\cap Y:\min(0.4,0.7)=0.4
$$





$$
\neg X\cup\neg Y:\max(0.6,0.3)=0.6
$$





$$
\neg X\cap\neg Y:\min(0.6,0.3)=0.3
$$



### Element c5



$$
\neg X:1-0.9=0.1\qquad\neg Y:1-0.1=0.9
$$





$$
X\cup Y:\max(0.9,0.1)=0.9
$$





$$
X\cap Y:\min(0.9,0.1)=0.1
$$





$$
\neg X\cup\neg Y:\max(0.1,0.9)=0.9
$$





$$
\neg X\cap\neg Y:\min(0.1,0.9)=0.1
$$



---

## M2 · Q2(a) Fuzzy fire-hazard system [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-reexam-2026--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-reexam-2026/q2a

Longer past-paper practice restricted to Fuzzy, GA and PSO.

**A building safety department wants a fuzzy logic system to predict fire hazards. Inputs are Temperature (1–100°C) and Smoke Level (1–100). The output Fire Risk (1–100) has labels Low, Moderate and High. Define triangular membership functions, construct at least nine rules, explain Mamdani inference and defuzzify for Temperature=65°C and Smoke=80.** [10 marks]

### Answer

#### Given

| Variable | Crisp value |
| --- | --- |
| Temperature | 65 |
| Smoke Level | 80 |

The question asks us to design the membership functions. This solution chooses Low=Tri(1,25,50), Medium=Tri(25,50,75), High=Tri(50,75,100) for both inputs. Output labels use the same triangles in their respective order. These are explicit design choices, not additional printed givens.

#### To find

A complete stated design and its continuous Mamdani centroid.

#### Formula and why it applies

Use min for AND and implication, max for aggregation and the true area centroid of the resulting shape. A peak-only weighted average is a different defuzzifier.



$$
z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

##### Step 1. Specify the membership functions

| Input / output position | Triangle | Peak |
| --- | --- | --- |
| Low / Low | (1,25,50) | 25 |
| Medium / Moderate | (25,50,75) | 50 |
| High / High | (50,75,100) | 75 |

Use 0 outside each triangle, the rising fraction before the peak and the falling fraction after it. This design is evaluated at the requested input; a deployed controller would also need coverage/fallback at all boundary values.

##### Step 2. Write all nine rules

| Temperature / Smoke Level | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Low | Low | Moderate |
| Medium | Low | Moderate | High |
| High | Moderate | High | High |

Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.

##### Step 3. Fuzzify Temperature = 65



$$
\mu_{Low}(65)=0
$$





$$
\mu_{Medium}(65)=\frac{75-65}{75-50}=0.4
$$





$$
\mu_{High}(65)=\frac{65-50}{75-50}=0.6
$$



##### Step 4. Fuzzify Smoke Level = 80



$$
\mu_{Low}(80)=0
$$





$$
\mu_{Medium}(80)=0
$$





$$
\mu_{High}(80)=\frac{100-80}{100-75}=0.8
$$



##### Step 5. Evaluate all rules and aggregate matching consequents

| Temperature | Smoke Level | Firing strength | Consequent |
| --- | --- | --- | --- |
| Low | Low | min(0,0) = 0 | Low |
| Low | Medium | min(0,0) = 0 | Low |
| Low | High | min(0,0.8) = 0 | Moderate |
| Medium | Low | min(0.4,0) = 0 | Low |
| Medium | Medium | min(0.4,0) = 0 | Moderate |
| Medium | High | min(0.4,0.8) = 0.4 | High |
| High | Low | min(0.6,0) = 0 | Moderate |
| High | Medium | min(0.6,0) = 0 | High |
| High | High | min(0.6,0.8) = 0.6 | High |

Aggregated label strengths: Low = 0, Moderate = 0, High = 0.6.



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



##### Step 6. Draw the aggregated output

Swipe across the diagram to read its labels ↔

![The shaded upper envelope counts any overlap only once.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fire_aggregate.e0cab4ad42.svg)

Diagram: The shaded upper envelope counts any overlap only once.. Labels: Chosen triangular output sets and their max-aggregate | 0 | 0.5 | 1 | 1 | 25 | 50 | 75 | 100 | μ | Output score | Low | Moderate | High | centroid ≈ 75

The shaded upper envelope counts any overlap only once.

##### Step 7. Calculate area and moment of each straight-line strip

For a strip from a to b with endpoint heights u and v, its trapezoid area is A. Its first moment M is the integral of z times the line height.



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}\big[(2a+b)u+(a+2b)v\big]
$$



| a | b | u | v | Area A | Moment M |
| --- | --- | --- | --- | --- | --- |
| 50 | 65 | 0 | 0.6 | 4.5 | 270 |
| 65 | 85 | 0.6 | 0.6 | 12 | 900 |
| 85 | 100 | 0.6 | 0 | 4.5 | 405 |

##### Step 8. Divide total moment by total area



$$
\sum A=21
$$





$$
\sum M=1575
$$





$$
z^*=\frac{1575}{21}\approx75
$$



**Final answer.** For these stated triangles and rules, the centroid is 75. This is in the high-risk region of this illustrative fuzzy design.

Because the paper asks for a design, a different explicitly specified membership/rule system can yield a different numerical output. Explain the choices and use the chosen defuzzification method consistently; no particular examiner mark outcome is promised.

## Why the clipped High shape is symmetric about 75

Only the High output survives, at height .6. Its triangle is (50,75,100). Solve its rising edge: (z−50)/25=.6, so z=50+15=65. Solve its falling edge: (100−z)/25=.6, so z=100−15=85.

| Piece | Area calculation | Centre | Moment |
| --- | --- | --- | --- |
| Left triangle [50,65] | ½×15×.6=4.5 | (50+65+65)/3=60 | 4.5×60=270 |
| Rectangle [65,85] | 20×.6=12 | (65+85)/2=75 | 12×75=900 |
| Right triangle [85,100] | ½×15×.6=4.5 | (85+85+100)/3=90 | 4.5×90=405 |

The horizontal centroid of a triangle is the average of the three vertex x-coordinates. Add areas: 4.5+12+4.5=21. Add moments:270+900+405=1575. Divide 1575/21=75, agreeing with symmetry.

---

## M2 · Q3(b) Fuzzy relations and composition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-reexam-2026--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-reexam-2026/q3b

Longer past-paper practice restricted to Fuzzy, GA and PSO.

**Question. A = {0.6/small + 0.4/medium + 0.1/large}, B = {0.4/slow + 0.8/moderate + 0.3/fast}, C = {0.5/small + 0.2/medium + 0.4/large}. Find R = A × B, S = C × B and the max–min composition S ∘ R.** [10 marks]

### Answer

#### Given

The fuzzy sets or relation matrices and their listed row/column order.

#### To find

The relation matrix/matrices and the composition specified in the question.

#### Formula and why it applies

For Cartesian products take min of row and column membership. For the ordered matrix composition shown here:



$$
T_{ik}=\max_j\min(S_{ij},R_{jk})
$$



If max–product is asked instead, replace the inner min by multiplication.

#### Solution

##### Step 1. R and S



$$
R=\begin{bmatrix}0.4&0.6&0.3\\0.4&0.4&0.3\\0.1&0.1&0.1\end{bmatrix},\qquad S=\begin{bmatrix}0.4&0.5&0.3\\0.2&0.2&0.2\\0.4&0.4&0.3\end{bmatrix}
$$



##### Step 2. S ∘ R



$$
(1,1)=\max[\min(.4,.4),\min(.5,.4),\min(.3,.1)]=\max(.4,.4,.1)=0.4
$$





$$
(1,2)=\max[\min(.4,.6),\min(.5,.4),\min(.3,.1)]=\max(.4,.4,.1)=0.4
$$





$$
(1,3)=\max[\min(.4,.3),\min(.5,.3),\min(.3,.1)]=0.3
$$





$$
\text{row 2 (all 0.2)}=(0.2,0.2,0.2);\quad(3,1)=\max(.4,.4,.1)=0.4,\;(3,2)=\max(.4,.4,.1)=0.4,\;(3,3)=0.3
$$



**Final answer.** 

$$
R=\begin{bmatrix}.4&.6&.3\\.4&.4&.3\\.1&.1&.1\end{bmatrix}
$$

, 

$$
S=\begin{bmatrix}.4&.5&.3\\.2&.2&.2\\.4&.4&.3\end{bmatrix}
$$

, 

$$
S\circ R=\begin{bmatrix}0.4&0.4&0.3\\0.2&0.2&0.2\\0.4&0.4&0.3\end{bmatrix}
$$

. (The key gives R and S only.)

## Every cell without the row shortcuts

Both printed relations run from size to speed; their middle labels do not match for genuine relation composition. The numerical working below follows the question’s intended row-of-S with column-of-R operation using explicitly assumed positional alignment of the three middle entries.

### R: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| R11 | 0.6 | 0.4 | 0.4 |
| R12 | 0.6 | 0.8 | 0.6 |
| R13 | 0.6 | 0.3 | 0.3 |
| R21 | 0.4 | 0.4 | 0.4 |
| R22 | 0.4 | 0.8 | 0.4 |
| R23 | 0.4 | 0.3 | 0.3 |
| R31 | 0.1 | 0.4 | 0.1 |
| R32 | 0.1 | 0.8 | 0.1 |
| R33 | 0.1 | 0.3 | 0.1 |

### S: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| S11 | 0.5 | 0.4 | 0.4 |
| S12 | 0.5 | 0.8 | 0.5 |
| S13 | 0.5 | 0.3 | 0.3 |
| S21 | 0.2 | 0.4 | 0.2 |
| S22 | 0.2 | 0.8 | 0.2 |
| S23 | 0.2 | 0.3 | 0.2 |
| S31 | 0.4 | 0.4 | 0.4 |
| S32 | 0.4 | 0.8 | 0.4 |
| S33 | 0.4 | 0.3 | 0.3 |

**Result cell (1,1)**



$$
\max\{\min(0.4,0.4),\min(0.5,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (1,2)**



$$
\max\{\min(0.4,0.6),\min(0.5,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (1,3)**



$$
\max\{\min(0.4,0.3),\min(0.5,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.3,0.3,0.1\}=0.3
$$



**Result cell (2,1)**



$$
\max\{\min(0.2,0.4),\min(0.2,0.4),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (2,2)**



$$
\max\{\min(0.2,0.6),\min(0.2,0.4),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (2,3)**



$$
\max\{\min(0.2,0.3),\min(0.2,0.3),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (3,1)**



$$
\max\{\min(0.4,0.4),\min(0.4,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (3,2)**



$$
\max\{\min(0.4,0.6),\min(0.4,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (3,3)**



$$
\max\{\min(0.4,0.3),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.3,0.3,0.1\}=0.3
$$



---

## M2 · Q4(a) PSO, one iteration [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-reexam-2026--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-reexam-2026/q4a

Longer past-paper practice restricted to Fuzzy, GA and PSO.

**Question. Maximize 

$$
F(x)=x_1^2-x_1x_2+x_2^2+3x_1+4x_2+5
$$

 using Particle Swarm Optimization. 

$$
X=\begin{bmatrix}3.1472&-4.0246\\4.0579&-2.2150\end{bmatrix},\;V=\begin{bmatrix}0.2194&0.2449\\0.1908&0.2228\end{bmatrix}
$$

. Take 

$$
W=0.9,\;c_1=c_2=1.5,\;r_1=0.5949,\;r_2=0.0855
$$

. Optimize and give the solution after 1 iteration showing the step-by-step process.** [10 marks]

### Answer

#### Given

P1: 

$$
x=(3.1472,\,-4.0246)
$$

, 

$$
v=(0.2194,\,0.2449)
$$

. P2: 

$$
x=(4.0579,\,-2.2150)
$$

, 

$$
v=(0.1908,\,0.2228)
$$

. 

$$
c_1r_1=0.89235
$$

, 

$$
c_2r_2=0.12825
$$

.

#### To find

Updated velocities, positions, pbest and gbest after one iteration.

#### Formula and why it applies



$$
v^{new}=wv+c_1r_1(pbest-x)+c_2r_2(gbest-x),\quad x^{new}=x+v^{new}
$$



Initial personal bests equal the starting positions. Use one frozen global best for all particles. This question maximises fitness, so keep a memory only when its score is larger.

#### Solution

##### Step 1. Fitness of P1 (term by term)



$$
x_1^2=9.904868,\;-x_1x_2=+12.666221,\;x_2^2=16.197405,\;3x_1=9.4416,\;4x_2=-16.0984
$$





$$
F_1=9.904868+12.666221+16.197405+9.4416-16.0984+5=37.1117
$$



##### Step 2. Fitness of P2



$$
F_2=16.466552+8.988249+4.906225+12.1737-8.86+5=38.6747
$$



##### Step 3. pbest and gbest

pbest = current positions. 

$$
38.6747>37.1117
$$

, so **gbest = P2 = (4.0579, −2.2150)**.

##### Step 4. Particle 1 updates



$$
v_{11}=0.9(0.2194)+0+0.12825(4.0579-3.1472)=0.19746+0.116797=0.314257
$$





$$
x_{11}=3.1472+0.314257=3.461457
$$





$$
v_{12}=0.9(0.2449)+0+0.12825(-2.2150+4.0246)=0.22041+0.232081=0.452491
$$





$$
x_{12}=-4.0246+0.452491=-3.572109
$$



##### Step 5. Particle 2 updates (gbest particle: only inertia acts)



$$
v_{21}=0.9(0.1908)=0.17172,\quad x_{21}=4.22962;\qquad v_{22}=0.9(0.2228)=0.20052,\quad x_{22}=-2.01448
$$



##### Step 6. New fitness and bests

Use the same objective at each new position. Keep full precision internally; displayed coordinates are rounded.



$$
F(3.461457275,-3.5721088)=(3.461457275)^2-(3.461457275)(-3.5721088)+(-3.5721088)^2+3(3.461457275)+4(-3.5721088)+5
$$





$$
=11.981686467+12.364701993+12.759961279+10.384371825+(-14.2884352)+5\approx38.202286364
$$





$$
F(4.22962,-2.01448)=(4.22962)^2-(4.22962)(-2.01448)+(-2.01448)^2+3(4.22962)+4(-2.01448)+5
$$





$$
=17.889685344+8.520484898+4.05812967+12.68886+(-8.05792)+5\approx40.099239912
$$



| Particle | New position | New F | Old F | pbest |
| --- | --- | --- | --- | --- |
| 1 | (3.461457, −3.572109) | 38.2023 | 37.1117 | updated |
| 2 | (4.22962, −2.01448) | 40.0992 | 38.6747 | updated |

The best pbest is now P2's with F = 40.0992, so gbest moves to (4.22962, −2.01448).

**Final answer.** 

$$
V=\begin{bmatrix}0.314257&0.452491\\0.17172&0.20052\end{bmatrix}
$$

, 

$$
X=\begin{bmatrix}3.461457&-3.572109\\4.22962&-2.01448\end{bmatrix}
$$

. Both particles improved; new gbest = (4.22962, −2.01448) with F = 40.0992.

**Official key warning.** The re-exam answer key solves a *different* problem: particles (0.4, 0.3) and (0.3, 0.4) with velocities (0.1, −0.2) and (−0.2, 0.1), giving fitness 7.53 and 7.86. Do not copy it. The numbers above solve the question as printed.

This X and V are particles 1 and 2 of your lecture's five-particle example; only the function differs (+3x₁ and +5 here instead of +2x₁ and +3).

---

## M2 · Q5(a) Genetic algorithm [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-reexam-2026--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-reexam-2026/q5a

Longer past-paper practice restricted to Fuzzy, GA and PSO.

**Implement a GA to maximise 

$$
f(x)=2x^3-3x^2+8x
$$

 for x in [0,50]. Take 4-bit representations of 12, 20, 17, 13. Crossover after the second bit and mutate by flipping any one bit. Produce two offspring and comment on fitness.** [10 marks]

### Answer

**The printed data are inconsistent.** 20 and 17 do not fit into four bits, and covering 0–50 needs six bits. We use six-bit encoding to preserve the supplied parent values and the stated range.

#### Given

Printed parents: [12, 20, 17, 13]. Worked variant: [12, 20, 17, 13] with 6 bits. For the unspecified selection step, select the two highest-fitness candidates. For the unspecified mutation location, flip the last bit of each child. Crossover is after bit 2.

#### To find

Two valid children under the declared assumptions and their fitness.

#### Formula and why it applies

Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.



$$
f(x)=2x^3-3x^2+8x
$$



#### Solution

##### Step 1. Encode and evaluate the declared parent population

| x | Binary | Fitness substitution |
| --- | --- | --- |
| 12 | 001100 | 2(12³) − 3(12²) + 8(12) = 3120 |
| 20 | 010100 | 2(20³) − 3(20²) + 8(20) = 14960 |
| 17 | 010001 | 2(17³) − 3(17²) + 8(17) = 9095 |
| 13 | 001101 | 2(13³) − 3(13²) + 8(13) = 3991 |

##### Step 2. Select the two fittest under the stated assumption

[20, 17] with fitness [14960, 9095].

##### Step 3. Cut after bit 2 and exchange tails

| Parent 1 | Parent 2 | Child 1 | Child 2 |
| --- | --- | --- | --- |
| 01 | 0100 | 01 | 0001 | 010001 | 010100 |

##### Step 4. Flip the last bit of each child

| Before | After | Decoded x |
| --- | --- | --- |
| 010001 | 010000 | 16 |
| 010100 | 010101 | 21 |

##### Step 5. Evaluate both children

| x | Fitness calculation |
| --- | --- |
| 16 | 2(4096) − 3(256) + 8(16) = 7552 |
| 21 | 2(9261) − 3(441) + 8(21) = 17367 |

##### Step 6. Compare with the selected parents

Best parent score = 14960; best child score = 17367. Parent average = 12027.5; child average = 12459.5. Both the best score and the average score increased in this worked variant. An individual child can still be worse than a parent; GA does not guarantee improvement after every random operator.

**Final answer.** Under these declared repairs and operator choices, children are [16, 21] with fitness [7552, 17367]. These are not unique answers to the inconsistent and under-specified original question.

The printed wording about “two offspring” is not an explicit requirement for two complete generations. The M2 examples separately work two full generations because your class update asks for iteration 2.

## Evaluate the polynomial without skipping the powers

Calculate x²=x×x, then x³=x²×x. Multiply each by its coefficient and combine with the written signs. A bit-string repair in the worked answer is an explicitly stated response to inconsistent printed givens; it is not a new instruction in the original paper.

### x=12



$$
x^2=12\times12=144\qquad x^3=144\times12=1728
$$





$$
2x^3=3456\quad 3x^2=432\quad 8x=96
$$





$$
f(12)=3456-432+96=3120
$$



### x=20



$$
x^2=20\times20=400\qquad x^3=400\times20=8000
$$





$$
2x^3=16000\quad 3x^2=1200\quad 8x=160
$$





$$
f(20)=16000-1200+160=14960
$$



### x=17



$$
x^2=17\times17=289\qquad x^3=289\times17=4913
$$





$$
2x^3=9826\quad 3x^2=867\quad 8x=136
$$





$$
f(17)=9826-867+136=9095
$$



### x=13



$$
x^2=13\times13=169\qquad x^3=169\times13=2197
$$





$$
2x^3=4394\quad 3x^2=507\quad 8x=104
$$





$$
f(13)=4394-507+104=3991
$$



### x=16



$$
x^2=16\times16=256\qquad x^3=256\times16=4096
$$





$$
2x^3=8192\quad 3x^2=768\quad 8x=128
$$





$$
f(16)=8192-768+128=7552
$$



### x=21



$$
x^2=21\times21=441\qquad x^3=441\times21=9261
$$





$$
2x^3=18522\quad 3x^2=1323\quad 8x=168
$$





$$
f(21)=18522-1323+168=17367
$$



---

## M2 · Q7(a) Applications of fuzzy logic [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/papers/paper-reexam-2026--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/papers/paper-reexam-2026/q7a

Longer past-paper practice restricted to Fuzzy, GA and PSO.

**List the applications of fuzzy logic. Explain any one application in detail.** [10 marks]

### Answer

### Definition

Fuzzy logic is a multi-valued logic, introduced by Lotfi Zadeh (1965), in which truth values range over [0, 1]; it lets machines reason with vague, human-like terms such as “slightly dirty” or “very hot”.

### Applications

| Area | Examples |
| --- | --- |
| Home appliances | Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners |
| Automotive | Automatic transmission, anti-lock braking (ABS), cruise control, engine control |
| Transportation | Traffic-signal control, Sendai subway train control (smooth braking and acceleration) |
| Consumer electronics | Camera autofocus and auto-exposure, image stabilisation |
| Industrial control | Cement kilns, pH, temperature and distillation control in chemical plants |
| Aerospace | Satellite and spacecraft attitude control |
| Medicine | Diagnosis support, anaesthesia dosage control |
| Finance and decisions | Loan approval, credit and fire-risk scoring, stock trading rules |
| AI and robotics | Robot navigation, natural-language interfaces, expert systems |

### One application in detail: fuzzy washing machine

1. **Problem.** Wash time depends on how dirty and how greasy the clothes are. These are vague (“a bit dirty”), and a fixed timer wastes water and power.
2. **Inputs and outputs.** Sensors measure dirt (turbidity of water) and grease; the output is wash time. Each is described by fuzzy sets: dirt Small/Medium/High, grease Small/Medium/High, time Very Short … Very Long.
3. **Fuzzification.** Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.
4. **Rule base.** 9 expert rules, e.g. IF dirt is High AND grease is High THEN time is Very Long; IF dirt is Small AND grease is Small THEN time is Very Short.
5. **Inference.** Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.
6. **Defuzzification.** Use the specified defuzzifier. For a separate representative-weighted illustration, strengths [.6,.4,.2] at times [25,40,60] give (.6×25+.4×40+.2×60)/(.6+.4+.2)=(15+16+12)/1.2≈35.833 minutes. These illustrative strengths are supplied here, not derived from unspecified input graphs. A Mamdani area centroid requires the full aggregate shape.
7. **Benefits.** Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.

### Advantages and disadvantages (bonus)

**Advantages:** handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. **Disadvantages:** rules and membership functions depend on expert judgement; results are hard to verify formally; tuning can take time; not suited where very high precision is required.

**Yaad rakho:** Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.

---

## M2 · Q1(a) · Fuzzy operations [2]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-1--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-1/q1a

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q1(a). On U = {u1, u2, u3}, A has memberships [0.2, 0.8, 0.6] and B has memberships [0.7, 0.3, 0.5]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [2 marks · Practice]

#### Given

| Element | u1 | u2 | u3 |
| --- | --- | --- | --- |
| A | 0.2 | 0.8 | 0.6 |
| B | 0.7 | 0.3 | 0.5 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-0.7=0.3
$$





$$
\mu_{A\setminus B}(u_1)=\min(0.2,0.3)=0.2
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0.2 | 0.7 | max(0.2, 0.7) = 0.7 | min(0.2, 0.7) = 0.2 | 1 − 0.7 = 0.3 | min(0.2, 0.3) = 0.2 |
| u2 | 0.8 | 0.3 | max(0.8, 0.3) = 0.8 | min(0.8, 0.3) = 0.3 | 1 − 0.3 = 0.7 | min(0.8, 0.7) = 0.7 |
| u3 | 0.6 | 0.5 | max(0.6, 0.5) = 0.6 | min(0.6, 0.5) = 0.5 | 1 − 0.5 = 0.5 | min(0.6, 0.5) = 0.5 |

**Final answer.** A ∪ B = [0.7, 0.8, 0.6]; A ∩ B = [0.2, 0.3, 0.5]; Bᶜ = [0.3, 0.7, 0.5]; A ∖ B = [0.2, 0.7, 0.5].

---

## M2 · Q1(b) · Swarm intelligence [2]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-1--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-1/q1b

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q1(b). Define swarm intelligence. Briefly explain one nature-inspired algorithm.** [2 marks · Practice]

#### Answer

Swarm intelligence is collective problem-solving arising from interactions among simple agents. PSO is inspired by social movement in flocks. Each particle represents a candidate solution and has a position and velocity. It moves using its own best visited position and the swarm’s best position. Repeated objective evaluation guides the search.

---

## M2 · Q2 · GA through two generations [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-1--q2/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-1/q2

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q2. Maximise 

$$
f(x)=x^2
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [3, 5, 10, 12]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [1, 2, 3, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Current individual row numbers [3, 4, 4, 3] |
| 2 | Current individual row numbers [2, 3, 2, 3] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 3 | 0011 | 3 × 3 = 9 |
| 2 | 5 | 0101 | 5 × 5 = 25 |
| 3 | 10 | 1010 | 10 × 10 = 100 |
| 4 | 12 | 1100 | 12 × 12 = 144 |

##### Step 2. Generation 1: apply the supplied selection order

The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 3 | 10 | 1010 |
| 2 | 4 | 12 | 1100 |
| 3 | 4 | 12 | 1100 |
| 4 | 3 | 10 | 1010 |

##### Step 3. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 10 | 10 | 11 | 00 | 1000 | 1110 |
| 3 & 4 | 11 | 00 | 10 | 10 | 1110 | 1000 |

##### Step 4. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1000 | Flip bit 4 | 1001 |
| 2 | 1110 | Flip bit 4 | 1111 |
| 3 | 1110 | Flip bit 4 | 1111 |
| 4 | 1000 | Flip bit 4 | 1001 |

##### Step 5. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1001 | 8 + 0 + 0 + 1 = 9 | 9² = 81 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1001 | 8 + 0 + 0 + 1 = 9 | 9² = 81 |

##### Step 6. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{9+25+100+144}{4}=\frac{278}{4}=69.5
$$





$$
\overline f_{new}=\frac{81+225+225+81}{4}=\frac{612}{4}=153
$$



Best objective: 144 → 225. Higher is better. The next population is [9, 15, 15, 9]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 7. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 9 | 1001 | 9 × 9 = 81 |
| 2 | 15 | 1111 | 15 × 15 = 225 |
| 3 | 15 | 1111 | 15 × 15 = 225 |
| 4 | 9 | 1001 | 9 × 9 = 81 |

##### Step 8. Generation 2: apply the supplied selection order

The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 2 | 15 | 1111 |
| 2 | 3 | 15 | 1111 |
| 3 | 2 | 15 | 1111 |
| 4 | 3 | 15 | 1111 |

##### Step 9. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 11 | 11 | 11 | 11 | 1111 | 1111 |
| 3 & 4 | 11 | 11 | 11 | 11 | 1111 | 1111 |

##### Step 10. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1111 | Flip bit 4 | 1110 |
| 2 | 1111 | Flip bit 4 | 1110 |
| 3 | 1111 | Flip bit 4 | 1110 |
| 4 | 1111 | Flip bit 4 | 1110 |

##### Step 11. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |

##### Step 12. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{81+225+225+81}{4}=\frac{612}{4}=153
$$





$$
\overline f_{new}=\frac{196+196+196+196}{4}=\frac{784}{4}=196
$$



Best objective: 225 → 196. Higher is better. The next population is [14, 14, 14, 14]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [14, 14, 14, 14]. Best final objective = 196 at x = [14].

---

## M2 · Q3 · Two-particle PSO through iteration 2 [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-1--q3/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-1/q3

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q3. Minimise 

$$
f(x)=x^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (-1) | (0) |
| B | (3) | (0) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(-1)=(-1)^2=1=1
$$



**Particle B**



$$
f(3)=3^2=9=9
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(-1)
$$



Its score is 1. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (-1). pbest values are A: (-1), B: (3).

##### Step 4. Iteration 1: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=-1-(-1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-1-(-1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=(-1)+0=-1
$$



##### Step 5. Iteration 1: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3-(3)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-1-(3)=-4
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-4)=-2
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-2)=-2
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=3+(-2)=1
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(-1)=(-1)^2=1=1
$$



**Particle B**



$$
f(1)=1^2=1=1
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 1 | Keep old: tie | (-1) |
| B | 9 | 1 | Replace: new score is lower | (1) |

Compare the retained pbest scores. gbest = **(-1)**, with objective **1**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (-1) | (0) | (-1) |
| B | (1) | (-2) | (1) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (-1). pbest values are A: (-1), B: (1).

##### Step 10. Iteration 2: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=-1-(-1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-1-(-1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=(-1)+0=-1
$$



##### Step 11. Iteration 2: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-2)=-1
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-1-(1)=-2
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-2)=-1
$$



Add the three velocity contributions.



$$
v^{(2)}=(-1)+0+(-1)=-2
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1+(-2)=-1
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(-1)=(-1)^2=1=1
$$



**Particle B**



$$
f(-1)=(-1)^2=1=1
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 1 | Keep old: tie | (-1) |
| B | 1 | 1 | Keep old: tie | (1) |

Compare the retained pbest scores. gbest = **(-1)**, with objective **1**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (-1) | (0) | (-1) |
| B | (-1) | (-2) | (1) |

**Final answer.** After iteration 2, gbest = (-1), objective = 1. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

---

## M2 · Q4 · Fuzzy architecture [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-1--q4/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-1/q4

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q4. Explain the architecture of a Mamdani fuzzy inference system with a fan-controller example.** [3 marks · Practice]

#### Answer

The fuzzifier maps crisp temperature and occupancy inputs to membership degrees. The knowledge base contains membership functions and IF–THEN rules. The inference engine combines antecedent degrees, applies each rule’s consequent and aggregates the inferred outputs. The defuzzifier converts this aggregate to a numerical fan speed. For example, IF temperature is High AND occupancy is High THEN fan speed is Very High.

---

## M2 · Q1(a) · Fuzzy operations [2]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-2--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-2/q1a

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q1(a). On U = {u1, u2, u3}, A has memberships [0.1, 0.5, 1] and B has memberships [0.9, 0.4, 0]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [2 marks · Practice]

#### Given

| Element | u1 | u2 | u3 |
| --- | --- | --- | --- |
| A | 0.1 | 0.5 | 1 |
| B | 0.9 | 0.4 | 0 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-0.9=0.1
$$





$$
\mu_{A\setminus B}(u_1)=\min(0.1,0.1)=0.1
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0.1 | 0.9 | max(0.1, 0.9) = 0.9 | min(0.1, 0.9) = 0.1 | 1 − 0.9 = 0.1 | min(0.1, 0.1) = 0.1 |
| u2 | 0.5 | 0.4 | max(0.5, 0.4) = 0.5 | min(0.5, 0.4) = 0.4 | 1 − 0.4 = 0.6 | min(0.5, 0.6) = 0.5 |
| u3 | 1 | 0 | max(1, 0) = 1 | min(1, 0) = 0 | 1 − 0 = 1 | min(1, 1) = 1 |

**Final answer.** A ∪ B = [0.9, 0.5, 1.0]; A ∩ B = [0.1, 0.4, 0.0]; Bᶜ = [0.1, 0.6, 1.0]; A ∖ B = [0.1, 0.5, 1.0].

---

## M2 · Q1(b) · Swarm intelligence [2]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-2--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-2/q1b

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q1(b). Define swarm intelligence. Briefly explain one nature-inspired algorithm.** [2 marks · Practice]

#### Answer

Swarm intelligence is collective problem-solving arising from interactions among simple agents. PSO is inspired by social movement in flocks. Each particle represents a candidate solution and has a position and velocity. It moves using its own best visited position and the swarm’s best position. Repeated objective evaluation guides the search.

---

## M2 · Q2 · GA through two generations [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-2--q2/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-2/q2

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q2. Maximise 

$$
f(x)=x^2
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [1, 6, 9, 14]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 3 of children [1, 2, 3, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Current individual row numbers [3, 4, 4, 3] |
| 2 | Current individual row numbers [2, 3, 2, 3] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 1 | 0001 | 1 × 1 = 1 |
| 2 | 6 | 0110 | 6 × 6 = 36 |
| 3 | 9 | 1001 | 9 × 9 = 81 |
| 4 | 14 | 1110 | 14 × 14 = 196 |

##### Step 2. Generation 1: apply the supplied selection order

The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 3 | 9 | 1001 |
| 2 | 4 | 14 | 1110 |
| 3 | 4 | 14 | 1110 |
| 4 | 3 | 9 | 1001 |

##### Step 3. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 10 | 01 | 11 | 10 | 1010 | 1101 |
| 3 & 4 | 11 | 10 | 10 | 01 | 1101 | 1010 |

##### Step 4. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1010 | Flip bit 3 | 1000 |
| 2 | 1101 | Flip bit 3 | 1111 |
| 3 | 1101 | Flip bit 3 | 1111 |
| 4 | 1010 | Flip bit 3 | 1000 |

##### Step 5. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8² = 64 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8² = 64 |

##### Step 6. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{1+36+81+196}{4}=\frac{314}{4}=78.5
$$





$$
\overline f_{new}=\frac{64+225+225+64}{4}=\frac{578}{4}=144.5
$$



Best objective: 196 → 225. Higher is better. The next population is [8, 15, 15, 8]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 7. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 8 | 1000 | 8 × 8 = 64 |
| 2 | 15 | 1111 | 15 × 15 = 225 |
| 3 | 15 | 1111 | 15 × 15 = 225 |
| 4 | 8 | 1000 | 8 × 8 = 64 |

##### Step 8. Generation 2: apply the supplied selection order

The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 2 | 15 | 1111 |
| 2 | 3 | 15 | 1111 |
| 3 | 2 | 15 | 1111 |
| 4 | 3 | 15 | 1111 |

##### Step 9. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 11 | 11 | 11 | 11 | 1111 | 1111 |
| 3 & 4 | 11 | 11 | 11 | 11 | 1111 | 1111 |

##### Step 10. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1111 | Flip bit 3 | 1101 |
| 2 | 1111 | Flip bit 3 | 1101 |
| 3 | 1111 | Flip bit 3 | 1101 |
| 4 | 1111 | Flip bit 3 | 1101 |

##### Step 11. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13² = 169 |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13² = 169 |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13² = 169 |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13² = 169 |

##### Step 12. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{64+225+225+64}{4}=\frac{578}{4}=144.5
$$





$$
\overline f_{new}=\frac{169+169+169+169}{4}=\frac{676}{4}=169
$$



Best objective: 225 → 169. Higher is better. The next population is [13, 13, 13, 13]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [13, 13, 13, 13]. Best final objective = 169 at x = [13].

---

## M2 · Q3 · Two-particle PSO through iteration 2 [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-2--q3/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-2/q3

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q3. Minimise 

$$
f(x)=x^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (2) | (0) |
| B | (5) | (0) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(2)=2^2=4=4
$$



**Particle B**



$$
f(5)=5^2=25=25
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(2)
$$



Its score is 4. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (2). pbest values are A: (2), B: (5).

##### Step 4. Iteration 1: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=2-(2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=2-(2)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=2+0=2
$$



##### Step 5. Iteration 1: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=5-(5)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=2-(5)=-3
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-3)=-1.5
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-1.5)=-1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=5+(-1.5)=3.5
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(2)=2^2=4=4
$$



**Particle B**



$$
f(3.5)=3.5^2=12.25=12.25
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 4 | 4 | Keep old: tie | (2) |
| B | 25 | 12.25 | Replace: new score is lower | (3.5) |

Compare the retained pbest scores. gbest = **(2)**, with objective **4**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (2) | (0) | (2) |
| B | (3.5) | (-1.5) | (3.5) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (2). pbest values are A: (2), B: (3.5).

##### Step 10. Iteration 2: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=2-(2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=2-(2)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=2+0=2
$$



##### Step 11. Iteration 2: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1.5)=-0.75
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3.5-(3.5)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=2-(3.5)=-1.5
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-1.5)=-0.75
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.75)+0+(-0.75)=-1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=3.5+(-1.5)=2
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(2)=2^2=4=4
$$



**Particle B**



$$
f(2)=2^2=4=4
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 4 | 4 | Keep old: tie | (2) |
| B | 12.25 | 4 | Replace: new score is lower | (2) |

Compare the retained pbest scores. gbest = **(2)**, with objective **4**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (2) | (0) | (2) |
| B | (2) | (-1.5) | (2) |

**Final answer.** After iteration 2, gbest = (2), objective = 4. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

---

## M2 · Q4 · Fuzzy membership [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-2--q4/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-2/q4

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q4. A fuzzy set A has triangular membership Tri(15, 25, 35). Find membership at x = 32.** [3 marks · Practice]

#### Given

Left endpoint a = 15; peak b = 25; right endpoint c = 35; input x = 32.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

25 < 32 < 35, so membership decreases as x moves away from the peak.

##### Step 2. Choose the correct expression

Falling side



$$
\mu_A(32)=\frac{35-32}{35-25}=\frac{3}{10}=0.3
$$



##### Step 3. Interpret the value

The degree of belonging to A is 0.3. It is a membership degree, not a probability.

**Final answer.** μA(32) = 0.3.

---

## M2 · Q1(a) · Fuzzy operations [2]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-3--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-3/q1a

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q1(a). On U = {u1, u2, u3}, A has memberships [0.7, 0.2, 0.9] and B has memberships [0.3, 0.8, 0.4]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [2 marks · Practice]

#### Given

| Element | u1 | u2 | u3 |
| --- | --- | --- | --- |
| A | 0.7 | 0.2 | 0.9 |
| B | 0.3 | 0.8 | 0.4 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-0.3=0.7
$$





$$
\mu_{A\setminus B}(u_1)=\min(0.7,0.7)=0.7
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0.7 | 0.3 | max(0.7, 0.3) = 0.7 | min(0.7, 0.3) = 0.3 | 1 − 0.3 = 0.7 | min(0.7, 0.7) = 0.7 |
| u2 | 0.2 | 0.8 | max(0.2, 0.8) = 0.8 | min(0.2, 0.8) = 0.2 | 1 − 0.8 = 0.2 | min(0.2, 0.2) = 0.2 |
| u3 | 0.9 | 0.4 | max(0.9, 0.4) = 0.9 | min(0.9, 0.4) = 0.4 | 1 − 0.4 = 0.6 | min(0.9, 0.6) = 0.6 |

**Final answer.** A ∪ B = [0.7, 0.8, 0.9]; A ∩ B = [0.3, 0.2, 0.4]; Bᶜ = [0.7, 0.2, 0.6]; A ∖ B = [0.7, 0.2, 0.6].

---

## M2 · Q1(b) · Swarm intelligence [2]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-3--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-3/q1b

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q1(b). Define swarm intelligence. Briefly explain one nature-inspired algorithm.** [2 marks · Practice]

#### Answer

Swarm intelligence is collective problem-solving arising from interactions among simple agents. PSO is inspired by social movement in flocks. Each particle represents a candidate solution and has a position and velocity. It moves using its own best visited position and the swarm’s best position. Repeated objective evaluation guides the search.

---

## M2 · Q2 · GA through two generations [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-3--q2/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-3/q2

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q2. Maximise 

$$
f(x)=x^2
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [2, 7, 8, 13]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [1, 2, 3, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Current individual row numbers [3, 4, 4, 3] |
| 2 | Current individual row numbers [2, 3, 2, 3] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 2 | 0010 | 2 × 2 = 4 |
| 2 | 7 | 0111 | 7 × 7 = 49 |
| 3 | 8 | 1000 | 8 × 8 = 64 |
| 4 | 13 | 1101 | 13 × 13 = 169 |

##### Step 2. Generation 1: apply the supplied selection order

The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 3 | 8 | 1000 |
| 2 | 4 | 13 | 1101 |
| 3 | 4 | 13 | 1101 |
| 4 | 3 | 8 | 1000 |

##### Step 3. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 10 | 00 | 11 | 01 | 1001 | 1100 |
| 3 & 4 | 11 | 01 | 10 | 00 | 1100 | 1001 |

##### Step 4. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1001 | Flip bit 4 | 1000 |
| 2 | 1100 | Flip bit 4 | 1101 |
| 3 | 1100 | Flip bit 4 | 1101 |
| 4 | 1001 | Flip bit 4 | 1000 |

##### Step 5. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8² = 64 |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13² = 169 |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13² = 169 |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8² = 64 |

##### Step 6. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{4+49+64+169}{4}=\frac{286}{4}=71.5
$$





$$
\overline f_{new}=\frac{64+169+169+64}{4}=\frac{466}{4}=116.5
$$



Best objective: 169 → 169. Higher is better. The next population is [8, 13, 13, 8]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 7. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 8 | 1000 | 8 × 8 = 64 |
| 2 | 13 | 1101 | 13 × 13 = 169 |
| 3 | 13 | 1101 | 13 × 13 = 169 |
| 4 | 8 | 1000 | 8 × 8 = 64 |

##### Step 8. Generation 2: apply the supplied selection order

The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 2 | 13 | 1101 |
| 2 | 3 | 13 | 1101 |
| 3 | 2 | 13 | 1101 |
| 4 | 3 | 13 | 1101 |

##### Step 9. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 11 | 01 | 11 | 01 | 1101 | 1101 |
| 3 & 4 | 11 | 01 | 11 | 01 | 1101 | 1101 |

##### Step 10. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1101 | Flip bit 4 | 1100 |
| 2 | 1101 | Flip bit 4 | 1100 |
| 3 | 1101 | Flip bit 4 | 1100 |
| 4 | 1101 | Flip bit 4 | 1100 |

##### Step 11. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1100 | 8 + 4 + 0 + 0 = 12 | 12² = 144 |
| 1100 | 8 + 4 + 0 + 0 = 12 | 12² = 144 |
| 1100 | 8 + 4 + 0 + 0 = 12 | 12² = 144 |
| 1100 | 8 + 4 + 0 + 0 = 12 | 12² = 144 |

##### Step 12. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{64+169+169+64}{4}=\frac{466}{4}=116.5
$$





$$
\overline f_{new}=\frac{144+144+144+144}{4}=\frac{576}{4}=144
$$



Best objective: 169 → 144. Higher is better. The next population is [12, 12, 12, 12]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [12, 12, 12, 12]. Best final objective = 144 at x = [12].

---

## M2 · Q3 · Two-particle PSO through iteration 2 [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-3--q3/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-3/q3

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q3. Minimise 

$$
f(x)=x^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (1) | (2) |
| B | (4) | (-1) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(1)=1^2=1=1
$$



**Particle B**



$$
f(4)=4^2=16=16
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(1)
$$



Its score is 1. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (1), B: (4).

##### Step 4. Iteration 1: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times2=1
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=1+0+0=1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=1+1=2
$$



##### Step 5. Iteration 1: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1)=-0.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=4-(4)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(4)=-3
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-3)=-1.5
$$



Add the three velocity contributions.



$$
v^{(1)}=(-0.5)+0+(-1.5)=-2
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=4+(-2)=2
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(2)=2^2=4=4
$$



**Particle B**



$$
f(2)=2^2=4=4
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 4 | Keep old: new score is worse | (1) |
| B | 16 | 4 | Replace: new score is lower | (2) |

Compare the retained pbest scores. gbest = **(1)**, with objective **1**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (2) | (1) | (1) |
| B | (2) | (-2) | (2) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (1), B: (2).

##### Step 10. Iteration 2: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times1=0.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(2)=-1
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(-1)=-0.5
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(2)=-1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-1)=-0.5
$$



Add the three velocity contributions.



$$
v^{(2)}=0.5+(-0.5)+(-0.5)=-0.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=2+(-0.5)=1.5
$$



##### Step 11. Iteration 2: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-2)=-1
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=2-(2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(2)=-1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-1)=-0.5
$$



Add the three velocity contributions.



$$
v^{(2)}=(-1)+0+(-0.5)=-1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=2+(-1.5)=0.5
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(1.5)=1.5^2=2.25=2.25
$$



**Particle B**



$$
f(0.5)=0.5^2=0.25=0.25
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 2.25 | Keep old: new score is worse | (1) |
| B | 4 | 0.25 | Replace: new score is lower | (0.5) |

Compare the retained pbest scores. gbest = **(0.5)**, with objective **0.25**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (1.5) | (-0.5) | (1) |
| B | (0.5) | (-1.5) | (0.5) |

**Final answer.** After iteration 2, gbest = (0.5), objective = 0.25. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

---

## M2 · Q4 · Fuzzy defuzzification [3]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/mocks/m2-paper-v2-3--q4/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/mocks/m2-paper-v2-3/q4

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

**Confirmed M2 pattern:** Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

**Q4. Using the weighted-average method, combine output representatives [20, 50, 80] % with respective strengths [0.2, 0.6, 0.2].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 20 | 0.2 |
| 50 | 0.6 |
| 80 | 0.2 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0.2 × 20 | 4 |
| 0.6 × 50 | 30 |
| 0.2 × 80 | 16 |

##### Step 2. Add the products



$$
4+30+16=50
$$



##### Step 3. Add the strengths



$$
0.2+0.6+0.2=1
$$



##### Step 4. Divide



$$
z^*=\frac{50}{1}=50
$$



**Final answer.** 50 %.

---

## M2 · The final revision: methods, theory and common mistakes

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/revision/m2-revision-v2--final-read/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/revision/m2-revision-v2/final-read

A compact read after the worked lessons.

## Q1: short calculations and definitions

| Asked for | Write |
| --- | --- |
| Union / intersection | Same element, max / min respectively. |
| Complement / difference | 1−μA / min(μA,1−μB). |
| Triangle membership | Locate x; rising (x−a)/(b−a), falling (c−x)/(c−b), 0 outside, 1 at peak. |
| Swarm intelligence | Collective problem-solving emerging from interacting simple agents; explain PSO through position, velocity, pbest and gbest. |

## GA: the table to make in the exam

Individual → current x → bit string → fitness → selected parent → crossover child → mutated child → decoded x → new fitness. Use this resulting population as the input to the second generation. The cut position and flipped bit are counted from the stated end; this guide counts from the left.

Do not change the mutation instruction midway because an answer looks worse. Without elitism, fitness can worsen. Do not confuse a mating-pool index with the decimal x value.

## PSO: the table to make in the exam

Particle → old position → old velocity → pbest → gbest → inertia/personal/social terms → new velocity → new position → new objective → retained pbest. After all particles, update gbest. For synchronous updates, freeze the old gbest throughout one iteration.

At initialisation pbest=x, hence personal pull=0. In iteration 2 it need not be zero. For minimisation, smaller objective wins; a worse move must not overwrite a better memory.

## Fuzzy controller: five operations

1. Calculate input memberships using the specified graphs.
2. Apply AND=min or the supplied connective to obtain rule strengths.
3. Clip consequents using min-implication.
4. Combine output sets by max-aggregation.
5. Use the named defuzzification method. MoM, full area centroid and peak-weighted average are different operations.

## Three short theory answers to revise

**Mamdani:** crisp inputs → fuzzifier → knowledge base and inference engine → aggregation → defuzzifier → crisp output. Rules are interpretable, but require careful membership/rule design and can grow in number.

**GA:** population search inspired by evolution, using evaluation, selection, crossover, mutation and replacement. Flexible and derivative-free, but may be expensive or converge prematurely.

**PSO:** particles move using inertia, personal best and swarm best. Simple and derivative-free, but parameter-dependent and not guaranteed to find a global optimum.

## Calculator and rounding

Enter a fraction as (whole numerator) ÷ (whole denominator). For a negative square use parentheses: (−2)²=4. Retain full calculator precision through iterations and round only the displayed result. Binary place values 8,4,2,1 can be checked manually without a special calculator mode.

**Yaad rakho:** Question ki instruction follow karo; answer ko sundar banane ke liye data ya operator mat badlo.

---

## M2 · Portion, source priority and what was checked

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/about/about--portion-sources/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/about/about/portion-sources

What this guide covers, where it came from, and every error found in the slides and answer keys

## M2

The 8 October class update identifies Fuzzy Logic, GA and PSO, including rules, architecture, advantages/disadvantages, fuzzy operations and numerical work through iteration 2. The confirmed pattern is Q1(a) 2 marks and Q1(b) 2 marks compulsory, plus any two of three 3-mark questions. ACO and GA-for-TSP remain in TEE, not the M2 core.

## TEE official syllabus

1. Uncertain knowledge and reasoning: uncertainty, full joint distributions, Bayes, naive Bayes, Bayesian networks, mixture models, GMM, EM and clustering.
2. Fuzzy systems: rules, properties/operations, membership functions, intuition-based fuzzification, mean of maxima, centroid, Mamdani and applications.
3. Evolutionary intelligence: biological basis, GA terms/search space, simple/general GA, encoding/selection/crossover/mutation, stopping, constraints, GA-for-TSP, ACO and swarm optimisation.
4. Reinforcement learning: Markov processes, MRP, MDP, policies, value functions, Bellman equations and applications.

The course policy specifies a 100-mark, three-hour TEE scaled to 50, and 10-mark class tests. The available Final 24 November 2025 and Re-exam 31 January 2026 papers have Q1 compulsory plus any four of Q2–Q7. The next paper’s instructions take precedence.

## Source priority

Primary course sources are the AY 2026–27 syllabus and course-policy files, faculty slides and solved-problem material in the 8 October OneDrive archive, the two actual question papers, and the class data supplied in the conversation. The old generated IS2 draft and the separate generated midterm PDF are not authorities for the new teaching sequence.

Handwritten photos can contain inconsistent arithmetic or incomplete conventions. The fan example states its chosen membership functions; the PSO example states minimisation and synchronous updates. Missing selection choices, mutation bits or inconsistent encodings in older papers are labelled explicitly rather than presented as unique answers.

## Technical references used for checking conventions

- [MathWorks: fuzzy inference process](https://www.mathworks.com/help/fuzzy/fuzzy-inference-process.html) — separation of antecedent operations, implication, aggregation and defuzzification.
- [MathWorks: defuzzification definitions](https://www.mathworks.com/help/fuzzy/defuzz.html) — centroid uses the area; MoM uses locations at the maximum.
- [MathWorks: particle swarm update](https://www.mathworks.com/help/gads/particle-swarm-optimization-algorithm.html) — velocity components and best-position memory. Its adaptive neighbourhood implementation is not substituted for the fixed classroom global-best examples.

New worked numerical examples are calculated by reproducible scripts and checked separately. Build checks validate formula rendering and internal routes. This does not justify a promise that no typo can remain, that every future numerical is predictable, or that reading alone guarantees a score.

---

## M2 · How inconsistent source questions are handled

Canonical: https://deep-learning-study-room.vercel.app/read/is2/m2/about/about--corrections/

Reader: https://deep-learning-study-room.vercel.app/is2/#m2/about/about/corrections

What this guide covers, where it came from, and every error found in the slides and answer keys

## State the issue before solving a changed question

The final GA paper requests four-bit parents larger than 15 while also restricting x to 0–15. Those conditions cannot all hold. Its worked example declares a repaired parent set. The re-exam GA paper needs six bits to cover the stated 0–50 range. An encoding change must not silently change the legal range.

The final joint table sums to 1.002 rather than 1. Its lesson distinguishes ratios from the printed weights, normalisation, and an assumed typo correction. None is presented as a guaranteed marking-scheme interpretation.

Some fuzzy classroom solutions calculate a peak-weighted output and call it a centroid. The new lessons name that operation and separately teach the true area centroid. The class fan photographs do not supply one consistent complete set of membership functions, so its worked design makes every breakpoint explicit.

For relation composition, check the intermediate labels and the author’s convention for S∘R. A numerical matrix product alone does not resolve a mismatched relation domain.

---

## TEE · How the TEE is set and how to prepare

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/tee-start--tee-plan/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/tee-start/tee-plan

Term-end examination · 100 marks · 3 hours · all four units

## Paper pattern (both 2025–26 papers)

- 100 marks, 3 hours, scaled to 50.
- **Q1 compulsory**: four 5-mark parts, typically (a) a joint-probability table, (b) applications of ACO or PSO, (c) fuzzy set operations, (d) a two-state Markov transition matrix and diagram.
- **Answer any four of Q2–Q7**, each with two 10-mark parts.

## What came in each paper

| Topic | Unit | Nov 2025 | Jan 2026 |
| --- | --- | --- | --- |
| Joint table (5) | 1 | Q1a | Q1a |
| GMM: k-means, log-likelihood, parameters (10) | 1 | Q2b | Q2b |
| Bayesian network query (10) | 1 | Q3a | Q3a |
| Naive Bayes (10) | 1 | Q4b | Q4b |
| Fuzzy set operations (5) | 2 | Q1c | Q1c |
| Mamdani design + defuzzify (10) | 2 | Q3b | Q2a |
| Fuzzy relation composition (10) | 2 | Q4a | Q3b |
| Fuzzy applications (10) | 2 | Q6a | Q7a |
| PSO numerical (10) | 3 | Q2a | Q4a |
| GA numerical (10) | 3 | Q5b | Q5a |
| ACO numerical (10) | 3 | Q7b | Q6a |
| PSO / ACO applications (5–10) | 3 | Q1b, Q7a | Q1b |
| Markov 2-state (5) | 4 | Q1d | Q1d |
| Markov 3-state, 5 parts (10) | 4 | Q5a, Q6b | Q5b, Q6b |
| Bellman + RL applications (10) | 4 | — | Q7b |

These two available papers repeat many question families. They guide practice but do not establish an exhaustive list for the next examination. The reading route also covers the official syllabus topics not asked in these two papers.

## Choosing your four questions

1. Q1 first (20 marks, about 30 minutes).
2. Judge each complete 20-mark question, including both 10-mark parts. Prepare the repeated numerical families (PSO, ACO, GA, Markov, Bayesian networks and Naive Bayes) together with their paired theory. Do not select a question merely because one part is numerical.
3. After about 30 minutes for Q1, budget about 35 minutes for each of the four selected 20-mark questions and 10 minutes to re-check arithmetic (30+4×35+10=180 minutes).

## Study route

The TEE reading route covers Units 1–4; if continuing after M2, begin with Unit 1, then the TEE-only GA-for-TSP/ACO material and Unit 4, solve both papers in the “Solved papers” tab without looking, compare, and finish with the formula sheets and the last-day revision.

## Question evidence versus teaching examples

The table above describes the actual November 2025 final and January 2026 re-exam. The solved papers retain their original marks. Other worked examples labelled Practice are authored learning exercises; their marks are suggested practice sizes.

Both papers ask GMM comparison with k-means, log-likelihood derivation and a K=5 parameter count. The small EM-update examples explain the faculty topic but are not additional observed TEE questions. Q-learning is an optional extension, outside the core formula list. Retain the full syllabus theory even when these two papers did not ask a particular variant.

---

## TEE · Every paper: question, unit, marks and solved answer

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/tee-start--question-map/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/tee-start/question-map

Term-end examination · 100 marks · 3 hours · all four units

## Use this map with the solved papers

Each row links directly to the full question and its answer. **Offered marks** count all printed choices; **attempted marks** are the marks you are allowed to answer. Unit totals below describe what appeared on that paper, not a prediction or a compulsory unit-wise distribution.

**Types:** Numerical = calculations; Theory = explain/compare; Mixed = calculations with explanation; Case = apply or design a system. A case can contain substantial calculation.

## 2026-01-31 · Re-examination · current 2025–26 paper

**100 marks to attempt; 140 marks offered.** Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.

**Offered marks by current unit:** Unit 1: 35, Unit 2: 35, Unit 3: 35, Unit 4: 35. Unspecified internal task marks are not split or guessed.

| Question | Marks | Current unit and topic | Type | Answer |
| --- | --- | --- | --- | --- |
| **Q1(a)** | 5 | Unit 1 · Joint probability: disease, fever and test | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1a/) |
| **Q1(b)** | 5 | Unit 3 · PSO applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1b/) |
| **Q1(c)** | 5 | Unit 2 · Fuzzy set operations | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1c/) |
| **Q1(d)** | 5 | Unit 4 · Two-state Markov bank model | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1d/) |
| **Q2(a)** | 10 | Unit 2 · Mamdani fire-controller design and centroid | Case | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q2a/) |
| **Q2(b)** | 10 | Unit 1 · GMM, k-means, likelihood and parameters | Mixed | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q2b/) |
| **Q3(a)** | 10 | Unit 1 · Bayesian network: fever given no flu | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q3a/) |
| **Q3(b)** | 10 | Unit 2 · Fuzzy Cartesian product and composition | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q3b/) |
| **Q4(a)** | 10 | Unit 3 · PSO one iteration and best memories | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q4a/) |
| **Q4(b)** | 10 | Unit 1 · Naive Bayes job classification | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q4b/) |
| **Q5(a)** | 10 | Unit 3 · Genetic algorithm offspring and fitness | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q5a/) |
| **Q5(b)** | 10 | Unit 4 · Markov booking channels and stationary distribution | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q5b/) |
| **Q6(a)** | 10 | Unit 3 · ACO travelling salesman tour and pheromones | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q6a/) |
| **Q6(b)** | 10 | Unit 4 · Markov aircraft movement and stationary distribution | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q6b/) |
| **Q7(a)** | 10 | Unit 2 · Fuzzy logic applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q7a/) |
| **Q7(b)** | 10 | Unit 4 · Bellman equation and RL applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q7b/) |

## 2025-11-24 · Final examination · current 2025–26 paper

**100 marks to attempt; 140 marks offered.** Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.

**Offered marks by current unit:** Unit 1: 35, Unit 2: 35, Unit 3: 45, Unit 4: 25. Unspecified internal task marks are not split or guessed.

| Question | Marks | Current unit and topic | Type | Answer |
| --- | --- | --- | --- | --- |
| **Q1(a)** | 5 | Unit 1 · Joint probability and conditional inference | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1a/) |
| **Q1(b)** | 5 | Unit 3 · ACO applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1b/) |
| **Q1(c)** | 5 | Unit 2 · Fuzzy set operations | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1c/) |
| **Q1(d)** | 5 | Unit 4 · Two-state Markov transition model | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1d/) |
| **Q2(a)** | 10 | Unit 3 · PSO one iteration and best memories | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q2a/) |
| **Q2(b)** | 10 | Unit 1 · GMM, k-means, likelihood and parameters | Mixed | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q2b/) |
| **Q3(a)** | 10 | Unit 1 · Bayesian network: wet grass given no rain | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q3a/) |
| **Q3(b)** | 10 | Unit 2 · Mamdani loan-controller design and centroid | Case | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q3b/) |
| **Q4(a)** | 10 | Unit 2 · Fuzzy Cartesian product and composition | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q4a/) |
| **Q4(b)** | 10 | Unit 1 · Naive Bayes flu classification | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q4b/) |
| **Q5(a)** | 10 | Unit 4 · Markov hotel movement and stationary distribution | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q5a/) |
| **Q5(b)** | 10 | Unit 3 · Genetic algorithm offspring and fitness | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q5b/) |
| **Q6(a)** | 10 | Unit 2 · Fuzzy logic applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q6a/) |
| **Q6(b)** | 10 | Unit 4 · Markov learner progression and stationary state | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q6b/) |
| **Q7(a)** | 10 | Unit 3 · PSO applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q7a/) |
| **Q7(b)** | 10 | Unit 3 · ACO travelling salesman tour and pheromones | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q7b/) |

## 2025-04-28 · Final / re-examination · Historical Semester VI

**100 marks to attempt; 140 marks offered.** Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.

**Offered marks by current unit:** Unit 1: 35, Unit 2: 35, Unit 3: 35, Unit 4: 35. Unspecified internal task marks are not split or guessed.

| Question | Marks | Current unit and topic | Type | Answer |
| --- | --- | --- | --- | --- |
| **Q1(a)** | 5 | Unit 1 · Joint masses, normalization and conditional probability | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1a/) |
| **Q1(b)** | 5 | Unit 3 · Genetic algorithm applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1b/) |
| **Q1(c)** | 5 | Unit 2 · Fuzzy union, intersection and complements | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1c/) |
| **Q1(d)** | 5 | Unit 4 · Cable-company Markov matrix and diagram | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1d/) |
| **Q2(a)** | 10 | Unit 2 · Fuzzy investment-controller design and centroid | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q2a/) |
| **Q2(b)** | 10 | Unit 1 · GMM versus k-means, log likelihood and parameter count | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q2b/) |
| **Q3(a)** | 10 | Unit 1 · Bayesian-network conditional cough probability | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q3a/) |
| **Q3(b)** | 10 | Unit 2 · Fuzzy Cartesian relations and composition-domain ambiguity | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q3b/) |
| **Q4(a)** | 10 | Unit 3 · PSO one iteration with missing initialization | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q4a/) |
| **Q4(b)** | 10 | Unit 1 · Naive Bayes product-purchase classification | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q4b/) |
| **Q5(a)** | 10 | Unit 3 · Binary GA crossover, one-bit mutation and fitness | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q5a/) |
| **Q5(b)** | 10 | Unit 4 · Bike-sharing Markov transitions, retention and gains | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q5b/) |
| **Q6(a)** | 10 | Unit 3 · ACO tour lengths, evaporation and pheromone deposition | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q6a/) |
| **Q6(b)** | 10 | Unit 4 · Two-step walking/cycling Markov transition | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q6b/) |
| **Q7(a)** | 10 | Unit 2 · Fuzzy logic applications and complete controller example | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q7a/) |
| **Q7(b)** | 10 | Unit 4 · Bellman equations and reinforcement-learning applications | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q7b/) |

**Source qualification:** Some questions omit parameter choices or contain ambiguous/inconsistent source data. The relevant answer distinguishes printed data from assumptions and calculates valid alternatives; all source questions remain represented.

## 2024-06-25 · Re-examination · Historical Semester VI

**100 marks to attempt; 140 marks offered.** Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.

**Offered marks by current unit:** Unit 1: 30, Unit 2: 40, Unit 3: 40, Unit 4: 30. Unspecified internal task marks are not split or guessed.

| Question | Marks | Current unit and topic | Type | Answer |
| --- | --- | --- | --- | --- |
| **Q1(a)** | 5 | Unit 3 · Traditional versus evolutionary optimization | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1a/) |
| **Q1(b)** | 5 | Unit 1 · Bayes posterior for red ball | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1b/) |
| **Q1(c)** | 5 | Unit 2 · Fuzzy union, intersection and complements | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1c/) |
| **Q1(d)** | 5 | Unit 4 · Irreducibility and stationary distribution | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1d/) |
| **Q2(a)** | 10 | Unit 1 · GMM modified log likelihood and parameters | Mixed | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q2a/) |
| **Q2(b)** | 10 | Unit 2 · Fuzzy washing-machine controller | Design | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q2b/) |
| **Q3(a)** | 10 | Unit 2 · Fuzzy relation and max-product comparison | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q3a/) |
| **Q3(b)** | 10 | Unit 3 · PSO maximization, supplied parameters | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q3b/) |
| **Q4(a)** | 10 | Unit 1 · Naive Bayes and Laplace smoothing | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q4a/) |
| **Q4(b)** | 10 | Unit 4 · Transition matrix properties and two-step probabilities | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q4b/) |
| **Q5(a)** | 10 | Unit 3 · GA selection, crossover and survivor replacement | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q5a/) |
| **Q5(b)** | 10 | Unit 2 · Mean of maxima and centroid of trapezoids | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q5b/) |
| **Q6(a)** | 10 | Unit 3 · Genetic algorithm for four-city TSP | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q6a/) |
| **Q6(b)** | 10 | Unit 4 · Markov process and homework transition paths | Mixed | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q6b/) |
| **Q7(a)** | 5 | Unit 1 · Expectation Maximization algorithm | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7a/) |
| **Q7(b)** | 5 | Unit 2 · Lambda-cut of a fuzzy relation | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7b/) |
| **Q7(c)** | 5 | Unit 3 · ACO path length and pheromone update | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7c/) |
| **Q7(d)** | 5 | Unit 4 · Bellman equation | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7d/) |

**Source qualification:** Some questions omit parameter choices or contain ambiguous/inconsistent source data. The relevant answer distinguishes printed data from assumptions and calculates valid alternatives; all source questions remain represented.

## 2024-04-17 · Final examination · Historical Semester VI

**100 marks to attempt; 140 marks offered.** Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.

**Offered marks by current unit:** Unit 1: 30, Unit 2: 40, Unit 3: 40, Unit 4: 30. Unspecified internal task marks are not split or guessed.

| Question | Marks | Current unit and topic | Type | Answer |
| --- | --- | --- | --- | --- |
| **Q1(a)** | 5 | Unit 1 · Conditional probability from fruit counts | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1a/) |
| **Q1(b)** | 5 | Unit 2 · Membership function and age sketch | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1b/) |
| **Q1(c)** | 5 | Unit 3 · Mutation operators | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1c/) |
| **Q1(d)** | 5 | Unit 4 · Markov chain diagram and path probability | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1d/) |
| **Q2(a)** | 10 | Unit 1 · Bayesian network joint probabilities | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q2a/) |
| **Q2(b)** | 10 | Unit 2 · Fuzzy Cartesian product and composition | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q2b/) |
| **Q3(a)** | 10 | Unit 1 · GMM versus K-means | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q3a/) |
| **Q3(b)** | 10 | Unit 2 · Center of sums defuzzification | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q3b/) |
| **Q4(a)** | 10 | Unit 2 · Fuzzy quality-control design | Design | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q4a/) |
| **Q4(b)** | 10 | Unit 3 · ACO components and roles | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q4b/) |
| **Q5(a)** | 10 | Unit 3 · PSO inspiration, parameters and one iteration | Mixed | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q5a/) |
| **Q5(b)** | 10 | Unit 4 · Brand-switching transition matrix | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q5b/) |
| **Q6(a)** | 10 | Unit 3 · GA ranking and three crossover methods | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q6a/) |
| **Q6(b)** | 10 | Unit 4 · Markov property and weather path | Mixed | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q6b/) |
| **Q7(a)** | 5 | Unit 1 · Bayes bag posterior | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7a/) |
| **Q7(b)** | 5 | Unit 2 · Max–min relational composition | Numerical | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7b/) |
| **Q7(c)** | 5 | Unit 3 · Point versus uniform crossover | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7c/) |
| **Q7(d)** | 5 | Unit 4 · Applications of reinforcement learning | Theory | [Full solution](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7d/) |

**Source qualification:** Some questions omit parameter choices or contain ambiguous/inconsistent source data. The relevant answer distinguishes printed data from assumptions and calculates valid alternatives; all source questions remain represented.

## What this evidence does and does not establish

Prepare each complete question: choices apply to whole questions, so a strong numerical alone may not cover its paired theory. Repeated topics deserve practice, but the next paper can change the combination. Historical course codes and syllabus changes are kept visible; out-of-syllabus questions are not counted as missing current topics.

Same-date papers can be different programme or batch variants. They are listed separately, so their marks must not be added as if one examination offered all those questions. Duplicate scans are reconciled to one represented paper.

---

## TEE · Symbols, brackets and iteration labels: how to read a formula

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--reading-formulas/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/reading-formulas

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Read a formula as a calculation instruction

A **variable** is a name for a number that can change. In **f(x)=x²+1**, x is the input, f is the name of the scoring rule, and f(x) is its result. An **equation** says that the expressions on both sides have the same value. A formula tells you how to calculate a quantity.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| x² | x multiplied by itself | 3² = 3 × 3 = 9 |
| 2x or 2(x) | 2 multiplied by x | For x=3: 2x=6, while x²=9 |
| f(3) | Apply the rule named f to input 3 | If f(x)=x²+1, then f(3)=10 |
| x₁ and x₂ | First and second named entries; the small lower number is a label | If a position is (3,7), x₁=3 and x₂=7 |
| x at time t | A version of x at a particular iteration | Old x=3; after a move x=2. The time label is not squaring. |
| = and ≈ | Exactly equal; approximately equal after rounding | 1/3 ≈ 0.333333 |
| ∈ and { } | Belongs to; a collection of values | x ∈ {2,5} means x may be 2 or 5 |

**Evaluate f(x)=2x²+1 at x=−3.** [2 marks · Worked example]

#### Given

The rule is f(x)=2x²+1. The supplied input is x=−3.

#### To find

f(−3): the output of this rule for input −3.

#### Formula and why it applies



$$
f(x)=2x^2+1
$$



The question supplies the rule. Replace x by −3, square that whole input, multiply the square by 2, and add 1. Parentheses keep the negative input together.

#### Solution

##### Step 1. Substitute with parentheses



$$
f(-3)=2(-3)^2+1
$$



##### Step 2. Do the square first



$$
(-3)^2=(-3)\times(-3)=9
$$



##### Step 3. Multiply by 2



$$
2\times9=18
$$



##### Step 4. Add 1



$$
f(-3)=18+1=19
$$



**Final answer.** f(−3)=19.

**Evaluate g(x)=(x−2)/4 at x=10.** [2 marks · Worked example]

#### Given

The rule is g(x)=(x−2)/4. The supplied input is x=10.

#### To find

g(10): the output of this rule for input 10.

#### Formula and why it applies



$$
g(x)=\frac{x-2}{4}
$$



The fraction bar groups the numerator x−2. Subtract 2 from the input first, then divide the entire difference by 4.

#### Solution

##### Step 1. Replace the input



$$
g(10)=\frac{10-2}{4}
$$



##### Step 2. Finish the numerator



$$
10-2=8
$$



##### Step 3. Divide



$$
g(10)=8/4=2
$$



**Final answer.** g(10)=2.

**At iteration 0, x=4. The rule is new x = old x − 1. Find x after two iterations.** [2 marks · Worked example]

#### Given

Initial value x=4 at iteration 0. Every update subtracts 1 from the current value. Perform two updates.

#### To find

The value after update 1 and after update 2.

#### Formula and why it applies



$$
x^{(t+1)}=x^{(t)}-1
$$



t labels the current iteration, and t+1 labels the next. The parenthesised upper label records the step; it is not a power. Apply the supplied rule once, then use that new answer as the input to the second update.

#### Solution

##### Step 1. Iteration 1 uses the initial value



$$
x^{(1)}=4-1=3
$$



##### Step 2. Iteration 2 uses the updated value



$$
x^{(2)}=3-1=2
$$



##### Step 3. Distinguish a label from a power

x at iteration 2 is 2. Squaring the initial value would give 4²=16; that is a different operation.

**Final answer.** After update 1: x=3. After update 2: x=2. The sequence is 4 → 3 → 2.

**Yaad rakho:** Symbol sirf naam hai. Pehle bolo kaunsa number chahiye, phir uski jagah value likho.

---

## TEE · Position, score, minimisation and maximisation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--objective/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/objective

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## What are we trying to do in IS2?

**An intelligent system** uses information and a decision procedure to choose an output or an action. In M2, you study three different procedures.

| Topic | Input | What the procedure does | Output |
| --- | --- | --- | --- |
| Fuzzy logic | Temperature and occupancy | Applies rules such as IF hot AND crowded THEN fast | A fan-speed setting |
| Genetic algorithm (GA) | A population of candidate answers | Selects, combines and changes candidate answers | A good solution and its fitness |
| Particle swarm optimization (PSO) | Positions and velocities of particles | Moves candidate answers using individual and shared experience | A best position and its objective value |

## Candidate answer and score are different

An **objective function** is the calculation used to score an answer. In **minimisation**, a smaller score is better; in **maximisation**, a larger score is better. The letter **x** names a candidate answer. The notation **f(x)**, read “f of x”, means its score. Parentheses here do not mean f multiplied by x.

**For the minimisation problem 

$$
f(x)=(x-3)^2
$$

, find the score at 

$$
x=2
$$

.** [2 marks · Practice]

#### Given



$$
x=2
$$

, 

$$
f(x)=(x-3)^2
$$



#### To find

The objective value f(x).

#### Formula and why it applies

Replace x by the supplied number. Square means multiply the result by itself.

#### Solution

##### Step 1. Subtract 3



$$
x-3=2-3=-1
$$



##### Step 2. Square the difference



$$
f(2)=(-1)^2=(-1)\times(-1)=1
$$



**Final answer.** The position is x = 2; its score is 1. These are two different numbers.

**For the minimisation problem 

$$
f(x)=(x-3)^2
$$

, find the score at 

$$
x=5
$$

.** [2 marks · Practice]

#### Given



$$
x=5
$$

, 

$$
f(x)=(x-3)^2
$$



#### To find

The objective value f(x).

#### Formula and why it applies

Replace x by the supplied number. Square means multiply the result by itself.

#### Solution

##### Step 1. Subtract 3



$$
x-3=5-3=2
$$



##### Step 2. Square the difference



$$
f(5)=(2)^2=(2)\times(2)=4
$$



**Final answer.** The position is x = 5; its score is 4. These are two different numbers.

**For the minimisation problem 

$$
f(x)=(x-3)^2
$$

, find the score at 

$$
x=-1
$$

.** [2 marks · Practice]

#### Given



$$
x=-1
$$

, 

$$
f(x)=(x-3)^2
$$



#### To find

The objective value f(x).

#### Formula and why it applies

Replace x by the supplied number. Square means multiply the result by itself.

#### Solution

##### Step 1. Subtract 3



$$
x-3=(-1)-3=-4
$$



##### Step 2. Square the difference



$$
f(-1)=(-4)^2=(-4)\times(-4)=16
$$



**Final answer.** The position is x = -1; its score is 16. These are two different numbers.

Comparing these candidates: x = 2 has score 1, x = 5 has score 4, and x = −1 has score 16. For minimisation, x = 2 is the best of these three. A negative position is allowed unless the question gives a restriction; a low score, not a low coordinate, decides the winner.

**Yaad rakho:** x = answer ki jagah; f(x) = us answer ka score. Min mein chhota score jeetega.

---

## TEE · Fractions, brackets, minimum and maximum

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--arithmetic/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/arithmetic

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Fractions, min and max

A fraction means division: the top number is the **numerator**, and the bottom is the **denominator**. Calculate each bracket first. **min** selects the smallest listed number; **max** selects the largest. Neither word means addition.

**Evaluate 

$$
\frac{32-25}{35-25}
$$

.** [2 marks · Practice]

#### Given

Top: 32 − 25; bottom: 35 − 25.

#### To find

The quotient.

#### Formula and why it applies

Subtract separately in the numerator and denominator, then divide.

#### Solution

##### Step 1. Calculate the numerator



$$
32-25=7
$$



##### Step 2. Calculate the denominator



$$
35-25=10
$$



##### Step 3. Divide



$$
\frac{7}{10}=0.7
$$



**Final answer.** 0.7

**Evaluate 

$$
\frac{35-32}{35-25}
$$

.** [2 marks · Practice]

#### Given

Top: 35 − 32; bottom: 35 − 25.

#### To find

The quotient.

#### Formula and why it applies

Subtract separately in the numerator and denominator, then divide.

#### Solution

##### Step 1. Calculate the numerator



$$
35-32=3
$$



##### Step 2. Calculate the denominator



$$
35-25=10
$$



##### Step 3. Divide



$$
\frac{3}{10}=0.3
$$



**Final answer.** 0.3

**Evaluate 

$$
\frac{7-6}{8-6}
$$

.** [2 marks · Practice]

#### Given

Top: 7 − 6; bottom: 8 − 6.

#### To find

The quotient.

#### Formula and why it applies

Subtract separately in the numerator and denominator, then divide.

#### Solution

##### Step 1. Calculate the numerator



$$
7-6=1
$$



##### Step 2. Calculate the denominator



$$
8-6=2
$$



##### Step 3. Divide



$$
\frac{1}{2}=0.5
$$



**Final answer.** 0.5

**Find 

$$
\max\{\min(0.7,0.2),\min(0.4,0.8)\}
$$

.** [2 marks · Practice]

#### Given

Two inner min operations followed by one outer max.

#### To find

One number.

#### Formula and why it applies

Work from the innermost brackets outward. This exact pattern occurs in fuzzy relation composition.

#### Solution

##### Step 1. First pair



$$
\min(0.7,0.2)=0.2
$$



##### Step 2. Second pair



$$
\min(0.4,0.8)=0.4
$$



##### Step 3. Choose the larger result



$$
\max(0.2,0.4)=0.4
$$



**Final answer.** 0.4.

**Yaad rakho:** Pehle bracket, phir divide. AND ka min; OR ka max.

---

## TEE · Percentages, probabilities and cumulative intervals

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--probability/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/probability

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Probability is a share of a specified total

A probability is a number between 0 and 1. In these finite examples, 0 means an event has no probability mass and 1 means it occurs with certainty under the model. In a continuous distribution, a single exact value can have probability zero without being logically impossible; probabilities then describe intervals. 25% means 25 out of 100, so it equals 25÷100=0.25. For equally likely outcomes, probability is favourable outcomes divided by all possible outcomes. For GA selection, it is the candidate’s weight divided by the sum of weights.



$$
P(\text{event})=\frac{\text{favourable count}}{\text{total count}}
$$



**A bag contains 3 red balls and 7 blue balls. One ball is drawn uniformly at random. Find the probability of red and of blue.** [2 marks · Worked example]

#### Given

Red=3; blue=7. Each ball is equally likely.

#### To find

Both probabilities and their percentages.

#### Formula and why it applies



$$
P(\text{colour})=\frac{\text{balls of that colour}}{\text{all balls}}
$$



All balls are equally likely, so counting them gives probability. The denominator counts all balls; the numerator counts the requested colour.

#### Solution

##### Step 1. Find the total



$$
3+7=10
$$



##### Step 2. Red probability



$$
P(R)=3/10=0.3=30\%
$$



##### Step 3. Blue probability



$$
P(B)=7/10=0.7=70\%
$$



**Final answer.** Red 0.3; blue 0.7. Their sum is 1.

## From weights to probabilities to cumulative probabilities

A **weight** need not itself be a probability. Weights 1, 2, 3, 4 add to 10. Dividing every weight by 10 makes their total 1: this is **normalisation**. **Cumulative** means “total accumulated so far”. It turns separate shares into boundaries along a line from 0 to 1.

**Candidates A, B, C and D have weights 1, 2, 3 and 4. Find probabilities and cumulative probabilities. Which candidate is selected by random draw r=0.55?** [2 marks · Worked example]

#### Given

Weights [1,2,3,4], draw 0.55. Use intervals including their lower endpoint and excluding their upper endpoint.

#### To find

Four probabilities, their running totals and the selected candidate.

#### Formula and why it applies



$$
P_i=F_i/(F_A+F_B+F_C+F_D)
$$



F is weight. P is its share. Add P values in row order for the cumulative boundary.

#### Solution

##### Step 1. Add all weights



$$
1+2+3+4=10
$$



##### Step 2. Divide each weight by that same total

| Candidate | Division | Probability |
| --- | --- | --- |
| A | 1÷10 | 0.1 |
| B | 2÷10 | 0.2 |
| C | 3÷10 | 0.3 |
| D | 4÷10 | 0.4 |

##### Step 3. Build the running totals

| Candidate | Running addition | Interval |
| --- | --- | --- |
| A | 0+0.1=0.1 | 0 ≤ r < 0.1 |
| B | 0.1+0.2=0.3 | 0.1 ≤ r < 0.3 |
| C | 0.3+0.3=0.6 | 0.3 ≤ r < 0.6 |
| D | 0.6+0.4=1 | 0.6 ≤ r ≤ 1 |

##### Step 4. Locate the draw

0.55 is at least 0.3 and less than 0.6. It lies in C’s interval. The draw is not compared with C’s weight 3.

**Final answer.** Candidate C is selected.

Swipe across the diagram to read its labels ↔

![Each interval width equals its probability. Running totals mark the ends.](https://deep-learning-study-room.vercel.app/is2/fig/depth_roulette.12804497d2.svg)

Diagram: Each interval width equals its probability. Running totals mark the ends.. Labels: Probabilities become intervals on the same 0–1 line | A | 0.1 | 0 | B | 0.2 | 0.1 | C | 0.3 | 0.3 | D | 0.4 | 0.6 | 1 | r = 0.55 selects C

Each interval width equals its probability. Running totals mark the ends.

**Two unnormalised class scores are 0.12 and 0.08. Convert them to probabilities.** [2 marks · Worked example]

#### Given

Scores A=0.12 and B=0.08; they describe the only two alternatives.

#### To find

Normalised probabilities.

#### Formula and why it applies

Divide each score by the sum, preserving their ratio.

#### Solution

##### Step 1. Sum the scores



$$
0.12+0.08=0.20
$$



##### Step 2. Normalise A



$$
P(A)=0.12/0.20=0.6
$$



##### Step 3. Normalise B



$$
P(B)=0.08/0.20=0.4
$$



**Final answer.** A=0.6 and B=0.4. The original score 0.12 was not the final probability.

**Yaad rakho:** Probability = apna hissa ÷ sabka total. Cumulative = ab tak ke saare hisse jodna.

---

## TEE · Binary from the beginning: positions, place values and bits

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--binary/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/binary

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## 1. Position means the digit's place

**A position is simply a place occupied by one digit in a number.** A digit is the symbol written there. The **place value** tells us how much one unit in that position is worth.

Start with an ordinary number you already know: **23**. Its two digits are 2 and 3. They do not contribute the same kind of unit.

|  | LEFT: tens place | RIGHT: ones place |
| --- | --- | --- |
| Value of this place | 10 | 1 |
| Digit written here | 2 | 3 |
| Contribution | 2 × 10 = 20 | 3 × 1 = 3 |



$$
23=(2\times 10)+(3\times 1)=20+3
$$



The **2** means two tens because of where it sits. In **32**, the same digit 2 sits on the right and means only two ones. Changing a digit’s position can change its contribution.

**Yaad rakho:** Position = digit ki jagah. Place value = us jagah par likhe ONE ki keemat. 23 mein 2 ka contribution 20 hai, kyunki woh tens ki jagah par hai.

## 2. Binary changes the size of the groups

Our ordinary number system is **decimal**: it has ten possible digits, 0 to 9. Its places are ones, tens, hundreds, and so on. Moving one place left multiplies the place value by 10.

**Binary** has only two possible digits: **0 and 1**. One binary digit is called a **bit**. Therefore, a **4-bit number means four digit boxes**, each holding either 0 or 1.

In binary, grouping happens in **twos**. The rightmost box counts single units. After one single, a second single cannot be written as digit “2”, because binary has no digit 2. Instead, the two singles become **one group of two** in the next box on the left.

**Binary 10 means one group of two and zero single units.**

It represents the ordinary number 2. Read its digits as “one-zero” when discussing binary, so you do not accidentally read it as decimal ten.

Two groups of two make **4**, so the next box to the left is the fours place. Two groups of four make **8**, so the next box is the eights place. This is why the values double.

| Ordinary number | Binary digits | Meaning |
| --- | --- | --- |
| 0 | 0 | No single units |
| 1 | 1 | One single unit |
| 2 | 10 | One two + zero ones = 2 |
| 3 | 11 | One two + one one = 3 |
| 4 | 100 | One four + zero twos + zero ones = 4 |

**Yaad rakho:** Decimal mein 10 ka group; binary mein 2 ka group. Do singles = ek pair; do pairs = ek group of four.

## 3. Build the places from the RIGHT

First draw four empty boxes. **Start with the box furthest to the right.** Give that place the value 1. Move left one box at a time, doubling the previous value.

1. **1st box from the right:** value 1.
2. **2nd box from the right:** 1 × 2 = 2.
3. **3rd box from the right:** 2 × 2 = 4.
4. **4th box from the right:** 4 × 2 = 8.

Place value: what ONE in this box is worth

4th from right**8**

3rd from right**4**

2nd from right**2**

1st from right**1**

← Double each time you move one box LEFT

Start at the RIGHT with 1. Then 1 × 2 = 2, 2 × 2 = 4, and 4 × 2 = 8.

We built the values by moving right to left: **1 → 2 → 4 → 8**. Once the boxes are on paper, reading them in the usual left-to-right direction shows **8, 4, 2, 1**. These are the same four places, viewed in the opposite direction.

**Position number is not place value.** The third box from the right has position number 3, but its place value is 4. “Third” tells you where the box is; “4” tells you what a 1 in it contributes.

If you add a fifth box on the left, its value is 8 × 2 = **16**. The rightmost place stays 1; adding a box on the left does not change the existing places.

**Yaad rakho:** Sabse RIGHT se 1 likho. LEFT jaate jaate double karo: 1, 2, 4, 8, 16. Question ke digits baad mein in boxes mein rakho.

## 4. The place value stays fixed; the digit chooses it

Keep the digit **1** the same and move it into a different place. Put 0 in every other box. Watch how its position changes the number it represents:

| Binary digits | Where the 1 sits | Decimal value |
| --- | --- | --- |
| 0001 | 1st place from the right: ones | 1 × 1 = 1 |
| 0010 | 2nd place from the right: twos | 1 × 2 = 2 |
| 0100 | 3rd place from the right: fours | 1 × 4 = 4 |
| 1000 | 4th place from the right: eights | 1 × 8 = 8 |

In all four rows, the written digit is still 1. Its **position** decides whether that 1 contributes one, two, four or eight.

Now put **1 0 1 1** in the four boxes. The values 8, 4, 2 and 1 are labels for the boxes. The written digits tell us which values to include:

- **Digit 1:** take one of this place value.
- **Digit 0:** take zero of this place value.

Place value: what ONE in this box is worth

4th from right**8**

3rd from right**4**

2nd from right**2**

1st from right**1**

Digits written in those boxes

**1**include

**0**skip

**1**include

**1**include

Each box contributes

1 × 8**8**

0 × 4**0**

1 × 2**2**

1 × 1**1**

Add the contributions: 8 + 0 + 2 + 1 = 11 in ordinary decimal notation.

The 0 above does **not** mean the place value changes from 4 to 0. The place is still worth 4 per unit; the digit says to take zero units of it. Its contribution is therefore 0 × 4 = 0.

The three 1s are the same digit, but they sit in different places. They contribute **8, 2 and 1**. Therefore, binary 1011 represents decimal 11.

**Yaad rakho:** Box ki value fixed. Andar 1 hai toh value lo; 0 hai toh skip karo. Phir li hui values jodo.

## 5. Binary to decimal: four complete examples

**Decode** means convert the binary digits into an ordinary decimal number. In exam notation, a small 2 below a number means binary; a small 10 means decimal. These small labels identify the number system. They are not multipliers.



$$
(1011)_2=(11)_{10}
$$



This line says: “one-zero-one-one in binary and eleven in decimal represent the same quantity.”

**Convert the binary number 

$$
(1011)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 1011, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Binary digit | 1 | 0 | 1 | 1 |

##### Step 2. Calculate the contribution of the 8-place

The digit is 1, so include the value of this place.



$$
1\times 8=8
$$



##### Step 3. Calculate the contribution of the 4-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 4=0
$$



##### Step 4. Calculate the contribution of the 2-place

The digit is 1, so include the value of this place.



$$
1\times 2=2
$$



##### Step 5. Calculate the contribution of the 1-place

The digit is 1, so include the value of this place.



$$
1\times 1=1
$$



##### Step 6. Add the contributions



$$
8+0+2+1=11
$$



**Final answer.** 

$$
(1011)_2=(11)_{10}
$$

.

**Convert the binary number 

$$
(0110)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 0110, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Binary digit | 0 | 1 | 1 | 0 |

##### Step 2. Calculate the contribution of the 8-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 8=0
$$



##### Step 3. Calculate the contribution of the 4-place

The digit is 1, so include the value of this place.



$$
1\times 4=4
$$



##### Step 4. Calculate the contribution of the 2-place

The digit is 1, so include the value of this place.



$$
1\times 2=2
$$



##### Step 5. Calculate the contribution of the 1-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 1=0
$$



##### Step 6. Add the contributions



$$
0+4+2+0=6
$$



**Final answer.** 

$$
(0110)_2=(6)_{10}
$$

.

**Convert the binary number 

$$
(1001)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 1001, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Binary digit | 1 | 0 | 0 | 1 |

##### Step 2. Calculate the contribution of the 8-place

The digit is 1, so include the value of this place.



$$
1\times 8=8
$$



##### Step 3. Calculate the contribution of the 4-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 4=0
$$



##### Step 4. Calculate the contribution of the 2-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 2=0
$$



##### Step 5. Calculate the contribution of the 1-place

The digit is 1, so include the value of this place.



$$
1\times 1=1
$$



##### Step 6. Add the contributions



$$
8+0+0+1=9
$$



**Final answer.** 

$$
(1001)_2=(9)_{10}
$$

.

**Convert the binary number 

$$
(10011)_2
$$

 to decimal.** [2 marks · Practice]

#### Given

Binary digits: 10011, in this exact order.

#### To find

The ordinary decimal number represented by these digits.

#### Formula and why it applies

Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.



$$
\text{Number}=\text{sum of (digit}\times\text{place value)}
$$



#### Solution

##### Step 1. Write the place values above the digits

| Place value | 16 | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- | --- |
| Binary digit | 1 | 0 | 0 | 1 | 1 |

##### Step 2. Calculate the contribution of the 16-place

The digit is 1, so include the value of this place.



$$
1\times 16=16
$$



##### Step 3. Calculate the contribution of the 8-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 8=0
$$



##### Step 4. Calculate the contribution of the 4-place

The digit is 0, so this place contributes zero. Its place value still stays the same.



$$
0\times 4=0
$$



##### Step 5. Calculate the contribution of the 2-place

The digit is 1, so include the value of this place.



$$
1\times 2=2
$$



##### Step 6. Calculate the contribution of the 1-place

The digit is 1, so include the value of this place.



$$
1\times 1=1
$$



##### Step 7. Add the contributions



$$
16+0+0+2+1=19
$$



**Final answer.** 

$$
(10011)_2=(19)_{10}
$$

.

## 6. Decimal to binary: choose each digit

**Encode** means write an ordinary number using binary digits. The direction of the task is now reversed: the number is known, and you have to choose the 0s and 1s.

For four bits, write the places 8, 4, 2, 1. Start with the largest place on the left. Use it only if it does not exceed the amount still needed. Whenever you use a place, subtract it before moving to the next one.

**Yaad rakho:** Number banana hai. Badi value se start: jitna bacha hai usmein value fit ho toh 1 aur subtract; fit nahi ho toh 0.

**Write the decimal number 6 as an unsigned 4-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 6. Required length: 4 bits, meaning exactly 4 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 4 boxes and label their values

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ |

Start with the whole number 6 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 8-place

We still need 6. Taking 8 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **6**.

##### Step 3. Choose the digit in the 4-place

We still need 6. This is at least 4, so take one 4. Write **1** in this box.



$$
\text{Remaining}=6-4=2
$$



##### Step 4. Choose the digit in the 2-place

We still need 2. This is at least 2, so take one 2. Write **1** in this box.



$$
\text{Remaining}=2-2=0
$$



##### Step 5. Choose the digit in the 1-place

We still need 0. Taking 1 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 6. Read the digits from LEFT to RIGHT

The boxes now contain **0 1 1 0**. Join them in the same order: **0110**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 7. Check by converting back



$$
0\times 8+1\times 4+1\times 2+0\times 1=6
$$



**Final answer.** 

$$
(6)_{10}=(0110)_2
$$

. The answer has 4 bits.

**Write the decimal number 11 as an unsigned 4-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 11. Required length: 4 bits, meaning exactly 4 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 4 boxes and label their values

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ |

Start with the whole number 11 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 8-place

We still need 11. This is at least 8, so take one 8. Write **1** in this box.



$$
\text{Remaining}=11-8=3
$$



##### Step 3. Choose the digit in the 4-place

We still need 3. Taking 4 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **3**.

##### Step 4. Choose the digit in the 2-place

We still need 3. This is at least 2, so take one 2. Write **1** in this box.



$$
\text{Remaining}=3-2=1
$$



##### Step 5. Choose the digit in the 1-place

We still need 1. This is at least 1, so take one 1. Write **1** in this box.



$$
\text{Remaining}=1-1=0
$$



##### Step 6. Read the digits from LEFT to RIGHT

The boxes now contain **1 0 1 1**. Join them in the same order: **1011**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 7. Check by converting back



$$
1\times 8+0\times 4+1\times 2+1\times 1=11
$$



**Final answer.** 

$$
(11)_{10}=(1011)_2
$$

. The answer has 4 bits.

**Write the decimal number 19 as an unsigned 5-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 19. Required length: 5 bits, meaning exactly 5 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 5 boxes and label their values

| Place value | 16 | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ | □ |

Start with the whole number 19 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 16-place

We still need 19. This is at least 16, so take one 16. Write **1** in this box.



$$
\text{Remaining}=19-16=3
$$



##### Step 3. Choose the digit in the 8-place

We still need 3. Taking 8 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **3**.

##### Step 4. Choose the digit in the 4-place

We still need 3. Taking 4 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **3**.

##### Step 5. Choose the digit in the 2-place

We still need 3. This is at least 2, so take one 2. Write **1** in this box.



$$
\text{Remaining}=3-2=1
$$



##### Step 6. Choose the digit in the 1-place

We still need 1. This is at least 1, so take one 1. Write **1** in this box.



$$
\text{Remaining}=1-1=0
$$



##### Step 7. Read the digits from LEFT to RIGHT

The boxes now contain **1 0 0 1 1**. Join them in the same order: **10011**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 8. Check by converting back



$$
1\times 16+0\times 8+0\times 4+1\times 2+1\times 1=19
$$



**Final answer.** 

$$
(19)_{10}=(10011)_2
$$

. The answer has 5 bits.

**Write the decimal number 0 as an unsigned 4-bit binary number.** [2 marks · Practice]

#### Given

Decimal number: 0. Required length: 4 bits, meaning exactly 4 digit boxes.

#### To find

The binary digits, including any zero at the beginning needed to keep the required length.

#### Formula and why it applies

At each place, compare its value with the amount still needed. If that amount is at least the place value, write 1 and subtract that value. Otherwise write 0 and keep the remaining amount unchanged.

This works because each place can be used either once (1) or not at all (0). The selected places must add up to the given number.

#### Solution

##### Step 1. Make 4 boxes and label their values

| Place value | 8 | 4 | 2 | 1 |
| --- | --- | --- | --- | --- |
| Digit to choose | □ | □ | □ | □ |

Start with the whole number 0 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.

##### Step 2. Choose the digit in the 8-place

We still need 0. Taking 8 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 3. Choose the digit in the 4-place

We still need 0. Taking 4 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 4. Choose the digit in the 2-place

We still need 0. Taking 2 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 5. Choose the digit in the 1-place

We still need 0. Taking 1 would be too much, so skip this place. Write **0** in this box.

We used nothing from this place. The remaining amount stays **0**.

##### Step 6. Read the digits from LEFT to RIGHT

The boxes now contain **0 0 0 0**. Join them in the same order: **0000**.

The remaining amount is 0, so we have made the required number exactly.

##### Step 7. Check by converting back



$$
0\times 8+0\times 4+0\times 2+0\times 1=0
$$



**Final answer.** 

$$
(0)_{10}=(0000)_2
$$

. The answer has 4 bits.

## 7. A zero at the start can keep the required length

**Leading zeros** are zeros at the beginning, on the left. Binary 110 and 0110 both represent decimal 6:



$$
(110)_2=(1\times4)+(1\times2)+(0\times1)=6
$$





$$
(0110)_2=(0\times8)+(1\times4)+(1\times2)+(0\times1)=6
$$



The added leftmost place contributes zero. It changes the length from three bits to four bits, but not the value. If a GA question requires four bits, write **0110**.

This rule is specifically about zeros on the **left**. Appending a zero on the right shifts the existing digits into places worth twice as much. For example, binary 1100 is 8 + 4 = 12, not 6.

## 8. How many bits are enough?

For these GA conversions, **unsigned** means the bits represent zero or a positive whole number, with no negative sign. The smallest 4-bit value is 0000. The largest is 1111 because all four places are included.

**Find the largest unsigned integer that can be represented using 4 bits. Can decimal 19 fit in 4 bits?** [2 marks · Practice]

#### Given

Four places with values 8, 4, 2 and 1. Each digit is either 0 or 1.

#### To find

The largest possible value and whether 19 can be represented.

#### Formula and why it applies

A digit contributes the most when it is 1. Set every digit to 1 and add all the place values.

#### Solution

##### Step 1. Use all four places

The largest 4-bit string is **1111**.

##### Step 2. Add their values



$$
8+4+2+1=15
$$



##### Step 3. Compare with 19

19 is greater than 15, so four bits are insufficient. Add the 16-place on the left. Then 19 = 16 + 2 + 1, giving **10011** in five bits.

**Final answer.** The maximum is 15. Decimal 19 needs at least 5 bits.

The general rule is 

$$
\text{largest unsigned value}=2^n-1
$$

. Here n means the number of bits. The power 

$$
2^n
$$

 means multiplying n copies of 2; for four bits, 

$$
2^4=2\times2\times2\times2=16
$$

, so the maximum is 16 − 1 = 15. There are 16 different values, from 0 through 15, because zero is also one value.

| Bits | Place values from left to right | Unsigned values |
| --- | --- | --- |
| 3 | 4, 2, 1 | 0 to 7 |
| 4 | 8, 4, 2, 1 | 0 to 15 |
| 5 | 16, 8, 4, 2, 1 | 0 to 31 |

If an exam gives a number outside the capacity of the stated bit length, state that inconsistency. Do not silently cut off a digit: removing the 16-place from 10011 would change 19 into 3. Also retain any separate allowed range stated in the question.

## 9. Where this fits in a genetic algorithm

A **chromosome** is the representation of one candidate solution in a genetic algorithm. With the direct unsigned binary encoding used here, decimal 6 is represented by the four-bit chromosome **0110**.

During crossover or mutation, the algorithm changes these bits. Afterwards, **decode the resulting chromosome** to find its new value of x. Then use that x in the given objective or fitness function. The binary string, its decimal value, and its fitness score are different things.

**Yaad rakho:** Encode: number se bits. Decode: bits se number. GA mein bits badle toh x dobara decode karo, phir uska score nikalo.

---

## TEE · Vectors, coordinates, matrices and transpose from the first entry

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--coordinates/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/coordinates

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## A vector is an ordered list of numbers

A **scalar** is one number, such as 5. A **vector** is an ordered list, such as (3,7). Order matters: the first number may be horizontal position and the second vertical position. A **matrix** is a rectangular table of numbers. These words describe how numbers are arranged, not a new kind of arithmetic.

| Arrangement | Example | How to read it |
| --- | --- | --- |
| Scalar | 5 | One value |
| Row vector | [3,7] | One row, two entries |
| Column vector | 

$$
\begin{bmatrix}3\\7\end{bmatrix}
$$

 | Two rows, one entry |
| Matrix | 

$$
\begin{bmatrix}3&7\\4&2\end{bmatrix}
$$

 | Two rows, two columns |

## Rows go across; columns go down

For a matrix A, **A₂₁** means the entry in **row 2, column 1**. The first lower label is the row; the second is the column. Matrix size is written **number of rows × number of columns**. A 2×3 matrix has two rows containing three entries each.

Swipe across the diagram to read its labels ↔

![Read an entry by finding its row first and its column second.](https://deep-learning-study-room.vercel.app/is2/fig/depth_matrix.a8870f4ab6.svg)

Diagram: Read an entry by finding its row first and its column second.. Labels: Rows across. Columns down. Entry A₂₃ = 7. | Column 1 | Column 2 | Column 3 | Row 1 | 2 | 5 | 8 | Row 2 | 1 | 4 | 7 | Two rows × three columns = 2 × 3 matrix

Read an entry by finding its row first and its column second.

**Let A have first row [2,5,8] and second row [1,4,7]. State its size and find A₂₃ and A₁₂.** [2 marks · Worked example]

#### Given



$$
A=\begin{bmatrix}2&5&8\\1&4&7\end{bmatrix}
$$



#### To find

Matrix dimensions and two entries.

#### Formula and why it applies

Read the lower labels in row–column order.

#### Solution

##### Step 1. Count the arrangement

There are 2 horizontal rows and 3 vertical columns. Size=2×3.

##### Step 2. Find A₂₃

Row 2 is [1,4,7]. Its third entry is 7.

##### Step 3. Find A₁₂

Row 1 is [2,5,8]. Its second entry is 5.

**Final answer.** Size 2×3; A₂₃=7; A₁₂=5.

**A particle has position x=(3,7), velocity v=(−1,2), and best position p=(1,8). Find p−x, half of that difference, and x+v.** [2 marks · Worked example]

#### Given

Position x=(3,7); velocity v=(−1,2); personal-best position p=(1,8). First and second coordinates stay in the same order.

#### To find

The difference p−x, the scaled difference 0.5(p−x), and the updated position x+v.

#### Formula and why it applies

Match first with first and second with second. A scalar multiplies every coordinate.

#### Solution

##### Step 1. Subtract corresponding coordinates



$$
p-x=(1-3,\;8-7)=(-2,1)
$$



##### Step 2. Multiply both coordinates by 0.5



$$
0.5(p-x)=(0.5(-2),\;0.5(1))=(-1,0.5)
$$



##### Step 3. Add the velocity to the position



$$
x+v=(3+(-1),\;7+2)=(2,9)
$$



**Final answer.** Difference (−2,1); scaled difference (−1,0.5); new position (2,9).

## Transpose exchanges rows and columns

The superscript **T** in Aᵀ means **transpose**. It does not mean multiply or raise A to a power. Row 1 of A becomes column 1 of Aᵀ; row 2 becomes column 2. An m×n arrangement becomes n×m.

**Find the transpose of A = [[2,5,8],[1,4,7]].** [2 marks · Worked example]

#### Given



$$
A=\begin{bmatrix}2&5&8\\1&4&7\end{bmatrix}
$$



#### To find

Aᵀ.

#### Formula and why it applies

Turn each old row into a new column, keeping its order.

#### Solution

##### Step 1. Move the first row

[2,5,8] becomes the first column from top to bottom.

##### Step 2. Move the second row

[1,4,7] becomes the second column from top to bottom.

##### Step 3. Write the new arrangement



$$
A^T=\begin{bmatrix}2&1\\5&4\\8&7\end{bmatrix}
$$



**Final answer.** Aᵀ has 3 rows and 2 columns. No number changed.

**Calculate the dot product of [2,3] and [4,5].** [2 marks · Worked example]

#### Given

First vector a=[2,3]; second vector b=[4,5]. Each has two entries.

#### To find

The dot product a·b, a single number obtained by adding the two matching products.

#### Formula and why it applies



$$
a\cdot b=a_1b_1+a_2b_2
$$



Multiply corresponding entries, then add the products. Markov matrix multiplication later repeats this for each destination column.

#### Solution

##### Step 1. First product



$$
2\times4=8
$$



##### Step 2. Second product



$$
3\times5=15
$$



##### Step 3. Add



$$
8+15=23
$$



**Final answer.** The dot product is 23. It is not the vector [8,15].

**Yaad rakho:** Vector = order wali list. Matrix = rows-columns ka table. Entry padhte waqt pehle row, phir column.

---

## TEE · Graph axes, intervals and the fractions inside membership functions

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--graphs/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/graphs

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Read a graph one input at a time

The **horizontal axis** runs left to right and shows input x. The **vertical axis** runs bottom to top and shows the output. A point (3,0.4) means: input 3 gives output 0.4. In a membership graph, the vertical output is a degree between 0 and 1.

To read the graph at x=3, start at 3 on the bottom axis, move vertically until you reach the line, then move horizontally to the vertical axis. The height you read is the membership.

Swipe across the diagram to read its labels ↔

![Halfway along a straight rise from height 0 to height 1 gives height 0.5.](https://deep-learning-study-room.vercel.app/is2/fig/depth_slope.c91a1030aa.svg)

Diagram: Halfway along a straight rise from height 0 to height 1 gives height 0.5.. Labels: Read x = 4: halfway from 2 to 6, so height = 0.5 | 0 | 0.25 | 0.5 | 1 | 0 | 2 | 3 | 4 | 6 | 8 | μ | Input x | Straight rising membership | x = 4

Halfway along a straight rise from height 0 to height 1 gives height 0.5.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| x < 5 | Strictly less than 5 | 4.9 qualifies; 5 does not |
| x ≤ 5 | Less than or equal to 5 | Both 4.9 and 5 qualify |
| 2 ≤ x ≤ 8 | x is between 2 and 8 including both ends | The interval is [2,8] |
| [2,8) | Include 2; exclude 8 | Useful for roulette interval boundaries |
| Piecewise formula | Choose one calculation according to where x lies | Rising branch, falling branch or outside |

**A straight membership line rises from (2,0) to (6,1). Find its height at x=3.** [2 marks · Worked example]

#### Given

Left input=2; peak input=6; required input=3.

#### To find

Membership height.

#### Formula and why it applies



$$
\text{height}=\frac{\text{distance from left}}{\text{total rising width}}
$$



A straight line changes by the same proportion of its height as the proportion travelled along its width.

#### Solution

##### Step 1. Find distance travelled



$$
3-2=1
$$



##### Step 2. Find total width



$$
6-2=4
$$



##### Step 3. Divide distance by width



$$
\mu(3)=\frac{1}{4}=0.25
$$



**Final answer.** Membership=0.25.

**A straight membership line rises from (2,0) to (6,1). Find its height at x=4.** [2 marks · Worked example]

#### Given

Left input=2; peak input=6; required input=4.

#### To find

Membership height.

#### Formula and why it applies



$$
\text{height}=\frac{\text{distance from left}}{\text{total rising width}}
$$



A straight line changes by the same proportion of its height as the proportion travelled along its width.

#### Solution

##### Step 1. Find distance travelled



$$
4-2=2
$$



##### Step 2. Find total width



$$
6-2=4
$$



##### Step 3. Divide distance by width



$$
\mu(4)=\frac{2}{4}=0.5
$$



**Final answer.** Membership=0.5.

**A straight membership line rises from (10,0) to (30,1). Find its height at x=25.** [2 marks · Worked example]

#### Given

Left input=10; peak input=30; required input=25.

#### To find

Membership height.

#### Formula and why it applies



$$
\text{height}=\frac{\text{distance from left}}{\text{total rising width}}
$$



A straight line changes by the same proportion of its height as the proportion travelled along its width.

#### Solution

##### Step 1. Find distance travelled



$$
25-10=15
$$



##### Step 2. Find total width



$$
30-10=20
$$



##### Step 3. Divide distance by width



$$
\mu(25)=\frac{15}{20}=0.75
$$



**Final answer.** Membership=0.75.

**A membership line falls from (5,1) to (8,0). Find its height at x=7.** [2 marks · Worked example]

#### Given

Peak=5; right zero=8; x=7.

#### To find

Membership.

#### Formula and why it applies



$$
\mu(x)=\frac{\text{distance still remaining to right zero}}{\text{total falling width}}
$$



#### Solution

##### Step 1. Remaining distance



$$
8-7=1
$$



##### Step 2. Total falling width



$$
8-5=3
$$



##### Step 3. Divide



$$
\mu(7)=1/3\approx0.333333
$$



**Final answer.** Membership≈0.333333. Using distance already travelled would reverse the falling line.

**Yaad rakho:** Chadhti line: left se kitna aage? Utarti line: right tak kitna baaki? Dono mein poori width se divide.

---

## TEE · Sum notation, ordinary averages and weighted averages

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--sums-averages/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/sums-averages

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Σ means add a list of terms

The capital Greek letter **Σ** is read “sum”. The lower label says where to start and the upper label where to stop. The small index i is just a counter: first item, second item, third item.



$$
\sum_{i=1}^{3}a_i=a_1+a_2+a_3
$$



**For a₁=2, a₂=5 and a₃=8, calculate Σaᵢ and their mean.** [2 marks · Worked example]

#### Given

Three numbers: 2,5,8.

#### To find

Sum and ordinary average.

#### Formula and why it applies



$$
\bar a=\frac{a_1+a_2+a_3}{3}
$$



The bar means average. Each number has equal weight.

#### Solution

##### Step 1. Expand the sum symbol



$$
\sum_{i=1}^3 a_i=2+5+8
$$



##### Step 2. Add



$$
2+5=7\quad7+8=15
$$



##### Step 3. Divide by the count of numbers



$$
\bar a=15/3=5
$$



**Final answer.** Sum=15; mean=5.

## A weighted average gives unequal influence

If values 20 and 80 have weights 3 and 1, this is equivalent to averaging [20,20,20,80]. Therefore you divide by the **sum of weights**, not by the number of distinct values. Weights may also be decimals. Their total need not initially be 1.



$$
\bar z=\frac{w_1z_1+w_2z_2+\cdots}{w_1+w_2+\cdots}
$$



**Find the weighted average of [20, 80] with corresponding weights [3, 1].** [2 marks · Worked example]

#### Given

| Value | Its weight |
| --- | --- |
| 20 | 3 |
| 80 | 1 |

#### To find

The weighted average of the listed values.

#### Formula and why it applies



$$
\bar z=\frac{\sum_i w_i z_i}{\sum_i w_i}
$$



zᵢ is a value and wᵢ is its corresponding weight. Multiply each value by its own weight, add, then divide by total weight. Here all weights are nonnegative and their total is positive.

#### Solution

##### Step 1. Multiply value 1 by its weight



$$
20\times3=60
$$



##### Step 2. Multiply value 2 by its weight



$$
80\times1=80
$$



##### Step 3. Add the weighted products



$$
60+80=140
$$



##### Step 4. Add the weights



$$
3+1=4
$$



##### Step 5. Divide the two totals



$$
\bar z=\frac{140}{4}=35
$$



**Final answer.** 35.

**Find the weighted average of [20, 50, 80] with corresponding weights [0.2, 0.6, 0.2].** [2 marks · Worked example]

#### Given

| Value | Its weight |
| --- | --- |
| 20 | 0.2 |
| 50 | 0.6 |
| 80 | 0.2 |

#### To find

The weighted average of the listed values.

#### Formula and why it applies



$$
\bar z=\frac{\sum_i w_i z_i}{\sum_i w_i}
$$



zᵢ is a value and wᵢ is its corresponding weight. Multiply each value by its own weight, add, then divide by total weight. Here all weights are nonnegative and their total is positive.

#### Solution

##### Step 1. Multiply value 1 by its weight



$$
20\times0.2=4
$$



##### Step 2. Multiply value 2 by its weight



$$
50\times0.6=30
$$



##### Step 3. Multiply value 3 by its weight



$$
80\times0.2=16
$$



##### Step 4. Add the weighted products



$$
4+30+16=50
$$



##### Step 5. Add the weights



$$
0.2+0.6+0.2=1
$$



##### Step 6. Divide the two totals



$$
\bar z=\frac{50}{1}=50
$$



**Final answer.** 50.

**Find the weighted average of [65, 85] with corresponding weights [0.3, 0.5].** [2 marks · Worked example]

#### Given

| Value | Its weight |
| --- | --- |
| 65 | 0.3 |
| 85 | 0.5 |

#### To find

The weighted average of the listed values.

#### Formula and why it applies



$$
\bar z=\frac{\sum_i w_i z_i}{\sum_i w_i}
$$



zᵢ is a value and wᵢ is its corresponding weight. Multiply each value by its own weight, add, then divide by total weight. Here all weights are nonnegative and their total is positive.

#### Solution

##### Step 1. Multiply value 1 by its weight



$$
65\times0.3=19.5
$$



##### Step 2. Multiply value 2 by its weight



$$
85\times0.5=42.5
$$



##### Step 3. Add the weighted products



$$
19.5+42.5=62
$$



##### Step 4. Add the weights



$$
0.3+0.5=0.8
$$



##### Step 5. Divide the two totals



$$
\bar z=\frac{62}{0.8}=77.5
$$



**Final answer.** 77.5.

## Π means multiply a list of terms



$$
\prod_{i=1}^{3}a_i=a_1a_2a_3
$$



For [0.5,0.2,0.4], first 0.5×0.2=0.1, then 0.1×0.4=0.04. Σ would instead give 1.1. Naive Bayes multiplies likelihood factors; it does not add them.

**Yaad rakho:** Sigma = sab jodo. Product Pi = sab multiply. Weighted mean = value×weight ke total ko weights ke total se divide.

---

## TEE · Powers, roots, absolute values and exp on the calculator

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/core-maths--powers-exponentials/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/core-maths/powers-exponentials

Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.

## Powers, roots and exponentials used later

A positive integer power repeats multiplication. 2³=2×2×2=8; it does not mean 2×3. A nonzero number raised to power 0 equals 1. A negative power means a reciprocal: 2⁻²=1/(2²)=1/4. A square root reverses a square for a nonnegative result: √9=3.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| 2⁰, 2¹, 2², 2³ | Binary place values | 1,2,4,8 |
| |x| | Absolute value: distance from zero | |−3|=3 and |3|=3 |
| e ≈ 2.71828 | A fixed mathematical constant | e⁰=1 |
| exp(u) | Another way of writing eᵘ | exp(−2)=e⁻²≈0.135335 |
| ln(x) | The natural logarithm; the exponent giving x from e | ln(e²)=2; ln(1)=0 |

**Calculate exp(−x²/2) at x=-2.** [2 marks · Worked example]

#### Given

x=-2; exp means e raised to the bracketed exponent.

#### To find

The exponential value.

#### Formula and why it applies

Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.

#### Solution

##### Step 1. Square x



$$
(-2)^2=4
$$



##### Step 2. Negate and divide by 2



$$
u=-\frac{4}{2}=-2
$$



##### Step 3. Evaluate the exponential



$$
e^u=e^{-2}\approx 0.135335283
$$



**Final answer.** 0.135335283.

**Calculate exp(−x²/2) at x=0.** [2 marks · Worked example]

#### Given

x=0; exp means e raised to the bracketed exponent.

#### To find

The exponential value.

#### Formula and why it applies

Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.

#### Solution

##### Step 1. Square x



$$
(0)^2=0
$$



##### Step 2. Negate and divide by 2



$$
u=-\frac{0}{2}=0
$$



##### Step 3. Evaluate the exponential



$$
e^u=e^{0}\approx 1
$$



**Final answer.** 1.

**Calculate exp(−x²/2) at x=2.** [2 marks · Worked example]

#### Given

x=2; exp means e raised to the bracketed exponent.

#### To find

The exponential value.

#### Formula and why it applies

Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.

#### Solution

##### Step 1. Square x



$$
(2)^2=4
$$



##### Step 2. Negate and divide by 2



$$
u=-\frac{4}{2}=-2
$$



##### Step 3. Evaluate the exponential



$$
e^u=e^{-2}\approx 0.135335283
$$



**Final answer.** 0.135335283.

On an fx-991ES-style calculator, eˣ is normally the shifted function above ln. Enter the complete exponent in brackets. Use the negative-number key for −2 where required. Confirm against e⁰=1 before a longer calculation. The exact key labels depend on the model.

**Yaad rakho:** exp ka matlab e ki power. Pehle exponent ka poora hisaab, phir eˣ.

---

## TEE · AND, OR and NOT with a picture

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-zero--and-or/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-zero/and-or

Start here if probability is new: counting, AND/OR, conditional probability and Bayes with pictures

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Experiment | An observation with possible outcomes | One coin toss |
| Outcome | One complete result | Heads |
| Event | A set of outcomes satisfying a statement | Die result is even: {2,4,6} |
| A AND B | Both statements hold | Likes cricket and football |
| A OR B | At least one statement holds, including both | Likes either sport or both |
| NOT A | All outcomes outside A | Does not like cricket |

**Before this:** read [Probability from zero](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-zero--given/). Here we combine two events.

## The picture: 100 students

In a class of 100, 40 play cricket, 30 play football, and 10 of them play both. Put the 10 “both” in the overlap first, then fill the rest: only cricket = 40 − 10 = 30, only football = 30 − 10 = 20, neither = 100 − 30 − 10 − 20 = 40.

Swipe across the diagram to read its labels ↔

![AND = the overlap, OR = everything inside either circle](https://deep-learning-study-room.vercel.app/is2/fig/prob_venn.84491b9acc.svg)

Diagram: AND = the overlap, OR = everything inside either circle. Labels: AND = the overlap, OR = everything inside either circle | all students = 100 | only Cricket | 30 | both | 10 | only Football | 20 | neither = 40

## AND (both happen) = the overlap



$$
P(C\text{ and }F)=P(C\cap F)=\frac{10}{100}=0.1
$$



## OR (at least one happens) = everything inside the circles

Count: 30 + 10 + 20 = 60, so P(C or F) = 0.6. With a formula: add both circles, then subtract the overlap because it was counted twice:



$$
P(C\cup F)=P(C)+P(F)-P(C\cap F)=0.4+0.3-0.1=0.6
$$



## NOT = outside



$$
P(\text{not }C)=1-P(C)=1-0.4=0.6\qquad P(\text{neither})=1-P(C\cup F)=0.4
$$



## Independent events: multiply for AND

Two events are **independent** if one does not change the chance of the other (two separate coin tosses). Then



$$
P(A\text{ and }B)=P(A)\times P(B)\qquad P(\text{two heads})=0.5\times0.5=0.25
$$



Cricket and football are *not* independent here: 0.4 × 0.3 = 0.12 ≠ 0.1.

| Word in the question | Symbol | What to do |
| --- | --- | --- |
| and / both | ∩, ∧, comma | overlap; multiply only if independent |
| or / at least one | ∪, ∨ | add, subtract the overlap |
| not | ¬, ′, c | 1 minus |
| given / if we know | | | next lesson: divide |

**Yaad rakho:** AND = dono (beech ka hissa). OR = koi bhi ek (jodo, overlap ek baar ghatao). NOT = 1 minus.

---

## TEE · “Given”: conditional probability by shrinking the world

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-zero--given/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-zero/given

Start here if probability is new: counting, AND/OR, conditional probability and Bayes with pictures

**In one line:** “P(A given B)” means: forget everyone who is not B, and ask what fraction of the B group is also A.

## Using the 100 students

Question: if a student plays cricket, what is the probability that they also play football? “Given cricket” means we look only at the 40 cricket players. Of those, 10 play football.



$$
P(F\mid C)=\frac{\text{both}}{\text{cricket}}=\frac{10}{40}=0.25
$$



The same with probabilities instead of counts:



$$
\boxed{P(A\mid B)=\frac{P(A\text{ and }B)}{P(B)}}\qquad P(F\mid C)=\frac{0.1}{0.4}=0.25
$$



The thing after the bar “|” always goes in the denominator. Notice 

$$
P(C\mid F)=10/30=0.33
$$

 is different: the world you shrink to changes.

## Reading a joint table

A **joint table** lists the probability of every combination. Example: 200 patients.

| Counts | Flu | No flu | Row total |
| --- | --- | --- | --- |
| Fever | 30 | 20 | 50 |
| No fever | 10 | 140 | 150 |
| Column total | 40 | 160 | 200 |

Divide every cell by 200 to get the probability table:

| P | Flu | No flu | Total |
| --- | --- | --- | --- |
| Fever | 0.15 | 0.10 | 0.25 |
| No fever | 0.05 | 0.70 | 0.75 |
| Total | 0.20 | 0.80 | 1 |

- **Joint**: one cell. P(fever and flu) = 0.15.
- **Marginal**: a row or column total. P(flu) = 0.15 + 0.05 = 0.20.
- **Conditional**: a cell ÷ a total. P(flu | fever) = 0.15 / 0.25 = 0.6; P(fever | flu) = 0.15 / 0.20 = 0.75.

Exam tables have three variables (e.g. disease, fever, test), with two possible values each, so there are 8 cells, but the method is identical: add the cells you need, divide by the cells of the “given” part. Solved PYQs: [full joint distribution](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-prob--full-joint/).

## Product rule (just the formula turned around)



$$
P(A\text{ and }B)=P(A\mid B)\,P(B)
$$



Bayesian networks use this again and again: multiply a “given” probability by the probability of the thing given.

**Yaad rakho:** “Given B” = duniya chhoti karke sirf B wale log dekho. Formula: dono ÷ given wala.

## Two complete conditional-probability examples

**A table of 200 patients has 160 patients without flu; 140 of those also have no fever. Find P(no fever | no flu).** [2 marks · Practice]

#### Given

No-flu group=160; both no fever and no flu=140.

#### To find

The conditional probability.

#### Formula and why it applies

Keep only the evidence group. The denominator measures that group; the numerator measures the part satisfying both events.



$$
P(A\mid B)=\frac{P(A\cap B)}{P(B)},\qquad P(B)>0
$$



#### Solution

##### Step 1. Choose numerator and denominator

Numerator=140; denominator=160. The quantity after the bar identifies the denominator.

##### Step 2. Divide



$$
\frac{140}{160}=0.875
$$



**Final answer.** 0.875.

**Given P(A and B)=0.12 and P(B)=0.30, find P(A | B).** [2 marks · Practice]

#### Given

Joint event probability=0.12; evidence probability=0.30.

#### To find

The conditional probability.

#### Formula and why it applies

Keep only the evidence group. The denominator measures that group; the numerator measures the part satisfying both events.



$$
P(A\mid B)=\frac{P(A\cap B)}{P(B)},\qquad P(B)>0
$$



#### Solution

##### Step 1. Choose numerator and denominator

Numerator=0.12; denominator=0.3. The quantity after the bar identifies the denominator.

##### Step 2. Divide



$$
\frac{0.12}{0.3}=0.4
$$



**Final answer.** 0.4.

---

## TEE · Bayes' rule with a tree of 1000 people

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-zero--bayes-tree/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-zero/bayes-tree

Start here if probability is new: counting, AND/OR, conditional probability and Bayes with pictures

A probability tree branches by successive conditions. Multiply along one complete path because all its events must occur together. Add different complete paths when either path qualifies. Counts such as 0.99 out of 1,000 are **expected counts** in the illustration, not fractions of an actual person. Scaling the same model to 100,000 gives 100 diseased people, 99 positive among them, and 1,998 false positives among 99,900 others. The posterior is 99/(99+1998)=99/2097≈0.0472103.

**In one line:** to reverse a “given”, imagine a crowd, split it by the cause, then by the evidence, and count.

## The question

A disease affects 1 person in 1000. A test is positive for 99% of sick people, and wrongly positive for 2% of healthy people. Your test is positive. How likely is it that you are sick?

Swipe across the diagram to read its labels ↔

![Imagine 1000 people (disease 1 in 1000, test catches 99%, false alarm 2%)](https://deep-learning-study-room.vercel.app/is2/fig/prob_tree.201d46f630.svg)

Diagram: Imagine 1000 people (disease 1 in 1000, test catches 99%, false alarm 2%). Labels: Imagine 1000 people (disease 1 in 1000, test catches 99%, false alarm 2%) | 1000 people | 1 has disease | 0.001 × 1000 | 999 healthy | 0.999 × 1000 | 0.99 test + | 99% of 1 | 0.01 test − | 19.98 test + | 2% of 999 (false alarm) | 979.02 test − | All positives = 0.99 + 19.98 = 20.97 people; only 0.99 of them are ill → 0.99 / 20.97 = 0.047 (4.7%)

## Counting on the tree

1. Of 1000 people, 1 is sick and 999 are healthy.
2. The sick person tests positive with 99%: 0.99 people.
3. Healthy people test positive with 2%: 0.02 × 999 = 19.98 people.
4. Everyone who tests positive: 0.99 + 19.98 = 20.97 people.
5. Of those, sick: 0.99. So P(sick | positive) = 0.99 / 20.97 = 0.047.

Only about 4.7%, because the healthy group is so much bigger that its small false-alarm rate still produces most positives.

## The same thing as a formula



$$
P(\text{sick}\mid+)=\frac{P(+\mid\text{sick})\,P(\text{sick})}{P(+\mid\text{sick})P(\text{sick})+P(+\mid\text{healthy})P(\text{healthy})}=\frac{0.99\times0.001}{0.99\times0.001+0.02\times0.999}=0.047
$$



Each part of the formula is one branch of the tree. Names: P(sick) is the **prior** (before the test), P(+ | sick) the **likelihood**, the denominator the **evidence** (all positives), and the answer the **posterior** (after the test).

**Yaad rakho:** Bayes = tree banao: pehle cause se baanto, phir evidence se. Answer = “jo humein chahiye” ÷ “saare jo evidence dikhate hain”.

Next: the formal version and more examples in [Bayes' rule](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-prob--bayes-rule/).

---

## TEE · Why agents need probability (and the basic rules)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-prob--uncertainty/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-prob/uncertainty

Unit 1 · Quantifying uncertainty, inference using the full joint distribution, Bayes rule

**Action A pays 10 points with probability 0.6 and −2 points with probability 0.4. Action B always pays 4 points. Which has greater expected reward?** [2 marks · Worked example]

#### Given

Action A: reward 10 with probability 0.6, reward −2 with probability 0.4. Action B: reward 4 with probability 1. The two probabilities for A add to 1.

#### To find

Expected score for each action.

#### Formula and why it applies



$$
\mathbb E[R]=\sum_i P_iR_i
$$



Expectation is a probability-weighted average. It need not equal any one actual outcome.

#### Solution

##### Step 1. A: weight each outcome



$$
0.6\times10=6\qquad0.4\times(-2)=-0.8
$$



##### Step 2. A: add



$$
\mathbb E[R_A]=6-0.8=5.2
$$



##### Step 3. B: certain outcome



$$
\mathbb E[R_B]=1\times4=4
$$



##### Step 4. Compare

5.2>4, so A has the greater expected reward. A single attempt can still return −2.

**Final answer.** A:5.2; B:4. Choose A under an expected-reward criterion.

Ω names the sample space (all outcomes). ω names one outcome. The symbol E or 𝔼 means expectation here; it does not mean an observed reward. A rational probabilistic decision uses both how likely outcomes are and how desirable they are.

**In one line:** when an agent cannot be certain, it should hold a degree of belief between 0 and 1 for each possibility and update it with evidence; probability theory is the tool for that.

## Acting under uncertainty

An agent is uncertain because of **partial observability** (it cannot see everything) and **non-determinism** (actions do not always have the same result). Pure logic fails in such domains. Example: “Toothache ⇒ Cavity” is false (gum disease also causes toothache), and listing every possible cause is impossible. Logic fails for three reasons:

1. **Laziness**: listing every antecedent and consequent is too much work.
2. **Theoretical ignorance**: science has no complete theory of the domain.
3. **Practical ignorance**: we cannot run every test on every patient.

So the agent assigns a **degree of belief** (probability), e.g. “80% of toothache patients have cavities”. **Decision theory = probability theory + utility theory**: a rational agent chooses the action with the **maximum expected utility** (e.g. a taxi choosing when to leave for the airport balances the chance of missing the flight against waiting time).

Sources of uncertainty in AI: incomplete data, noise, ambiguity, stochastic environments, model and algorithm limits.

## Basic notation

| Term | Meaning / rule |
| --- | --- |
| Sample space Ω | All possible worlds; 

$$
0\le P(\omega)\le1
$$

, 

$$
\sum_\omega P(\omega)=1
$$

 |
| Prior (unconditional) | 

$$
P(a)
$$

: belief before evidence, e.g. 

$$
P(cavity)=0.2
$$

 |
| Posterior (conditional) | 

$$
P(a\mid b)=\dfrac{P(a\land b)}{P(b)}
$$

, 

$$
P(b)>0
$$

 |
| Product rule | 

$$
P(a\land b)=P(a\mid b)P(b)=P(b\mid a)P(a)
$$

 |
| Complement | 

$$
P(\lnot a)=1-P(a)
$$

 |
| Inclusion–exclusion | 

$$
P(a\lor b)=P(a)+P(b)-P(a\land b)
$$

 |
| Marginalisation | 

$$
P(Y)=\sum_z P(Y,z)
$$

 |
| Total probability | 

$$
P(b)=P(b\mid a)P(a)+P(b\mid\lnot a)P(\lnot a)
$$

 |
| Independence | 

$$
P(a\land b)=P(a)P(b)
$$

, equivalently 

$$
P(a\mid b)=P(a)
$$

 |
| Distribution | Bold 

$$
\mathbf P(Weather)=\langle0.6,0.1,0.29,0.01\rangle
$$

 lists all values |

**Yaad rakho:** Logic “haan/na” bolta hai; probability “kitna yakeen” batati hai. Conditional = joint ÷ evidence.

---

## TEE · Inference using the full joint distribution (5-mark PYQs)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-prob--full-joint/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-prob/full-joint

Unit 1 · Quantifying uncertainty, inference using the full joint distribution, Bayes rule

A joint-probability table is a list of complete combinations. Three Yes/No variables have 2×2×2=8 combinations. “Marginalise” means ignore a variable by adding its possible cases. “Condition” means first restrict attention to the evidence cases, then divide by their total. For unnormalised weights .12 and .08, the total is .20; α=1/.20=5, so α×.12=.6 and α×.08=.4. α is only a rescaling constant.

**In one line:** a full joint table lists the probability of every combination; to answer any question, add the cells where it is true, and for “given” questions divide by the cells of the evidence.

## Method

1. **Marginal** 

$$
P(a)
$$

: add every cell in which a is true.
2. **Conditional** 

$$
P(a\mid e)=\dfrac{P(a\land e)}{P(e)}
$$

: add cells where both hold, divide by the sum of cells where e holds.
3. **Normalisation**: 

$$
\mathbf P(A\mid e)=\alpha\,\mathbf P(A,e)
$$

 with 

$$
\alpha=1/P(e)
$$

: compute the unnormalised values for every value of A, then scale them to sum to 1.

**Question. For the dentist table below find P(cavity ∨ toothache), P(cavity | toothache) and P(¬cavity | toothache).** [class example · 3 marks]

#### Given

The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.

#### To find

All requested marginal and conditional probabilities.

#### Formula and why it applies

Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum.



$$
P(A\mid E)=\frac{P(A\cap E)}{P(E)},\quad P(E)>0
$$



#### Solution

|  | toothache, catch | toothache, ¬catch | ¬toothache, catch | ¬toothache, ¬catch |
| --- | --- | --- | --- | --- |
| **cavity** | 0.108 | 0.012 | 0.072 | 0.008 |
| **¬cavity** | 0.016 | 0.064 | 0.144 | 0.576 |

##### Step 1. Disjunction



$$
P(cavity\lor toothache)=0.108+0.012+0.072+0.008+0.016+0.064=0.28
$$



##### Step 2. Conditionals



$$
P(toothache)=0.108+0.012+0.016+0.064=0.2,\qquad P(cavity\mid toothache)=\frac{0.12}{0.2}=0.6,\qquad P(\lnot cavity\mid toothache)=\frac{0.08}{0.2}=0.4
$$



With α: 

$$
\mathbf P(Cavity\mid toothache)=\alpha\langle0.12,\,0.08\rangle=\langle0.6,\,0.4\rangle
$$

, 

$$
\alpha=1/0.2=5
$$

.

**Final answer.** P(cavity OR toothache)=0.28; P(cavity | toothache)=0.6; P(no cavity | toothache)=0.4.

**Question. A supermarket recorded the joint distribution of Product type (Y: premium = 1, regular = 0), Payment mode (X: credit = 1, debit = 0) and Gender (Z: female = 1, male = 0). (a) If a customer bought a premium item, find the probability that (1) they are female, (2) they paid by credit card. (b) Find (1) P(premium) and (2) P(credit card). (c) Given a male customer paid by debit card, find the probability he bought a regular item.** [5 marks · Final Nov 2025 Q1a]

#### Given

The printed eight entries are reproduced below. Their total is 1.002, not 1. Therefore the table is inconsistent as a probability distribution.

|  | Credit, female | Credit, male | Debit, female | Debit, male |
| --- | --- | --- | --- | --- |
| **Premium (Y=1)** | 0.08 | 0.10 | 0.072 | 0.05 |
| **Regular (Y=0)** | 0.10 | 0.15 | 0.25 | 0.20 |

#### To find

The five requested probabilities, stating how the inconsistent data are interpreted.

#### Formula and why it applies

For this worked solution, treat all printed entries as nonnegative weights and normalise by their total 1.002. This preserves the printed ratios. It is a declared interpretation, not a claim about the examiner’s intended correction.



$$
P(E)=\frac{\text{sum of weights for }E}{\text{sum of all weights}}
$$





$$
P(A\mid E)=\frac{\text{sum of weights for }A\cap E}{\text{sum of weights for }E}
$$



#### Solution

##### Step 1. Validate the full table



$$
0.08+0.10+0.072+0.05+0.10+0.15+0.25+0.20=1.002
$$



Use total weight 1.002 consistently for unconditional probabilities.

##### Step 2. Premium row total



$$
w(premium)=0.08+0.10+0.072+0.05=0.302
$$



##### Step 3. Female given premium



$$
P(female\mid premium)=\frac{0.08+0.072}{0.302}=\frac{0.152}{0.302}\approx0.503311
$$



##### Step 4. Credit given premium



$$
P(credit\mid premium)=\frac{0.08+0.10}{0.302}=\frac{0.18}{0.302}\approx0.596026
$$



##### Step 5. Normalised premium marginal



$$
P(premium)=\frac{0.302}{1.002}\approx0.301397
$$



##### Step 6. Normalised credit marginal



$$
P(credit)=\frac{0.08+0.10+0.10+0.15}{1.002}=\frac{0.43}{1.002}\approx0.429142
$$



##### Step 7. Regular given male and debit



$$
P(regular\mid male,debit)=\frac{0.20}{0.05+0.20}=0.8
$$



**Final answer.** Under common normalisation: (a) 0.503311 and 0.596026; (b) 0.301397 and 0.429142; (c) 0.8.

**Alternative correction:** if 0.072 is corrected to 0.070, the total becomes 1 and the corresponding answers are (a) 0.50 and 0.60; (b) 0.30 and 0.43; (c) 0.8. This agrees with the interpretation used in the supplied key. State the correction; do not call raw totals 0.302 and 0.43 valid marginals of the original inconsistent table.

**Question. For a disease Y with fever X as a symptom, a test Z is conducted. Joint probabilities: Disease (Y=1): fever & test+ 0.576, fever & test− 0.144, no fever & test+ 0.072, no fever & test− 0.016; No disease (Y=0): 0.008, 0.064, 0.012, 0.108. (1) If fever occurs and the test is positive, what is the probability of disease? (2) What is the probability that a random person tests positive? (3) Given no fever, what is the probability of still having the disease?** [5 marks · Re-exam Jan 2026 Q1a]

#### Given

The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.

#### To find

All requested marginal and conditional probabilities.

#### Formula and why it applies

Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum.



$$
P(A\mid E)=\frac{P(A\cap E)}{P(E)},\quad P(E)>0
$$



#### Solution

##### Step 1. (1)



$$
P(Y{=}1\mid X{=}1,Z{=}1)=\frac{0.576}{0.576+0.008}=\frac{0.576}{0.584}=0.986
$$



##### Step 2. (2) Add every test-positive cell



$$
P(Z{=}1)=0.576+0.072+0.008+0.012=0.668
$$



##### Step 3. (3)



$$
P(X{=}0)=0.072+0.016+0.012+0.108=0.208,\qquad P(Y{=}1\mid X{=}0)=\frac{0.072+0.016}{0.208}=\frac{0.088}{0.208}=0.423
$$



**Final answer.** (1) 0.986; (2) 0.668; (3) 0.423.

**Key correction.** The key writes 0.088/0.076 = 1.158 for part (3). A probability cannot exceed 1; the denominator must be P(no fever) = 0.208.

**Yaad rakho:** “Given” wali cheez denominator mein jaati hai. Pehle evidence ke saare cells jodo, phir upar wale.

---

## TEE · Bayes’ rule: meaning, derivation and three complete examples

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-prob--bayes-rule/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-prob/bayes-rule

Unit 1 · Quantifying uncertainty, inference using the full joint distribution, Bayes rule

## What Bayes’ rule reverses

A **prior** is the probability of a cause before the new evidence. A **likelihood** is the probability of that evidence if the cause is true. A **posterior** is the probability of the cause after observing the evidence. These are different conditional directions: P(positive | disease) is not P(disease | positive).

## Derivation



$$
P(A\cap B)=P(B\mid A)P(A)=P(A\mid B)P(B)
$$



Divide both sides by P(B), provided that P(B)>0.



$$
P(A\mid B)=\frac{P(B\mid A)P(A)}{P(B)}
$$



If A and its complement are the only two possibilities, evidence B can arise by either path. Add both paths in the denominator.



$$
P(A\mid B)=\frac{P(B\mid A)P(A)}{P(B\mid A)P(A)+P(B\mid\neg A)P(\neg A)}
$$



| Symbol | Read it as |
| --- | --- |
| P(A) | Prior: how common is A? |
| P(B | A) | Likelihood: if A is true, how likely is B? |
| P(B) | Evidence: how common is B through all possible causes? |
| P(A | B) | Posterior: among B cases, what fraction come from A? |

**A hypothetical population has a disease prevalence of 1 in 1000. A test is positive in 99% of diseased cases and 2% of healthy cases. Given a positive result, calculate the probability of disease.** [4 marks · Worked probability example]

#### Given

A = disease; B = positive test. P(A)=0.001; P(B|A)=0.99; P(B|not A)=0.02.

#### To find

The reversed conditional probability P(A | B).

#### Formula and why it applies

The question gives evidence given each cause, but asks for cause given evidence. Bayes’ rule combines the prior with that likelihood and divides by all ways of obtaining the evidence.



$$
P(A\mid B)=\frac{P(B\mid A)P(A)}{P(B\mid A)P(A)+P(B\mid\neg A)P(\neg A)}
$$



#### Solution

##### Step 1. Find the other prior



$$
P(\neg A)=1-0.001=0.999
$$



##### Step 2. Evidence through the requested cause

Multiply the prior for disease by the likelihood within that group.



$$
P(A\cap B)=0.001\times0.99=0.00099
$$



##### Step 3. Evidence through the other cause

Now include the path through healthy.



$$
P(\neg A\cap B)=0.999\times0.02=0.01998
$$



##### Step 4. Add both paths for total evidence



$$
P(B)=0.00099+0.01998=0.02097
$$



##### Step 5. Normalise the requested path



$$
P(A\mid B)=\frac{0.00099}{0.02097}\approx0.0472103
$$



**Final answer.** 0.0472103 ≈ 4.721030043%.

**In a hypothetical population, 49% are female and 51% male. 8% of females and 12% of males are classified high-risk in the supplied data. Given that a person is high-risk, find the probability that the person is male.** [3 marks · Worked probability example]

#### Given

A = male; B = high-risk category. P(A)=0.51; P(B|A)=0.12; P(B|not A)=0.08.

#### To find

The reversed conditional probability P(A | B).

#### Formula and why it applies

The question gives evidence given each cause, but asks for cause given evidence. Bayes’ rule combines the prior with that likelihood and divides by all ways of obtaining the evidence.



$$
P(A\mid B)=\frac{P(B\mid A)P(A)}{P(B\mid A)P(A)+P(B\mid\neg A)P(\neg A)}
$$



#### Solution

##### Step 1. Find the other prior



$$
P(\neg A)=1-0.51=0.49
$$



##### Step 2. Evidence through the requested cause

Multiply the prior for male by the likelihood within that group.



$$
P(A\cap B)=0.51\times0.12=0.0612
$$



##### Step 3. Evidence through the other cause

Now include the path through female.



$$
P(\neg A\cap B)=0.49\times0.08=0.0392
$$



##### Step 4. Add both paths for total evidence



$$
P(B)=0.0612+0.0392=0.1004
$$



##### Step 5. Normalise the requested path



$$
P(A\mid B)=\frac{0.0612}{0.1004}\approx0.609561753
$$



**Final answer.** 0.609561753 ≈ 60.956175299%.

**Machine A makes 60% of items and Machine B makes 40%. Defect rates are 4% for A and 1% for B. A randomly chosen item is defective. Find the probability that Machine A made it.** [3 marks · Worked probability example]

#### Given

Cause A = Machine A; evidence B = defective item. P(A)=0.60; P(B|A)=0.04; P(B|not A)=0.01.

#### To find

The reversed conditional probability P(A | B).

#### Formula and why it applies

The question gives evidence given each cause, but asks for cause given evidence. Bayes’ rule combines the prior with that likelihood and divides by all ways of obtaining the evidence.



$$
P(A\mid B)=\frac{P(B\mid A)P(A)}{P(B\mid A)P(A)+P(B\mid\neg A)P(\neg A)}
$$



#### Solution

##### Step 1. Find the other prior



$$
P(\neg A)=1-0.6=0.4
$$



##### Step 2. Evidence through the requested cause

Multiply the prior for Machine A by the likelihood within that group.



$$
P(A\cap B)=0.6\times0.04=0.024
$$



##### Step 3. Evidence through the other cause

Now include the path through Machine B.



$$
P(\neg A\cap B)=0.4\times0.01=0.004
$$



##### Step 4. Add both paths for total evidence



$$
P(B)=0.024+0.004=0.028
$$



##### Step 5. Normalise the requested path



$$
P(A\mid B)=\frac{0.024}{0.028}\approx0.857142857
$$



**Final answer.** 0.857142857 ≈ 85.714285714%.

A rare prior can make a positive result much less conclusive than its sensitivity suggests. The posterior still depends on the actual prior and both test rates; rarity alone does not determine the answer.

**Yaad rakho:** Pehle requested cause ka path multiply. Neeche evidence tak pahunchne wale saare paths add.

---

## TEE · The naive Bayes model (worked on PlayTennis)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-nb--model/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-nb/model

Unit 1 · Naive Bayes model · 10-mark PYQ in both papers

## What the data and the question represent

A **training row** is one past case whose correct class is known. Its **features** are the information used to predict that class. In the flu exercise, Fever, Cough and Temperature are features; Flu Yes/No is the class. A **query** is the new case whose features are known but whose class must be predicted.

A **prior** is the class share before using the query features. A **likelihood** asks how common one query feature is inside that class. A **posterior** is the class probability after accounting for the query. The naive assumption makes the feature likelihoods multiply once the class is fixed; it does not assert that all features are independent in the whole population.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Π likelihoods | Multiply every feature factor | With factors .5,.2,.4: .5×.2=.1; .1×.4=.04 |
| score(C) | An unnormalised class weight | Prior .3 times .04 gives .012 |
| max | The largest numerical score | max(.012,.008)=.012 |
| argmax | The label attaining the largest score | The winning label is the class with score .012 |
| Laplace denominator N꜀+k | Class count plus number of possible values for this feature | Temperature has three values, so k=3; a Yes/No feature has k=2 |

**In one line:** assume the features are independent given the class; then score each class as prior × product of feature likelihoods and pick the largest.

## Definition

**Naive Bayes** is a supervised probabilistic classifier based on Bayes' rule with the **naive assumption** that all features are conditionally independent given the class:



$$
P(C\mid a_1,\dots,a_n)\;\propto\;P(C)\prod_{i=1}^{n}P(a_i\mid C),\qquad v_{NB}=\arg\max_{c}\,P(c)\prod_iP(a_i\mid c)
$$



“Naive” because real features are often correlated; it still works very well for spam filtering, sentiment analysis and medical screening.

## Steps (as taught)

1. **Priors**: 

$$
P(c)=
$$

 (rows of class c) / (total rows).
2. **Likelihood tables**: for each attribute value, 

$$
P(a_i\mid c)=
$$

 (rows of class c with that value) / (rows of class c).
3. **Score** each class for the new instance and choose the larger. Optionally normalise: divide each score by their sum.

**Zero-frequency problem.** If a value never occurs with a class, that factor is 0 and the whole score is 0. The main unsmoothed solutions below leave a zero count as zero. Apply smoothing when it is specified, consistently in every class. Textbooks fix it with **Laplace smoothing**: 

$$
P(a\mid c)=\dfrac{\text{count}+1}{N_c+k}
$$

, k = number of values of the attribute. Mention it in one line; it can change the answer.

**Question. Using the 14-day PlayTennis data (9 Yes, 5 No), classify ⟨Outlook = Sunny, Temperature = Cool, Humidity = High, Wind = Strong⟩.** [class example · 6 marks]

#### Given

Class counts: Yes=9, No=5. Within Yes, counts for Sunny/Cool/High/Strong are 2/3/3/3; within No they are 3/1/4/3. Classify Sunny, Cool, High, Strong.

#### To find

Both class scores and the predicted class.

#### Formula and why it applies

Conditional independence given the class allows the product of feature likelihoods.



$$
score(C)=P(C)\prod_jP(a_j\mid C)
$$



Divide each score by their sum only after computing both.

#### Solution

##### Step 1. Priors



$$
P(yes)=\tfrac9{14}\approx0.643,\qquad P(no)=\tfrac5{14}\approx0.357
$$



##### Step 2. Likelihoods needed

|  | Sunny | Cool | High | Strong |
| --- | --- | --- | --- | --- |
| Yes | 2/9 | 3/9 | 3/9 | 3/9 |
| No | 3/5 | 1/5 | 4/5 | 3/5 |

##### Step 3. Scores



$$
v(yes)=\tfrac9{14}\cdot\tfrac29\cdot\tfrac39\cdot\tfrac39\cdot\tfrac39\approx0.005291005,\qquad v(no)=\tfrac5{14}\cdot\tfrac35\cdot\tfrac15\cdot\tfrac45\cdot\tfrac35\approx0.020571429
$$



##### Step 4. Normalise



$$
P(yes\mid x)=\frac{1/189}{1/189+18/875}\approx0.204582651,\qquad P(no\mid x)\approx0.795417349
$$



**Final answer.** PlayTennis = **No** (0.795).

**Yaad rakho:** Naive Bayes = prior × (har feature ka fraction) ka guna. Jo bada, wohi class.

---

## TEE · Solved PYQ: naive Bayes for flu (Final 2025, 10 marks)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-nb--flu/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-nb/flu

Unit 1 · Naive Bayes model · 10-mark PYQ in both papers

**Question. A hospital wants to predict flu from Fever (Yes/No), Cough (Yes/No) and Temperature Level (Low/Normal/High). Training data: (Yes, Yes, High, Yes), (No, No, Normal, No), (Yes, No, Low, No), (Yes, Yes, High, Yes), (No, Yes, Normal, No), (Yes, Yes, High, Yes), (No, No, Low, No), (Yes, No, Normal, No). Using naive Bayes, predict whether a patient with Fever = Yes, Cough = Yes, Temperature = Normal has flu.** [10 marks · Final Nov 2025 Q4b]

#### Given

The full training data are in Step 1. Query: Fever=Yes, Cough=Yes, Temperature=Normal. The main calculation uses unsmoothed counts.

#### To find

Both class scores and the predicted class.

#### Formula and why it applies



$$
score(C)=P(C)\prod_jP(a_j\mid C)
$$



C is a class label. Each aⱼ is one query feature value. First count inside a class, then multiply the prior and all three likelihoods.

#### Solution

##### Step 1. Write the training rows as a table

| Row | Fever | Cough | Temperature | Class |
| --- | --- | --- | --- | --- |
| 1 | Yes | Yes | High | Yes |
| 2 | No | No | Normal | No |
| 3 | Yes | No | Low | No |
| 4 | Yes | Yes | High | Yes |
| 5 | No | Yes | Normal | No |
| 6 | Yes | Yes | High | Yes |
| 7 | No | No | Low | No |
| 8 | Yes | No | Normal | No |

##### Step 2. Separate the two class groups

| Class | Rows in this group | Class count | Prior |
| --- | --- | --- | --- |
| Yes | 1, 4, 6 | 3 | 3/8 = 0.375 |
| No | 2, 3, 5, 7, 8 | 5 | 5/8 = 0.625 |

##### Step 3. For class Yes, count Fever=Yes

Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.



$$
P(\text{Fever}=\text{Yes}\mid C=\text{Yes})=\frac{3}{3}=1
$$



##### Step 4. For class Yes, count Cough=Yes

Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.



$$
P(\text{Cough}=\text{Yes}\mid C=\text{Yes})=\frac{3}{3}=1
$$



##### Step 5. For class Yes, count Temperature=Normal

Look only at class Yes rows 1, 4, 6. No row in this class has that feature value.



$$
P(\text{Temperature}=\text{Normal}\mid C=\text{Yes})=\frac{0}{3}=0
$$



##### Step 6. Multiply the Yes score one factor at a time



$$
P(Yes)=3/8=0.375
$$





$$
0.375\times1=0.375
$$





$$
0.375\times1=0.375
$$





$$
0.375\times0=0
$$



##### Step 7. For class No, count Fever=Yes

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 3, 8.



$$
P(\text{Fever}=\text{Yes}\mid C=\text{No})=\frac{2}{5}=0.4
$$



##### Step 8. For class No, count Cough=Yes

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Cough}=\text{Yes}\mid C=\text{No})=\frac{1}{5}=0.2
$$



##### Step 9. For class No, count Temperature=Normal

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 2, 5, 8.



$$
P(\text{Temperature}=\text{Normal}\mid C=\text{No})=\frac{3}{5}=0.6
$$



##### Step 10. Multiply the No score one factor at a time



$$
P(No)=5/8=0.625
$$





$$
0.625\times0.4=0.25
$$





$$
0.25\times0.2=0.05
$$





$$
0.05\times0.6=0.03
$$



##### Step 11. Compare the scores



$$
score(Yes)=0\qquad score(No)=0.03
$$



The larger score belongs to No. Normalise only if a posterior probability is requested: divide each score by their total 0.03.

**Final answer.** Predict No. Yes score=0; No score=0.03.

The zero Yes score is caused by an absent training combination. If Laplace smoothing is explicitly required, apply it to all feature likelihoods in both classes. That is a different calculation and may change the prediction; do not mix smoothed and unsmoothed sides.

**Yaad rakho:** Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.

---

## TEE · Solved PYQ: naive Bayes for a job offer (Re-exam 2026, 10 marks)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-nb--job-offer/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-nb/job-offer

Unit 1 · Naive Bayes model · 10-mark PYQ in both papers

**Question. Predict whether a candidate accepts a job offer from Experience (Fresher/Mid/Senior), Expected Salary (Low/Medium/High) and Company Reputation (Good/Average). Data: (Fresher, Low, Good, Yes), (Mid, High, Good, Yes), (Senior, High, Average, No), (Fresher, Medium, Average, Yes), (Senior, Low, Good, No), (Mid, Medium, Good, Yes), (Fresher, High, Average, No), (Senior, Medium, Average, No). New candidate: Mid, Low, Good.** [10 marks · Re-exam Jan 2026 Q4b]

#### Given

The full training data are in Step 1. Query: Experience=Mid, Salary=Low, Reputation=Good. The main calculation uses unsmoothed counts.

#### To find

Both class scores and the predicted class.

#### Formula and why it applies



$$
score(C)=P(C)\prod_jP(a_j\mid C)
$$



C is a class label. Each aⱼ is one query feature value. First count inside a class, then multiply the prior and all three likelihoods.

#### Solution

##### Step 1. Write the training rows as a table

| Row | Experience | Salary | Reputation | Class |
| --- | --- | --- | --- | --- |
| 1 | Fresher | Low | Good | Yes |
| 2 | Mid | High | Good | Yes |
| 3 | Senior | High | Average | No |
| 4 | Fresher | Medium | Average | Yes |
| 5 | Senior | Low | Good | No |
| 6 | Mid | Medium | Good | Yes |
| 7 | Fresher | High | Average | No |
| 8 | Senior | Medium | Average | No |

##### Step 2. Separate the two class groups

| Class | Rows in this group | Class count | Prior |
| --- | --- | --- | --- |
| Yes | 1, 2, 4, 6 | 4 | 4/8 = 0.5 |
| No | 3, 5, 7, 8 | 4 | 4/8 = 0.5 |

##### Step 3. For class Yes, count Experience=Mid

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 2, 6.



$$
P(\text{Experience}=\text{Mid}\mid C=\text{Yes})=\frac{2}{4}=0.5
$$



##### Step 4. For class Yes, count Salary=Low

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1.



$$
P(\text{Salary}=\text{Low}\mid C=\text{Yes})=\frac{1}{4}=0.25
$$



##### Step 5. For class Yes, count Reputation=Good

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1, 2, 6.



$$
P(\text{Reputation}=\text{Good}\mid C=\text{Yes})=\frac{3}{4}=0.75
$$



##### Step 6. Multiply the Yes score one factor at a time



$$
P(Yes)=4/8=0.5
$$





$$
0.5\times0.5=0.25
$$





$$
0.25\times0.25=0.0625
$$





$$
0.0625\times0.75=0.046875
$$



##### Step 7. For class No, count Experience=Mid

Look only at class No rows 3, 5, 7, 8. No row in this class has that feature value.



$$
P(\text{Experience}=\text{Mid}\mid C=\text{No})=\frac{0}{4}=0
$$



##### Step 8. For class No, count Salary=Low

Look only at class No rows 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Salary}=\text{Low}\mid C=\text{No})=\frac{1}{4}=0.25
$$



##### Step 9. For class No, count Reputation=Good

Look only at class No rows 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Reputation}=\text{Good}\mid C=\text{No})=\frac{1}{4}=0.25
$$



##### Step 10. Multiply the No score one factor at a time



$$
P(No)=4/8=0.5
$$





$$
0.5\times0=0
$$





$$
0\times0.25=0
$$





$$
0\times0.25=0
$$



##### Step 11. Compare the scores



$$
score(Yes)=0.046875\qquad score(No)=0
$$



The larger score belongs to Yes. Normalise only if a posterior probability is requested: divide each score by their total 0.046875.

**Final answer.** Predict Yes. Yes score=0.046875; No score=0.

**Official key note.** The key gives No = 0.0068 and P(Yes) = 0.873. That No value comes from Laplace smoothing (1/7 × 2/7 × 2/6 × 0.5), but the key did not smooth the Yes side. If you smooth, smooth both: Yes = 0.5 × 3/7 × 2/7 × 4/6 = 0.0408, No = 0.0068, P(Yes) = 0.857. The prediction is Yes either way.

**Yaad rakho:** Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.

---

## TEE · Bayesian networks: structure, CPTs and the chain rule

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-bn--semantics/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-bn/semantics

Unit 1 · Semantics of Bayesian networks and exact inference · 10-mark PYQ in both papers

## A Bayesian network starts as a diagram of variables

A **node** is a variable, such as Rain. An **edge** is an arrow representing a direct dependency in the model. A **parent** has an arrow into a node. A **root** has no parents. **Directed acyclic graph (DAG)** means arrows have directions and you cannot follow them around a loop back to the starting node. The graph alone does not establish real-world causation.

A **CPT** is a conditional probability table: for each parent configuration, it states the probabilities of the child’s values. A **Boolean** variable has two values, true and false. If a CPT gives P(Wet=true|Rain=true)=.9, its complementary entry is P(Wet=false|Rain=true)=1−.9=.1.

**In Rain → Wet, P(Rain)=0.2, P(Wet|Rain)=0.9 and P(Wet|no Rain)=0.1. Find P(Rain AND Wet), P(Wet), and P(Rain|Wet).** [2 marks · Worked example]

#### Given

P(Rain)=0.2; P(Wet|Rain)=0.9; P(Wet|no Rain)=0.1. Each variable has two possible values: true or false. Rain is the root; Wet depends on Rain.

#### To find

A joint probability, a marginal probability and a posterior.

#### Formula and why it applies

Multiply down one complete case, add the alternative ways to get Wet, then divide by the evidence probability.

#### Solution

##### Step 1. Rain and wet



$$
P(R,W)=0.2\times0.9=0.18
$$



##### Step 2. No rain and wet



$$
P(\neg R,W)=(1-0.2)\times0.1=0.8\times0.1=0.08
$$



##### Step 3. Total wet



$$
P(W)=0.18+0.08=0.26
$$



##### Step 4. Restrict to the wet cases



$$
P(R\mid W)=0.18/0.26=9/13\approx0.692307692
$$



**Final answer.** Joint .18; marginal .26; posterior≈.692308.

**In one line:** a Bayesian network is a DAG of random variables in which each node stores P(node | its parents); multiplying those tables gives the full joint distribution.

## Definition

A **Bayesian network** (belief network) is a directed acyclic graph in which:

1. each **node** is a random variable;
2. a directed **edge** X → Y means the model conditions Y on X (X is a parent of Y); a causal interpretation needs additional assumptions; there are no directed cycles;
3. each node has a **conditional probability table (CPT)** 

$$
\mathbf P(X_i\mid Parents(X_i))
$$

. A root node stores its prior.

Swipe across the diagram to read its labels ↔

![Burglary network (Russell and Norvig)](https://deep-learning-study-room.vercel.app/is2/fig/bn_burglary.9802d6d53d.svg)

Diagram: Burglary network (Russell and Norvig). Labels: Burglary network (Russell and Norvig) | Burglary | P(B) = 0.001 | Earthquake | P(E) = 0.002 | Alarm | P(A|B,E): .95 · .94 · .29 · .001 | (TT · TF · FT · FF) | JohnCalls | P(J|A) = .90, P(J|¬A) = .05 | MaryCalls | P(M|A) = .70, P(M|¬A) = .01

## Semantics: the chain rule for Bayesian networks



$$
P(x_1,\dots,x_n)=\prod_{i=1}^{n}P\big(x_i\mid parents(X_i)\big)
$$



So the network *is* a compact description of the full joint distribution. For the burglary network:



$$
P(J,M,A,B,E)=P(J\mid A)\,P(M\mid A)\,P(A\mid B,E)\,P(B)\,P(E)
$$



**Conditional independence:** each node is conditionally independent of its non-descendants given its parents (e.g. JohnCalls is independent of Burglary once Alarm is known).

**Compactness:** a Boolean node with k Boolean parents needs 

$$
2^k
$$

 numbers. The burglary network needs 1 + 1 + 4 + 2 + 2 = 10 numbers instead of 

$$
2^5-1=31
$$

 for the full joint.

## Building a network

1. Choose the variables.
2. Choose an acyclic variable order; when a causal model is justified, cause-before-effect is often useful.
3. For each variable, choose as parents a suitable set of earlier variables that captures its conditional dependencies.
4. Write its CPT.

**Yaad rakho:** Har node sirf apne parents se baat karta hai. Joint = sab nodes ka P(node | parents) ka guna.

---

## TEE · Inference in Bayesian networks: enumeration, α and variable elimination

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-bn--inference/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-bn/inference

Unit 1 · Semantics of Bayesian networks and exact inference · 10-mark PYQ in both papers

## Expand the hidden-variable calculation before the compact formula

For burglary given both calls, B is the query, J=true and M=true are evidence, and E and A are hidden. “Hidden” only means their values are not supplied in the query. A sum over a Boolean variable adds its true and false cases.

| Calculation | Burglary true | Burglary false |
| --- | --- | --- |
| Average alarm probability over E | .95×.002 + .94×.998 = .94002 | .29×.002 + .001×.998 = .001578 |
| No-alarm probability | 1−.94002=.05998 | 1−.001578=.998422 |
| Both calls if alarm | .9×.7=.63 | .9×.7=.63 |
| Both calls if no alarm | .05×.01=.0005 | .05×.01=.0005 |
| Calls and this B value | .001×(.63×.94002 + .0005×.05998)=.00059224259 | .999×(.63×.001578 + .0005×.998422)=.001491857649 |

Add the final two weights: .00059224259+.001491857649=.002084100239. Divide the burglary weight by that total: .00059224259/.002084100239≈.284171835. No step equates P(B|calls) with P(calls|B); the prior P(B) is included explicitly.

**In one line:** to answer P(query | evidence), sum the chain-rule product over every hidden variable, do it for each value of the query, and normalise with α.

## Three kinds of question

| Question type | Method |
| --- | --- |
| Every variable's value given | Multiply the CPT entries (chain rule) |
| One marginal, e.g. P(J) | Sum over hidden variables; no α |
| Query given evidence, e.g. P(B | j, m) | Enumerate for each value of B, then 

$$
\alpha=1/\text{(sum)}
$$

 |

**Question. In the burglary network find (a) P(j, m, a, ¬b, ¬e), (b) P(JohnCalls), (c) P(Burglary | John and Mary call).** [class examples · 10 marks]

For the burglary example: B and E are independent roots with P(B)=0.001 and P(E)=0.002. Alarm A has parents B,E. John J and Mary M each have parent A. P(A|B,E)=0.95, P(A|B,¬E)=0.94, P(A|¬B,E)=0.29, P(A|¬B,¬E)=0.001. P(J|A)=0.9, P(J|¬A)=0.05; P(M|A)=0.7, P(M|¬A)=0.01. False probabilities are the complements of the listed true probabilities.

#### Given

The network, root probabilities and conditional probability tables stated in the question.

#### To find

The requested joint, marginal or evidence-conditioned probability.

#### Formula and why it applies

A Bayesian network factorises the joint using each node conditioned on its parents. Sum over hidden values; normalise for evidence.



$$
P(x_1,\ldots,x_n)=\prod_iP(x_i\mid parents_i)
$$



#### Solution

##### (a) Chain rule



$$
P=P(j\mid a)P(m\mid a)P(a\mid\lnot b,\lnot e)P(\lnot b)P(\lnot e)=0.90\times0.70\times0.001\times0.999\times0.998=0.000628
$$



##### (b) Marginal: first P(a)



$$
P(a)=0.95(0.001)(0.002)+0.94(0.001)(0.998)+0.29(0.999)(0.002)+0.001(0.999)(0.998)=0.002516
$$





$$
P(j)=P(j\mid a)P(a)+P(j\mid\lnot a)P(\lnot a)=0.90(0.002516)+0.05(0.997484)=0.0521
$$



##### (c) Enumeration with α (hidden: E, A)



$$
P(b\mid j,m)=\alpha\,P(b)\sum_aP(j\mid a)P(m\mid a)\sum_eP(a\mid b,e)P(e)
$$





$$
=\alpha\,(0.001)\big[0.9(0.7)(0.95\times0.002+0.94\times0.998)+0.05(0.01)(0.05\times0.002+0.06\times0.998)\big]=\alpha\times0.000592
$$





$$
P(\lnot b\mid j,m)=\alpha\,(0.999)\big[0.9(0.7)(0.29\times0.002+0.001\times0.998)+0.05(0.01)(0.71\times0.002+0.999\times0.998)\big]=\alpha\times0.001492
$$





$$
\alpha=\frac1{0.000592+0.001492}=479.8\;\Rightarrow\;P(b\mid j,m)=0.284,\;P(\lnot b\mid j,m)=0.716
$$



**Final answer.** (a) 0.000628; (b) 0.0521; (c) 0.284. Even when both neighbours call, a burglary is only about 28% likely because burglaries are rare.

**Slide note.** One slide prints .71 for 

$$
P(\lnot a\mid b,\lnot e)
$$

; it is 1 − 0.94 = 0.06 (corrected by hand on the slide).

## Variable elimination (why it is faster)

Enumeration repeats the same products many times (exponential, 

$$
O(2^n)
$$

). **Variable elimination** pushes each sum as far inside as possible, computes it once and stores the result as a **factor**; hidden variables are “summed out” one at a time:



$$
P(J)=\sum_AP(J\mid A)\sum_MP(M\mid A)\sum_BP(B)\underbrace{\sum_EP(A\mid B,E)P(E)}_{f_1(A,B)}
$$



Any sum of a CPT over its own variable is 1 (e.g. 

$$
\sum_MP(M\mid A)=1
$$

), so irrelevant (barren) nodes drop out.

**Question. Heart-disease network: Exercise → HD ← Diet; HD → BP. P(E) = 0.7, P(D = healthy) = 0.25; P(HD | E, D) = 0.25 (E, healthy), 0.45 (E, unhealthy), 0.55 (¬E, healthy), 0.75 (¬E, unhealthy); P(BP high | HD) = 0.85, P(BP high | ¬HD) = 0.2. A patient has high BP. Find P(HD | BP).** [class example · 6 marks]

#### Given

The network, root probabilities and conditional probability tables stated in the question.

#### To find

The requested joint, marginal or evidence-conditioned probability.

#### Formula and why it applies

A Bayesian network factorises the joint using each node conditioned on its parents. Sum over hidden values; normalise for evidence.



$$
P(x_1,\ldots,x_n)=\prod_iP(x_i\mid parents_i)
$$



#### Solution

##### Step 1. P(HD) by summing out E and D



$$
P(hd)=0.7(0.25\times0.25+0.45\times0.75)+0.3(0.55\times0.25+0.75\times0.75)=0.7(0.4)+0.3(0.7)=0.49
$$



##### Step 2. Unnormalised



$$
\alpha\,P(bp\mid hd)P(hd)=\alpha(0.85)(0.49)=\alpha\,0.4165,\qquad\alpha\,P(bp\mid\lnot hd)P(\lnot hd)=\alpha(0.2)(0.51)=\alpha\,0.102
$$



##### Step 3. Normalise



$$
\alpha=\frac1{0.5185},\quad P(hd\mid bp)=0.803,\quad P(\lnot hd\mid bp)=0.197
$$



**Final answer.** 0.803.

**Yaad rakho:** Hidden variables par sum, query ki dono values nikaalo, α se 1 banao. Sirf marginal (P(J)) ho to α nahi.

---

## TEE · Solved PYQ: wet grass given no rain (Final 2025, 10 marks)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-bn--sprinkler/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-bn/sprinkler

Unit 1 · Semantics of Bayesian networks and exact inference · 10-mark PYQ in both papers

The following table enumerates the values of Cloudy and Sprinkler that were not fixed by the question. Two Boolean choices give four rows: true/true, true/false, false/true, false/false. Each row is one mutually exclusive complete case. Read the CPT entry using that row’s parent values, multiply its factors, and add the resulting row weights. The denominator must include all cases matching the evidence, including both possible values of the queried outcome.

**Question. Cloudy → Sprinkler, Cloudy → Rain, Sprinkler and Rain → Wet Grass. P(Cloudy) = 0.5; P(Sprinkler | C) = 0.10, P(Sprinkler | ¬C) = 0.50; P(Rain | C) = 0.80, P(Rain | ¬C) = 0.20; P(Wet | S, R) = 0.99, P(Wet | S, ¬R) = 0.90, P(Wet | ¬S, R) = 0.90, P(Wet | ¬S, ¬R) = 0.01. Calculate the probability of the grass being wet given it doesn't rain.** [10 marks · Final Nov 2025 Q3a]

#### Given

C→S, C→R, (S,R)→W. Root and conditional probabilities are listed in the question. Evidence R=false.

#### To find

P(W=true | R=false). Hidden variables C and S must be summed out.

#### Formula and why it applies

Use the network joint and divide by the evidence probability.



$$
P(W\mid\neg R)=\frac{\sum_{c,s}P(c)P(s\mid c)P(\neg R\mid c)P(W\mid s,\neg R)}{\sum_cP(c)P(\neg R\mid c)}
$$



#### Solution

Swipe across the diagram to read its labels ↔

![Final 2025 Q3a: sprinkler network](https://deep-learning-study-room.vercel.app/is2/fig/bn_sprinkler.a251583272.svg)

Diagram: Final 2025 Q3a: sprinkler network. Labels: Final 2025 Q3a: sprinkler network | Cloudy | P(C) = 0.5 | Sprinkler | P(S|C) = 0.1, P(S|¬C) = 0.5 | Rain | P(R|C) = 0.8, P(R|¬C) = 0.2 | Wet grass | P(W|S,R): .99 · .90 · .90 · .01 | (TT · TF · FT · FF)

##### Step 1. Joint by the chain rule



$$
P(C,S,R,W)=P(C)\,P(S\mid C)\,P(R\mid C)\,P(W\mid S,R)
$$



##### Step 2. Sum over C and S with R = false, W = true

| C | S | P(C) | P(S|C) | P(¬R|C) | P(W|S,¬R) | Product |
| --- | --- | --- | --- | --- | --- | --- |
| T | T | 0.5 | 0.1 | 0.2 | 0.90 | 0.0090 |
| T | F | 0.5 | 0.9 | 0.2 | 0.01 | 0.0009 |
| F | T | 0.5 | 0.5 | 0.8 | 0.90 | 0.1800 |
| F | F | 0.5 | 0.5 | 0.8 | 0.01 | 0.0020 |
| **P(W, ¬R)** | | | | | | **0.1919** |

##### Step 3. Evidence



$$
P(\lnot R)=P(C)P(\lnot R\mid C)+P(\lnot C)P(\lnot R\mid\lnot C)=0.5(0.2)+0.5(0.8)=0.5
$$



##### Step 4. Divide



$$
P(W\mid\lnot R)=\frac{0.1919}{0.5}=0.3838
$$



**Final answer.** P(grass wet | no rain) ≈ **0.384**. Without rain, the grass is wet mainly when the sprinkler runs (more likely on non-cloudy days).

**Keep the requested conditional probability separate.** The supplied key discusses P(Wet) and P(Rain | Wet), whereas this question asks P(Wet | no rain). The answer to the printed question is 0.3838. For comparison, the exact marginal from the printed CPT is calculated below; it is not 0.6505.

#### Optional comparison: calculate P(Wet) from the same network

The four no-rain cases already total 0.1919. Now add the four rain cases, keeping the same Cloudy/Sprinkler order.



$$
P(W,R)=0.5(0.1)(0.8)(0.99)+0.5(0.9)(0.8)(0.90)+0.5(0.5)(0.2)(0.99)+0.5(0.5)(0.2)(0.90)
$$





$$
P(W,R)=0.0396+0.324+0.0495+0.045=0.4581
$$





$$
P(W)=P(W,R)+P(W,\neg R)=0.4581+0.1919=0.6500
$$





$$
P(R\mid W)=\frac{0.4581}{0.6500}\approx0.704769231
$$



**Meaning:** the unconditional chance of Wet is 0.65, the chance of Rain among wet cases is about 0.704769, and the requested chance of Wet among no-rain cases is 0.3838. These are three different questions.

**Trap.** Do not plug in the marginal P(Sprinkler) = 0.3; sprinkler and rain both depend on Cloudy, so you must sum over Cloudy (given no rain, P(S) = 0.42).

---

## TEE · Solved PYQ: fever given no flu (Re-exam 2026, 10 marks)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-bn--flu-network/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-bn/flu-network

Unit 1 · Semantics of Bayesian networks and exact inference · 10-mark PYQ in both papers

The following table enumerates the values of Weather and Cough that were not fixed by the question. Two Boolean choices give four rows: true/true, true/false, false/true, false/false. Each row is one mutually exclusive complete case. Read the CPT entry using that row’s parent values, multiply its factors, and add the resulting row weights. The denominator must include all cases matching the evidence, including both possible values of the queried outcome.

**Question. Weather → Flu, Weather → Cough, Flu and Cough → Fever. P(Weather) = 0.75; P(Flu | W) = 0.2, P(Flu | ¬W) = 0.5; P(Cough | W) = 0.70, P(Cough | ¬W) = 0.25; P(Fever | Flu, Cough) = 0.60, P(Fever | Flu, ¬Cough) = 0.02, P(Fever | ¬Flu, Cough) = 0.60, P(Fever | ¬Flu, ¬Cough) = 0.01. Calculate the probability of a person having fever given he doesn't have flu.** [10 marks · Re-exam Jan 2026 Q3a]

#### Given

W→F, W→C, (F,C)→V. The complete probabilities are in the question. Evidence F=false.

#### To find

P(V=true | F=false), summing hidden W and C.

#### Formula and why it applies

Use the network joint and normalise by the no-Flu evidence.



$$
P(V\mid\neg F)=\frac{\sum_{w,c}P(w)P(\neg F\mid w)P(c\mid w)P(V\mid\neg F,c)}{\sum_wP(w)P(\neg F\mid w)}
$$



#### Solution

Swipe across the diagram to read its labels ↔

![Re-exam 2026 Q3a: weather–flu–cough–fever network](https://deep-learning-study-room.vercel.app/is2/fig/bn_flu.1d732f0fb6.svg)

Diagram: Re-exam 2026 Q3a: weather–flu–cough–fever network. Labels: Re-exam 2026 Q3a: weather–flu–cough–fever network | Weather | P(W) = 0.75 | Flu | P(F|W) = 0.2, P(F|¬W) = 0.5 | Cough | P(C|W) = 0.7, P(C|¬W) = 0.25 | Fever | P(V|F,C): .60 · .02 · .60 · .01 | (TT · TF · FT · FF)

##### Step 1. Chain rule



$$
P(W,F,C,V)=P(W)\,P(F\mid W)\,P(C\mid W)\,P(V\mid F,C)
$$



##### Step 2. Sum over W and C with F = false, V = true

| W | C | P(W) | P(¬F|W) | P(C|W) | P(V|¬F,C) | Product |
| --- | --- | --- | --- | --- | --- | --- |
| T | T | 0.75 | 0.8 | 0.70 | 0.60 | 0.252 |
| T | F | 0.75 | 0.8 | 0.30 | 0.01 | 0.0018 |
| F | T | 0.25 | 0.5 | 0.25 | 0.60 | 0.01875 |
| F | F | 0.25 | 0.5 | 0.75 | 0.01 | 0.0009375 |
| **P(V, ¬F)** | | | | | | **0.2734875** |

##### Step 3. Evidence



$$
P(\lnot F)=0.75(0.8)+0.25(0.5)=0.6+0.125=0.725
$$



##### Step 4. Divide



$$
P(V\mid\lnot F)=\frac{0.2734875}{0.725}=0.3772
$$



**Final answer.** P(fever | no flu) ≈ **0.377** (fever without flu comes mostly from cough).

**Key correction.** The key uses P(Flu) = 0.05 and P(Fever | ¬Flu) = 0.2, which are not in this network, and answers 0.2. Marking scheme (still applies): write the equation with hidden variables (2), take true/false cases (3), substitute (2), answer (3).

---

## TEE · Before GMM: centre, spread, density and likelihood

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-gmm--centre-spread/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-gmm/centre-spread

Unit 1 · Mixture models, GMM, expectation maximization, clustering using GMM · 10-mark PYQ in both papers

## Mean, variance and standard deviation

A Gaussian component describes a cluster using its **mean** (centre) and **variance** (spread). The **standard deviation** is the square root of variance. The Greek letters μ and σ name these two quantities; σ² is the variance.

**Calculate the mean, population variance and standard deviation of [1, 3, 5].** [2 marks · Worked example]

#### Given

Data values: [1, 3, 5]. Number of observations n=3. Use population variance, dividing by n.

#### To find

The mean μ, population variance σ², and standard deviation σ.

#### Formula and why it applies



$$
\mu=\frac{\sum_i x_i}{n}\quad\sigma^2=\frac{\sum_i(x_i-\mu)^2}{n}\quad\sigma=\sqrt{\sigma^2}
$$



This descriptive/maximum-likelihood convention divides by n. The n−1 sample-variance estimator is a different convention.

#### Solution

##### Step 1. Add and divide for the mean



$$
\mu=\frac{1+3+5}{3}=3
$$



##### Step 2. Subtract the mean, then square

| x | x−mean | Squared deviation |
| --- | --- | --- |
| 1 | -2 | 4 |
| 3 | 0 | 0 |
| 5 | 2 | 4 |

##### Step 3. Average the squared deviations



$$
\sigma^2=\frac{4+0+4}{3}=2.666666667
$$



##### Step 4. Take the square root



$$
\sigma=\sqrt{2.666666667}\approx1.632993162
$$



**Final answer.** Mean=3; variance=2.666666667; standard deviation≈1.632993162.

**Calculate the mean, population variance and standard deviation of [2, 4].** [2 marks · Worked example]

#### Given

Data values: [2, 4]. Number of observations n=2. Use population variance, dividing by n.

#### To find

The mean μ, population variance σ², and standard deviation σ.

#### Formula and why it applies



$$
\mu=\frac{\sum_i x_i}{n}\quad\sigma^2=\frac{\sum_i(x_i-\mu)^2}{n}\quad\sigma=\sqrt{\sigma^2}
$$



This descriptive/maximum-likelihood convention divides by n. The n−1 sample-variance estimator is a different convention.

#### Solution

##### Step 1. Add and divide for the mean



$$
\mu=\frac{2+4}{2}=3
$$



##### Step 2. Subtract the mean, then square

| x | x−mean | Squared deviation |
| --- | --- | --- |
| 2 | -1 | 1 |
| 4 | 1 | 1 |

##### Step 3. Average the squared deviations



$$
\sigma^2=\frac{1+1}{2}=1
$$



##### Step 4. Take the square root



$$
\sigma=\sqrt{1}\approx1
$$



**Final answer.** Mean=3; variance=1; standard deviation≈1.

**Calculate the mean, population variance and standard deviation of [4, 4, 4].** [2 marks · Worked example]

#### Given

Data values: [4, 4, 4]. Number of observations n=3. Use population variance, dividing by n.

#### To find

The mean μ, population variance σ², and standard deviation σ.

#### Formula and why it applies



$$
\mu=\frac{\sum_i x_i}{n}\quad\sigma^2=\frac{\sum_i(x_i-\mu)^2}{n}\quad\sigma=\sqrt{\sigma^2}
$$



This descriptive/maximum-likelihood convention divides by n. The n−1 sample-variance estimator is a different convention.

#### Solution

##### Step 1. Add and divide for the mean



$$
\mu=\frac{4+4+4}{3}=4
$$



##### Step 2. Subtract the mean, then square

| x | x−mean | Squared deviation |
| --- | --- | --- |
| 4 | 0 | 0 |
| 4 | 0 | 0 |
| 4 | 0 | 0 |

##### Step 3. Average the squared deviations



$$
\sigma^2=\frac{0+0+0}{3}=0
$$



##### Step 4. Take the square root



$$
\sigma=\sqrt{0}\approx0
$$



**Final answer.** Mean=4; variance=0; standard deviation≈0.

The constant data [4,4,4] have variance zero. A standard Gaussian density formula requires positive variance; do not divide by zero when fitting a component.

## Density, likelihood and logarithm have different jobs

A **density** is the height of a continuous distribution. Probability over an interval is area, so density height can exceed 1 without violating probability rules. A **likelihood** treats the observed data as fixed and scores candidate model parameters. For independent observations, their densities multiply.

**A model assigns density 0.2 to one observation and 0.5 to a second independent observation. Find likelihood and natural log-likelihood.** [2 marks · Worked example]

#### Given

Two density values .2 and .5.

#### To find

Product and its natural logarithm.

#### Formula and why it applies



$$
L=p(x_1)p(x_2)\qquad\ln L=\ln p(x_1)+\ln p(x_2)
$$



The logarithm turns a product into a sum.

#### Solution

##### Step 1. Multiply the densities



$$
L=0.2\times0.5=0.1
$$



##### Step 2. Take ln of that product



$$
\ln L=\ln(0.1)\approx-2.302585093
$$



##### Step 3. Show the equivalent sum



$$
\ln(0.2)+\ln(0.5)\approx-1.609437912-0.693147181=-2.302585093
$$



**Final answer.** Likelihood .1; log-likelihood≈−2.302585093.

Do not turn a sum inside a log into a sum of logs: ln(.2+.5)=ln(.7)≈−.356675, whereas ln(.2)+ln(.5)≈−2.302585. A GMM has an inner sum over components, which must stay inside each observation’s logarithm.

**Yaad rakho:** Mean = centre. Variance = squared distance ka average. Likelihood = fixed data ko model kitna support karta hai.

---

## TEE · GMM prerequisites: mean, variance, density and mixture

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-gmm--mixture-models/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-gmm/mixture-models

Unit 1 · Mixture models, GMM, expectation maximization, clustering using GMM · 10-mark PYQ in both papers

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Component k | One Gaussian group in the mixture | Component 1 may have mean 2; component 2 mean 4 |
| Mixing weight πₖ | The prior share assigned to component k | π₁=.4 and π₂=.6 sum to 1 |
| N(x|μ,σ²) | The Gaussian density evaluated at x | The vertical bar supplies parameters; it is not division |
| Σ over k | Add contributions of every component | p(x)=.4N₁(x)+.6N₂(x) |

## Mean, spread and a Gaussian component

A **mean** is the centre, found by adding observations and dividing by their count. A **variance** measures squared spread around the mean. In one dimension, a Gaussian component is described by mean μ and positive variance σ². Its standard deviation σ is the square root of that variance.

A **density** is a height, not the probability of one exact real-valued observation. Areas under a density give probabilities. Density heights can exceed 1; their total area must be 1.



$$
\mathcal N(x\mid\mu,\sigma^2)=\frac1{\sqrt{2\pi}\,\sigma}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)
$$



Here π inside 2π is the constant 3.14159…; the separately written πₖ in a mixture denotes a component weight. exp(a)=eᵃ, and the calculator eˣ key evaluates it. The minus sign in the exponent reduces density away from the mean.

**For a standard Gaussian with μ=0 and σ²=1, find the density at x=0.** [3 marks · Practice]

#### Given

x=0; μ=0; σ=1.

#### To find

Density N(x|0,1).

#### Formula and why it applies

Use the Gaussian density with the supplied mean and variance.

#### Solution

##### Step 1. Squared distance



$$
(0-0)^2=0
$$



##### Step 2. Exponent



$$
-0/(2\times1)=0
$$



##### Step 3. Exponential



$$
e^{0}\approx1
$$



##### Step 4. Divide by the normalising factor



$$
\frac{1}{\sqrt{2\pi}}\approx0.39894228
$$



**Final answer.** 0.39894228 (a density, not an exact-point probability).

**For a standard Gaussian with μ=0 and σ²=1, find the density at x=1.** [3 marks · Practice]

#### Given

x=1; μ=0; σ=1.

#### To find

Density N(x|0,1).

#### Formula and why it applies

Use the Gaussian density with the supplied mean and variance.

#### Solution

##### Step 1. Squared distance



$$
(1-0)^2=1
$$



##### Step 2. Exponent



$$
-1/(2\times1)=-0.5
$$



##### Step 3. Exponential



$$
e^{-0.5}\approx0.60653066
$$



##### Step 4. Divide by the normalising factor



$$
\frac{0.60653066}{\sqrt{2\pi}}\approx0.241970725
$$



**Final answer.** 0.241970725 (a density, not an exact-point probability).

**For a standard Gaussian with μ=0 and σ²=1, find the density at x=2.** [3 marks · Practice]

#### Given

x=2; μ=0; σ=1.

#### To find

Density N(x|0,1).

#### Formula and why it applies

Use the Gaussian density with the supplied mean and variance.

#### Solution

##### Step 1. Squared distance



$$
(2-0)^2=4
$$



##### Step 2. Exponent



$$
-4/(2\times1)=-2
$$



##### Step 3. Exponential



$$
e^{-2}\approx0.135335283
$$



##### Step 4. Divide by the normalising factor



$$
\frac{0.135335283}{\sqrt{2\pi}}\approx0.053990967
$$



**Final answer.** 0.053990967 (a density, not an exact-point probability).

## Mixture model and hidden component

A **mixture model** combines component densities. A Gaussian mixture model (GMM) uses K Gaussian components. A hidden component label says which component generated a point; it is not observed in ordinary clustering. A weight πₖ is the prior probability of choosing component k. All weights are nonnegative and sum to 1.



$$
p(x)=\sum_{k=1}^K\pi_k\mathcal N(x\mid\mu_k,\sigma_k^2)
$$



For two components this means π₁×density₁ + π₂×density₂. A GMM can represent several concentrations of data rather than forcing all points around one mean.

Swipe across the diagram to read its labels ↔

![The total density is a weighted sum of component densities.](https://deep-learning-study-room.vercel.app/is2/fig/gmm_mix.84e959698a.svg)

Diagram: The total density is a weighted sum of component densities.. Labels: A 1-D Gaussian mixture: three weighted bells add up to p(x) | -8 | -4 | 0 | 4 | 8 | p | x

The total density is a weighted sum of component densities.

**At x, two component densities are 0.2 and 0.05, with weights 0.6 and 0.4. Find the mixture density.** [2 marks · Practice]

#### Given

π₁=.6, π₂=.4; densities=.2,.05.

#### To find

p(x).

#### Formula and why it applies

Weight each component density, then add.



$$
p(x)=\pi_1N_1+\pi_2N_2
$$



#### Solution

##### Step 1. First contribution



$$
0.6(0.2)=0.12
$$



##### Step 2. Second contribution



$$
0.4(0.05)=0.02
$$



##### Step 3. Add



$$
p(x)=0.12+0.02=0.14
$$



**Final answer.** Mixture density = 0.14.

**Yaad rakho:** Har Gaussian ek group ka model; mixture = weights ke saath sab densities ka sum.

---

## TEE · EM for GMM: every responsibility and parameter update

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-gmm--em/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-gmm/em

Unit 1 · Mixture models, GMM, expectation maximization, clustering using GMM · 10-mark PYQ in both papers

**At one observation, the two weighted component densities are q₁=0.12 and q₂=0.03. Find the responsibilities. Then use responsibilities [0.8,0.2] for data [1,5] to find a component’s new mean.** [2 marks · Worked example]

#### Given

Part A: weighted component densities q₁=0.12 and q₂=0.03 for one observation. Part B: data x₁=1 and x₂=5, with component responsibilities 0.8 and 0.2 respectively. Part A compares components for one point; Part B combines points for one component.

#### To find

Two responsibilities and a weighted mean.

#### Formula and why it applies



$$
\gamma_{ik}=q_{ik}/\sum_jq_{ij}\qquad\mu_k^{new}=\frac{\sum_i\gamma_{ik}x_i}{\sum_i\gamma_{ik}}
$$



i identifies an observation; k identifies a component. Notice which index is being added in each formula.

#### Solution

##### Step 1. Normalise one observation



$$
q_1+q_2=0.12+0.03=0.15
$$





$$
\gamma_1=0.12/0.15=0.8\quad\gamma_2=0.03/0.15=0.2
$$



##### Step 2. Find the effective component count



$$
N_k=0.8+0.2=1
$$



##### Step 3. Weight each observation



$$
0.8\times1=0.8\qquad0.2\times5=1
$$



##### Step 4. Add and divide



$$
\mu_k^{new}=(0.8+1)/1=1.8
$$



**Final answer.** Responsibilities [.8,.2]; new mean 1.8. A point contributes a fraction of a count instead of being assigned wholly to one component.

## What EM is estimating

**Expectation–maximisation (EM)** alternates two calculations when component assignments are hidden. The E-step estimates how responsible each component is for each observation. The M-step uses those responsibilities as weights to update the model parameters.

A **responsibility** γᵢₖ is a posterior component probability: for observation i, how likely is component k under the current model? For each observation, the responsibilities sum to 1. Unlike fuzzy memberships, these probabilities are explicitly normalised across mixture components.

| Symbol | Meaning |
| --- | --- |
| i / k | Observation number / component number |
| γᵢₖ | Responsibility of component k for observation i |
| Nₖ | Sum of responsibilities for component k: an effective count |
| μₖ | Component mean |
| σ²ₖ | Component variance |
| πₖ | Component mixing weight |



$$
\gamma_{ik}=\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\sum_j\pi_j\mathcal N(x_i\mid\mu_j,\sigma_j^2)}
$$





$$
N_k=\sum_i\gamma_{ik},\quad\mu_k^{new}=\frac{\sum_i\gamma_{ik}x_i}{N_k}
$$





$$
(\sigma_k^2)^{new}=\frac{\sum_i\gamma_{ik}(x_i-\mu_k^{new})^2}{N_k},\quad\pi_k^{new}=N_k/n
$$



The E-step uses all old parameters. The M-step mean uses those fixed responsibilities; the variance uses the newly calculated mean. One exact EM update cannot lower the likelihood when its optimisation steps are performed correctly; numerical approximations and regularisation need their own interpretation. EM can still reach a local solution.

**For observations {1,3,5}, initialise a two-component GMM with means 2 and 4, both variances 1, and both weights 0.5. Perform one complete EM iteration.** [6 marks · Practice]

#### Given

n=3, K=2, μ₁=2, μ₂=4; σ₁²=σ₂²=1; π₁=π₂=.5.

#### To find

Six responsibilities and the new weights, means and variances.

#### Formula and why it applies

Apply the E-step and M-step equations above. Calculate with full precision; decimals below are displayed to nine places.

#### Solution

##### Step 1. E-step: weighted densities for x=1



$$
q_1=0.5\frac{e^{-(1-2)^2/2}}{\sqrt{2\pi}}\approx0.120985362
$$





$$
q_2=0.5\frac{e^{-(1-4)^2/2}}{\sqrt{2\pi}}\approx0.002215924
$$



##### Step 2. E-step: weighted densities for x=3



$$
q_1=0.5\frac{e^{-(3-2)^2/2}}{\sqrt{2\pi}}\approx0.120985362
$$





$$
q_2=0.5\frac{e^{-(3-4)^2/2}}{\sqrt{2\pi}}\approx0.120985362
$$



##### Step 3. E-step: weighted densities for x=5



$$
q_1=0.5\frac{e^{-(5-2)^2/2}}{\sqrt{2\pi}}\approx0.002215924
$$





$$
q_2=0.5\frac{e^{-(5-4)^2/2}}{\sqrt{2\pi}}\approx0.120985362
$$



##### Step 4. E-step: normalise responsibilities for x=1



$$
\gamma_1=\frac{0.120985362}{0.120985362+0.002215924}\approx0.98201379
$$





$$
\gamma_2=1-\gamma_1\approx0.01798621
$$



##### Step 5. E-step: normalise responsibilities for x=3



$$
\gamma_1=\frac{0.120985362}{0.120985362+0.120985362}\approx0.5
$$





$$
\gamma_2=1-\gamma_1\approx0.5
$$



##### Step 6. E-step: normalise responsibilities for x=5



$$
\gamma_1=\frac{0.002215924}{0.002215924+0.120985362}\approx0.01798621
$$





$$
\gamma_2=1-\gamma_1\approx0.98201379
$$



##### Step 7. M-step: effective count for component 1



$$
N_1=0.98201379+0.5+0.01798621=1.5
$$



##### Step 8. M-step: mean for component 1



$$
\mu_1^{new}=\frac{0.98201379(1)+0.5(3)+0.01798621(5)}{1.5}\approx1.714629893
$$



##### Step 9. M-step: variance for component 1

| x | Responsibility | Squared deviation from new mean | Weighted squared deviation |
| --- | --- | --- | --- |
| 1 | 0.98201379 | 0.510695884 | 0.501510401 |
| 3 | 0.5 | 1.652176311 | 0.826088156 |
| 5 | 0.01798621 | 10.793656738 | 0.194136976 |



$$
(\sigma_1^2)^{new}=\frac{1.521735533}{1.5}\approx1.014490355
$$



##### Step 10. M-step: mixture weight for component 1



$$
\pi_1^{new}=1.5/3=0.5
$$



##### Step 11. M-step: effective count for component 2



$$
N_2=0.01798621+0.5+0.98201379=1.5
$$



##### Step 12. M-step: mean for component 2



$$
\mu_2^{new}=\frac{0.01798621(1)+0.5(3)+0.98201379(5)}{1.5}\approx4.285370107
$$



##### Step 13. M-step: variance for component 2

| x | Responsibility | Squared deviation from new mean | Weighted squared deviation |
| --- | --- | --- | --- |
| 1 | 0.01798621 | 10.793656738 | 0.194136976 |
| 3 | 0.5 | 1.652176311 | 0.826088156 |
| 5 | 0.98201379 | 0.510695884 | 0.501510401 |



$$
(\sigma_2^2)^{new}=\frac{1.521735533}{1.5}\approx1.014490355
$$



##### Step 14. M-step: mixture weight for component 2



$$
\pi_2^{new}=1.5/3=0.5
$$



**Final answer.** Means ≈ [1.714629893, 4.285370107]; variances ≈ [1.014490355, 1.014490355]; weights [0.5,0.5].

**Yaad rakho:** E: har point ki responsibility. M: responsibilities se weighted mean, variance, weight.

---

## TEE · 10-mark answer: GMM vs k-means, log-likelihood derivation, parameters for K = 5

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-gmm--ten-mark-answer/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-gmm/ten-mark-answer

Unit 1 · Mixture models, GMM, expectation maximization, clustering using GMM · 10-mark PYQ in both papers

## Read the derivation’s symbols first

“i.i.d.” means the observations are modelled as independent draws from the same distribution. The product Π runs over observations; the inner sum Σ runs over components. λki in some notes is the same responsibility that other sections call γik. A superscript i here labels the observation, not an exponent.

Jensen’s inequality gives a lower bound on the log of the component sum. EM chooses responsibilities making that bound touch the current likelihood, then updates the parameters to maximise the bound with those responsibilities fixed. This explains the two alternating steps; λ values are not arbitrary new model parameters.

| Parameter | Number in a 1D K-component GMM | Why |
| --- | --- | --- |
| Means | K | One centre for each component |
| Variances | K | One spread for each component |
| Independent mixing weights | K−1 | The last weight is 1 minus the others |
| Total | 3K−1 | K+K+(K−1) |

For K=2, choose μ₁,μ₂,σ₁²,σ₂² and π₁: five free numbers. Then π₂=1−π₁. For K=5, 5+5+4=14. In 2D with a full covariance matrix, each component instead has two means and three independent covariance entries (two variances and one shared off-diagonal covariance). Five such components have 5×(2+3)+4=29 free parameters.

**Asked twice as:** “With reference to GMM: compare GMM with the k-means algorithm; derive the equation for the log-likelihood function; what will be the number of parameters to be computed if K = 5?” [10 marks · Final 2025 Q2b and Re-exam 2026 Q2b; key: up to the maximum-likelihood equation 5, estimation 5]

### 1. GMM versus k-means

| Aspect | k-means | GMM |
| --- | --- | --- |
| Assignment | Hard: each point in exactly one cluster | Soft: probability 

$$
\lambda_k^i
$$

 of belonging to each cluster |
| Model | Geometric: nearest centroid | Probabilistic generative model 

$$
\sum_k\pi_k\mathcal N(\mu_k,\Sigma_k)
$$

 |
| Cluster shape | Spherical, similar size | Elliptical, any size/orientation; overlapping clusters |
| Parameters | K centroids | Weights, means, covariances (1-D: 3K − 1) |
| Algorithm / objective | Assign–update; minimise squared distances | EM; maximise log-likelihood |
| Output | Hard labels and fitted centroids | Labels, membership probabilities and a density (useful for anomaly detection) |
| Relation | The hard-assignment, equal spherical variance, small-variance limit of a Gaussian-mixture objective leads to the k-means objective. Ordinary finite-variance EM is not the same algorithm as k-means. Both need K in advance and depend on initialisation. | |

### 2. Derivation of the log-likelihood

**Step 1. Model.** Each point is generated by choosing component k with probability 

$$
\pi_k
$$

 and drawing 

$$
x_i\sim\mathcal N(\mu_k,\sigma_k^2)
$$

, so its density is 

$$
f_{mix}(x_i)=\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)
$$

.

**Step 2. Likelihood.** Points are i.i.d., so the likelihood is a product (θ = all parameters):



$$
L(\theta)=\prod_{i=1}^{n}\Big[\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big]
$$



**Step 3. Log-likelihood.** Logs turn the product into a sum:



$$
\log L(\theta)=\sum_{i=1}^{n}\log\Big(\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big)
$$



**Step 4. Why it cannot be solved directly.** The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.

**Step 5. Jensen's inequality.** log is concave, so for weights 

$$
\lambda_k\ge0,\;\sum\lambda_k=1
$$

: 

$$
\log\big(\sum_k\lambda_ka_k\big)\ge\sum_k\lambda_k\log a_k
$$

. Introduce 

$$
\lambda_k^i
$$

 for every point (

$$
\sum_k\lambda_k^i=1
$$

), multiply and divide inside the log:



$$
\log L(\theta)=\sum_i\log\Big(\sum_k\lambda_k^i\,\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}\Big)\;\ge\;\sum_i\sum_k\lambda_k^i\log\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}
$$



**Step 6. Estimation (EM).** Maximise the lower bound alternately. Fixing θ gives the E-step 

$$
\lambda_k^i=\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)/\sum_l\pi_l\mathcal N(x_i\mid\mu_l,\sigma_l^2)
$$

. Fixing λ and differentiating (with a Lagrange multiplier for 

$$
\sum\pi_k=1
$$

) gives the M-step:



$$
\hat\mu_k=\frac{\sum_i\lambda_k^ix_i}{\sum_i\lambda_k^i},\qquad\hat\sigma_k^2=\frac{\sum_i\lambda_k^i(x_i-\hat\mu_k)^2}{\sum_i\lambda_k^i},\qquad\hat\pi_k=\frac{\sum_i\lambda_k^i}{n}
$$



### 3. Number of parameters for K = 5

The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:



$$
2K+(K-1)=3K-1=3(5)-1=\mathbf{14}
$$



(5 means + 5 variances + 4 free weights, since the 5 weights must add to 1.) In two dimensions with full covariance it would be 29.

**Slide note.** One slide puts the convex inequality under the “concave” heading. Correct: log is *concave*, so 

$$
f(\sum\lambda a)\ge\sum\lambda f(a)
$$

 (≥, not >).

---

## TEE · Clustering with GMM: uses, advantages and limits

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-gmm--clustering-applications/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u1-gmm/clustering-applications

Unit 1 · Mixture models, GMM, expectation maximization, clustering using GMM · 10-mark PYQ in both papers

## Clustering using GMM

1. Choose K (domain knowledge, or a criterion such as BIC).
2. Fit the GMM with EM.
3. For each point compute 

$$
\lambda_k^i
$$

; the largest gives its cluster, and the values show how confident the assignment is.
4. Points with very low 

$$
p(x)
$$

 under every component are anomalies.

**Example (class).** Marks 45, 48, 50, 52, 80, 82, 85, 88, 90 form two groups, “average” near 50 and “high performers” near 85. A two-component GMM gives each student a probability of belonging to each group; students in between (none here) would get split probabilities instead of a forced label.

## Applications

- Customer segmentation in marketing
- Image segmentation (pixel colours) and background subtraction in video
- Speaker identification and speech recognition
- Anomaly and fraud detection (low-density points)
- Density estimation and generating new samples

## Advantages and limitations

| Advantages | Limitations |
| --- | --- |
| Soft assignments with probabilities | K must be chosen in advance |
| Flexible elliptical, overlapping clusters | Sensitive to initialisation; can stop at a local optimum |
| Interpretable parameters (weights, means, covariances) | Assumes each cluster is Gaussian |
| Gives a full density model | Costly for many dimensions (covariance matrices) |

**Probability vs likelihood** (lab question): probability fixes the parameters and asks how likely the data is; likelihood fixes the observed data and asks how plausible each parameter value is. Maximum-likelihood estimation chooses the parameters that make the observed data most probable.

### Why an unrestricted GMM can collapse

A Gaussian centred on one training observation can make its variance approach zero, causing its density there and the mixture likelihood to grow without a finite bound. This is a singularity, not evidence of a useful perfect cluster. Practical fitting therefore uses a positive variance/covariance floor or a prior, sensible initialisation, and checks for nearly empty components. Different starts can reach different local solutions. These qualifications do not change the stated one-iteration classroom calculation.

Primary reference: [Bishop, Pattern Recognition and Machine Learning, chapter 9](https://www.microsoft.com/en-us/research/wp-content/uploads/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf).

---

## TEE · Fuzzy sets: what membership actually means

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--membership-meaning/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/membership-meaning

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Start with an input and a label

Suppose the input is **temperature 32°C** and the fuzzy label is **Hot**. A membership function is the rule that converts that temperature into a degree of matching the label. If μHot(32)=0.7, read it aloud as “the membership of 32 degrees in Hot is 0.7”. The lower word Hot names the set; 32 is the input; 0.7 is the output.

The same temperature can have membership 0.3 in Medium and 0.7 in Hot. These are two descriptions of one input. Fuzzy memberships do not generally have to sum to 1. By contrast, probabilities of mutually exclusive, exhaustive outcomes do.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Universe U | All input values being considered | Temperatures from 0 to 40°C |
| Crisp value | One definite measured number | 32°C |
| Linguistic term | A word naming a fuzzy category | Low, Medium, High |
| μA(x) | Degree to which input x fits category A | μHot(32)=0.7 |

**Yaad rakho:** 32 temperature hai; 0.7 us temperature ka Hot label mein degree hai. Dono ko mix mat karo.

## Why “true or false” is sometimes too rigid

Suppose a controller says a room is hot only when its temperature is at least 30°C. At 29.9°C it says “not hot”; at 30°C it says “hot”. That sharp boundary is a **crisp** rule. Fuzzy logic allows a gradual degree of belonging to the category “Hot”.

**Definition.** A fuzzy set A on a universe U assigns every element x a membership degree μA(x) between 0 and 1. The symbol μ is the Greek letter “mu”; read μA(x) as “the degree to which x belongs to set A”.



$$
\mu_A:U\rightarrow[0,1]
$$



| Term | Meaning | Temperature example |
| --- | --- | --- |
| Universe U | All allowed input values | Temperatures from 0°C to 40°C |
| Element x | The particular input being considered | 32°C |
| Fuzzy set A | A category described by a membership function | Hot |
| Membership μA(x) | How strongly x fits that category | μHot(32) = 0.7 |

## Read membership correctly

Membership 0 means no belonging; 1 means full belonging; 0.7 means partial belonging under the chosen definition. **It does not mean a 70% chance that the measured temperature is 32°C.** Nor is it a 70% chance that the sensor is correct. Fuzziness concerns the gradual meaning of “Hot”; probability concerns uncertainty about which event occurs.

| Input | Warm membership | Hot membership | Interpretation |
| --- | --- | --- | --- |
| 28 | 0.8 | 0.1 | Fits Warm strongly and Hot weakly |
| 32 | 0.3 | 0.7 | Fits Hot more than Warm |
| 35 | 0 | 1 | Fully Hot in this chosen model |

These memberships need not add to 1. Overlapping categories are allowed. A crisp set is the special case in which membership can only be 0 or 1. A crisp set can also contain infinitely many elements; “crisp” does not mean “finite”.

**On U = {20, 25, 30, 35}, the Hot memberships are [0, 0.2, 0.6, 1]. Write the fuzzy set Hot and identify the fully and partly belonging inputs.** [2 marks · Practice]

#### Given

Ordered inputs [20, 25, 30, 35]; memberships [0, 0.2, 0.6, 1].

#### To find

The set notation and interpretation.

#### Formula and why it applies

In the common fuzzy-set notation μ/x, the slash separates membership from element; it is not division.

#### Solution

##### Step 1. Pair each input with its membership

| x | μHot(x) |
| --- | --- |
| 20 | 0 |
| 25 | 0.2 |
| 30 | 0.6 |
| 35 | 1 |

##### Step 2. Write the set



$$
Hot=\{0/20,\;0.2/25,\;0.6/30,\;1/35\}
$$



##### Step 3. Interpret

35 fully belongs; 25 and 30 partly belong; 20 does not belong.

**Final answer.** Hot = {0/20, 0.2/25, 0.6/30, 1/35}.

**Distinguish crisp and fuzzy sets.** [2 marks · Practice]

#### Answer

| Crisp set | Fuzzy set |
| --- | --- |
| Membership is 0 or 1 | Membership is any value in [0,1] |
| A sharp boundary separates members | A membership function permits gradual boundaries |
| Example: temperature ≥ 30°C | Example: degree of being Hot increases gradually |

**Yaad rakho:** μ ka matlab: is category mein kitna fit hota hai. Chance nahi.

---

## TEE · Triangular membership: choose the side, then calculate

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--triangle/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/triangle

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Why the triangle has two different fractions

Tri(2,5,8) means membership starts at zero at x=2, rises to 1 at x=5, then falls to zero at x=8. The first three numbers are **input positions**, not three membership degrees.

| Where is x? | Meaning | Calculation |
| --- | --- | --- |
| x≤2 or x≥8 | Outside, or at a zero-height endpoint | 0 |
| 2<x<5 | Part-way up the rising edge | (x−2)/(5−2) |
| x=5 | At the peak | 1 |
| 5<x<8 | Part-way down the falling edge | (8−x)/(8−5) |

For x=3: distance travelled is 3−2=1; total rising width is 5−2=3; the height is 1÷3. For x=7: distance still remaining is 8−7=1; total falling width is 8−5=3; again the height is 1÷3. Use the branch containing the input before doing any division.

**Yaad rakho:** a = start, b = peak, c = end. x kahan pada hai, wahi fraction decide karega.

## A graph is a rule for assigning membership

The horizontal axis gives the input x. The vertical axis gives membership μ. To read μ at an input, go vertically up from that x to the line, then horizontally to the membership axis.

A triangle has three parameters: **a** is the left zero, **b** is the peak with membership 1, and **c** is the right zero. We assume a < b < c.

Swipe across the diagram to read its labels ↔

![Rising side: use distance from the left end. Falling side: use distance from the right end.](https://deep-learning-study-room.vercel.app/is2/fig/v2_triangle.4eb0b27c9d.svg)

Diagram: Rising side: use distance from the left end. Falling side: use distance from the right end.. Labels: Triangle: left end 2, peak 5, right end 8 | 0 | 0.5 | 1 | 0 | 2 | 3 | 5 | 7 | 8 | 10 | μ | Input x | A | x = 3 | x = 7

Rising side: use distance from the left end. Falling side: use distance from the right end.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



## Why the two fractions have these forms

On the rising side, x − a is how far you have climbed across the horizontal base; b − a is the full rising width. Their ratio goes from 0 to 1. On the falling side, c − x is the remaining horizontal distance to the right zero; c − b is the full falling width. That ratio goes from 1 to 0.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 3.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 3.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

2 < 3 ≤ 5, so membership increases as x moves toward the peak.

##### Step 2. Choose the correct expression

Rising side



$$
\mu_A(3)=\frac{3-2}{5-2}=\frac{1}{3}=0.333333333
$$



##### Step 3. Interpret the value

The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.

**Final answer.** μA(3) = 0.333333333.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 7.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 7.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

5 < 7 < 8, so membership decreases as x moves away from the peak.

##### Step 2. Choose the correct expression

Falling side



$$
\mu_A(7)=\frac{8-7}{8-5}=\frac{1}{3}=0.333333333
$$



##### Step 3. Interpret the value

The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.

**Final answer.** μA(7) = 0.333333333.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 5.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 5.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

2 < 5 ≤ 5, so membership increases as x moves toward the peak.

##### Step 2. Choose the correct expression

Rising side



$$
\mu_A(5)=\frac{5-2}{5-2}=\frac{3}{3}=1
$$



##### Step 3. Interpret the value

The degree of belonging to A is 1. This is full membership at the peak.

**Final answer.** μA(5) = 1.

**A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 9.** [2 marks · Practice]

#### Given

Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 9.

#### To find

The membership degree μA(x), a number from 0 to 1.

#### Formula and why it applies

Locate x relative to a, b, c before choosing the branch.



$$
\mu_A(x)=\begin{cases}0,&x\le a\text{ or }x\ge c\\\dfrac{x-a}{b-a},&a<x\le b\\\dfrac{c-x}{c-b},&b<x<c\end{cases}
$$



#### Solution

##### Step 1. Locate the input

9 is outside the open support (2, 8) or at an endpoint.

##### Step 2. Choose the correct expression

Outside the triangle



$$
\mu_A(9)=0
$$



##### Step 3. Interpret the value

The degree of belonging to A is 0. It is a membership degree, not a probability.

**Final answer.** μA(9) = 0.

**Yaad rakho:** Peak se left: x − a. Peak se right: c − x. Neeche usi side ki poori width.

---

## TEE · Trapezoids, shoulders and intuition-based fuzzification

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--trapezoid-intuition/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/trapezoid-intuition

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## The middle is a flat top, not another slope

Trap(a,b,c,d) has four input positions: start rising at a, reach height 1 at b, stay at height 1 until c, and fall to zero at d. For Trap(0,2,6,8), any input between 2 and 6 has full membership. The rising width is 2−0=2; the falling width is 8−6=2.

| Input | Locate it | Numerator | Denominator | Membership |
| --- | --- | --- | --- | --- |
| 1 | Rising: 0<1<2 | 1−0=1 | 2−0=2 | 1/2=0.5 |
| 4 | Flat top: 2≤4≤6 | No division | No division | 1 |
| 7 | Falling: 6<7<8 | 8−7=1 | 8−6=2 | 1/2=0.5 |
| 9 | Beyond right endpoint | No division | No division | 0 |

A **left shoulder** can stay at height 1 for all sufficiently small inputs, then fall. A right shoulder does the reverse. If a diagram uses a vertical edge, read its stated endpoint convention; do not divide by a zero-width edge.

## Trapezoidal membership

A trapezoid has four parameters a < b ≤ c < d: rise from a to b, stay at 1 between b and c, then fall from c to d. The flat top means a whole interval fully belongs.

Swipe across the diagram to read its labels ↔

![From 20 to 30, the membership is exactly 1.](https://deep-learning-study-room.vercel.app/is2/fig/v2_trapezoid.dbfff598ea.svg)

Diagram: From 20 to 30, the membership is exactly 1.. Labels: A trapezoid has a fully belonging interval | 0 | 0.5 | 1 | 0 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 50 | μ | Input x | Comfortable

From 20 to 30, the membership is exactly 1.



$$
\mu(x)=\begin{cases}0,&x\le a\text{ or }x\ge d\\(x-a)/(b-a),&a<x<b\\1,&b\le x\le c\\(d-x)/(d-c),&c<x<d\end{cases}
$$



**For Trap(10,20,30,40), calculate μ(15).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=15.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 15 lies on the rising side.

##### Step 2. Apply that branch



$$
\mu(15)=(15-10)/(20-10)=5/10=0.5
$$



**Final answer.** μ(15) = 0.5.

**For Trap(10,20,30,40), calculate μ(25).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=25.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 25 lies on the flat top.

##### Step 2. Apply that branch



$$
\mu(25)=1
$$



**Final answer.** μ(25) = 1.

**For Trap(10,20,30,40), calculate μ(35).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=35.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 35 lies on the falling side.

##### Step 2. Apply that branch



$$
\mu(35)=(40-35)/(40-30)=5/10=0.5
$$



**Final answer.** μ(35) = 0.5.

**For Trap(10,20,30,40), calculate μ(45).** [2 marks · Practice]

#### Given

a=10, b=20, c=30, d=40; x=45.

#### To find

Membership at the input.

#### Formula and why it applies

Choose the piece of the trapezoid containing x. A plateau needs no division.

#### Solution

##### Step 1. Locate the input

x = 45 lies on the outside support.

##### Step 2. Apply that branch



$$
\mu(45)=0
$$



**Final answer.** μ(45) = 0.

## Other membership shapes

A left shoulder remains fully true at the low end; a right shoulder remains fully true at the high end. A Gaussian has a smooth rounded peak. In a numerical, use the supplied graph or expression: do not invent breakpoints from a label such as “High”.

## Fuzzification by the intuition method

**Fuzzification** converts a measured crisp input into its membership degrees. In the **intuition method**, a domain expert defines useful linguistic categories and membership functions from experience. For example, the designer chooses the Warm triangle (15,25,35); after that choice, μWarm(32) = (35−32)/(35−25) = 0.3 is a calculation, not another guess.

1. Specify the variable and its allowed range.
2. Choose linguistic labels such as Low, Medium and High.
3. Specify each shape and every breakpoint.
4. Evaluate the functions at the actual input.
5. Validate the controller on representative inputs and adjust the design if needed.

**Yaad rakho:** Shape banana design choice; shape milne ke baad membership calculate karni hai.

---

## TEE · Union, intersection, complement and difference

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--set-operations/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/set-operations

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Work on one element before working on a whole set

If A assigns element u₁ a degree 0.7 and B assigns the same element degree 0.4, every operation compares these two degrees. Do not compare u₁ from A with u₂ from B. ∪ means union (“A OR B”); ∩ means intersection (“A AND B”); superscript c means complement (“NOT”).

**At one element u, μA(u)=0.7 and μB(u)=0.4. Find union, intersection, complement of B and A\B.** [2 marks · Worked example]

#### Given

At the same element u, A assigns membership 0.7 and B assigns membership 0.4.

#### To find

The membership at u in A∪B, A∩B, Bᶜ and A minus B.

#### Formula and why it applies

Use max for OR, min for AND, and 1 minus membership for NOT. Difference is A AND NOT B.

#### Solution

##### Step 1. Union: choose the larger



$$
\max(0.7,0.4)=0.7
$$



##### Step 2. Intersection: choose the smaller



$$
\min(0.7,0.4)=0.4
$$



##### Step 3. Complement B first



$$
1-0.4=0.6
$$



##### Step 4. Intersect A with complement B



$$
\min(0.7,0.6)=0.6
$$



**Final answer.** Union 0.7; intersection 0.4; Bᶜ 0.6; A\B 0.6. Ordinary subtraction 0.7−0.4=0.3 would be the wrong difference operation.

## The four operations used in Q1

Use the **standard max–min convention** unless the question specifies another t-norm or t-conorm. “T-norm” simply names a fuzzy AND operator; here it is min. “T-conorm” names a fuzzy OR operator; here it is max.

| Operation | Meaning | Rule |
| --- | --- | --- |
| Union A ∪ B | A OR B | Take the larger membership |
| Intersection A ∩ B | A AND B | Take the smaller membership |
| Complement Aᶜ | NOT A | 1 − membership of A |
| Difference A ∖ B | A AND NOT B | min(μA, 1 − μB) |

**On U = {u1, u2, u3}, A has memberships [0.2, 0.8, 0.6] and B has memberships [0.7, 0.3, 0.5]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [3 marks · Practice]

#### Given

| Element | u1 | u2 | u3 |
| --- | --- | --- | --- |
| A | 0.2 | 0.8 | 0.6 |
| B | 0.7 | 0.3 | 0.5 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-0.7=0.3
$$





$$
\mu_{A\setminus B}(u_1)=\min(0.2,0.3)=0.2
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0.2 | 0.7 | max(0.2, 0.7) = 0.7 | min(0.2, 0.7) = 0.2 | 1 − 0.7 = 0.3 | min(0.2, 0.3) = 0.2 |
| u2 | 0.8 | 0.3 | max(0.8, 0.3) = 0.8 | min(0.8, 0.3) = 0.3 | 1 − 0.3 = 0.7 | min(0.8, 0.7) = 0.7 |
| u3 | 0.6 | 0.5 | max(0.6, 0.5) = 0.6 | min(0.6, 0.5) = 0.5 | 1 − 0.5 = 0.5 | min(0.6, 0.5) = 0.5 |

**Final answer.** A ∪ B = [0.7, 0.8, 0.6]; A ∩ B = [0.2, 0.3, 0.5]; Bᶜ = [0.3, 0.7, 0.5]; A ∖ B = [0.2, 0.7, 0.5].

**On U = {u1, u2, u3}, A has memberships [0, 1, 0.4] and B has memberships [1, 0, 0.4]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [3 marks · Practice]

#### Given

| Element | u1 | u2 | u3 |
| --- | --- | --- | --- |
| A | 0 | 1 | 0.4 |
| B | 1 | 0 | 0.4 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-1=0
$$





$$
\mu_{A\setminus B}(u_1)=\min(0,0)=0
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0 | 1 | max(0, 1) = 1 | min(0, 1) = 0 | 1 − 1 = 0 | min(0, 0) = 0 |
| u2 | 1 | 0 | max(1, 0) = 1 | min(1, 0) = 0 | 1 − 0 = 1 | min(1, 1) = 1 |
| u3 | 0.4 | 0.4 | max(0.4, 0.4) = 0.4 | min(0.4, 0.4) = 0.4 | 1 − 0.4 = 0.6 | min(0.4, 0.6) = 0.4 |

**Final answer.** A ∪ B = [1.0, 1.0, 0.4]; A ∩ B = [0.0, 0.0, 0.4]; Bᶜ = [0.0, 1.0, 0.6]; A ∖ B = [0.0, 1.0, 0.4].

**On U = {u1, u2, u3, u4}, A has memberships [0.9, 0.2, 0.5, 0.7] and B has memberships [0.6, 0.8, 0.1, 0.7]. Find A ∪ B, A ∩ B, Bᶜ and A ∖ B using standard max–min fuzzy operations.** [3 marks · Practice]

#### Given

| Element | u1 | u2 | u3 | u4 |
| --- | --- | --- | --- | --- |
| A | 0.9 | 0.2 | 0.5 | 0.7 |
| B | 0.6 | 0.8 | 0.1 | 0.7 |

#### To find

Four membership lists in exactly the same element order.

#### Formula and why it applies

Union is OR → max. Intersection is AND → min. Complement is NOT → 1 minus membership. Difference A ∖ B means A AND NOT B, so first complement B, then intersect with A.



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\qquad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$





$$
\mu_{B^c}=1-\mu_B\qquad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



#### Solution

##### Step 1. Align the same element

All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.

##### Step 2. Calculate one element completely



$$
\mu_{B^c}(u_1)=1-0.6=0.4
$$





$$
\mu_{A\setminus B}(u_1)=\min(0.9,0.4)=0.4
$$



##### Step 3. Repeat for each element

| Element | A | B | Union | Intersection | Bᶜ | A ∖ B |
| --- | --- | --- | --- | --- | --- | --- |
| u1 | 0.9 | 0.6 | max(0.9, 0.6) = 0.9 | min(0.9, 0.6) = 0.6 | 1 − 0.6 = 0.4 | min(0.9, 0.4) = 0.4 |
| u2 | 0.2 | 0.8 | max(0.2, 0.8) = 0.8 | min(0.2, 0.8) = 0.2 | 1 − 0.8 = 0.2 | min(0.2, 0.2) = 0.2 |
| u3 | 0.5 | 0.1 | max(0.5, 0.1) = 0.5 | min(0.5, 0.1) = 0.1 | 1 − 0.1 = 0.9 | min(0.5, 0.9) = 0.5 |
| u4 | 0.7 | 0.7 | max(0.7, 0.7) = 0.7 | min(0.7, 0.7) = 0.7 | 1 − 0.7 = 0.3 | min(0.7, 0.3) = 0.3 |

**Final answer.** A ∪ B = [0.9, 0.8, 0.5, 0.7]; A ∩ B = [0.6, 0.2, 0.1, 0.7]; Bᶜ = [0.4, 0.2, 0.9, 0.3]; A ∖ B = [0.4, 0.2, 0.5, 0.3].

**Why not subtract A − B?** With A=0.2 and B=0.7, raw subtraction gives −0.5, which is not a membership degree. Under this convention, A ∖ B = min(0.2, 0.3) = 0.2. Some alternative fuzzy algebras define other difference operators; always identify the specified convention.

**Yaad rakho:** Union bada; intersection chhota; complement 1 se ghata; difference = pehle B ka complement, phir min.

---

## TEE · Fuzzy properties, De Morgan laws and α-cuts

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--properties/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/properties

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Translate the property names

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Commutative | Changing order changes nothing | max(0.3,0.8)=max(0.8,0.3)=0.8 |
| Associative | Regroup the same operation | max(max(0.2,0.7),0.4)=max(0.2,max(0.7,0.4))=0.7 |
| Idempotent | Combining a membership with itself keeps it | min(0.6,0.6)=0.6 |
| Involution | Complement twice returns the original | 1−(1−0.4)=1−0.6=0.4 |
| De Morgan | NOT swaps AND and OR while complementing each operand | 1−max(a,b)=min(1−a,1−b) |

## Properties that remain valid

| Property | Statement for max–min operations |
| --- | --- |
| Commutative | A ∪ B = B ∪ A; A ∩ B = B ∩ A |
| Associative | (A ∪ B) ∪ C = A ∪ (B ∪ C); likewise for intersection |
| Idempotent | A ∪ A = A; A ∩ A = A |
| Distributive | A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C); and its dual |
| Involution | (Aᶜ)ᶜ = A |
| De Morgan | (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ; (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ |

## Two crisp identities do not generally hold

For fuzzy sets, A ∪ Aᶜ need not equal the entire universe at membership 1; A ∩ Aᶜ need not be the empty set at membership 0.

**At an element x, μA(x)=0.4. Calculate μ(A ∪ Aᶜ) and μ(A ∩ Aᶜ).** [2 marks · Practice]

#### Given

μA(x)=0.4; standard complement/max/min.

#### To find

Whether excluded middle and non-contradiction hold at this element.

#### Formula and why it applies

Complement first, then use max or min.

#### Solution

##### Step 1. Complement



$$
\mu_{A^c}(x)=1-0.4=0.6
$$



##### Step 2. Union



$$
\max(0.4,0.6)=0.6\ne1
$$



##### Step 3. Intersection



$$
\min(0.4,0.6)=0.4\ne0
$$



**Final answer.** The union is 0.6 and the intersection is 0.4; the crisp identities fail here.

**Verify the first De Morgan law for μA=0.3 and μB=0.8.** [2 marks · Practice]

#### Given

A=0.3, B=0.8 at the same element.

#### To find

Both sides of (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ.

#### Formula and why it applies

Evaluate the operations independently on each side.

#### Solution

##### Step 1. Left side



$$
1-\max(0.3,0.8)=1-0.8=0.2
$$



##### Step 2. Right side



$$
\min(1-0.3,1-0.8)=\min(0.7,0.2)=0.2
$$



**Final answer.** Both sides equal 0.2.

**For U={a,b,c,d} and memberships A=[0,0.3,1,0.7], find support, core, boundary, height and the 0.7-cut.** [2 marks · Worked example]

#### Given

Universe U={a,b,c,d}. Memberships: A(a)=0, A(b)=0.3, A(c)=1, A(d)=0.7. Cut level α=0.7.

#### To find

The support, core, boundary and 0.7-cut as sets of elements, and the height as one membership value.

#### Formula and why it applies

Support: degree>0; core: degree=1; boundary: 0<degree<1; height: largest degree; α-cut: degree≥α.

#### Solution

##### Step 1. Inspect each element

| Element | Degree | Positive? | Exactly 1? | At least 0.7? |
| --- | --- | --- | --- | --- |
| a | 0 | No | No | No |
| b | 0.3 | Yes | No | No |
| c | 1 | Yes | Yes | Yes |
| d | 0.7 | Yes | No | Yes |

##### Step 2. Collect the requested elements

Support={b,c,d}. Core={c}. Boundary={b,d}. The 0.7-cut={c,d}.

##### Step 3. Read the height

The maximum degree is 1, so the height is 1 and the set is normal.

**Final answer.** Support {b,c,d}; core {c}; boundary {b,d}; height 1; 0.7-cut {c,d}.

**Find the 0.5-cut of the triangular fuzzy set Tri(2,5,8).** [2 marks · Worked example]

#### Given

Triangle start a=2, peak b=5, end c=8; cut level α=0.5. Retain all inputs whose membership is at least 0.5.

#### To find

Left and right endpoints of the retained interval.

#### Formula and why it applies

The triangle rises past 0.5, remains above it, then falls through 0.5. Solve height=0.5 on both slopes.

#### Solution

##### Step 1. Left slope: multiply both sides by 3



$$
(x-2)/3=0.5
$$





$$
x-2=0.5\times3=1.5
$$



##### Step 2. Isolate the left input



$$
x=1.5+2=3.5
$$



##### Step 3. Right slope: multiply both sides by 3



$$
(8-x)/3=0.5
$$





$$
8-x=1.5
$$



##### Step 4. Isolate the right input



$$
x=8-1.5=6.5
$$



##### Step 5. Include all inputs between them

The graph is at or above 0.5 for 3.5≤x≤6.5. Include the endpoints because the condition is ≥.

**Final answer.** The 0.5-cut is [3.5,6.5].

## Describing a fuzzy set

**Support:** inputs with μ > 0. **Core:** inputs with μ = 1. **Boundary:** inputs with 0 < μ < 1. **Height:** largest membership (more generally the supremum). A set is normal when its height is 1; it is subnormal when its height is below 1. A crossover point has membership 0.5. An α-cut contains inputs with μ ≥ α.

For Tri(2,5,8), support is (2,8), core is {5}, height is 1, and the 0.5-cut is [3.5,6.5]. Solve (x−2)/3=0.5 → x=3.5 and (8−x)/3=0.5 → x=6.5.

A one-dimensional fuzzy set is **convex** if every α-cut is an interval (or empty). The membership between two inputs must not dip below the smaller endpoint membership. A single triangle is convex; two separated peaks with a lower valley may not be.

**Yaad rakho:** Fuzzy A aur NOT A dono partial ho sakte hain. Isliye crisp waali 1 aur 0 identities blindly nahi lagani.

---

## TEE · Mamdani architecture: what every block does

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--mamdani-architecture/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/mamdani-architecture

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Follow one measurement through the controller

A **controller** turns measurements into an action setting. Consider temperature 32°C and occupancy 7 people. The input numbers first become membership degrees. The rules then combine those degrees. Only the final defuzzification returns one fan-speed number.

| Stage | What goes in | Operation | What comes out |
| --- | --- | --- | --- |
| Fuzzifier | 32°C and 7 people | Use the supplied membership graphs | Temperature Medium=.3, High=.7; occupancy High=.5 |
| Knowledge base | Chosen labels and their shapes | Store graphs and IF–THEN rules | A reusable definition of how the controller works |
| Inference | Medium=.3 AND High=.5 | Rule strength=min(.3,.5)=.3 | “Fan High” fires at .3 |
| Aggregation | All clipped output sets | Take the largest output degree at each speed | One combined fuzzy output shape |
| Defuzzifier | Combined shape | Apply the specified MoM, centroid or representative method | One numerical speed |

The **antecedent** is the IF part (“temperature is Medium AND occupancy is High”). The **consequent** is the THEN part (“fan speed is High”). A rule strength of 0.3 is a membership height; it does not mean the fan runs at 30%.

## Definition: a fuzzy inference system

A **fuzzy inference system (FIS)** maps inputs to an output by evaluating fuzzy IF–THEN rules. A **Mamdani FIS** uses fuzzy sets in the rule consequents, combines their inferred output sets, and defuzzifies the result.

Crisp inputs32°C; 7 people

→

Fuzzificationdegrees of Warm/Hot etc.

→

Rules + inferencerule strengths and clipped outputs

→

Aggregationone combined output shape

→

Defuzzificationone fan-speed number

## Architecture: what each block contributes

| Block | What it stores or calculates | Concrete meaning |
| --- | --- | --- |
| Fuzzifier | Membership values of the measured inputs | 32°C may be Medium to degree 0.3 and High to degree 0.7 |
| Knowledge base: database | Ranges and membership functions | Medium = Tri(15,25,35) |
| Knowledge base: rule base | IF–THEN rules | IF temperature High AND occupancy High THEN fan Very High |
| Inference engine | Combines conditions and applies consequents | min for AND; clips the output triangle at the rule strength |
| Aggregator | Combines all rule outputs | At every output location, take the maximum clipped membership |
| Defuzzifier | Converts the aggregate to one crisp value | Use centroid or mean of maxima, as requested |

## Parts of an IF–THEN rule

In “IF temperature is High AND occupancy is High THEN fan speed is Very High”, the IF part is the **antecedent** (condition), and the THEN part is the **consequent** (output category). The input variable temperature, the label High, and the numerical membership μHigh(32) are different things.

## Why a rule strength is not yet the fan speed

A strength such as 0.3 says how strongly a rule fires. It is on the membership scale 0–1. Fan speed might be on a 0–100% scale. Defuzzification is the step that produces a number on that output scale.

**Explain the architecture of a Mamdani fuzzy inference system.** [3 marks · Practice]

#### Answer

A Mamdani FIS contains a fuzzifier, knowledge base, inference engine and defuzzifier. The database specifies membership functions and the rule base stores IF–THEN rules. Crisp inputs are fuzzified. The inference engine calculates rule firing strengths and constructs output fuzzy sets. These sets are aggregated, then defuzzified into a crisp action. For a fan controller, temperature and occupancy are inputs and fan speed is the output.

**Yaad rakho:** Input ka degree → rule ka strength → output ka shape → final number.

---

## TEE · Rule firing, clipping and aggregation: four solved cases

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--rules-clipping/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/rules-clipping

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Clipping means limiting a height

A rule firing at strength 0.3 cannot give its consequent a membership above 0.3. At every candidate speed z, keep the smaller of 0.3 and the original output-set membership. The speed axis is unchanged.

**At speeds 40, 60 and 80, output set A has memberships [0.1,0.8,0.2] and set B has [0,0.4,1]. Rule A fires at 0.3 and rule B at 0.5. Clip and max-aggregate the sets.** [2 marks · Worked example]

#### Given

| Speed | Original A membership | Original B membership |
| --- | --- | --- |
| 40 | 0.1 | 0 |
| 60 | 0.8 | 0.4 |
| 80 | 0.2 | 1 |

Rule A strength=0.3; rule B strength=0.5. Compare memberships at the same speed.

#### To find

The combined membership at each speed.

#### Formula and why it applies



$$
\mu_{out}(z)=\max(\min(0.3,\mu_A(z)),\min(0.5,\mu_B(z)))
$$



Inner min limits a rule’s height; outer max keeps the stronger support at that speed.

#### Solution

##### Step 1. Clip A

At 40: min(.3,.1)=.1. At 60: min(.3,.8)=.3. At 80: min(.3,.2)=.2.

##### Step 2. Clip B

At 40: min(.5,0)=0. At 60: min(.5,.4)=.4. At 80: min(.5,1)=.5.

##### Step 3. Aggregate at each speed

| Speed | Clipped A | Clipped B | max(A,B) |
| --- | --- | --- | --- |
| 40 | 0.1 | 0 | 0.1 |
| 60 | 0.3 | 0.4 | 0.4 |
| 80 | 0.2 | 0.5 | 0.5 |

**Final answer.** Combined degrees [0.1,0.4,0.5] at speeds [40,60,80]. A separate defuzzification step is still required.

**Yaad rakho:** Clip = height ki ceiling. Aggregate = har same x par sabse upar wala height.

## Four different calculations happen in inference

**AND/OR** combine conditions within a rule. **Implication** uses the resulting strength to modify that rule’s output membership function. **Aggregation** merges different rule outputs. Here we use min-AND, max-OR, min-implication and max-aggregation.



$$
\alpha_{AND}=\min(a,b)\qquad\alpha_{OR}=\max(a,b)
$$





$$
\mu_{\mathrm{rule}}(z)=\min(\alpha,\mu_{\mathrm{consequent}}(z))
$$





$$
\mu_{\mathrm{aggregate}}(z)=\max_r\mu_{\mathrm{rule}\ r}(z)
$$



α (“alpha”) is the rule firing strength. z names a possible output value. The subscript r labels a rule, not a multiplication.

**A rule has two condition degrees 0.7 and 0.5, joined by AND. Find its firing strength.** [2 marks · Practice]

#### Given

a=0.7; b=0.5; connective=AND.

#### To find

The strength α.

#### Formula and why it applies

Use the smaller degree because both conditions must hold.

#### Solution

##### Step 1. Select the operator



$$
\alpha=\min(0.7,0.5)
$$



##### Step 2. Evaluate



$$
\alpha=0.5
$$



**Final answer.** 0.5.

**A rule has two condition degrees 0.3 and 0, joined by AND. Find its firing strength.** [2 marks · Practice]

#### Given

a=0.3; b=0; connective=AND.

#### To find

The strength α.

#### Formula and why it applies

Use the smaller degree because both conditions must hold.

#### Solution

##### Step 1. Select the operator



$$
\alpha=\min(0.3,0)
$$



##### Step 2. Evaluate



$$
\alpha=0
$$



**Final answer.** 0.

**A rule has two condition degrees 0.2 and 0.8, joined by OR. Find its firing strength.** [2 marks · Practice]

#### Given

a=0.2; b=0.8; connective=OR.

#### To find

The strength α.

#### Formula and why it applies

Use the larger degree because either condition is sufficient.

#### Solution

##### Step 1. Select the operator



$$
\alpha=\max(0.2,0.8)
$$



##### Step 2. Evaluate



$$
\alpha=0.8
$$



**Final answer.** 0.8.

**Rule 1 fires at 0.3 and its original output membership at z=60 is 0.8. Rule 2 fires at 0.6 and its original membership at z=60 is 0.2. Find the aggregate membership at z=60 using min-implication and max-aggregation.** [3 marks · Practice]

#### Given

Rule 1: α₁=0.3, μ₁(60)=0.8. Rule 2: α₂=0.6, μ₂(60)=0.2.

#### To find

Membership at the single output location z=60 after implication and aggregation.

#### Formula and why it applies

Clip each original degree at its rule strength; then take the larger clipped degree.

#### Solution

##### Step 1. Clip rule 1



$$
\mu_{R1}(60)=\min(0.3,0.8)=0.3
$$



##### Step 2. Clip rule 2



$$
\mu_{R2}(60)=\min(0.6,0.2)=0.2
$$



##### Step 3. Aggregate at this output location



$$
\mu_{out}(60)=\max(0.3,0.2)=0.3
$$



**Final answer.** The aggregate membership at z=60 is 0.3. This is not a crisp fan-speed answer.

Swipe across the diagram to read its labels ↔

![Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.](https://deep-learning-study-room.vercel.app/is2/fig/v2_clip.f101b5cfa9.svg)

Diagram: Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.. Labels: Min-implication clips the triangle at strength 0.3 | 0 | 0.3 | 1 | 50 | 54.5 | 65 | 75.5 | 80 | μ | Output z | Original High | clip 0.3

Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.

**Yaad rakho:** AND ke liye min; output clip karne ke liye bhi min; rules ko jodne ke liye max. Har min ka role alag hai.

---

## TEE · Mean of maxima: discrete peaks and clipped plateaus

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--mom/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/mom

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

**Maximum membership** is a height. **Mean of maxima** averages the horizontal locations attaining that height. If heights at speeds [20,50,80] are [.2,.6,.6], the maximum height is .6 and the qualifying speeds are 50 and 80; MoM=(50+80)/2=65. Do not average [.6,.6], which would return a degree rather than a speed. A continuous flat maximum from 50 to 80 also has midpoint 65.

## Mean of maxima (MoM)

**Defuzzification** converts the aggregate membership function into one crisp output. For MoM, first find the largest membership height, then average the output locations attaining that height. Do not average the membership values themselves.



$$
z^*_{MoM}=\frac{z_1+\cdots+z_m}{m}
$$



For a continuous flat maximum from a to b, the mean is its midpoint:



$$
z^*_{MoM}=\frac{a+b}{2}
$$



**For the following discrete aggregate, find the mean-of-maxima output.** [2 marks · Practice]

#### Given

| Output z | Membership μ |
| --- | --- |
| 10 | 0.2 |
| 20 | 0.8 |
| 30 | 0.8 |
| 40 | 0.3 |

#### To find

MoM crisp output.

#### Formula and why it applies

Find all locations at the largest height, then average only those locations.

#### Solution

##### Step 1. Find the maximum height



$$
\mu_{max}=0.8
$$



##### Step 2. List the locations attaining it

20, 30

##### Step 3. Average these locations



$$
z^*=\frac{20+30}{2}=25
$$



**Final answer.** 25.

**For the following discrete aggregate, find the mean-of-maxima output.** [2 marks · Practice]

#### Given

| Output z | Membership μ |
| --- | --- |
| 1 | 0.1 |
| 2 | 0.4 |
| 3 | 0.9 |
| 4 | 0.2 |

#### To find

MoM crisp output.

#### Formula and why it applies

Find all locations at the largest height, then average only those locations.

#### Solution

##### Step 1. Find the maximum height



$$
\mu_{max}=0.9
$$



##### Step 2. List the locations attaining it

3

##### Step 3. Average these locations



$$
z^*=\frac{3}{1}=3
$$



**Final answer.** 3.

**A single triangular output Tri(50,65,80) is clipped at α=0.3. Find its crisp value by mean of maxima.** [3 marks · Practice]

#### Given

a=50, b=65, c=80; clip height α=0.3.

#### To find

Both plateau endpoints and their mean.

#### Formula and why it applies

Set the rising and falling membership fractions equal to 0.3. Every point between those intersections has the maximum height.

#### Solution

##### Step 1. Find the left endpoint



$$
\frac{z_L-50}{65-50}=0.3
$$





$$
z_L-50=0.3\times15=4.5
$$





$$
z_L=54.5
$$



##### Step 2. Find the right endpoint



$$
\frac{80-z_R}{80-65}=0.3
$$





$$
80-z_R=4.5
$$





$$
z_R=75.5
$$



##### Step 3. Average endpoints



$$
z^*=(54.5+75.5)/2=65
$$



**Final answer.** MoM = 65.

Swipe across the diagram to read its labels ↔

![The maximum extends over [54.5,75.5], whose midpoint is 65.](https://deep-learning-study-room.vercel.app/is2/fig/v2_clip.f101b5cfa9.svg)

Diagram: The maximum extends over [54.5,75.5], whose midpoint is 65.. Labels: Min-implication clips the triangle at strength 0.3 | 0 | 0.3 | 1 | 50 | 54.5 | 65 | 75.5 | 80 | μ | Output z | Original High | clip 0.3

The maximum extends over [54.5,75.5], whose midpoint is 65.

For several disjoint continuous maximum plateaus, a continuous MoM uses a length-weighted mean over all maximum intervals; simply averaging two outside endpoints is not generally valid. In tabulated questions, average the listed locations at the maximum.

**Yaad rakho:** Sabse upar ka level dekho; us level par x-values ka mean lo.

---

## TEE · Centroid: three table sums and one area calculation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--centroid/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/centroid

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

## Centroid means the balance point of the whole shape

Imagine the area under the output graph as a thin sheet of uniform material. The centroid is its horizontal balance point. More area on one side pulls the answer toward that side. In a discrete problem, each membership is a weight. In a continuous problem, the entire area supplies the weights.

The integral sign ∫ means adding very thin strips across a continuous interval. The denominator ∫μ(z)dz is the total area. The numerator ∫zμ(z)dz is the **first moment**: position multiplied by area, accumulated across the shape. Their ratio has units of the output, such as fan-speed percent.

**A non-overlapping aggregate consists of a rectangle of width 4 and height 0.5 centred at z=2, plus a triangle of base 4 and height 0.5 centred horizontally at z=6. Find the area centroid.** [2 marks · Worked example]

#### Given

Rectangle: width 4, height 0.5, horizontal centre 2. Triangle: base 4, height 0.5, horizontal centroid 6. Their areas do not overlap.

#### To find

The combined horizontal centroid.

#### Formula and why it applies



$$
z^*=\frac{A_1c_1+A_2c_2}{A_1+A_2}
$$



Each piece contributes area times its own centre. Use this only for a valid decomposition of the aggregate.

#### Solution

##### Step 1. Rectangle area



$$
A_1=4\times0.5=2
$$



##### Step 2. Triangle area



$$
A_2=\tfrac12\times4\times0.5=1
$$



##### Step 3. First moments



$$
A_1c_1=2\times2=4
$$





$$
A_2c_2=1\times6=6
$$



##### Step 4. Totals



$$
A=2+1=3\qquad M=4+6=10
$$



##### Step 5. Divide



$$
z^*=10/3\approx3.333333
$$



**Final answer.** Centroid≈3.333333, closer to the larger-area piece.

For overlapping clipped sets, first form their max-aggregate. Adding the areas of the original overlapping sets would count the overlap twice.

## Centroid: the balance point of the output

The centroid uses the whole aggregate membership distribution. For a discrete output table, multiply each output location by its membership, add the products, then divide by total membership.



$$
z^*=\frac{\sum_i z_i\mu(z_i)}{\sum_i\mu(z_i)}
$$



The index i simply numbers table entries. Σ (“sigma”) means add all listed terms. The denominator must be nonzero.

**Find the discrete centroid of the aggregate membership table.** [3 marks · Practice]

#### Given

| z | μ(z) |
| --- | --- |
| 10 | 0.2 |
| 20 | 0.6 |
| 30 | 0.4 |

#### To find

One centroid value on the output scale.

#### Formula and why it applies

This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.



$$
z^*=\frac{\sum z_i\mu_i}{\sum\mu_i}
$$



#### Solution

##### Step 1. Multiply every location by its membership

| z | μ | z × μ |
| --- | --- | --- |
| 10 | 0.2 | 2 |
| 20 | 0.6 | 12 |
| 30 | 0.4 | 12 |

##### Step 2. Add the numerator



$$
2+12+12=26
$$



##### Step 3. Add the denominator



$$
0.2+0.6+0.4=1.2
$$



##### Step 4. Divide



$$
z^*=\frac{26}{1.2}=21.666666667
$$



**Final answer.** 21.666666667.

**Find the discrete centroid of the aggregate membership table.** [3 marks · Practice]

#### Given

| z | μ(z) |
| --- | --- |
| 0 | 0.5 |
| 5 | 1 |
| 10 | 0.5 |

#### To find

One centroid value on the output scale.

#### Formula and why it applies

This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.



$$
z^*=\frac{\sum z_i\mu_i}{\sum\mu_i}
$$



#### Solution

##### Step 1. Multiply every location by its membership

| z | μ | z × μ |
| --- | --- | --- |
| 0 | 0.5 | 0 |
| 5 | 1 | 5 |
| 10 | 0.5 | 5 |

##### Step 2. Add the numerator



$$
0+5+5=10
$$



##### Step 3. Add the denominator



$$
0.5+1+0.5=2
$$



##### Step 4. Divide



$$
z^*=\frac{10}{2}=5
$$



**Final answer.** 5.

**Find the discrete centroid of the aggregate membership table.** [3 marks · Practice]

#### Given

| z | μ(z) |
| --- | --- |
| 20 | 0 |
| 40 | 0.3 |
| 60 | 0.6 |
| 80 | 0.1 |

#### To find

One centroid value on the output scale.

#### Formula and why it applies

This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.



$$
z^*=\frac{\sum z_i\mu_i}{\sum\mu_i}
$$



#### Solution

##### Step 1. Multiply every location by its membership

| z | μ | z × μ |
| --- | --- | --- |
| 20 | 0 | 0 |
| 40 | 0.3 | 12 |
| 60 | 0.6 | 36 |
| 80 | 0.1 | 8 |

##### Step 2. Add the numerator



$$
0+12+36+8=56
$$



##### Step 3. Add the denominator



$$
0+0.3+0.6+0.1=1
$$



##### Step 4. Divide



$$
z^*=\frac{56}{1}=56
$$



**Final answer.** 56.

## For a continuous shape, integrate the area



$$
z^*=\frac{\int z\mu(z)\,dz}{\int\mu(z)\,dz}
$$



The denominator is the area under the aggregate. The numerator is its first moment about zero: area weighted by horizontal location. For a shape made of non-overlapping rectangles and triangles, compute each part’s area A and its own centroid c, then use 

$$
z^*=(\sum A_jc_j)/(\sum A_j)
$$

. Overlapping regions of a max-aggregate must not be counted twice.

**An aggregate is a rectangle of height 0.5 from z=0 to z=4, followed by a right triangle decreasing from height 0.5 at z=4 to 0 at z=6. Find its area centroid.** [3 marks · Practice]

#### Given

Rectangle [0,4], height 0.5; triangle with vertices (4,0),(4,0.5),(6,0).

#### To find

Centroid of the combined area.

#### Formula and why it applies

The parts do not overlap except at their boundary. Weight each part’s horizontal centroid by its area.

#### Solution

##### Step 1. Rectangle area and centre



$$
A_1=4\times0.5=2\qquad c_1=(0+4)/2=2
$$



##### Step 2. Triangle area and centre



$$
A_2=\tfrac12\times2\times0.5=0.5
$$





$$
c_2=(4+4+6)/3=14/3
$$



##### Step 3. Add first moments



$$
A_1c_1+A_2c_2=2(2)+0.5(14/3)=19/3
$$



##### Step 4. Divide by total area



$$
z^*=(19/3)/(2+0.5)=38/15\approx2.533333
$$



**Final answer.** Centroid ≈ 2.533333. The plateau MoM would be 2, so different methods can legitimately give different results.

**Yaad rakho:** Centroid = har location × uska weight, total karke total weight se divide.

---

## TEE · Weighted average and centroid are not automatically the same

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--weighted-average/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/weighted-average

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

This is the same weighted-average calculation taught in Essential maths. Here a representative output value c is weighted by a rule strength α. Keep the pair together: strength .3 belonging to speed 65 contributes .3×65. The denominator is the total strength. It is not automatically the number of rules, and the representative is not automatically the area-centre of a clipped set.

## Weighted average of output representatives

Some classroom solutions use one representative (often the peak) per output label and weight it by the firing strength. That is a **weighted-average or height-based calculation**. It is exact for a specified weighted combination of singleton outputs, but is not generally the centroid of a max-aggregated, clipped Mamdani shape.

Always name the method. A table of memberships at actual output locations supports the discrete centroid. A list of category peaks and strengths supports the specified representative-weighted calculation. Full continuous output shapes support area centroid.

**Using the weighted-average method, combine output representatives [25, 75] mph with respective strengths [0.1, 0.7].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 25 | 0.1 |
| 75 | 0.7 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0.1 × 25 | 2.5 |
| 0.7 × 75 | 52.5 |

##### Step 2. Add the products



$$
2.5+52.5=55
$$



##### Step 3. Add the strengths



$$
0.1+0.7=0.8
$$



##### Step 4. Divide



$$
z^*=\frac{55}{0.8}=68.75
$$



**Final answer.** 68.75 mph.

**Using the weighted-average method, combine output representatives [40, 65, 85] % fan speed with respective strengths [0, 0.3, 0.5].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 40 | 0 |
| 65 | 0.3 |
| 85 | 0.5 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0 × 40 | 0 |
| 0.3 × 65 | 19.5 |
| 0.5 × 85 | 42.5 |

##### Step 2. Add the products



$$
0+19.5+42.5=62
$$



##### Step 3. Add the strengths



$$
0+0.3+0.5=0.8
$$



##### Step 4. Divide



$$
z^*=\frac{62}{0.8}=77.5
$$



**Final answer.** 77.5 % fan speed.

**Using the weighted-average method, combine output representatives [25, 40, 60] minutes with respective strengths [0.6, 0.4, 0.2].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 25 | 0.6 |
| 40 | 0.4 |
| 60 | 0.2 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0.6 × 25 | 15 |
| 0.4 × 40 | 16 |
| 0.2 × 60 | 12 |

##### Step 2. Add the products



$$
15+16+12=43
$$



##### Step 3. Add the strengths



$$
0.6+0.4+0.2=1.2
$$



##### Step 4. Divide



$$
z^*=\frac{43}{1.2}=35.833333333
$$



**Final answer.** 35.833333333 minutes.

| Method | What it uses | Limitation |
| --- | --- | --- |
| MoM | Locations at maximum membership | Ignores lower portions of the shape; can change abruptly |
| Area centroid | Entire aggregated output area | Needs an area/moment calculation or numerical integration |
| Representative weighted average | Supplied representative values and strengths | Not interchangeable with a clipped Mamdani area centroid |

No method is universally “most accurate”. The correct exam calculation is the method specified by the question. If all memberships or all weights are zero, division by zero is undefined; a controller needs an explicit fallback rule.

**Yaad rakho:** Formula similar dikhega, par weight kya hai? Membership, area, ya rule strength—pehle woh identify karo.

## Faculty slide example: one temperature input

This is a different example from the two-input fan design. With Warm=Tri(20,30,40) and Hot=Tri(30,40,50), temperature 32 gives Warm=(40−32)/10=0.8 and Hot=(32−30)/10=0.2. The slide uses output representatives 50 and 80.

**Using the weighted-average method, combine output representatives [50, 80] % fan speed with respective strengths [0.8, 0.2].** [3 marks · Practice]

#### Given

| Output representative | Strength |
| --- | --- |
| 50 | 0.8 |
| 80 | 0.2 |

#### To find

One crisp output by the specified weighted-average method.

#### Formula and why it applies

Each representative is multiplied by its strength; add these products and divide by the total strength. Here α is a strength and z is a representative value. These are not automatically the full area of a clipped Mamdani set.



$$
z^*=\frac{\sum_i\alpha_i z_i}{\sum_i\alpha_i}
$$



#### Solution

##### Step 1. Multiply each value by its strength

| Strength × value | Product |
| --- | --- |
| 0.8 × 50 | 40 |
| 0.2 × 80 | 16 |

##### Step 2. Add the products



$$
40+16=56
$$



##### Step 3. Add the strengths



$$
0.8+0.2=1
$$



##### Step 4. Divide



$$
z^*=\frac{56}{1}=56
$$



**Final answer.** 56 % fan speed.

---

## TEE · Class fan question: 32°C, 7 people, every rule and step

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--class-fan/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/class-fan

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

There are 3 temperature labels and 3 occupancy labels. Pair each temperature label with each occupancy label: 3×3=9 possible AND rules. At the specified input, any rule containing a zero input membership has strength min(0,other)=0 and contributes no output. The rules with nonzero strength remain; their output labels come from the supplied rule table, not from the magnitude of the strength.

This is the fan-controller design question shared in class: temperature 32°C and occupancy 7. The photos contain inconsistent graph breakpoints and arithmetic. A design question permits a stated design; below, every membership function is specified explicitly. These choices make the solution reproducible and should not be read as a uniquely recoverable answer from the photos.

**Design a Mamdani fan controller for temperature 0–40°C and occupancy 0–10, with three input labels each and five fan-speed labels on 0–100%. For T=32°C and occupancy=7, use the membership functions and nine rules below. Calculate all memberships, firing strengths, and active output sets. Find fan speed by (a) mean of maxima and (b) the specified representative-weighted average.** [10 marks · Class-question adaptation; full design]

#### Given

| Variable | Low / Very Low | Medium / Low | High / Medium | High output | Very High output |
| --- | --- | --- | --- | --- | --- |
| Temperature | Tri(0,10,20) | Tri(15,25,35) | Tri(25,35,40) | — | — |
| Occupancy | Tri(0,2,4) | Tri(3,5,7) | Tri(6,8,10) | — | — |
| Fan speed | Tri(0,10,20) | Tri(10,25,40) | Tri(20,40,60) | Tri(50,65,80) | Tri(70,85,100) |

Input T=32°C; occupancy=7. Use min-AND, min-clipping and max-aggregation.

| Temperature | Occupancy | Fan output |
| --- | --- | --- |
| Low | Low | Very Low |
| Low | Medium | Low |
| Low | High | Medium |
| Medium | Low | Low |
| Medium | Medium | Medium |
| Medium | High | High |
| High | Low | Medium |
| High | Medium | High |
| High | High | Very High |

#### To find

Input memberships → nine rule strengths → clipped output → two named crisp outputs.

#### Formula and why it applies

Use the appropriate triangle branch for membership. AND takes the smaller degree. Each output is clipped at that strength; rules with the same consequent combine by max. MoM uses only the highest plateau. The requested representative weighted average uses category peaks and strengths.



$$
\alpha_r=\min(\mu_{T,r},\mu_{O,r})\quad\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



#### Solution

##### Step 1. Read the temperature graph

Swipe across the diagram to read its labels ↔

![At 32, Medium is on its falling side; High is on its rising side.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fan_temp.434c9b6635.svg)

Diagram: At 32, Medium is on its falling side; High is on its rising side.. Labels: Chosen temperature membership functions | 0 | 0.5 | 1 | 0 | 10 | 15 | 20 | 25 | 32 | 35 | 40 | μ | Temperature in °C | Low | Medium | High | 32°C

At 32, Medium is on its falling side; High is on its rising side.



$$
\mu_L(32)=0
$$





$$
\mu_M(32)=\frac{35-32}{35-25}=\frac3{10}=0.3
$$





$$
\mu_H(32)=\frac{32-25}{35-25}=\frac7{10}=0.7
$$



##### Step 2. Read the occupancy graph

Swipe across the diagram to read its labels ↔

![At 7, Medium reaches its right zero and High is halfway up its rising edge.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fan_people.1861531dd1.svg)

Diagram: At 7, Medium reaches its right zero and High is halfway up its rising edge.. Labels: Chosen occupancy membership functions | 0 | 0.5 | 1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | μ | Number of people | Low | Medium | High | 7 people

At 7, Medium reaches its right zero and High is halfway up its rising edge.



$$
\mu_L(7)=0\qquad\mu_M(7)=0
$$





$$
\mu_H(7)=\frac{7-6}{8-6}=\frac12=0.5
$$



##### Step 3. Evaluate all nine rules

| T label / degree | O label / degree | min = strength | Output |
| --- | --- | --- | --- |
| Low / 0 | Low / 0 | 0 | Very Low |
| Low / 0 | Medium / 0 | 0 | Low |
| Low / 0 | High / 0.5 | 0 | Medium |
| Medium / 0.3 | Low / 0 | 0 | Low |
| Medium / 0.3 | Medium / 0 | 0 | Medium |
| Medium / 0.3 | High / 0.5 | 0.3 | High |
| High / 0.7 | Low / 0 | 0 | Medium |
| High / 0.7 | Medium / 0 | 0 | High |
| High / 0.7 | High / 0.5 | 0.5 | Very High |

##### Step 4. Clip and aggregate



$$
\mu_{out}(z)=\max\{\min(0.3,\mu_H(z)),\min(0.5,\mu_{VH}(z))\}
$$



Swipe across the diagram to read its labels ↔

![High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fan_output.8708d0ea77.svg)

Diagram: High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.. Labels: Two active output sets | 0 | 0.5 | 1 | 50 | 54.5 | 65 | 70 | 75 | 77.5 | 85 | 92.5 | 100 | μ | Fan speed (%) | High | Very High | clip 0.3 | clip 0.5

High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.

##### Step 5. Find the highest plateau for MoM

The maximum is 0.5, belonging to Very High. Its triangle is (70,85,100).



$$
\frac{z_L-70}{15}=0.5\Rightarrow z_L=77.5
$$





$$
\frac{100-z_R}{15}=0.5\Rightarrow z_R=92.5
$$





$$
z^*_{MoM}=\frac{77.5+92.5}{2}=85
$$



##### Step 6. Multiply the representatives by strengths



$$
0.3\times65=19.5
$$





$$
0.5\times85=42.5
$$



##### Step 7. Add, then divide for the weighted average



$$
z^*_{WA}=\frac{19.5+42.5}{0.3+0.5}=\frac{62}{0.8}=77.5
$$



**Final answer.** For this explicitly stated design: MoM = 85%; representative-weighted output = 77.5%. These are different methods. 77.5% is not claimed to be the true continuous Mamdani area centroid.

**How to adapt it in the exam:** if breakpoints or output representatives differ, recompute the memberships from those data. The sequence of operations stays unchanged. If the question explicitly asks for the area centroid, integrate the max-aggregated shape; do not silently substitute the weighted average above.

**Yaad rakho:** Temperature aur people ka degree nikalo → 9 min → active outputs clip → jo method poocha hai woh lagao.

## Why the Very High plateau has midpoint 85

For the stated Very High triangle (70,85,100) clipped at height 0.5, solve the rising edge: (z−70)/(85−70)=0.5, so z−70=0.5×15=7.5 and z=77.5. On the falling edge, (100−z)/(100−85)=0.5, so 100−z=7.5 and z=92.5. Thus the highest flat interval is [77.5,92.5]. Its midpoint is (77.5+92.5)/2=170/2=85.

Continue with the [complete area-centroid calculation for this same fan design](https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--centroid-comparison/): 77.086956522%, with all overlap breakpoints and area/moment arithmetic shown.

---

## TEE · The same fan controller: true area centroid versus MoM and weighted average

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--centroid-comparison/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/centroid-comparison

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

The preceding class-fan lesson makes the input shapes and nine rules explicit because the photographs do not specify one internally consistent design. Keep that exact stated design here: temperature 32°C, occupancy 7, High output Tri(50,65,80) firing at 0.3 and Very High output Tri(70,85,100) firing at 0.5. This continuation calculates the actual area centroid of their max-aggregate. It does not reinterpret 77.5 as a centroid.

**For the stated two-input class fan controller at T=32°C and occupancy=7, calculate the true continuous Mamdani area centroid of High=Tri(50,65,80) clipped at 0.3 and Very High=Tri(70,85,100) clipped at 0.5. Compare it with mean of maxima and the specified representative-weighted average.** [6 marks]

Worked teaching continuation of the class-design adaptation; the mark allocation here is for practice.

#### Given

All other output rules have strength zero. Use min for implication, max for aggregation and speed z on 0–100%. The two active rule strengths were calculated from input memberships: min(0.3,0.5)=0.3 and min(0.7,0.5)=0.5.

#### To find

Every visible segment of the aggregate, its area and first moment, the centroid, and the differences between the three crisp answers.

#### Formula and why it applies



$$
\mu_{out}(z)=\max\{\min(0.3,\mu_H(z)),\min(0.5,\mu_{VH}(z))\}
$$





$$
z^*_{COA}=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



Centroid balances all the area under the upper envelope. A straight strip with endpoints (a,u) and (b,v) has the following area A and first moment M; adding only disjoint strips counts overlap once.



$$
A=\frac{(b-a)(u+v)}2,\qquad M=\frac{b-a}{6}[(2a+b)u+(a+2b)v]
$$



#### Solution

##### Step 1. Locate the two clipped plateaus



$$
H:\quad z_L=50+0.3(65-50)=54.5,\quad z_R=80-0.3(80-65)=75.5
$$





$$
VH:\quad z_L=70+0.5(85-70)=77.5,\quad z_R=100-0.5(100-85)=92.5
$$



High has a 0.3 plateau from 54.5 to 75.5. Very High has a 0.5 plateau from 77.5 to 92.5.

##### Step 2. Find where the upper envelope changes owner

Very High rises through the High plateau at height 0.3. Solve its rising equation:



$$
(z-70)/15=0.3\quad\Rightarrow\quad z=74.5
$$



Before 74.5, clipped High supplies the upper envelope. After 74.5, Very High is above it. The descending High edge from 75.5 to 80 lies underneath and contributes no extra aggregate area.

##### Step 3. Trace the aggregate graph

Swipe across the diagram to read its labels ↔

![Fan output: trace the upper envelope before finding its centroid](https://deep-learning-study-room.vercel.app/is2/fig/deep_fan_centroid.98bf1c217d.svg)

Diagram: Fan output: trace the upper envelope before finding its centroid. Labels: Fan output: trace the upper envelope before finding its centroid | High clipped at 0.3; Very High clipped at 0.5. Hidden overlap is counted once. | 0 | 0.3 | 0.5 | 50 | 54.5 | 74.5 | 77.5 | 92.5 | 100 | Centroid ≈77.087% | Fan speed z (%) | Area = 17.25; first moment = 1329.75; centroid = moment ÷ area.

Read left to right: (50,0) → (54.5,0.3) → (74.5,0.3) → (77.5,0.5) → (92.5,0.5) → (100,0). Membership is zero outside this support. Each adjacent pair is one straight strip in the table.

##### Step 4. Work the rising first strip explicitly



$$
A_1=(54.5-50)(0+0.3)/2=0.675
$$





$$
M_1=\frac{4.5}{6}[(100+54.5)0+(50+109)0.3]=35.775
$$



The first moment has units of speed multiplied by area. Dividing total moment by total area returns speed.

##### Step 5. Calculate all disjoint strips

| a | b | u | v | Area A | First moment M |
| --- | --- | --- | --- | --- | --- |
| 50 | 54.5 | 0 | 0.3 | 0.675 | 35.775 |
| 54.5 | 74.5 | 0.3 | 0.3 | 6 | 387 |
| 74.5 | 77.5 | 0.3 | 0.5 | 1.2 | 91.35 |
| 77.5 | 92.5 | 0.5 | 0.5 | 7.5 | 637.5 |
| 92.5 | 100 | 0.5 | 0 | 1.875 | 178.125 |



$$
\sum A=0.675+6+1.2+7.5+1.875=17.25
$$





$$
\sum M=35.775+387+91.35+637.5+178.125=1329.75
$$



##### Step 6. Divide for the actual centroid



$$
z^*_{COA}=1329.75/17.25=1773/23\approx77.086956522\%
$$



##### Step 7. Compare methods on the same aggregate

| Method | Calculation | Answer |
| --- | --- | --- |
| Area centroid | 1329.75 ÷ 17.25 | 77.086956522% |
| Mean of maxima | (77.5+92.5) ÷ 2 | 85% |
| Specified representative weighted average | (0.3×65+0.5×85) ÷ (0.3+0.5) | 77.5% |

MoM uses only the highest plateau. The representative method uses two chosen peaks and two rule strengths. The area centroid uses the full max-aggregate, so these are three legitimate but different calculations.

**Final answer.** Area centroid ≈77.086956522%; MoM=85%; representative-weighted output=77.5%. Report the method with the value. The centroid is inside the support [50,100], as a balance point must be.

**Boundary coverage of this teaching design.** With the ordinary triangles stated in the class adaptation, every temperature degree is zero at T=0 or T=40, and every occupancy degree is zero at occupancy=0 or 10. Then no rule fires and an area centroid is undefined. To make a controller cover the entire declared input range, explicitly redesign outer sets as shoulders or specify an out-of-coverage rule; do not silently divide by zero. The worked T=32, occupancy=7 case has positive area and is unaffected.

**Yaad rakho:** Centroid mein poore shaded area ka balance chahiye. Peak × strength wala shortcut same calculation nahi hai.

---

## TEE · Fuzzy theory: definitions, architecture, advantages and applications

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--exam-theory/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/exam-theory

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

**Explain fuzzy logic with one application.** [2 marks · Practice]

#### Answer

Fuzzy logic represents gradual truth or category membership using values between 0 and 1. A temperature controller can use Low, Medium and High temperature sets. It evaluates rules such as IF temperature is High THEN fan speed is High, combines the rule outputs and defuzzifies them into a numerical fan speed. This permits gradual control around category boundaries.

**Give the advantages and limitations of a Mamdani fuzzy controller.** [3 marks · Practice]

#### Answer

| Advantages | Limitations |
| --- | --- |
| Human-readable rules express expert knowledge | Membership functions and rules require careful design |
| Can model gradual boundaries without an exact analytic plant model | Rule count can grow rapidly with more inputs and categories |
| Handles overlapping linguistic descriptions | A poorly chosen rule base can produce poor or uncovered outputs |
| Suitable for many control applications | Does not automatically learn or guarantee optimal control |

**Describe the design of a fuzzy fan controller.** [3 marks · Practice]

#### Answer

Choose temperature and occupancy as inputs and fan speed as output. Define their ranges and Low/Medium/High membership functions. Construct a rule table linking input labels to output labels. Fuzzify measured inputs, use min to obtain AND-rule strengths, clip the consequent sets and max-aggregate them. Apply the specified defuzzification method to obtain a fan speed. Test the design at normal inputs and range boundaries.

## Other applications you can explain

| Application | Inputs | Example rule | Output |
| --- | --- | --- | --- |
| Washing machine | Dirtiness, load | IF dirt High AND load High THEN wash time Long | Wash duration |
| Loan decision support | Income, credit score | IF income High AND credit Good THEN approval suitability High | Suitability score (not an automatic legal lending decision) |
| Fire warning | Temperature, smoke | IF temperature High OR smoke High THEN risk High | Alarm-risk score |
| Vehicle control | Distance, relative speed | IF distance Small AND closing speed High THEN braking Strong | Braking command |

**Yaad rakho:** Theory answer mein definition → blocks/steps → ek concrete example. Sirf headings se marks nahi milte.

---

## TEE · Gaussian, singleton and bell memberships

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-core--smooth-memberships/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-core/smooth-memberships

Definitions → membership graphs → operations → rules → defuzzification → complete controller.

For a Gaussian membership, c is the input at the centre and σ controls the width. Compute x−c, square it, divide by 2σ², put a minus sign in front, and apply eˣ. The maximum membership is 1 at x=c because the exponent becomes 0. Increasing σ makes the same distance from the centre count as a smaller relative distance, so the curve becomes wider. A Gaussian membership is not the same formula as a normal probability density: there is no 1/(√(2π)σ) multiplier here.

## A smooth membership function

A Gaussian membership function reaches 1 at its centre c and decreases smoothly on both sides. Its width σ must be positive. This is a fuzzy membership curve, not a normalised probability density: there is no 1/(√(2π)σ) factor.



$$
\mu(x)=\exp\left(-\frac{(x-c)^2}{2\sigma^2}\right)
$$



exp(u) means eᵘ. The calculator evaluates it using eˣ; calculate the entire negative exponent first. A squared distance treats equal left and right offsets equally.

**For Gaussian membership with c=10 and σ=2, find μ(10).** [2 marks · Practice]

#### Given

x=10; centre c=10; width σ=2.

#### To find

Membership degree.

#### Formula and why it applies

Use squared distance from the centre in the Gaussian membership formula.

#### Solution

##### Step 1. Distance from the centre



$$
10-10=0
$$



##### Step 2. Square the distance and width



$$
(0)^2=0\qquad2\sigma^2=2(2^2)=8
$$



##### Step 3. Exponent



$$
-0/8=0
$$



##### Step 4. Evaluate e to this power



$$
\mu(10)=e^{0}\approx1
$$



**Final answer.** 1.

**For Gaussian membership with c=10 and σ=2, find μ(12).** [2 marks · Practice]

#### Given

x=12; centre c=10; width σ=2.

#### To find

Membership degree.

#### Formula and why it applies

Use squared distance from the centre in the Gaussian membership formula.

#### Solution

##### Step 1. Distance from the centre



$$
12-10=2
$$



##### Step 2. Square the distance and width



$$
(2)^2=4\qquad2\sigma^2=2(2^2)=8
$$



##### Step 3. Exponent



$$
-4/8=-0.5
$$



##### Step 4. Evaluate e to this power



$$
\mu(12)=e^{-0.5}\approx0.60653066
$$



**Final answer.** 0.60653066.

**For Gaussian membership with c=10 and σ=2, find μ(14).** [2 marks · Practice]

#### Given

x=14; centre c=10; width σ=2.

#### To find

Membership degree.

#### Formula and why it applies

Use squared distance from the centre in the Gaussian membership formula.

#### Solution

##### Step 1. Distance from the centre



$$
14-10=4
$$



##### Step 2. Square the distance and width



$$
(4)^2=16\qquad2\sigma^2=2(2^2)=8
$$



##### Step 3. Exponent



$$
-16/8=-2
$$



##### Step 4. Evaluate e to this power



$$
\mu(14)=e^{-2}\approx0.135335283
$$



**Final answer.** 0.135335283.

## Singleton

A singleton fuzzy set has membership 1 at exactly one specified point and 0 elsewhere. For a singleton at c=50: μ(50)=1, μ(49)=0 and μ(51)=0. A singleton consequent is represented by one numerical output; this is why a specified weighted average of singleton outputs is a legitimate calculation.

## Generalised bell (when its formula is supplied)



$$
\mu(x)=\frac1{1+\left|\frac{x-c}{a}\right|^{2b}}
$$



c is the centre, a>0 controls width and b>0 controls the slope. Absolute value |u| is the nonnegative magnitude: |−2|=2. At x=c membership is 1; at x=c±a membership is 1/2.

**For a=2, b=1 and c=10, find generalised-bell membership at x=14.** [2 marks · Practice]

#### Given

a=2, b=1, c=10; x=14.

#### To find

μ(14).

#### Formula and why it applies

Subtract the centre, divide by a, take the absolute value, raise to 2b, then use the reciprocal.

#### Solution

##### Step 1. Scaled distance



$$
|(14-10)/2|=|2|=2
$$



##### Step 2. Power



$$
2^{2(1)}=4
$$



##### Step 3. Final reciprocal



$$
\mu(14)=1/(1+4)=0.2
$$



**Final answer.** 0.2.

**Yaad rakho:** Gaussian MF ka centre 1 hota hai. GMM density ke normalising factor ko yahan mat lagao.

---

## TEE · Cartesian product: every cell explained

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-relations--cartesian/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-relations/cartesian

Longer Unit 2 numerical practice, also useful for TEE.

## How a row membership and a column membership meet

Let A₁=.6 and A₂=.2 label two rows. Let B₁=.3, B₂=.8 and B₃=.5 label three columns. Cell R₂₃ belongs to row 2 and column 3, so use A₂=.2 and B₃=.5. Their min is .2. You do not multiply 2×3; those subscripts only locate the cell.



$$
R_{23}=\min(A_2,B_3)=\min(0.2,0.5)=0.2
$$



There are two choices of row and three of column, so fill six cells in a 2×3 rectangle. Keep the row and column labels when reporting a relation.

## What is a fuzzy relation?

A fuzzy set gives a membership to one element. A **fuzzy relation** gives a degree to an ordered pair. A matrix is a convenient table: rows name the first element and columns name the second.

For the standard min-based Cartesian product R=A×B, put the A memberships down the rows and the B memberships across the columns. Each cell is the smaller of its row and column memberships.



$$
R_{ij}=\min(\mu_A(a_i),\mu_B(b_j))
$$



**Find the fuzzy Cartesian product A×B for memberships A=[0.6, 0.2] and B=[0.3, 0.8, 0.5].** [3 marks · Practice]

#### Given

Ordered A memberships [0.6, 0.2]; B memberships [0.3, 0.8, 0.5].

#### To find

A 2×3 relation matrix.

#### Formula and why it applies

Every row corresponds to an A element and every column to a B element; apply min in every cell.



$$
R_{ij}=\min(A_i,B_j)
$$



#### Solution

##### Step 1. Determine dimensions

2 row elements × 3 column elements.

##### Step 2. Compute each cell

| A ↓ / B → | 0.3 | 0.8 | 0.5 |
| --- | --- | --- | --- |
| 0.6 | min(0.6,0.3) = 0.3 | min(0.6,0.8) = 0.6 | min(0.6,0.5) = 0.5 |
| 0.2 | min(0.2,0.3) = 0.2 | min(0.2,0.8) = 0.2 | min(0.2,0.5) = 0.2 |

##### Step 3. Write the matrix



$$
R=\begin{bmatrix}0.3&0.6&0.5\\0.2&0.2&0.2\end{bmatrix}
$$



**Final answer.** R is the matrix in Step 3.

**Find the fuzzy Cartesian product A×B for memberships A=[1, 0.4] and B=[0.7, 0].** [3 marks · Practice]

#### Given

Ordered A memberships [1, 0.4]; B memberships [0.7, 0].

#### To find

A 2×2 relation matrix.

#### Formula and why it applies

Every row corresponds to an A element and every column to a B element; apply min in every cell.



$$
R_{ij}=\min(A_i,B_j)
$$



#### Solution

##### Step 1. Determine dimensions

2 row elements × 2 column elements.

##### Step 2. Compute each cell

| A ↓ / B → | 0.7 | 0 |
| --- | --- | --- |
| 1 | min(1,0.7) = 0.7 | min(1,0) = 0 |
| 0.4 | min(0.4,0.7) = 0.4 | min(0.4,0) = 0 |

##### Step 3. Write the matrix



$$
R=\begin{bmatrix}0.7&0\\0.4&0\end{bmatrix}
$$



**Final answer.** R is the matrix in Step 3.

**Find the fuzzy Cartesian product A×B for memberships A=[0.2, 0.9, 0.5] and B=[0.6, 0.1].** [3 marks · Practice]

#### Given

Ordered A memberships [0.2, 0.9, 0.5]; B memberships [0.6, 0.1].

#### To find

A 3×2 relation matrix.

#### Formula and why it applies

Every row corresponds to an A element and every column to a B element; apply min in every cell.



$$
R_{ij}=\min(A_i,B_j)
$$



#### Solution

##### Step 1. Determine dimensions

3 row elements × 2 column elements.

##### Step 2. Compute each cell

| A ↓ / B → | 0.6 | 0.1 |
| --- | --- | --- |
| 0.2 | min(0.2,0.6) = 0.2 | min(0.2,0.1) = 0.1 |
| 0.9 | min(0.9,0.6) = 0.6 | min(0.9,0.1) = 0.1 |
| 0.5 | min(0.5,0.6) = 0.5 | min(0.5,0.1) = 0.1 |

##### Step 3. Write the matrix



$$
R=\begin{bmatrix}0.2&0.1\\0.6&0.1\\0.5&0.1\end{bmatrix}
$$



**Final answer.** R is the matrix in Step 3.

**Yaad rakho:** Row ka degree aur column ka degree—dono ka min us cell mein.

---

## TEE · Max–min composition: three complete matrix examples

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/fuzzy-relations--composition/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/fuzzy-relations/composition

Longer Unit 2 numerical practice, also useful for TEE.

## One result cell combines alternative two-link paths

For T₁₁, start at u₁ and end at w₁. If the middle domain has v₁ and v₂, there are two candidate paths. Their strengths come from matching row 1 of R with column 1 of S.

| Path | First link from R | Second link from S | Path strength |
| --- | --- | --- | --- |
| u₁ → v₁ → w₁ | .2 | .5 | min(.2,.5)=.2 |
| u₁ → v₂ → w₁ | .8 | .7 | min(.8,.7)=.7 |

Choose the stronger path: max(.2,.7)=.7, so T₁₁=.7. The middle label j runs through v₁ and v₂. The labels i and k stay fixed at 1 while this one cell is calculated. Then move to the next result cell.

**Yaad rakho:** Ek path mein dono links chahiye, isliye min. Alag paths mein best chalega, isliye max.

## Composition connects through a middle element

Suppose R relates U to V and S relates V to W. To find how strongly u connects to w through each middle v, take min of the two links. Then choose the strongest such path using max.



$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$



We call this matrix operation R composed with S here. Some books write the symbolic order in reverse. State the formula and row/column labels, especially when a question says S∘R. Composition requires the intermediate domains and their ordering to match; having two 3×3 matrices alone does not prove their labels match.

**Calculate the max–min composition using 

$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$

.** [3 marks · Practice]

#### Given



$$
R=\begin{bmatrix}0.2&0.8\\0.6&0.3\end{bmatrix}
$$





$$
S=\begin{bmatrix}0.5&0.9\\0.7&0.1\end{bmatrix}
$$



#### To find

Every entry of T.

#### Formula and why it applies

Pair each row entry with the corresponding column entry; min for a two-link path, max across the possible middle elements. This is not ordinary matrix multiplication.

#### Solution

##### Step 1. Cell (1,1): row 1 of R with column 1 of S



$$
T_{11}=\max\{\min(0.2,0.5),\min(0.8,0.7)\}
$$





$$
=\max\{0.2,0.7\}=0.7
$$



##### Step 2. Cell (1,2): row 1 of R with column 2 of S



$$
T_{12}=\max\{\min(0.2,0.9),\min(0.8,0.1)\}
$$





$$
=\max\{0.2,0.1\}=0.2
$$



##### Step 3. Cell (2,1): row 2 of R with column 1 of S



$$
T_{21}=\max\{\min(0.6,0.5),\min(0.3,0.7)\}
$$





$$
=\max\{0.5,0.3\}=0.5
$$



##### Step 4. Cell (2,2): row 2 of R with column 2 of S



$$
T_{22}=\max\{\min(0.6,0.9),\min(0.3,0.1)\}
$$





$$
=\max\{0.6,0.1\}=0.6
$$



**Final answer.** 

$$
T=\begin{bmatrix}0.7&0.2\\0.5&0.6\end{bmatrix}
$$

.

**Calculate the max–min composition using 

$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$

.** [3 marks · Practice]

#### Given



$$
R=\begin{bmatrix}1&0\\0.4&0.7\end{bmatrix}
$$





$$
S=\begin{bmatrix}0.2&0.6\\0.8&0.3\end{bmatrix}
$$



#### To find

Every entry of T.

#### Formula and why it applies

Pair each row entry with the corresponding column entry; min for a two-link path, max across the possible middle elements. This is not ordinary matrix multiplication.

#### Solution

##### Step 1. Cell (1,1): row 1 of R with column 1 of S



$$
T_{11}=\max\{\min(1,0.2),\min(0,0.8)\}
$$





$$
=\max\{0.2,0\}=0.2
$$



##### Step 2. Cell (1,2): row 1 of R with column 2 of S



$$
T_{12}=\max\{\min(1,0.6),\min(0,0.3)\}
$$





$$
=\max\{0.6,0\}=0.6
$$



##### Step 3. Cell (2,1): row 2 of R with column 1 of S



$$
T_{21}=\max\{\min(0.4,0.2),\min(0.7,0.8)\}
$$





$$
=\max\{0.2,0.7\}=0.7
$$



##### Step 4. Cell (2,2): row 2 of R with column 2 of S



$$
T_{22}=\max\{\min(0.4,0.6),\min(0.7,0.3)\}
$$





$$
=\max\{0.4,0.3\}=0.4
$$



**Final answer.** 

$$
T=\begin{bmatrix}0.2&0.6\\0.7&0.4\end{bmatrix}
$$

.

**Calculate the max–min composition using 

$$
T_{ik}=\max_j\min(R_{ij},S_{jk})
$$

.** [3 marks · Practice]

#### Given



$$
R=\begin{bmatrix}0.3&0.6&0.9\end{bmatrix}
$$





$$
S=\begin{bmatrix}0.8&0.1\\0.2&0.7\\0.5&0.4\end{bmatrix}
$$



#### To find

Every entry of T.

#### Formula and why it applies

Pair each row entry with the corresponding column entry; min for a two-link path, max across the possible middle elements. This is not ordinary matrix multiplication.

#### Solution

##### Step 1. Cell (1,1): row 1 of R with column 1 of S



$$
T_{11}=\max\{\min(0.3,0.8),\min(0.6,0.2),\min(0.9,0.5)\}
$$





$$
=\max\{0.3,0.2,0.5\}=0.5
$$



##### Step 2. Cell (1,2): row 1 of R with column 2 of S



$$
T_{12}=\max\{\min(0.3,0.1),\min(0.6,0.7),\min(0.9,0.4)\}
$$





$$
=\max\{0.1,0.6,0.4\}=0.6
$$



**Final answer.** 

$$
T=\begin{bmatrix}0.5&0.6\end{bmatrix}
$$

.

**Yaad rakho:** Har path mein min, phir saare paths mein max. Multiply-and-add nahi.

---

## TEE · GA meaning, biological idea and every basic term

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--meaning/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/meaning

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

| Object | Concrete value | Do not confuse it with |
| --- | --- | --- |
| Individual number | Row 2 | The candidate’s value x |
| Candidate value x | 11 | Its chromosome 1011 |
| Chromosome | 1011 | Its fitness |
| Fitness when maximising x² | 11×11=121 | Its row number or bit string |

In this guide, “gene 3” counts the third bit from the **left** starting at 1. Binary place values were built from the **right** starting with weight 1. These are two labelling conventions, not contradictory place-value rules. Read the end specified in an exam.

## What a genetic algorithm does

A **genetic algorithm (GA)** is a population-based optimisation method inspired by biological evolution. It maintains candidate solutions, evaluates their fitness, selects parents, generates children through crossover and mutation, and repeats the process.

In biology, genes carry inherited information. In a GA, an encoding plays the role of inherited information. The analogy motivates the operators; it does not mean that a computer chromosome is literally DNA.

| Term | Meaning | Four-bit example |
| --- | --- | --- |
| Individual | One candidate solution | x=11 |
| Chromosome | The complete encoded candidate | 1011 |
| Gene | One component of an encoding | The third bit |
| Allele | The value at a gene | 0 or 1 for binary encoding |
| Population | The collection of current individuals | [3,5,10,12] |
| Fitness | A score used to favour useful candidates | For max x², fitness of 11 is 121 |
| Generation | One cycle producing a new population | Select → cross → mutate → replace |
| Search space | All candidate solutions permitted | 4-bit integers: 0–15 |
| Elitism | Preserving best individuals unchanged | Copy the best into the next population |

An objective describes what the problem wants. Fitness describes what the selection mechanism favours. For maximising a nonnegative objective, they may be the same. For minimising cost, directly selecting in proportion to cost would favour bad candidates; use a specified transformation or a comparison-based selection method.

**For a maximisation GA with objective f(x)=x², find the fitness of x=3.** [2 marks · Practice]

#### Given

x=3; fitness equals the nonnegative objective x².

#### To find

Fitness, not the encoded chromosome.

#### Formula and why it applies

Square x to evaluate its objective; binary encoding is a separate representation step.

#### Solution

##### Step 1. Substitute x



$$
f(3)=3^2
$$



##### Step 2. Multiply



$$
3\times3=9
$$



**Final answer.** Fitness = 9.

**For a maximisation GA with objective f(x)=x², find the fitness of x=7.** [2 marks · Practice]

#### Given

x=7; fitness equals the nonnegative objective x².

#### To find

Fitness, not the encoded chromosome.

#### Formula and why it applies

Square x to evaluate its objective; binary encoding is a separate representation step.

#### Solution

##### Step 1. Substitute x



$$
f(7)=7^2
$$



##### Step 2. Multiply



$$
7\times7=49
$$



**Final answer.** Fitness = 49.

**For a maximisation GA with objective f(x)=x², find the fitness of x=12.** [2 marks · Practice]

#### Given

x=12; fitness equals the nonnegative objective x².

#### To find

Fitness, not the encoded chromosome.

#### Formula and why it applies

Square x to evaluate its objective; binary encoding is a separate representation step.

#### Solution

##### Step 1. Substitute x



$$
f(12)=12^2
$$



##### Step 2. Multiply



$$
12\times12=144
$$



**Final answer.** Fitness = 144.

**Yaad rakho:** Chromosome answer ka code; fitness us code wale answer ka score.

---

## TEE · Encoding: binary, real values and permutations

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--encoding/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/encoding

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

## Expand the compact decoding formula before using it



$$
x=b_1 2^3+b_2 2^2+b_3 2^1+b_4 2^0
$$



For four bits, b₁ is the leftmost bit and receives weight 8; b₄ is the rightmost and receives weight 1. In general n−i gives the power belonging to bit i. For 1011, the four terms are 1×8, 0×4, 1×2, 1×1. Add 8+0+2+1=11.

For real-range mapping, d/(2ⁿ−1) is the fraction of the way through the possible codes. Multiplying by U−L travels that fraction of the physical range. Adding L shifts the result to start at the lower limit.

| 3-bit code | Decoded d | Fraction d/7 | Mapped to [−2,5] |
| --- | --- | --- | --- |
| 000 | 0 | 0/7=0 | −2+0×7=−2 |
| 011 | 3 | 3/7 | −2+(3/7)×7=1 |
| 111 | 7 | 7/7=1 | −2+1×7=5 |

## Choose an encoding that can express legal solutions

**Binary encoding** uses bit strings; **real-valued encoding** stores real numbers directly; **permutation encoding** stores an order, such as a TSP city tour. An operator valid for bits may create invalid city tours, so encoding and operators must fit the problem.

| Representation | Candidate | Appropriate use |
| --- | --- | --- |
| Binary | 1011 | An unsigned integer or a coded real value |
| Real-valued | [0.2, 1.7] | Continuous parameters |
| Permutation | [A,C,B,D] | Visit order in TSP |

## Decode an n-bit integer



$$
x=b_1 2^{n-1}+b_2 2^{n-2}+\cdots+b_n2^0
$$



b₁ is the leftmost bit, not a coefficient you have to learn. In four bits the weights are 8,4,2,1. The maximum is 

$$
2^n-1
$$

.

**Decode the 4-bit chromosome 0011.** [2 marks · Practice]

#### Given

Bits 0011; place values 8,4,2,1.

#### To find

Integer x.

#### Formula and why it applies

Multiply each bit by its matching place value, then add.

#### Solution

##### Step 1. List contributions

| Bit | Place value | Contribution |
| --- | --- | --- |
| 0 | 8 | 0 |
| 0 | 4 | 0 |
| 1 | 2 | 2 |
| 1 | 1 | 1 |

##### Step 2. Add



$$
0+0+2+1=3
$$



**Final answer.** x=3.

**Decode the 4-bit chromosome 1010.** [2 marks · Practice]

#### Given

Bits 1010; place values 8,4,2,1.

#### To find

Integer x.

#### Formula and why it applies

Multiply each bit by its matching place value, then add.

#### Solution

##### Step 1. List contributions

| Bit | Place value | Contribution |
| --- | --- | --- |
| 1 | 8 | 8 |
| 0 | 4 | 0 |
| 1 | 2 | 2 |
| 0 | 1 | 0 |

##### Step 2. Add



$$
8+0+2+0=10
$$



**Final answer.** x=10.

**Decode the 4-bit chromosome 1111.** [2 marks · Practice]

#### Given

Bits 1111; place values 8,4,2,1.

#### To find

Integer x.

#### Formula and why it applies

Multiply each bit by its matching place value, then add.

#### Solution

##### Step 1. List contributions

| Bit | Place value | Contribution |
| --- | --- | --- |
| 1 | 8 | 8 |
| 1 | 4 | 4 |
| 1 | 2 | 2 |
| 1 | 1 | 1 |

##### Step 2. Add



$$
8+4+2+1=15
$$



**Final answer.** x=15.

## Encoding a real interval

If the question maps an n-bit integer d to a real interval [L,U], first decode d, then use:



$$
x=L+\frac{d}{2^n-1}(U-L)
$$



**Map the 3-bit string 101 to the real interval [−2,5] using linear binary decoding.** [3 marks · Practice]

#### Given

n=3, L=−2, U=5; string 101.

#### To find

Real x.

#### Formula and why it applies

The smallest bit code maps to L and the largest to U; the remaining codes are equally spaced.



$$
x=L+\frac d{2^n-1}(U-L)
$$



#### Solution

##### Step 1. Decode integer d



$$
d=1(4)+0(2)+1(1)=5
$$



##### Step 2. Calculate interval width and maximum code



$$
U-L=5-(-2)=7\qquad2^3-1=7
$$



##### Step 3. Map to the interval



$$
x=-2+(5/7)(7)=3
$$



**Final answer.** x=3.

**Yaad rakho:** Pehle bits se integer. Real range mapping explicitly diya ho tabhi next formula lagao.

---

## TEE · Roulette selection, cumulative intervals and alternatives

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--selection/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/selection

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

Before the three complete sums below, read the running-total example in [Percentages, probabilities and cumulative intervals](https://deep-learning-study-room.vercel.app/read/is2/m2/read/core-maths--probability/). For weights [1,2,3,4], candidate C’s own probability is 0.3, but its interval is [0.3,0.6). A draw of 0.55 selects C because it lies inside that interval; it is not required to be less than C’s individual probability.

## Selection chooses parents, usually with replacement

**Roulette-wheel selection** gives each candidate a probability proportional to a nonnegative fitness weight. A high weight occupies a larger interval on [0,1]. A supplied random number selects the interval containing it.



$$
P_i=F_i/\sum_jF_j
$$



Fᵢ is the fitness weight of individual i. The sum must be positive. Probabilities add to 1. Cumulative probability is the running sum and supplies the interval boundaries.

**Fitness weights of successive individuals are [1, 2, 3, 4]. Select parents using random numbers [0.05, 0.25, 0.55, 0.9].** [3 marks · Practice]

#### Given

Fitness weights [1, 2, 3, 4]; draws [0.05, 0.25, 0.55, 0.9].

#### To find

Parent row number for each draw.

#### Formula and why it applies

Divide by the fitness sum, form cumulative intervals, then locate each random draw. Use half-open intervals [lower,upper); the final upper endpoint 1 is included.

#### Solution

##### Step 1. Sum fitness



$$
\sum F=1+2+3+4=10
$$



##### Step 2. Find probabilities and cumulative bounds

| Individual | Fitness | Probability | Cumulative |
| --- | --- | --- | --- |
| 1 | 1 | 0.1 | 0.1 |
| 2 | 2 | 0.2 | 0.3 |
| 3 | 3 | 0.3 | 0.6 |
| 4 | 4 | 0.4 | 1 |

##### Step 3. Locate each draw

| Draw | Selected individual |
| --- | --- |
| 0.05 | 1 |
| 0.25 | 2 |
| 0.55 | 3 |
| 0.9 | 4 |

**Final answer.** Selected row numbers: [1, 2, 3, 4]. Repeated selection is permitted.

**Fitness weights of successive individuals are [4, 4, 2]. Select parents using random numbers [0.2, 0.6, 0.85].** [3 marks · Practice]

#### Given

Fitness weights [4, 4, 2]; draws [0.2, 0.6, 0.85].

#### To find

Parent row number for each draw.

#### Formula and why it applies

Divide by the fitness sum, form cumulative intervals, then locate each random draw. Use half-open intervals [lower,upper); the final upper endpoint 1 is included.

#### Solution

##### Step 1. Sum fitness



$$
\sum F=4+4+2=10
$$



##### Step 2. Find probabilities and cumulative bounds

| Individual | Fitness | Probability | Cumulative |
| --- | --- | --- | --- |
| 1 | 4 | 0.4 | 0.4 |
| 2 | 4 | 0.4 | 0.8 |
| 3 | 2 | 0.2 | 1 |

##### Step 3. Locate each draw

| Draw | Selected individual |
| --- | --- |
| 0.2 | 1 |
| 0.6 | 2 |
| 0.85 | 3 |

**Final answer.** Selected row numbers: [1, 2, 3]. Repeated selection is permitted.

**Fitness weights of successive individuals are [0, 3, 1]. Select parents using random numbers [0.2, 0.8].** [3 marks · Practice]

#### Given

Fitness weights [0, 3, 1]; draws [0.2, 0.8].

#### To find

Parent row number for each draw.

#### Formula and why it applies

Divide by the fitness sum, form cumulative intervals, then locate each random draw. Use half-open intervals [lower,upper); the final upper endpoint 1 is included.

#### Solution

##### Step 1. Sum fitness



$$
\sum F=0+3+1=4
$$



##### Step 2. Find probabilities and cumulative bounds

| Individual | Fitness | Probability | Cumulative |
| --- | --- | --- | --- |
| 1 | 0 | 0 | 0 |
| 2 | 3 | 0.75 | 0.75 |
| 3 | 1 | 0.25 | 1 |

##### Step 3. Locate each draw

| Draw | Selected individual |
| --- | --- |
| 0.2 | 2 |
| 0.8 | 3 |

**Final answer.** Selected row numbers: [2, 3]. Repeated selection is permitted.

## Other selection methods

| Method | Procedure | Why it is used |
| --- | --- | --- |
| Tournament | Sample a group and take its best candidate | Only objective comparisons are needed |
| Rank | Sort candidates; assign weights based on rank | Reduces sensitivity to a single huge raw fitness |
| Elitist survival | Preserve top individuals unchanged into the next population | Protects good solutions from destructive variation |

Selection is not automatically “replace the weakest with the fittest”. That is one possible classroom reproduction rule. If a problem gives selected parents, a rank rule, tournament contestants or roulette draws, follow that exact instruction.

**Yaad rakho:** Probability nikalo → cumulative banao → random number ka interval dekho.

---

## TEE · Crossover and mutation: four complete worked variants

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--operators/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/operators

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

## Cutting means splitting the written string

The **prefix** is the part before the cut; the **suffix** is the part after it. “10 joined with 00 gives 1000” means writing strings next to each other. It is not the arithmetic addition 10+00.

| Operation | Parents / instruction | Construction | Children |
| --- | --- | --- | --- |
| One-point crossover | 10|11 and 01|00 | First prefix + second tail; second prefix + first tail | 1000 and 0111 |
| Two-point crossover | 1|01|10 and 0|10|01 | Exchange only the middle blocks | 11010 and 00101 |
| Uniform crossover | A=1010, B=0101, mask=1100 | Child 1 takes A where mask=1 and B where mask=0; child 2 reverses this | 1001 and 0110 |
| Mutation | 1000; flip position 3 from left | The third bit is 0; replace it by 1; keep every other bit | 1010 |

These crossover operators are alternatives. Apply the operator stated in the question; do not apply all three in one generation. Mutation is a separate step after crossover in the worked exam workflow.

## Crossover combines; mutation changes

In **single-point crossover**, cut both parents after the specified bit. Child 1 keeps parent 1’s prefix and takes parent 2’s suffix; child 2 does the reverse. A cut after bit 2 in a four-bit string looks like 10|11.

**Cross parents 1011 and 0100 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 1011, 0100; cut after bit 2; mutation bit 4.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

10 | 11 and 01 | 00

##### Step 2. Exchange tails

10 + 00 → 1000  
01 + 11 → 0111

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 1000 | 0 | 1 | 1001 |
| 0111 | 1 | 0 | 0110 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 1001 | 8 + 0 + 0 + 1 | 9 |
| 0110 | 0 + 4 + 2 + 0 | 6 |

**Final answer.** Final children 1001 (9) and 0110 (6).

**Cross parents 0011 and 1100 after bit 1. Then flip bit 2 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 0011, 1100; cut after bit 1; mutation bit 2.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

0 | 011 and 1 | 100

##### Step 2. Exchange tails

0 + 100 → 0100  
1 + 011 → 1011

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 0100 | 1 | 0 | 0000 |
| 1011 | 0 | 1 | 1111 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 0000 | 0 + 0 + 0 + 0 | 0 |
| 1111 | 8 + 4 + 2 + 1 | 15 |

**Final answer.** Final children 0000 (0) and 1111 (15).

**Cross parents 1110 and 0001 after bit 3. Then flip bit 1 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 1110, 0001; cut after bit 3; mutation bit 1.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

111 | 0 and 000 | 1

##### Step 2. Exchange tails

111 + 1 → 1111  
000 + 0 → 0000

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 1111 | 1 | 0 | 0111 |
| 0000 | 0 | 1 | 1000 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 0111 | 0 + 4 + 2 + 1 | 7 |
| 1000 | 8 + 0 + 0 + 0 | 8 |

**Final answer.** Final children 0111 (7) and 1000 (8).

**Cross parents 1010 and 1010 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.** [3 marks · Practice]

#### Given

Parents 1010, 1010; cut after bit 2; mutation bit 4.

#### To find

Children after crossover, after mutation and their decimal values.

#### Formula and why it applies

Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.

#### Solution

##### Step 1. Mark the cut

10 | 10 and 10 | 10

##### Step 2. Exchange tails

10 + 10 → 1010  
10 + 10 → 1010

##### Step 3. Flip the specified bit

| Crossover child | Bit before | Bit after | Mutated child |
| --- | --- | --- | --- |
| 1010 | 0 | 1 | 1011 |
| 1010 | 0 | 1 | 1011 |

##### Step 4. Decode

| String | Place-value sum | x |
| --- | --- | --- |
| 1011 | 8 + 0 + 2 + 1 | 11 |
| 1011 | 8 + 0 + 2 + 1 | 11 |

**Final answer.** Final children 1011 (11) and 1011 (11).

**Two-point crossover** exchanges the segment between two cuts. **Uniform crossover** uses a given mask to choose, at each position, which parent contributes a gene. Mutation may flip a bit, perturb a real value, or swap two positions in a permutation. These are different operators; apply the one named in the question.

**Yaad rakho:** Crossover = tail exchange. Mutation = specified bit flip. Flip ka matlab 1 bhi 0 banega.

---

## TEE · GA architecture, two-generation flow, constraints and theory

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--algorithm/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/algorithm

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| Feasible | Obeys every stated constraint | x≤10: x=9 qualifies; x=12 does not |
| Penalty | A deduction for violating a constraint | For maximisation, subtract 100×excess |
| Elitism | Explicitly preserve a best old individual | Only apply if the question specifies it |
| Replacement | Choose what population the next generation uses | Our full-replacement examples use the new children |
| Stopping condition | A rule ending the repeated process | Stop after two complete generations |

## A complete GA generation

Encode + evaluate

→

Select parents

→

Crossover

→

Mutation

→

Evaluate childrenreplace and repeat

A **simple generational GA** replaces the population in generations using a chosen encoding, selection rule and variation operators. A more general GA may use steady-state replacement, different encodings, adaptive operators or explicit elitism. Always state the choices used in your worked answer.

## What “iteration 2” means here

Initial population → first generation’s selection/crossover/mutation → new population → second generation’s selection/crossover/mutation → final population. Stopping after the first children and labelling them iteration 2 is not two full generations.

## Stopping conditions

Stop after a fixed generation budget, after reaching a specified acceptable objective, or after little improvement for a stated number of generations. A finite run does not prove the global optimum.

## Constraints

A **constraint** restricts allowed solutions, such as 0≤x≤15 or “visit every city once”. Common approaches are valid-by-design encoding, repairing an invalid child, rejecting it, or using a penalty. A penalty must reduce attractiveness: subtract it in maximisation or add it to a minimised cost. Do not silently remove the original constraint because you used more bits.

**A maximisation problem has objective f(x)=x² and constraint x≤10. The given penalised fitness is F(x)=x²−100 max(0,x−10). Compare x=9 and x=12.** [3 marks · Practice]

#### Given

Penalty coefficient 100; bound 10; candidates 9 and 12.

#### To find

Penalised fitness of both candidates.

#### Formula and why it applies

Only excess above the bound receives a penalty.

#### Solution

##### Step 1. Feasible candidate 9



$$
\max(0,9-10)=0
$$





$$
F(9)=81-100(0)=81
$$



##### Step 2. Infeasible candidate 12



$$
\max(0,12-10)=2
$$





$$
F(12)=144-100(2)=-56
$$



##### Step 3. Compare

For this maximisation fitness, 81 > −56, so x=9 is preferred. Raw objective alone would misleadingly favour 12.

**Final answer.** F(9)=81; F(12)=−56.

| Advantages | Limitations |
| --- | --- |
| Derivative-free; supports many encodings | Many objective evaluations may be costly |
| Population explores several candidates | Premature convergence is possible |
| Crossover and mutation can create new candidates | Parameter and encoding choices affect results |
| Applicable to discontinuous or combinatorial searches | No guaranteed global optimum; variation can worsen fitness |

**Yaad rakho:** Do generation = do baar poora cycle. Sirf children banana aur decode karna do alag iterations nahi.

---

## TEE · Two generations with given selection, cut and mutation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--two-generations/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/two-generations

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

Swipe across the diagram to read its labels ↔

![This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.](https://deep-learning-study-room.vercel.app/is2/fig/v2_ga_generation.fa7bf86c05.svg)

Diagram: This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.. Labels: One complete GA generation: read from top to bottom | Selected parents | 1010 × 1100 | Cut after bit 2 | Mark the cut | 10 | 10 11 | 00 | Keep prefix, exchange suffix | After crossover | 1000 1110 | Children are 8 and 14 | Flip the last bit | 1001 1111 | 0 becomes 1 in each child | Decode and evaluate | 9² = 81 15² = 225 | These are the children’s fitness values

This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.

**Maximise 

$$
f(x)=x^2
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [3, 5, 10, 12]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [1, 2, 3, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Current individual row numbers [3, 4, 4, 3] |
| 2 | Current individual row numbers [2, 3, 2, 3] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 3 | 0011 | 3 × 3 = 9 |
| 2 | 5 | 0101 | 5 × 5 = 25 |
| 3 | 10 | 1010 | 10 × 10 = 100 |
| 4 | 12 | 1100 | 12 × 12 = 144 |

##### Step 2. Generation 1: apply the supplied selection order

The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 3 | 10 | 1010 |
| 2 | 4 | 12 | 1100 |
| 3 | 4 | 12 | 1100 |
| 4 | 3 | 10 | 1010 |

##### Step 3. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 10 | 10 | 11 | 00 | 1000 | 1110 |
| 3 & 4 | 11 | 00 | 10 | 10 | 1110 | 1000 |

##### Step 4. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1000 | Flip bit 4 | 1001 |
| 2 | 1110 | Flip bit 4 | 1111 |
| 3 | 1110 | Flip bit 4 | 1111 |
| 4 | 1000 | Flip bit 4 | 1001 |

##### Step 5. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1001 | 8 + 0 + 0 + 1 = 9 | 9² = 81 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1111 | 8 + 4 + 2 + 1 = 15 | 15² = 225 |
| 1001 | 8 + 0 + 0 + 1 = 9 | 9² = 81 |

##### Step 6. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{9+25+100+144}{4}=\frac{278}{4}=69.5
$$





$$
\overline f_{new}=\frac{81+225+225+81}{4}=\frac{612}{4}=153
$$



Best objective: 144 → 225. Higher is better. The next population is [9, 15, 15, 9]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 7. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 9 | 1001 | 9 × 9 = 81 |
| 2 | 15 | 1111 | 15 × 15 = 225 |
| 3 | 15 | 1111 | 15 × 15 = 225 |
| 4 | 9 | 1001 | 9 × 9 = 81 |

##### Step 8. Generation 2: apply the supplied selection order

The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.

| Mating-pool slot | Chosen individual | x | Chromosome |
| --- | --- | --- | --- |
| 1 | 2 | 15 | 1111 |
| 2 | 3 | 15 | 1111 |
| 3 | 2 | 15 | 1111 |
| 4 | 3 | 15 | 1111 |

##### Step 9. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 11 | 11 | 11 | 11 | 1111 | 1111 |
| 3 & 4 | 11 | 11 | 11 | 11 | 1111 | 1111 |

##### Step 10. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1111 | Flip bit 4 | 1110 |
| 2 | 1111 | Flip bit 4 | 1110 |
| 3 | 1111 | Flip bit 4 | 1110 |
| 4 | 1111 | Flip bit 4 | 1110 |

##### Step 11. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |
| 1110 | 8 + 4 + 2 + 0 = 14 | 14² = 196 |

##### Step 12. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{81+225+225+81}{4}=\frac{612}{4}=153
$$





$$
\overline f_{new}=\frac{196+196+196+196}{4}=\frac{784}{4}=196
$$



Best objective: 225 → 196. Higher is better. The next population is [14, 14, 14, 14]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [14, 14, 14, 14]. Best final objective = 196 at x = [14].

---

## TEE · Two generations including roulette selection

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--roulette-generations/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/roulette-generations

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

**Maximise 

$$
f(x)=x(15-x)+1
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [2, 5, 9, 12]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [2, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Random draws [0.1, 0.4, 0.65, 0.9] |
| 2 | Random draws [0.2, 0.4, 0.6, 0.95] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 2 | 0010 | 2 × (15 − 2) + 1 = 27 |
| 2 | 5 | 0101 | 5 × (15 − 5) + 1 = 51 |
| 3 | 9 | 1001 | 9 × (15 − 9) + 1 = 55 |
| 4 | 12 | 1100 | 12 × (15 − 12) + 1 = 37 |

##### Step 2. Generation 1: calculate roulette intervals

Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.



$$
\sum F=27+51+55+37\approx170
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 27 ÷ 170 ≈ 0.158823529 | 0 + 0.158823529 ≈ 0.158823529 |
| 2 | 51 ÷ 170 ≈ 0.3 | 0.158823529 + 0.3 ≈ 0.458823529 |
| 3 | 55 ÷ 170 ≈ 0.323529412 | 0.458823529 + 0.323529412 ≈ 0.782352941 |
| 4 | 37 ÷ 170 ≈ 0.217647059 | 0.782352941 + 0.217647059 ≈ 1 |

##### Step 3. Generation 1: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.1 | 0 ≤ 0.1 < 0.158823529 | 1 | 2 |
| 0.4 | 0.158823529 ≤ 0.4 < 0.458823529 | 2 | 5 |
| 0.65 | 0.458823529 ≤ 0.65 < 0.782352941 | 3 | 9 |
| 0.9 | 0.782352941 ≤ 0.9 < 1 | 4 | 12 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 4. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 00 | 10 | 01 | 01 | 0001 | 0110 |
| 3 & 4 | 10 | 01 | 11 | 00 | 1000 | 1101 |

##### Step 5. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 0001 | No mutation | 0001 |
| 2 | 0110 | Flip bit 4 | 0111 |
| 3 | 1000 | No mutation | 1000 |
| 4 | 1101 | Flip bit 4 | 1100 |

##### Step 6. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 0001 | 0 + 0 + 0 + 1 = 1 | 1(15−1)+1 = 15 |
| 0111 | 0 + 4 + 2 + 1 = 7 | 7(15−7)+1 = 57 |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8(15−8)+1 = 57 |
| 1100 | 8 + 4 + 0 + 0 = 12 | 12(15−12)+1 = 37 |

##### Step 7. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{27+51+55+37}{4}=\frac{170}{4}=42.5
$$





$$
\overline f_{new}=\frac{15+57+57+37}{4}=\frac{166}{4}=41.5
$$



Best objective: 55 → 57. Higher is better. The next population is [1, 7, 8, 12]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 8. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 1 | 0001 | 1 × (15 − 1) + 1 = 15 |
| 2 | 7 | 0111 | 7 × (15 − 7) + 1 = 57 |
| 3 | 8 | 1000 | 8 × (15 − 8) + 1 = 57 |
| 4 | 12 | 1100 | 12 × (15 − 12) + 1 = 37 |

##### Step 9. Generation 2: calculate roulette intervals

Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.



$$
\sum F=15+57+57+37\approx166
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 15 ÷ 166 ≈ 0.090361446 | 0 + 0.090361446 ≈ 0.090361446 |
| 2 | 57 ÷ 166 ≈ 0.343373494 | 0.090361446 + 0.343373494 ≈ 0.43373494 |
| 3 | 57 ÷ 166 ≈ 0.343373494 | 0.43373494 + 0.343373494 ≈ 0.777108434 |
| 4 | 37 ÷ 166 ≈ 0.222891566 | 0.777108434 + 0.222891566 ≈ 1 |

##### Step 10. Generation 2: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.2 | 0.090361446 ≤ 0.2 < 0.43373494 | 2 | 7 |
| 0.4 | 0.090361446 ≤ 0.4 < 0.43373494 | 2 | 7 |
| 0.6 | 0.43373494 ≤ 0.6 < 0.777108434 | 3 | 8 |
| 0.95 | 0.777108434 ≤ 0.95 < 1 | 4 | 12 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 11. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 01 | 11 | 01 | 11 | 0111 | 0111 |
| 3 & 4 | 10 | 00 | 11 | 00 | 1000 | 1100 |

##### Step 12. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 0111 | No mutation | 0111 |
| 2 | 0111 | Flip bit 4 | 0110 |
| 3 | 1000 | No mutation | 1000 |
| 4 | 1100 | Flip bit 4 | 1101 |

##### Step 13. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 0111 | 0 + 4 + 2 + 1 = 7 | 7(15−7)+1 = 57 |
| 0110 | 0 + 4 + 2 + 0 = 6 | 6(15−6)+1 = 55 |
| 1000 | 8 + 0 + 0 + 0 = 8 | 8(15−8)+1 = 57 |
| 1101 | 8 + 4 + 0 + 1 = 13 | 13(15−13)+1 = 27 |

##### Step 14. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{15+57+57+37}{4}=\frac{166}{4}=41.5
$$





$$
\overline f_{new}=\frac{57+55+57+27}{4}=\frac{196}{4}=49
$$



Best objective: 57 → 57. Higher is better. The next population is [7, 6, 8, 13]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [7, 6, 8, 13]. Best final objective = 57 at x = [7, 8].

---

## TEE · GA minimisation: transform cost before roulette selection

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/ga-core--minimisation/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/ga-core/minimisation

Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.

Roulette favours a larger weight. A minimisation objective instead favours a smaller cost. The stated transformation F=1/(1+cost) reverses their order for nonnegative costs: cost 0 → weight 1/1=1; cost 3 → 1/4=.25; cost 24 → 1/25=.04. The +1 prevents division by zero. This is one specified transformation, not a universal rule for every minimisation problem.

**Minimise 

$$
f(x)=(x-7)^2
$$

 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.** [3 marks · Practice; complete two-generation solution]

#### Given

Initial ordered population: [2, 4, 8, 12]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [2, 4] in every generation. Replace the whole population with the four children; no elitism.

| Generation | Selection instruction |
| --- | --- |
| 1 | Random draws [0.1, 0.4, 0.65, 0.9] |
| 2 | Random draws [0.2, 0.4, 0.6, 0.95] |

#### To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

#### Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Roulette uses Fᵢ/ΣF. For minimisation here, use Fᵢ=1/(1+f(xᵢ)); do not directly favour large costs.

#### Solution

##### Step 1. Generation 1: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 2 | 0010 | (2 − 7)² = 25 |
| 2 | 4 | 0100 | (4 − 7)² = 9 |
| 3 | 8 | 1000 | (8 − 7)² = 1 |
| 4 | 12 | 1100 | (12 − 7)² = 25 |

##### Step 2. Generation 1: calculate roulette intervals

Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.

| Individual | Cost | Fitness calculation |
| --- | --- | --- |
| 1 | 25 | 1 / (1 + 25) = 1 / 26 ≈ 0.038461538 |
| 2 | 9 | 1 / (1 + 9) = 1 / 10 ≈ 0.1 |
| 3 | 1 | 1 / (1 + 1) = 1 / 2 ≈ 0.5 |
| 4 | 25 | 1 / (1 + 25) = 1 / 26 ≈ 0.038461538 |



$$
\sum F=0.038461538+0.1+0.5+0.038461538\approx0.676923077
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 0.038461538 ÷ 0.676923077 ≈ 0.056818182 | 0 + 0.056818182 ≈ 0.056818182 |
| 2 | 0.1 ÷ 0.676923077 ≈ 0.147727273 | 0.056818182 + 0.147727273 ≈ 0.204545455 |
| 3 | 0.5 ÷ 0.676923077 ≈ 0.738636364 | 0.204545455 + 0.738636364 ≈ 0.943181818 |
| 4 | 0.038461538 ÷ 0.676923077 ≈ 0.056818182 | 0.943181818 + 0.056818182 ≈ 1 |

##### Step 3. Generation 1: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.1 | 0.056818182 ≤ 0.1 < 0.204545455 | 2 | 4 |
| 0.4 | 0.204545455 ≤ 0.4 < 0.943181818 | 3 | 8 |
| 0.65 | 0.204545455 ≤ 0.65 < 0.943181818 | 3 | 8 |
| 0.9 | 0.204545455 ≤ 0.9 < 0.943181818 | 3 | 8 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 4. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 01 | 00 | 10 | 00 | 0100 | 1000 |
| 3 & 4 | 10 | 00 | 10 | 00 | 1000 | 1000 |

##### Step 5. Generation 1: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 0100 | No mutation | 0100 |
| 2 | 1000 | Flip bit 4 | 1001 |
| 3 | 1000 | No mutation | 1000 |
| 4 | 1000 | Flip bit 4 | 1001 |

##### Step 6. Generation 1: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 0100 | 0 + 4 + 0 + 0 = 4 | (4−7)² = 9 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |
| 1000 | 8 + 0 + 0 + 0 = 8 | (8−7)² = 1 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |

##### Step 7. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{25+9+1+25}{4}=\frac{60}{4}=15
$$





$$
\overline f_{new}=\frac{9+4+1+4}{4}=\frac{18}{4}=4.5
$$



Best objective: 1 → 1. Lower is better. The next population is [4, 9, 8, 9]. No elitism is imposed, so the best previous individual is not automatically protected.

##### Step 8. Generation 2: evaluate and encode the current population

| Individual | x | Binary | Objective calculation |
| --- | --- | --- | --- |
| 1 | 4 | 0100 | (4 − 7)² = 9 |
| 2 | 9 | 1001 | (9 − 7)² = 4 |
| 3 | 8 | 1000 | (8 − 7)² = 1 |
| 4 | 9 | 1001 | (9 − 7)² = 4 |

##### Step 9. Generation 2: calculate roulette intervals

Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.

| Individual | Cost | Fitness calculation |
| --- | --- | --- |
| 1 | 9 | 1 / (1 + 9) = 1 / 10 ≈ 0.1 |
| 2 | 4 | 1 / (1 + 4) = 1 / 5 ≈ 0.2 |
| 3 | 1 | 1 / (1 + 1) = 1 / 2 ≈ 0.5 |
| 4 | 4 | 1 / (1 + 4) = 1 / 5 ≈ 0.2 |



$$
\sum F=0.1+0.2+0.5+0.2\approx1
$$



| Individual | Probability: weight ÷ total | Cumulative: old boundary + probability |
| --- | --- | --- |
| 1 | 0.1 ÷ 1 ≈ 0.1 | 0 + 0.1 ≈ 0.1 |
| 2 | 0.2 ÷ 1 ≈ 0.2 | 0.1 + 0.2 ≈ 0.3 |
| 3 | 0.5 ÷ 1 ≈ 0.5 | 0.3 + 0.5 ≈ 0.8 |
| 4 | 0.2 ÷ 1 ≈ 0.2 | 0.8 + 0.2 ≈ 1 |

##### Step 10. Generation 2: use the supplied random draws

| Random draw | Interval containing it | Selected individual | Selected x |
| --- | --- | --- | --- |
| 0.2 | 0.1 ≤ 0.2 < 0.3 | 2 | 9 |
| 0.4 | 0.3 ≤ 0.4 < 0.8 | 3 | 8 |
| 0.6 | 0.3 ≤ 0.6 < 0.8 | 3 | 8 |
| 0.95 | 0.8 ≤ 0.95 < 1 | 4 | 9 |

Intervals are left-closed and right-open, except that a draw of exactly 1 selects the last interval. No draw here is on a boundary. Draws select parents with replacement: selecting a parent once does not remove it. Calculations use unrounded weights; the table displays rounded numbers.

##### Step 11. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

| Pool slots paired | Parent A | Parent B | Child A | Child B |
| --- | --- | --- | --- | --- |
| 1 & 2 | 10 | 01 | 10 | 00 | 1000 | 1001 |
| 3 & 4 | 10 | 00 | 10 | 01 | 1001 | 1000 |

##### Step 12. Generation 2: mutate only the specified bits

| Child | Before mutation | Instruction | After mutation |
| --- | --- | --- | --- |
| 1 | 1000 | No mutation | 1000 |
| 2 | 1001 | Flip bit 4 | 1000 |
| 3 | 1001 | No mutation | 1001 |
| 4 | 1000 | Flip bit 4 | 1001 |

##### Step 13. Generation 2: decode and evaluate every child

| Chromosome | Decode using place values | Objective |
| --- | --- | --- |
| 1000 | 8 + 0 + 0 + 0 = 8 | (8−7)² = 1 |
| 1000 | 8 + 0 + 0 + 0 = 8 | (8−7)² = 1 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |
| 1001 | 8 + 0 + 0 + 1 = 9 | (9−7)² = 4 |

##### Step 14. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.



$$
\overline f_{old}=\frac{9+4+1+4}{4}=\frac{18}{4}=4.5
$$





$$
\overline f_{new}=\frac{1+1+4+4}{4}=\frac{10}{4}=2.5
$$



Best objective: 1 → 1. Lower is better. The next population is [8, 8, 9, 9]. No elitism is imposed, so the best previous individual is not automatically protected.

**Final answer.** After two generations the ordered population is [8, 8, 9, 9]. Best final objective = 1 at x = [8].

---

## TEE · GA approach to the travelling salesman problem

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u3-ga--ga-tsp/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u3-ga/ga-tsp

Unit 3 · Evolutionary intelligence and genetic algorithms · 10-mark GA numerical in both 2025–26 papers

## Read the route before encoding it

A **city** is a location. An **edge** connects two cities and has a travel distance. A **tour** visits each city exactly once and returns to its start. A **permutation** is an ordered arrangement without omissions or repetitions: [A,B,D,C] is valid for four cities; [A,B,B,C] is not.

A distance matrix uses row=departure city and column=arrival city. Entry dAB=5 means the A→B leg costs 5. In a symmetric problem dBA=5 too. A diagonal 0 means no distance from a city to itself, not a free trip to another city. For A→B→D→C→A, add dAB+dBD+dDC+dCA.

Factorial counts arrangements: 3!=3×2×1=6. With one of four cities fixed as the start, the other three can be ordered in six ways. In a symmetric TSP reverse-direction tours have equal length, although they are different written orders.

**In one line:** encode a tour as a permutation of cities, use fitness = 1/(tour length), and use crossover and mutation operators that always produce valid tours.

## The problem

**Travelling salesman problem (TSP):** given n cities and the distance between every pair, find the shortest route that visits each city exactly once and returns to the start. For a symmetric TSP with a fixed starting city, reversal-equivalent tours counted once, and n ≥ 3, the number of distinct tours is 

$$
(n-1)!/2
$$

 (12 for 5 cities, about 

$$
6\times10^{16}
$$

 for 20 cities), so exhaustive search quickly becomes impossible.

## How the GA is adapted

| GA part | For TSP |
| --- | --- |
| Encoding | **Permutation**: C A E B D means C → A → E → B → D → back to C. |
| Fitness | 

$$
F=1/L
$$

, where 

$$
L=\sum d(c_i,c_{i+1})+d(c_n,c_1)
$$

 includes the return edge. Shorter tour = higher fitness. |
| Selection | Roulette wheel on F, or tournament. |
| Crossover | Order crossover (OX), partially mapped crossover (PMX) or cycle crossover (CX). |
| Mutation | Swap two cities, or invert a segment (inversion), with small probability. |

**Why ordinary crossover fails.** Single-point crossover of A B C | D E and C E A | B D gives A B C B D: city B twice and E missing, which is not a tour. Permutation operators avoid this.

## Order-preserving crossover: the stated left-to-right variant

1. Copy a randomly chosen segment from Parent 1 into the child, in the same positions.
2. Fill the remaining positions from left to right with the cities of Parent 2 in their order, skipping cities already copied.

This variant fills empty positions from left to right; standard cyclic OX instead starts scanning and filling after the second cut. Do not mix the two conventions. Example: P1 = 2 4 [1 8 3] 5 7 6, P2 = 7 5 6 8 3 4 2 1. Copy 1 8 3; P2 order without them is 7 5 6 4 2 → child = **7 5 1 8 3 6 4 2**. (One GA slide prints 4 2 1 8 3 7 5 6, which uses a different fill order; state your rule in the exam.)

**Question. Five cities with distances AB = 2, AC = 9, AD = 10, AE = 7, BC = 6, BD = 4, BE = 3, CD = 8, CE = 5, DE = 1. Parents are ABECD and ADBEC. (a) Find their lengths and fitness. (b) Apply the left-to-right order-preserving crossover variant described above with the segment at positions 2–3. (c) Apply swap mutation to positions 3 and 4 of the child. Comment.** [practice · 10 marks]

#### Given

All ten symmetric distances in the question; parents ABECD and ADBEC. Use the explicitly stated left-to-right order-preserving crossover at positions 2–3, then swap positions 3 and 4.

#### To find

Parent lengths/fitness, the crossover child, and the mutated child.

#### Formula and why it applies

Add all edges including the return to the start. A shorter positive length gives a larger reciprocal fitness.



$$
L=\sum_{i=1}^{n-1}d(c_i,c_{i+1})+d(c_n,c_1),\quad F=1/L
$$



#### Solution

##### Step 1. Parent lengths (include the return edge)



$$
L(ABECD)=2+3+5+8+10=28,\quad F=1/28=0.0357
$$





$$
L(ADBEC)=10+4+3+5+9=31,\quad F=1/31=0.0323
$$



##### Step 2. Order crossover

Copy positions 2–3 from P1: \_ B E \_ \_. P2's order without B, E: A, D, C → fill positions 1, 4, 5.

Swipe across the diagram to read its labels ↔

![Order crossover keeps a valid tour: copy B E from P1, fill A, D, C in P2's order](https://deep-learning-study-room.vercel.app/is2/fig/ga_ox.8fd21cbc51.svg)

Diagram: Order crossover keeps a valid tour: copy B E from P1, fill A, D, C in P2's order. Labels: Order crossover keeps a valid tour: copy B E from P1, fill A, D, C in P2's order | Parent 1 | A | B | E | C | D | length 28 | Parent 2 | A | D | B | E | C | length 31 | Child (OX) | A | B | E | D | C | length 23 | After swap | A | B | D | E | C | length 21 (shortest)



$$
\text{Child}=ABEDC,\quad L=2+3+1+8+9=23,\quad F=0.0435
$$



##### Step 3. Swap mutation (positions 3 and 4)



$$
ABEDC\to ABDEC,\quad L=2+4+1+5+9=21,\quad F=0.0476
$$



**Final answer.** Child ABEDC (23) is shorter than both parents (28, 31) because it kept P1's short edge B–E and gained D–E (1). The mutated child ABDEC (21) is the shortest possible tour for this graph (checked against all 12 tours).

## Two more permutation crossovers (textbook, not in your slides)

**PMX** (partially mapped crossover): swap a middle segment and use the position mapping to repair duplicates. With the slide parents and segment 3–5 the mapping is 1↔6, giving children 7 5 1 8 3 4 2 6 and 2 4 6 8 3 5 7 1.

**Cycle crossover (CX)**: find cycles of positions between the parents and take alternate cycles from each parent; every city keeps a position it had in one of the parents.

## Algorithm (from your slides)

1. Initialise random tours (permutations).
2. Evaluate fitness = 1/L.
3. Select parents (roulette or tournament).
4. Apply OX to each pair.
5. Apply swap mutation with small probability.
6. Replace the population.
7. Repeat until the stopping condition; return the shortest tour.

**Yaad rakho:** TSP mein chromosome = shehron ka order. Fitness = 1/length. Normal crossover se shehar repeat honge, isliye OX.

---

## TEE · How pheromone feedback guides ant-colony search

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u3-aco--how-ants-work/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u3-aco/how-ants-work

Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers

**In one line:** ants leave pheromone as they walk; shorter paths get refreshed more often, so their scent stays stronger, so more ants choose them: positive feedback can favour shorter paths.

## Definition

**Ant colony optimization (ACO)** is a population-based, probabilistic metaheuristic, introduced by **Marco Dorigo in 1992**, that finds good paths through a graph by imitating how ants communicate with **pheromone** trails. It is especially suited to routing problems such as the **travelling salesman problem (TSP)**.

Swipe across the diagram to read its labels ↔

![Why ants find the shorter path](https://deep-learning-study-room.vercel.app/is2/fig/aco_bridge.3fc4d22f6d.svg)

Diagram: Why ants find the shorter path. Labels: Why ants find the shorter path | Nest | Food | short path: ants return sooner, pheromone builds up | long path: fewer trips per minute, pheromone evaporates

## How shorter paths can gain an advantage

1. **Random exploration.** At first, ants take all paths roughly equally and drop pheromone as they walk.
2. **Shorter path → faster round trip.** Ants on the short path return sooner, so that path receives pheromone more often per minute.
3. **Evaporation.** Pheromone evaporates. On the long path it has more time to fade between visits.
4. **Positive feedback.** Later ants prefer stronger scent, add even more pheromone, which can reinforce a useful route. A finite run is not guaranteed to discover the global shortest path.

This indirect communication through changes in the environment is called **stigmergy**: no ant tells another where to go; the trail does.

## From real ants to artificial ants

| Real ants | Artificial ants in ACO |
| --- | --- |
| Walk from nest to food | Build a solution by moving from node to node in a graph |
| Drop pheromone on the path used | Increase the pheromone value 

$$
\tau_{ij}
$$

 on every edge used |
| Pheromone evaporates | All 

$$
\tau_{ij}
$$

 shrink by the evaporation rate 

$$
\rho
$$

 each iteration |
| Prefer stronger scent | Choose the next node with a probability based on pheromone and distance |
| Colony reinforces frequently used paths | The algorithm searches for low-cost tours; it may stagnate on a suboptimal tour |

## TSP as a graph

| TSP | ACO |
| --- | --- |
| City | Node |
| Distance between two cities | Edge weight 

$$
d_{ij}
$$

 |
| Round trip visiting every city once | One ant's path |
| Tour length | Sum of the edges used, **including the edge back to the start** |

**Yaad rakho:** Chhota raasta = jaldi wapas = zyada pheromone = aur cheentiyan. Lamba raasta = pheromone ud jaata hai.

---

## TEE · ACO formulas: transition probability, city choice and pheromone update

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u3-aco--formulas/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u3-aco/formulas

Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers

**From city A an ant may choose B or C. Distances are AB=2 and AC=4. Pheromones are both 1 and α=β=1. Find the next-city probabilities.** [2 marks · Worked example]

#### Given

Current city A; allowed next cities B and C. Distances dAB=2 and dAC=4. Pheromones τAB=τAC=1, and exponents α=β=1. Visited cities are excluded.

#### To find

P(A→B) and P(A→C).

#### Formula and why it applies



$$
\eta_{ij}=1/d_{ij}\qquad P_{ij}=\tau_{ij}\eta_{ij}/\sum_{l\in allowed}\tau_{il}\eta_{il}
$$



Shorter distance gives a larger reciprocal. Normalise the desirability weights to probabilities.

#### Solution

##### Step 1. Take reciprocal distances



$$
\eta_{AB}=1/2=0.5\qquad\eta_{AC}=1/4=0.25
$$



##### Step 2. Multiply by pheromone



$$
w_B=1\times0.5=0.5\qquad w_C=1\times0.25=0.25
$$



##### Step 3. Add allowed weights



$$
0.5+0.25=0.75
$$



##### Step 4. Divide each weight by their total



$$
P_{AB}=0.5/0.75=2/3
$$





$$
P_{AC}=0.25/0.75=1/3
$$



**Final answer.** B has probability 2/3; C has probability 1/3. These are probabilities, not a rule forcing the nearest city every time.

Evaporation ρ=.5 means retain 1−.5=.5 of the old pheromone. A completed tour of length 20 deposits Q/20 on each edge it used; with Q=1 this is .05. An unused edge receives no deposit from that ant. Use complete tour length, not the length of the individual edge, in this denominator.

**In one line:** an ant picks the next city with probability ∝ pheromone × (1/distance); after all ants finish, pheromone evaporates and each ant adds Q/(its tour length) to every edge it used.

## 1. Transition probability

An ant 

$$
k
$$

 at city 

$$
i
$$

 moves to an unvisited city 

$$
j
$$

 with probability



$$
P^{k}_{ij}=\frac{\tau_{ij}^{\,\alpha}\,\eta_{ij}^{\,\beta}}{\displaystyle\sum_{l\in\text{allowed}}\tau_{il}^{\,\alpha}\,\eta_{il}^{\,\beta}},\qquad \eta_{ij}=\frac1{d_{ij}}
$$



- 

$$
\tau_{ij}
$$

: pheromone on edge 

$$
i
$$

–

$$
j
$$

; 

$$
\eta_{ij}
$$

: visibility (heuristic), the inverse of distance.
- 

$$
\alpha
$$

: weight of pheromone; 

$$
\beta
$$

: weight of distance. In every class example 

$$
\alpha=\beta=1
$$

.
- “allowed” = cities this ant has not visited yet.

With all 

$$
\tau=1
$$

 and 

$$
\alpha=\beta=1
$$

, the probabilities are simply proportional to 

$$
1/d
$$

.

## 2. Choosing the city with a random number (cumulative rule)

1. List the allowed cities **in alphabetical (city) order**, not sorted by probability.
2. Write their cumulative probabilities.
3. Pick the **first** city whose cumulative value is ≥ the random number 

$$
r
$$

.
4. When only one city is left, the ant goes there without using a random number, then returns to the start.

**Exam trap.** In Final 2025 Q7b, from city C the candidates are B (0.4) and D (0.6). In city order the ranges are B: 0–0.4, D: 0.4–1, so r = 0.8 selects D. If you sort by probability (D first) you would pick B and get the wrong tour. The official key uses city order.

## 3. Pheromone update (after all ants finish)



$$
\tau_{ij}\leftarrow(1-\rho)\,\tau_{ij}+\sum_{k=1}^{m}\Delta\tau^{k}_{ij},\qquad \Delta\tau^{k}_{ij}=\begin{cases}Q/L_k&\text{if ant }k\text{ used edge }(i,j)\\0&\text{otherwise}\end{cases}
$$



- 

$$
\rho
$$

: evaporation rate (fraction lost). Class examples use 

$$
\rho=0.5
$$

. 

$$
Q
$$

: deposit constant, usually 1.
- 

$$
L_k
$$

: length of ant 

$$
k
$$

's complete tour **including the return edge**. Shorter tours deposit more.
- Edges are undirected: update 

$$
\tau_{ij}
$$

 and 

$$
\tau_{ji}
$$

 together (the matrix stays symmetric).
- The update happens once per iteration, after every ant has finished; within an iteration all ants use the same pheromone values.

**When the question gives no ρ or Q** (both 2025–26 papers): write “Assume ρ = 0.5 and Q = 1, as in the class example” and proceed. That is exactly what the Final 2025 key does.

## 4. Algorithm (Ant System)

1. Initialise parameters: number of ants, α, β, ρ, Q, initial pheromone 

$$
\tau_0
$$

, maximum iterations.
2. Place each ant on its start city.
3. Each ant repeatedly chooses the next city with the transition probability until it has visited all cities, then returns to the start.
4. Compute each tour length 

$$
L_k
$$

 and record the best tour.
5. Update pheromone: evaporation, then deposit 

$$
Q/L_k
$$

.
6. Repeat steps 2–5 until the iteration limit; output the best tour.

| Parameter | Meaning | Typical value |
| --- | --- | --- |
| m | Number of ants | number of cities (or 20) |
| α | Pheromone importance | 1 |
| β | Distance (visibility) importance | 1 (often 2–5 in practice) |
| ρ | Evaporation rate | 0.5 in class numericals (0.05–0.5 in practice) |
| Q | Deposit constant | 1 (100 in one slide example) |
| 

$$
\tau_0
$$

 | Initial pheromone | 1 in exam questions |

**Yaad rakho:** Probability = τ × (1/d), phir normalize. City order mein cumulative, pehla ≥ r. Update = ½ purana + Q/L har us edge par jo use hua (wapas wala edge bhi).

---

## TEE · Solved PYQ: ACO for a 4-city TSP (Final 2025, 10 marks)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u3-aco--final-2025/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u3-aco/final-2025

Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers

**Question. For the four-city travelling salesman problem, the distance and pheromone matrices (A, B, C, D) are given. Apply Ant Colony Optimization. Calculate the path travelled by 2 ants to cover all cities starting from city A. Random numbers for Ant 1 are 0.3, 0.8 and for Ant 2 are 0.5, 0.7. Also update the pheromone matrix after 1 iteration.** [10 marks · Final Nov 2025 Q7b]

#### Given



$$
D=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&4&2&4\\B&4&0&3&6\\C&2&3&0&2\\D&4&6&2&0\end{array}\qquad \tau=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&1&1&1\\B&1&0&1&1\\C&1&1&0&1\\D&1&1&1&0\end{array}
$$



Assume 

$$
\alpha=\beta=1
$$

, 

$$
\rho=0.5
$$

, 

$$
Q=1
$$

 (class convention; not stated in the question).

#### To find

Tour of each ant, tour lengths, updated pheromone matrix.

Swipe across the diagram to read its labels ↔

![Final 2025 Q7b: distances (all pheromones start at 1)](https://deep-learning-study-room.vercel.app/is2/fig/aco_final_graph.ac3cd4aeac.svg)

Diagram: Final 2025 Q7b: distances (all pheromones start at 1). Labels: Final 2025 Q7b: distances (all pheromones start at 1) | 4 | 2 | 4 | 3 | 6 | 2 | A | B | C | D

#### Formula and why it applies



$$
P_{ij}=\frac{\tau_{ij}\,\eta_{ij}}{\sum_{l\in\text{allowed}}\tau_{il}\,\eta_{il}},\qquad\eta_{ij}=\frac1{d_{ij}}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}+\sum_{k:\,ij\in\mathrm{tour}_k}\frac{Q}{L_k}
$$



The sum includes **only ants whose completed tour contains edge ij**. An unused edge receives no deposit but still evaporates. Here distances are symmetric, so a traversed edge updates both symmetric matrix cells. Both ants construct their tours using the old pheromones; update after both finish, including their return to A.

#### Solution

##### Step 1. Probabilities from A (both ants start at A)



$$
\tau\eta:\;A\to B=1\times\tfrac14=0.25,\quad A\to C=1\times\tfrac12=0.5,\quad A\to D=1\times\tfrac14=0.25;\quad\text{sum}=1
$$



| Move | P | Cumulative | Range |
| --- | --- | --- | --- |
| A→B | 0.25 | 0.25 | 0–0.25 |
| A→C | 0.50 | 0.75 | 0.25–0.75 |
| A→D | 0.25 | 1.00 | 0.75–1 |

Ant 1: r = 0.3 → **C**. Ant 2: r = 0.5 → **C**.

##### Step 2. Probabilities from C (B and D left)



$$
C\to B=\tfrac13=0.3333,\quad C\to D=\tfrac12=0.5;\quad\text{sum}=0.8333\Rightarrow P_{CB}=0.4,\;P_{CD}=0.6
$$



Cumulative in city order: B 0–0.4, D 0.4–1. Ant 1: r = 0.8 → **D**. Ant 2: r = 0.7 → **D**.

##### Step 3. Complete the tours

Only B is left, then return to A.



$$
\text{Ant 1}=\text{Ant 2}:\;A\to C\to D\to B\to A,\qquad L=2+2+6+4=14
$$



Swipe across the diagram to read its labels ↔

![Both ants: A → C → D → B → A, length 14](https://deep-learning-study-room.vercel.app/is2/fig/aco_final_tour.1dbfdb8b98.svg)

Diagram: Both ants: A → C → D → B → A, length 14. Labels: Both ants: A → C → D → B → A, length 14 | 4 | 2 | 4 | 3 | 6 | 2 | A | B | C | D

##### Step 4. Pheromone update

Each ant deposits 

$$
Q/L=1/14=0.0714
$$

 on each edge of its tour; two ants used the same four edges (AC, CD, DB, BA), so each gets 

$$
2/14=0.1429
$$

.



$$
\text{used edge: }(1-0.5)(1)+0.1429=0.6429\qquad\text{unused edge (AD, BC): }(1-0.5)(1)+0=0.5
$$





$$
\tau_{\text{new}}=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&0.6429&0.6429&0.5\\B&0.6429&0&0.5&0.6429\\C&0.6429&0.5&0&0.6429\\D&0.5&0.6429&0.6429&0\end{array}
$$



**Final answer.** Both ants: A → C → D → B → A, length 14. Updated pheromone: 0.6429 on AB, AC, CD, BD; 0.5 on AD and BC. In the next iteration the ants will prefer the edges of this tour.

**Official key note.** The key's matrix shows 0.643 on AC, CD and BD but leaves AB at 0.5, i.e. it forgot to deposit on the return edge B → A even though it counted its length (4) in L = 14. Your slides deposit on the return edge, so AB = 0.6429 is correct. If you wish, write one line: “the return edge B–A is part of the tour, so it also receives Q/L.”

Official marking: path of Ant 1 (3) + path of Ant 2 (3) + pheromone matrix (4).

---

## TEE · Solved PYQ: ACO for a 4-city TSP (Re-exam 2026, 10 marks)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u3-aco--reexam-2026/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u3-aco/reexam-2026

Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers

**Question. For the four-city travelling salesman problem the distance matrix and pheromone matrix are given (all pheromones 1). Apply Ant Colony Optimization. Calculate the path travelled by 2 ants starting from city A; random numbers for Ant 1 are 0.3, 0.8 and for Ant 2 are 0.5, 0.7. Also update the pheromone matrix after 1 iteration.** [10 marks · Re-exam Jan 2026 Q6a]

#### Given



$$
D=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&1&2&3\\B&1&0&4&5\\C&2&4&0&6\\D&3&5&6&0\end{array},\qquad\tau_{ij}=1\;(i\ne j)
$$



Assume 

$$
\alpha=\beta=1,\;\rho=0.5,\;Q=1
$$

.

#### To find

Both tours, their lengths and the pheromone matrix after one iteration.

#### Formula and why it applies



$$
P_{ij}=\frac{\tau_{ij}^{\alpha}(1/d_{ij})^\beta}{\sum_{k\in allowed}\tau_{ik}^{\alpha}(1/d_{ik})^\beta}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}+\sum_{k:\,ij\in tour_k}\frac{Q}{L_k}
$$



Use unvisited cities in alphabetical order for cumulative selection. Every ant completes its tour using old pheromones; then evaporate and deposit on each undirected edge, including the return edge.

#### Solution

##### Step 1. From A



$$
\eta:\;B=1,\;C=0.5,\;D=0.3333;\;\text{sum}=1.8333\Rightarrow P=0.5455,\;0.2727,\;0.1818
$$



Cumulative: B 0–0.5455, C 0.5455–0.8182, D 0.8182–1. Ant 1 (0.3) → **B**; Ant 2 (0.5) → **B**.

##### Step 2. From B (C and D left)



$$
\eta:\;C=0.25,\;D=0.2;\;\text{sum}=0.45\Rightarrow P_{BC}=0.5556,\;P_{BD}=0.4444
$$



Cumulative: C 0–0.5556, D 0.5556–1. Ant 1 (0.8) → **D**; Ant 2 (0.7) → **D**.

##### Step 3. Complete the tours



$$
A\to B\to D\to C\to A,\qquad L=1+5+6+2=14\;\text{(both ants)}
$$



Swipe across the diagram to read its labels ↔

![Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14](https://deep-learning-study-room.vercel.app/is2/fig/aco_reexam_graph.02195c6ee9.svg)

Diagram: Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14. Labels: Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14 | 1 | 2 | 3 | 4 | 5 | 6 | A | B | C | D

##### Step 4. Pheromone update

Used edges AB, BD, DC, CA get 

$$
0.5(1)+2\times\frac1{14}=0.6429
$$

; unused edges AD and BC become 

$$
0.5
$$

.



$$
\tau_{\text{new}}=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&0.6429&0.6429&0.5\\B&0.6429&0&0.5&0.6429\\C&0.6429&0.5&0&0.6429\\D&0.5&0.6429&0.6429&0\end{array}
$$



**Final answer.** Both ants: A → B → D → C → A, length 14. Pheromone 0.6429 on AB, BD, CD, AC; 0.5 on AD, BC.

**Official key note.** This key applies *no evaporation* (

$$
1+0.1428=1.1428
$$

) and its matrix is inconsistent: it increases the unused edge A–D, leaves the used return edge C–A at 1, and gives B–D and D–B different values. If your examiner follows the no-evaporation idea, the consistent version is 1.1429 on AB, BD, CD, AC and 1 on AD, BC. The paper does not specify ρ. State the convention you use; the resulting matrix depends on it. Grading depends on the examiner’s intended convention.

---

## TEE · Practice: the lecture's Ant System example (two different tours)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u3-aco--lecture-example/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u3-aco/lecture-example

Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers

**Why do this:** in the papers both ants happened to take the same tour. In the class example they take different tours, which shows how the deposit adds up when two lengths differ.

**Question. Distances: AB = 5, AC = 6, AD = 7, BC = 2, BD = 9, CD = 3; all pheromones 1; 

$$
\alpha=\beta=1,\;\rho=0.5,\;Q=1
$$

. Two ants start at A. Ant 1 uses random numbers 0.45 then 0.5; Ant 2 uses 0.83 then 0.5. Find both tours and the updated pheromone matrix.** [lecture example · 10 marks]

#### Given

Symmetric distances AB=5, AC=6, AD=7, BC=2, BD=9, CD=3. Initial off-diagonal pheromone=1. α=β=1, ρ=0.5, Q=1. Ant draws: [0.45,0.5] and [0.83,0.5].

#### To find

Two complete tours and every updated edge pheromone.

#### Formula and why it applies

Prefer high pheromone and small distance, normalise over unvisited cities, then evaporate and deposit once per iteration.



$$
P_{ij}=\frac{\tau_{ij}^{\alpha}(1/d_{ij})^{\beta}}{\sum_{k\in allowed}\tau_{ik}^{\alpha}(1/d_{ik})^{\beta}}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}^{old}+\sum_{ants\ using\ ij}Q/L
$$



#### Solution

Swipe across the diagram to read its labels ↔

![Lecture example (Ant System): distances](https://deep-learning-study-room.vercel.app/is2/fig/aco_lecture_graph.629672bf56.svg)

Diagram: Lecture example (Ant System): distances. Labels: Lecture example (Ant System): distances | 5 | 6 | 7 | 2 | 9 | 3 | A | B | C | D

#### Solution

##### Step 1. From A



$$
\eta=\tfrac15,\tfrac16,\tfrac17=0.2,\;0.1667,\;0.1429;\;\text{sum}=0.5095\Rightarrow P=0.3925,\;0.3271,\;0.2804
$$



Cumulative: B 0–0.3925, C 0.3925–0.7196, D 0.7196–1. Ant 1 (0.45) → C. Ant 2 (0.83) → D.

##### Step 2. Ant 1 from C (B, D left)



$$
\eta=\tfrac12,\tfrac13\Rightarrow P_{CB}=0.6,\;P_{CD}=0.4
$$



r = 0.5 ≤ 0.6 → B; then D; then back to A.



$$
\text{Ant 1: }A\to C\to B\to D\to A,\quad L_1=6+2+9+7=24
$$



##### Step 3. Ant 2 from D (B, C left)



$$
\eta=\tfrac19,\tfrac13\Rightarrow P_{DB}=0.25,\;P_{DC}=0.75
$$



Cumulative B 0–0.25, C 0.25–1; r = 0.5 → C; then B; then A.



$$
\text{Ant 2: }A\to D\to C\to B\to A,\quad L_2=7+3+2+5=17
$$



##### Step 4. Deposits

| Edge | Used by | New τ |
| --- | --- | --- |
| AD, BC | both ants | 0.5 + 1/24 + 1/17 = 0.6005 |
| AC, BD | Ant 1 only | 0.5 + 1/24 = 0.5417 |
| AB, CD | Ant 2 only | 0.5 + 1/17 = 0.5588 |

**Final answer.** Ant 1: A-C-B-D-A (24); Ant 2: A-D-C-B-A (17). Ant 2's shorter tour deposits more (1/17 > 1/24), so its edges grow faster. AD and BC, used by both, end highest at 0.6005.

**Slide corrections.** The slide gives P(D→B) = 0.33 and P(D→C) = 0.66; the correct values are 0.25 and 0.75 (the choice of C does not change). The slide truncates 0.6005 and 0.5417 to 0.6004 and 0.5416.

## Write the requested final matrix

Ant 1 deposits 1/24≈.041666667; ant 2 deposits 1/17≈.058823529. Evaporation leaves .5 on every edge. Their shared edges AD and BC become .600490196. Ant-1-only edges AC and BD become .541666667; ant-2-only edges AB and CD become .558823529.



$$
\tau^{new}\approx\begin{bmatrix}0&.558823529&.541666667&.600490196\\.558823529&0&.600490196&.541666667\\.541666667&.600490196&0&.558823529\\.600490196&.541666667&.558823529&0\end{bmatrix}
$$



Row and column order is A,B,C,D. The diagonal 0 marks excluded self-edges. Off-diagonal entries mirror each other because this problem is undirected and symmetric.

---

## TEE · 5/10-mark answer: applications of ACO (explain one)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u3-aco--applications/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u3-aco/applications

Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers

**Asked as:** “List the applications of Ant Colony Optimization and explain any one application in detail.” [5 marks · Final 2025 Q1b; key: listing 3 + explanation 2]

### Definition (1 line)

Ant Colony Optimization is a probabilistic, population-based metaheuristic (Dorigo, 1992) in which artificial ants build solutions on a graph and communicate through pheromone trails. In the update rule used here, evaporation reduces all stored trails; deposits then reinforce edges of selected tours according to solution quality. Evaporation does not occur only on poor paths.

### Applications

1. **Travelling salesman problem**: shortest tour visiting every city once.
2. **Vehicle routing**: delivery routes for a fleet with capacity and time windows (minimising distance, time, fuel).
3. **Network routing**: adaptive routing of data packets in communication and sensor networks (AntNet).
4. **Job-shop and project scheduling**: assigning jobs to machines to minimise completion time.
5. **Image processing**: edge detection, with ants moving over pixel-intensity graphs.
6. **Assignment problems**: quadratic assignment, timetabling, graph colouring.
7. **Feature selection and data mining**: Ant-Miner for classification rules.
8. **Load balancing** in distributed systems and cloud task allocation.

### One application in detail: vehicle routing (or TSP)

1. **Graph.** Depot and customers are nodes; travel times or distances are edge weights.
2. **Ants.** Each ant builds a complete set of routes. From its current customer it chooses the next with probability 

$$
\propto\tau_{ij}\,(1/d_{ij})
$$

, skipping customers already served or that would exceed the vehicle capacity; when the vehicle is full it returns to the depot.
3. **Evaluation.** Total distance (plus penalties for late deliveries).
4. **Learning.** Pheromone evaporates everywhere and is added in proportion to 

$$
Q/L
$$

 on the routes of good solutions, so short connections are reinforced.
5. **Result.** Repeated iterations search for low-cost routes; finite-run convergence to the optimum is not guaranteed. Companies use this for parcel delivery, waste collection and school-bus routing.

### Advantages and limitations

| Advantages | Limitations |
| --- | --- |
| Naturally suited to graph and routing problems | Several parameters to tune (α, β, ρ, number of ants) |
| Can share useful route information and adapt search to changing graphs | Convergence time is uncertain; may stagnate on a sub-optimal path |
| Positive feedback + parallel ants | Theoretical analysis is difficult |

**Yaad rakho:** ACO = “raaste wale problems” (TSP, routing, scheduling). PSO = “numbers wale problems” (continuous function, weights).

---

## TEE · Swarm intelligence, particles, velocity, pbest and gbest

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/pso-core--meaning/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/pso-core/meaning

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

## Swarm intelligence

**Swarm intelligence** is collective problem-solving behaviour that emerges from interactions among many relatively simple agents and their environment. It is inspired by systems such as bird flocks, fish schools and ant colonies.

**Particle swarm optimization (PSO)** is a population-based search method inspired by social movement. Each particle represents a candidate solution. It moves through the search space using a velocity influenced by its own best previous position and the best position known to the swarm.

## Translate every PSO word into a concrete object

| Term | Meaning | Example |
| --- | --- | --- |
| Particle | One candidate solution | Particle A |
| Position x | The candidate’s coordinates | xA = 3 |
| Objective f(x) | The problem’s score for that candidate | f(3) = 3² = 9 |
| Velocity v | Proposed change of position | vA = −1 means move left by 1 |
| pbest | Best position that this particle has visited | A once visited x=1 with score 1 |
| gbest | Best position found by any particle | Among all personal bests, x=0.5 scores 0.25 |

Swipe across the diagram to read its labels ↔

![A best memory changes only when the new score improves.](https://deep-learning-study-room.vercel.app/is2/fig/v2_pso_memory.fcc9783a95.svg)

Diagram: A best memory changes only when the new score improves.. Labels: Best memory survives a worse move | Visit 1 | Position x = 3 | Score x² = 9 | Remember pbest = 3 | Visit 2 | Position x = 1 | Score x² = 1 | Remember pbest = 1 | Visit 3 | Position x = 2 | Score x² = 4 | Remember pbest = 1 | Minimise x²: after visiting x = 2, the best past position is still x = 1. | Current position and remembered best position are separate records.

A best memory changes only when the new score improves.

## Current position is not necessarily personal best

For minimising x², suppose a particle visits x=3, then x=1, then x=2. Its current position is 2, but its personal best stays 1 because 1² is less than 2². The particle remembers a better past result even after a bad move.

**A particle visits x=3, x=1, x=2 in that order while minimising f(x)=x². Find pbest after each visit.** [2 marks · Practice]

#### Given

Positions in chronological order: 3 → 1 → 2.

#### To find

The best-so-far position and score.

#### Formula and why it applies

Keep the location with the lowest objective encountered so far.

#### Solution

##### Step 1. First visit



$$
f(3)=9
$$



No history: pbest=3, best score=9.

##### Step 2. Second visit



$$
f(1)=1<9
$$



Replace pbest by 1.

##### Step 3. Third visit



$$
f(2)=4>1
$$



Keep pbest=1 even though the current position is 2.

**Final answer.** Final current position=2; pbest=1; personal-best score=1.

**Define swarm intelligence and briefly explain one nature-inspired algorithm.** [2 marks · Practice]

#### Answer

Swarm intelligence is collective problem-solving that emerges from interactions among simple agents. Particle swarm optimization is inspired by flocking behaviour. Each particle is a candidate solution with a position and velocity. It remembers its own best position and uses the swarm’s best position to guide movement. Repeated evaluation and movement search for a low-cost or high-fitness solution.

**Yaad rakho:** Position abhi kahan ho; pbest apna best past; gbest sabka best past.

---

## TEE · Read the PSO equation and work three individual updates

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/pso-core--equation/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/pso-core/equation

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

## First read the update in words

**New velocity = retained old velocity + pull toward personal best + pull toward the group best.** After finding that velocity, add it to the old position. You are calculating a movement, then applying it.

Swipe across the diagram to read its labels ↔

![A negative difference pulls toward a best position on the left.](https://deep-learning-study-room.vercel.app/is2/fig/depth_pso.88e9c2a672.svg)

Diagram: A negative difference pulls toward a best position on the left.. Labels: Read the direction before multiplying the pull | Best = 1 | Current = 4 | difference = 1 − 4 = −3 | coefficient 0.5 → pull 0.5 × (−3) = −1.5 (left)

A negative difference pulls toward a best position on the left.

Example: current x=4 and personal best=1 gives the difference 1−4=−3. A coefficient of .5 gives personal pull .5×(−3)=−1.5. The negative sign says “move left”; it does not mean a negative probability. If current x=−2 and best=1, the difference is 1−(−2)=1+2=3, which pulls right.

In vi,jt, i chooses the particle, j chooses its coordinate, and t chooses the recorded iteration. For particle B, coordinate 2, iteration 0, look at row B and the second velocity entry in the initial table. The letters identify a stored number; they are not extra multiplication factors.

## The velocity equation is three contributions added together



$$
v_{i,j}^{t+1}=w v_{i,j}^{t}+c_1r_1(pbest_{i,j}^{t}-x_{i,j}^{t})+c_2r_2(gbest_j^{t}-x_{i,j}^{t})
$$





$$
x_{i,j}^{t+1}=x_{i,j}^{t}+v_{i,j}^{t+1}
$$



| Symbol | Meaning |
| --- | --- |
| i | Which particle |
| j | Which coordinate of that particle |
| t / t+1 | Before / after this iteration; these are labels, not powers |
| w | Inertia weight: how much old velocity is kept |
| c₁r₁ | Combined strength of the pull to personal best |
| c₂r₂ | Combined strength of the pull to global best |
| r₁,r₂ | Random factors, normally in [0,1]; use the values supplied in an exam |

A best position to the left gives a negative difference and pulls left; a best position to the right gives a positive difference and pulls right. The multiplication sets the strength of each pull.

**For one coordinate, x=4, v=0, pbest=4, gbest=2. With w=0.5, c₁=c₂=1 and r₁=r₂=0.5, find the next velocity and position.** [3 marks · Practice]

#### Given

x=4, v=0, pbest=4, gbest=2; w=.5; c₁r₁=.5; c₂r₂=.5.

#### To find

New velocity followed by new position.

#### Formula and why it applies

Use the three-term velocity equation, then add the new velocity to x.



$$
v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)
$$



#### Solution

##### Step 1. Inertia



$$
0.5\times0=0
$$



##### Step 2. Personal pull



$$
0.5(4-(4))=0
$$



##### Step 3. Social pull



$$
0.5(2-(4))=-1
$$



##### Step 4. New velocity



$$
v_{new}=0+0+(-1)=-1
$$



##### Step 5. New position



$$
x_{new}=4+(-1)=3
$$



**Final answer.** vnew=-1; xnew=3.

**For one coordinate, x=4, v=-2, pbest=3, gbest=1. With w=0.5, c₁=c₂=1 and r₁=r₂=0.5, find the next velocity and position.** [3 marks · Practice]

#### Given

x=4, v=-2, pbest=3, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.

#### To find

New velocity followed by new position.

#### Formula and why it applies

Use the three-term velocity equation, then add the new velocity to x.



$$
v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)
$$



#### Solution

##### Step 1. Inertia



$$
0.5\times(-2)=-1
$$



##### Step 2. Personal pull



$$
0.5(3-(4))=-0.5
$$



##### Step 3. Social pull



$$
0.5(1-(4))=-1.5
$$



##### Step 4. New velocity



$$
v_{new}=(-1)+(-0.5)+(-1.5)=-3
$$



##### Step 5. New position



$$
x_{new}=4+(-3)=1
$$



**Final answer.** vnew=-3; xnew=1.

**For one coordinate, x=-2, v=1, pbest=-1, gbest=1. With w=0.5, c₁=c₂=1 and r₁=r₂=0.5, find the next velocity and position.** [3 marks · Practice]

#### Given

x=-2, v=1, pbest=-1, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.

#### To find

New velocity followed by new position.

#### Formula and why it applies

Use the three-term velocity equation, then add the new velocity to x.



$$
v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)
$$



#### Solution

##### Step 1. Inertia



$$
0.5\times1=0.5
$$



##### Step 2. Personal pull



$$
0.5(-1-(-2))=0.5
$$



##### Step 3. Social pull



$$
0.5(1-(-2))=1.5
$$



##### Step 4. New velocity



$$
v_{new}=0.5+0.5+1.5=2.5
$$



##### Step 5. New position



$$
x_{new}=(-2)+2.5=0.5
$$



**Final answer.** vnew=2.5; xnew=0.5.

**First-iteration shortcut:** if pbest was just initialised to x, the personal difference is zero. This follows from the initialisation; it is not a permanent property of PSO. A gbest particle can still move because its inertia term can be nonzero.

**Yaad rakho:** Old speed ka hissa + apne best ki pull + group best ki pull; phir new speed ko position mein add.

---

## TEE · Two particles, two iterations: start with the simplest minimisation

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/pso-core--two-particles/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/pso-core/two-particles

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

A synchronous iteration is a class photograph of the old swarm: every particle uses that same snapshot of gbest. First calculate all new positions, then compare all new scores and update memories. If particle A discovers a better position halfway through the calculations, B still uses the previous snapshot during this iteration. B can use the improved gbest in the next iteration.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

**Minimise 

$$
f(x)=x^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (-2) | (0) |
| B | (4) | (0) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(-2)=(-2)^2=4=4
$$



**Particle B**



$$
f(4)=4^2=16=16
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(-2)
$$



Its score is 4. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (-2). pbest values are A: (-2), B: (4).

##### Step 4. Iteration 1: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=-2-(-2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-2-(-2)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=(-2)+0=-2
$$



##### Step 5. Iteration 1: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=4-(4)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=-2-(4)=-6
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-6)=-3
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-3)=-3
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=4+(-3)=1
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(-2)=(-2)^2=4=4
$$



**Particle B**



$$
f(1)=1^2=1=1
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 4 | 4 | Keep old: tie | (-2) |
| B | 16 | 1 | Replace: new score is lower | (1) |

Compare the retained pbest scores. gbest = **(1)**, with objective **1**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (-2) | (0) | (-2) |
| B | (1) | (-3) | (1) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (-2), B: (1).

##### Step 10. Iteration 2: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=-2-(-2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(-2)=3
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(3)=1.5
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+1.5=1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=(-2)+1.5=-0.5
$$



##### Step 11. Iteration 2: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-3)=-1.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=(-1.5)+0+0=-1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1+(-1.5)=-0.5
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(-0.5)=(-0.5)^2=0.25=0.25
$$



**Particle B**



$$
f(-0.5)=(-0.5)^2=0.25=0.25
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 4 | 0.25 | Replace: new score is lower | (-0.5) |
| B | 1 | 0.25 | Replace: new score is lower | (-0.5) |

Compare the retained pbest scores. gbest = **(-0.5)**, with objective **0.25**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (-0.5) | (1.5) | (-0.5) |
| B | (-0.5) | (-1.5) | (-0.5) |

**Final answer.** After iteration 2, gbest = (-0.5), objective = 0.25. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

---

## TEE · A worse move: pbest stays in the past

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/pso-core--memory-matters/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/pso-core/memory-matters

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

**Minimise 

$$
f(x)=x^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (1) | (4) |
| B | (3) | (-1) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(1)=1^2=1=1
$$



**Particle B**



$$
f(3)=3^2=9=9
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(1)
$$



Its score is 1. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (1), B: (3).

##### Step 4. Iteration 1: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times4=2
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=2+0+0=2
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=1+2=3
$$



##### Step 5. Iteration 1: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1)=-0.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3-(3)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(3)=-2
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-2)=-1
$$



Add the three velocity contributions.



$$
v^{(1)}=(-0.5)+0+(-1)=-1.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=3+(-1.5)=1.5
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(3)=3^2=9=9
$$



**Particle B**



$$
f(1.5)=1.5^2=2.25=2.25
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 9 | Keep old: new score is worse | (1) |
| B | 9 | 2.25 | Replace: new score is lower | (1.5) |

Compare the retained pbest scores. gbest = **(1)**, with objective **1**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (3) | (2) | (1) |
| B | (1.5) | (-1.5) | (1.5) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (1). pbest values are A: (1), B: (1.5).

##### Step 10. Iteration 2: update particle A

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times2=1
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(3)=-2
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(-2)=-1
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(3)=-2
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-2)=-1
$$



Add the three velocity contributions.



$$
v^{(2)}=1+(-1)+(-1)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=3+(-1)=2
$$



##### Step 11. Iteration 2: update particle B

**Only coordinate**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1.5)=-0.75
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1.5-(1.5)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1.5)=-0.5
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-0.5)=-0.25
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.75)+0+(-0.25)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1.5+(-1)=0.5
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(2)=2^2=4=4
$$



**Particle B**



$$
f(0.5)=0.5^2=0.25=0.25
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 1 | 4 | Keep old: new score is worse | (1) |
| B | 2.25 | 0.25 | Replace: new score is lower | (0.5) |

Compare the retained pbest scores. gbest = **(0.5)**, with objective **0.25**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (2) | (-1) | (1) |
| B | (0.5) | (-1) | (0.5) |

**Final answer.** After iteration 2, gbest = (0.5), objective = 0.25. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

**Yaad rakho:** Naya result kharab ho toh position toh badlegi, pbest nahi.

---

## TEE · Two-dimensional PSO: keep the coordinates separate

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/pso-core--two-coordinates/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/pso-core/two-coordinates

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

A two-dimensional particle has two entries in its position and two in its velocity. Apply the scalar velocity calculation once to coordinate 1 and once to coordinate 2. Keep them in the same order to form the new pair. Only after both entries are ready do you insert the pair into f(x₁,x₂). Adding x₁ and x₂ into a single position would lose information.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

**Minimise 

$$
f(x)=x_1^2+x_2^2
$$

 using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [3 marks · Practice; expanded teaching solution]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (1, 1) | (0, 0) |
| B | (3, 2) | (0, 0) |

w=0.5, c₁=1, c₂=1, r₁=0.5, r₂=0.5. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



**Particle B**



$$
f(3, 2)=3^2+2^2=9+4=13
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(1, 1)
$$



Its score is 2. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (3, 2).

##### Step 4. Iteration 1: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=1+0=1
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=1+0=1
$$



##### Step 5. Iteration 1: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3-(3)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(3)=-2
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-2)=-1
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-1)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=3+(-1)=2
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=2-(2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(2)=-1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-1)=-0.5
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-0.5)=-0.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=2+(-0.5)=1.5
$$



##### Step 6. Iteration 1: evaluate the new positions

**Particle A**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



**Particle B**



$$
f(2, 1.5)=2^2+1.5^2=4+2.25=6.25
$$



##### Step 7. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 2 | 2 | Keep old: tie | (1, 1) |
| B | 13 | 6.25 | Replace: new score is lower | (2, 1.5) |

Compare the retained pbest scores. gbest = **(1, 1)**, with objective **2**.

##### Step 8. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (1, 1) | (0, 0) | (1, 1) |
| B | (2, 1.5) | (-1, -0.5) | (2, 1.5) |

##### Step 9. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (2, 1.5).

##### Step 10. Iteration 2: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1+0=1
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1-(1)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(2)}=0+0+0=0
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1+0=1
$$



##### Step 11. Iteration 2: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-1)=-0.5
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=2-(2)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(2)=-1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-1)=-0.5
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.5)+0+(-0.5)=-1
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=2+(-1)=1
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-0.5)=-0.25
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=1.5-(1.5)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1\times0.5=0.5
$$





$$
C=0.5\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=1-(1.5)=-0.5
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1\times0.5=0.5
$$





$$
S=0.5\times(-0.5)=-0.25
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.25)+0+(-0.25)=-0.5
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=1.5+(-0.5)=1
$$



##### Step 12. Iteration 2: evaluate the new positions

**Particle A**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



**Particle B**



$$
f(1, 1)=1^2+1^2=1+1=2
$$



##### Step 13. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 2 | 2 | Keep old: tie | (1, 1) |
| B | 6.25 | 2 | Replace: new score is lower | (1, 1) |

Compare the retained pbest scores. gbest = **(1, 1)**, with objective **2**.

##### Step 14. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (1, 1) | (0, 0) | (1, 1) |
| B | (1, 1) | (-1, -0.5) | (1, 1) |

**Final answer.** After iteration 2, gbest = (1, 1), objective = 2. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

---

## TEE · Class PSO photograph: all three particles through iteration 2

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/pso-core--class-three-particles/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/pso-core/class-three-particles

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

Work down the page: each particle is fully updated, then all scores and memories are compared. Keep at least six digits internally for longer decimal examples; the final table displays rounded values.

The positions, velocities and coefficients are transcribed from the class photo. We use f(x₁,x₂)=x₁²+x₂²−x₁x₂, minimisation, initial pbest=x, fixed supplied random factors and synchronous updates. The photo does not itself specify all these conventions; they are stated here to make the two-iteration extension unambiguous.

**Minimise 

$$
f(x)=x_1^2+x_2^2-x_1x_2
$$

 using 3 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.** [10 marks · Class data; two-iteration minimisation extension]

#### Given

| Particle | Initial position x⁰ | Initial velocity v⁰ |
| --- | --- | --- |
| A | (3.14, 7.21) | (0.1, 0.3) |
| B | (4.15, 7.31) | (0.5, 0.1) |
| C | (6.17, 8.27) | (0.2, 0) |

w=0.5, c₁=1.2, c₂=1.2, r₁=0.5, r₂=0.1. Initialise each pbest at its initial position. Use these random coefficients unchanged in both iterations. No bounds or velocity clamp are imposed in this example. Updates are synchronous: every particle uses the same previous-iteration gbest.

#### To find

The complete swarm state after iterations 1 and 2, and the best location found.

#### Formula and why it applies

PSO combines inertia, personal memory and shared memory. Subtract positions coordinate by coordinate. Evaluate the objective only after moving. For minimisation, replace a best only when its score decreases.



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$





$$
x^{t+1}=x^t+v^{t+1}
$$



#### Solution

##### Step 1. Evaluate every initial position

**Particle A**



$$
f(3.14, 7.21)=3.14^2+7.21^2-(3.14)(7.21)
$$





$$
=9.8596+51.9841-22.6394=39.2043
$$



**Particle B**



$$
f(4.15, 7.31)=4.15^2+7.31^2-(4.15)(7.31)
$$





$$
=17.2225+53.4361-30.3365=40.3221
$$



**Particle C**



$$
f(6.17, 8.27)=6.17^2+8.27^2-(6.17)(8.27)
$$





$$
=38.0689+68.3929-51.0259=55.4359
$$



##### Step 2. Initialise the memories

pbest is each initial position because there is no earlier history. The smallest objective decides gbest.



$$
gbest^0=(3.14, 7.21)
$$



Its score is 39.2043. Store the position, not only the score.

##### Step 3. Iteration 1: freeze the previous memories

All particles in this iteration use gbest = (3.14, 7.21). pbest values are A: (3.14, 7.21), B: (4.15, 7.31), C: (6.17, 8.27).

##### Step 4. Iteration 1: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.1=0.05
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3.14-(3.14)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(3.14)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0.05+0+0=0.05
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=3.14+0.05=3.19
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.3=0.15
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.21-(7.21)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.21)=0
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(0)=0
$$



Add the three velocity contributions.



$$
v^{(1)}=0.15+0+0=0.15
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=7.21+0.15=7.36
$$



##### Step 5. Iteration 1: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.5=0.25
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=4.15-(4.15)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(4.15)=-1.01
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-1.01)=-0.1212
$$



Add the three velocity contributions.



$$
v^{(1)}=0.25+0+(-0.1212)=0.1288
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=4.15+0.1288=4.2788
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.1=0.05
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.31-(7.31)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.31)=-0.1
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.1)=-0.012
$$



Add the three velocity contributions.



$$
v^{(1)}=0.05+0+(-0.012)=0.038
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=7.31+0.038=7.348
$$



##### Step 6. Iteration 1: update particle C

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.2=0.1
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=6.17-(6.17)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(6.17)=-3.03
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-3.03)=-0.3636
$$



Add the three velocity contributions.



$$
v^{(1)}=0.1+0+(-0.3636)=-0.2636
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=6.17+(-0.2636)=5.9064
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0=0
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=8.27-(8.27)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(8.27)=-1.06
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-1.06)=-0.1272
$$



Add the three velocity contributions.



$$
v^{(1)}=0+0+(-0.1272)=-0.1272
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(1)}=8.27+(-0.1272)=8.1428
$$



##### Step 7. Iteration 1: evaluate the new positions

**Particle A**



$$
f(3.19, 7.36)=3.19^2+7.36^2-(3.19)(7.36)
$$





$$
=10.1761+54.1696-23.4784=40.8673
$$



**Particle B**



$$
f(4.2788, 7.348)=4.2788^2+7.348^2-(4.2788)(7.348)
$$





$$
=18.30812944+53.993104-31.4406224=40.86061104
$$



**Particle C**



$$
f(5.9064, 8.1428)=5.9064^2+8.1428^2-(5.9064)(8.1428)
$$





$$
=34.88556096+66.30519184-48.09463392=53.09611888
$$



##### Step 8. Iteration 1: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 39.2043 | 40.8673 | Keep old: new score is worse | (3.14, 7.21) |
| B | 40.3221 | 40.86061104 | Keep old: new score is worse | (4.15, 7.31) |
| C | 55.4359 | 53.09611888 | Replace: new score is lower | (5.9064, 8.1428) |

Compare the retained pbest scores. gbest = **(3.14, 7.21)**, with objective **39.2043**.

##### Step 9. Iteration 1: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (3.19, 7.36) | (0.05, 0.15) | (3.14, 7.21) |
| B | (4.2788, 7.348) | (0.1288, 0.038) | (4.15, 7.31) |
| C | (5.9064, 8.1428) | (-0.2636, -0.1272) | (5.9064, 8.1428) |

##### Step 10. Iteration 2: freeze the previous memories

All particles in this iteration use gbest = (3.14, 7.21). pbest values are A: (3.14, 7.21), B: (4.15, 7.31), C: (5.9064, 8.1428).

##### Step 11. Iteration 2: update particle A

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.05=0.025
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=3.14-(3.19)=-0.05
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.05)=-0.03
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(3.19)=-0.05
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.05)=-0.006
$$



Add the three velocity contributions.



$$
v^{(2)}=0.025+(-0.03)+(-0.006)=-0.011
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=3.19+(-0.011)=3.179
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.15=0.075
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.21-(7.36)=-0.15
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.15)=-0.09
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.36)=-0.15
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.15)=-0.018
$$



Add the three velocity contributions.



$$
v^{(2)}=0.075+(-0.09)+(-0.018)=-0.033
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=7.36+(-0.033)=7.327
$$



##### Step 12. Iteration 2: update particle B

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.1288=0.0644
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=4.15-(4.2788)=-0.1288
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.1288)=-0.07728
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(4.2788)=-1.1388
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-1.1388)=-0.136656
$$



Add the three velocity contributions.



$$
v^{(2)}=0.0644+(-0.07728)+(-0.136656)=-0.149536
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=4.2788+(-0.149536)=4.129264
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times0.038=0.019
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=7.31-(7.348)=-0.038
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(-0.038)=-0.0228
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(7.348)=-0.138
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.138)=-0.01656
$$



Add the three velocity contributions.



$$
v^{(2)}=0.019+(-0.0228)+(-0.01656)=-0.02036
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=7.348+(-0.02036)=7.32764
$$



##### Step 13. Iteration 2: update particle C

**Coordinate 1**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-0.2636)=-0.1318
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=5.9064-(5.9064)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=3.14-(5.9064)=-2.7664
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-2.7664)=-0.331968
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.1318)+0+(-0.331968)=-0.463768
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=5.9064+(-0.463768)=5.442632
$$



**Coordinate 2**

Inertia = keep a fraction of the old velocity.



$$
I=0.5\times(-0.1272)=-0.0636
$$



Personal pull: first subtract the current coordinate from the personal-best coordinate.



$$
d_p=8.1428-(8.1428)=0
$$



Multiply the two personal coefficients, then multiply by the difference.



$$
c_1r_1=1.2\times0.5=0.6
$$





$$
C=0.6\times(0)=0
$$



Social pull: subtract the current coordinate from the frozen global-best coordinate.



$$
d_g=7.21-(8.1428)=-0.9328
$$



Multiply the social coefficients, then multiply by that difference.



$$
c_2r_2=1.2\times0.1=0.12
$$





$$
S=0.12\times(-0.9328)=-0.111936
$$



Add the three velocity contributions.



$$
v^{(2)}=(-0.0636)+0+(-0.111936)=-0.175536
$$



Add the new velocity to the old position. The parenthesised upper label is the iteration number.



$$
x^{(2)}=8.1428+(-0.175536)=7.967264
$$



##### Step 14. Iteration 2: evaluate the new positions

**Particle A**



$$
f(3.179, 7.327)=3.179^2+7.327^2-(3.179)(7.327)
$$





$$
=10.106041+53.684929-23.292533=40.498437
$$



**Particle B**



$$
f(4.129264, 7.32764)=4.129264^2+7.32764^2-(4.129264)(7.32764)
$$





$$
=17.050821182+53.69430797-30.257760057=40.487369094
$$



**Particle C**



$$
f(5.442632, 7.967264)=5.442632^2+7.967264^2-(5.442632)(7.967264)
$$





$$
=29.622243087+63.477295646-43.362885999=49.736652734
$$



##### Step 15. Iteration 2: update pbest, then gbest

| Particle | Old pbest score | New score | Decision | pbest position |
| --- | --- | --- | --- | --- |
| A | 39.2043 | 40.498437 | Keep old: new score is worse | (3.14, 7.21) |
| B | 40.3221 | 40.487369094 | Keep old: new score is worse | (4.15, 7.31) |
| C | 53.09611888 | 49.736652734 | Replace: new score is lower | (5.442632, 7.967264) |

Compare the retained pbest scores. gbest = **(3.14, 7.21)**, with objective **39.2043**.

##### Step 16. Iteration 2: record the complete state

| Particle | Position | Velocity | pbest |
| --- | --- | --- | --- |
| A | (3.179, 7.327) | (-0.011, -0.033) | (3.14, 7.21) |
| B | (4.129264, 7.32764) | (-0.149536, -0.02036) | (4.15, 7.31) |
| C | (5.442632, 7.967264) | (-0.463768, -0.175536) | (5.442632, 7.967264) |

**Final answer.** After iteration 2, gbest = (3.14, 7.21), objective = 39.2043. This is the best found in these two iterations, not a claim that PSO has proved the global optimum.

Swipe across the diagram to read its labels ↔

![Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.](https://deep-learning-study-room.vercel.app/is2/fig/v2_pso_class_paths.961831cda1.svg)

Diagram: Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.. Labels: 3 | 3.5 | 4 | 4.5 | 5 | 5.5 | 6 | 6.5 | 7 | 7.5 | 8 | 8.5 | Class PSO: positions after each iteration | 0 = initial, 1 = iteration 1, 2 = iteration 2 | A0 | A1 | A2 | B0 | B1 | B2 | C0 | C1 | C2 | First coordinate x₁ | The best-so-far location remains A0 = (3.14, 7.21) after both iterations.

Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.

---

## TEE · PSO algorithm, architecture, advantages and limitations

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/pso-core--theory/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/pso-core/theory

First understand position, velocity and memory; then solve complete two-iteration minimisation examples.

## Algorithm you can write in an exam

1. Define the objective and whether to minimise or maximise it. Initialise particle positions and velocities.
2. Evaluate every particle. Set each pbest to its initial position and gbest to the best among them.
3. Use the previous state to calculate each new velocity.
4. Update each position using that new velocity. Apply bounds or a velocity limit only according to the stated policy.
5. Evaluate the new positions. Update a pbest only when the new objective is better; choose gbest from the personal bests.
6. Repeat until the iteration budget or another stopping criterion is reached.

Initialise

→

Evaluate + memories

→

Velocity

→

Position

→

Evaluate + update memoriesrepeat until stopping

| Advantages | Limitations |
| --- | --- |
| Simple position/velocity updates; does not require objective derivatives | Can converge prematurely to a local region |
| Uses both individual and shared experience | Results depend on coefficients, initialisation and random factors |
| Useful for many continuous optimisation problems | Constraints and discrete encodings need suitable handling |
| Keeps best-so-far memories | Does not guarantee the global optimum in a finite run |

**Explain one application of PSO.** [3 marks · Practice]

#### Answer

In controller tuning, a particle can represent the gain values of a controller. The objective is a performance cost, such as tracking error plus an overshoot penalty. Each proposed gain vector is evaluated in the model. PSO updates candidate gains using individual and swarm bests. The best feasible gains found are selected and then validated on the actual system. A lower training cost alone does not prove safe real-world behaviour.

| Exam situation | Action |
| --- | --- |
| Minimisation | Lower f is better |
| Maximisation | Higher f is better; do not reverse velocity differences |
| Tie in best score | Keep the previous best unless a tie rule is supplied |
| Different random factors each iteration | Read the relevant row; do not reuse old factors |
| Synchronous update | Freeze gbest for all particles within one iteration |
| Position/velocity outside a limit | Use the limit-handling rule explicitly supplied; state an assumption if absent |

**Yaad rakho:** Velocity → position → score → pbest → gbest. Ye order har iteration mein same.

---

## TEE · Reinforcement learning: learning from rewards

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-rl--what-is-rl/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-rl/what-is-rl

Unit 4 · Introduction to reinforcement learning · TEE

## One interaction, with every word attached to a value

| Time | Current state | Chosen action | Observed reward | Next state |
| --- | --- | --- | --- | --- |
| 0 | Robot in room A | Move right | −1 for the move | Room B |
| 1 | Room B | Pick up parcel | +5 for pickup | Carrying parcel |
| 2 | Carrying parcel | Finish | +2 for delivery | Terminal |

The agent is the robot; the environment supplies the next state and reward after an action. A policy tells the robot which action to take in each state. An episode is one run up to termination. The immediate reward at time 0 is −1; the undiscounted return for the whole displayed run is −1+5+2=6. A value estimates future return, not just the next reward.

For ε-greedy with two actions, ε=.1 and a unique greedy action: exploit that action with probability .9; during the remaining .1, select uniformly from both actions. Thus the greedy action has probability .9+.1/2=.95 and the other .05. If a question uses a different exploration convention, follow that definition.

**In one line:** an agent learns what to do by trying actions, receiving rewards, and adjusting its behaviour so that the total reward over time is as large as possible.

## Definition (write this in the exam)

**Reinforcement learning (RL)** is a type of machine learning in which an **agent** learns a **policy**, a rule that maps situations (**states**) to **actions**, by interacting with an **environment**. After every action the environment returns a numerical **reward** and a new state. The agent's goal is to maximise the **expected cumulative (discounted) reward**, called the **return**. No labelled “correct action” is given; the agent discovers good actions by trial and error.

Swipe across the diagram to read its labels ↔

![At time t the agent sees state S t , chooses action A t ; the environment replies with reward R t+1 and next state S t+1 .](https://deep-learning-study-room.vercel.app/is2/fig/rl_loop_full.a9937cb961.svg)

Diagram: At time t the agent sees state S t , chooses action A t ; the environment replies with reward R t+1 and next state S t+1 .. Labels: One time-step of reinforcement learning | Agent | policy π(a | s) | Environment | P(s′ | s, a), R | action Aₜ | next state Sₜ₊₁ and reward Rₜ₊₁ | The loop repeats: S₀, A₀, R₁, S₁, A₁, R₂, S₂, …

At time t the agent sees state St, chooses action At; the environment replies with reward Rt+1 and next state St+1.

## The vocabulary you must know

| Term | Meaning | Example: a robot vacuum |
| --- | --- | --- |
| **Agent** | The learner and decision maker. | The vacuum's controller. |
| **Environment** | Everything outside the agent that responds to its actions. | The room, furniture, dust. |
| **State 

$$
s
$$

** | A description of the current situation. | Position + battery level. |
| **Action 

$$
a
$$

** | A choice the agent can make in a state. | Forward, turn left, return to dock. |
| **Reward 

$$
r
$$

** | Immediate scalar feedback after an action. | +1 per dust patch, −10 for hitting a wall. |
| **Policy 

$$
\pi
$$

** | The agent's behaviour: 

$$
\pi(a\mid s)
$$

 = probability of action 

$$
a
$$

 in state 

$$
s
$$

. | “If battery < 15%, go to dock.” |
| **Return 

$$
G_t
$$

** | Total discounted reward from time 

$$
t
$$

 onward. | All future dust collected, minus penalties. |
| **Value 

$$
v(s)
$$

** | Expected return starting from state 

$$
s
$$

. | How good it is to be at the centre with a full battery. |
| **Model** | The agent's knowledge of 

$$
P(s'\mid s,a)
$$

 and 

$$
R
$$

 (optional). | A map of the room. |

## Four elements of an RL system (Sutton and Barto)

1. **Policy**: defines behaviour (state → action).
2. **Reward signal**: defines the goal; the immediate desirability of a step.
3. **Value function**: long-term desirability of a state (what reward is expected later).
4. **Model of the environment** (optional): predicts the next state and reward, used for planning. Methods with a model are *model-based*; without one, *model-free* (for example, Q-learning).

## How RL differs from other learning

|  | Supervised | Unsupervised | Reinforcement |
| --- | --- | --- | --- |
| Feedback | Correct label for every input | None | A reward, often delayed |
| Goal | Predict labels | Find structure (clusters) | Maximise long-term return |
| Data | Fixed dataset (i.i.d.) | Fixed dataset | Generated by the agent's own actions (sequential) |
| Example | Spam classifier | Customer segments (GMM) | Game-playing agent |

## Two ideas that make RL special

**Delayed reward.** A move in chess earns nothing now but may win the game 30 moves later. RL must assign credit to earlier actions.

**Exploration versus exploitation.** To earn reward the agent should *exploit* the best action it knows, but to find better actions it must *explore* untried ones. A common rule is **ε-greedy**: with probability 

$$
1-\varepsilon
$$

 take the best-known action; with probability 

$$
\varepsilon
$$

 take a random one.

**Yaad rakho:** Agent karta hai, environment batata hai (reward + next state), policy decide karti hai, value future ka hisaab rakhti hai.

---

## TEE · Markov property, transition matrix and state diagram

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-markov--markov-chain/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-markov/markov-chain

Unit 4 · Markov processes · asked in every recent paper (5 and 10 marks)

A state is the current category, such as Savings or Current. A transition is one step from one category to another. The Markov assumption says that, once the current state is known, older states provide no additional information about the next-state probabilities in this model. It does not claim that the past never mattered; the current state must capture the relevant information.

**In one line:** in a Markov process the next state depends only on the present state, so the whole system is described by one table of “from → to” probabilities.

## Definitions

**Markov property.** A sequence of states 

$$
S_1, S_2, \dots
$$

 has the Markov property if the future is independent of the past given the present:



$$
P(S_{t+1}\mid S_t, S_{t-1},\dots,S_1)=P(S_{t+1}\mid S_t)
$$



**Markov process (Markov chain).** A memoryless random process given by a pair 

$$
\langle \mathcal S, P\rangle
$$

: a finite set of states 

$$
\mathcal S
$$

 and a **transition probability matrix** 

$$
P
$$

 with entries



$$
P_{ij}=P(S_{t+1}=j\mid S_t=i)
$$



Row 

$$
i
$$

 is the state you are **in now** (“from”); column 

$$
j
$$

 is the state you go **to next**. Two rules always hold:

1. Every entry is between 0 and 1: 

$$
0\le P_{ij}\le 1
$$

.
2. Every row sums to 1: 

$$
\sum_j P_{ij}=1
$$

 (from any state you must go somewhere, possibly staying).

A **state transition diagram** draws each state as a circle and each non-zero 

$$
P_{ij}
$$

 as an arrow from 

$$
i
$$

 to 

$$
j
$$

 labelled with the probability. Staying in the same state is a self-loop.

**Exam trap.** Rows are “from”, columns are “to”. “20% of Savings switch to Current” goes in row Savings, column Current. Always check that each row adds to 1 before moving on; an inconsistent row needs clarification before it can represent a probability distribution.

**Question. A survey shows that users switch between Brand X and Brand Y each year: 25% of Brand X users switch to Brand Y and 75% remain with X; 40% of Brand Y users switch to X and 60% remain with Y. (a) Write the transition probability matrix. (b) Draw the state transition diagram.** [5 marks · Final Nov 2025 Q1d]

#### Given

Two states: X, Y. From X: stay 0.75, to Y 0.25. From Y: to X 0.40, stay 0.60.

#### To find

Matrix 

$$
P
$$

 and its diagram.

#### Formula and why it applies



$$
P_{ij}=P(\text{next}=j\mid\text{now}=i)
$$

. Each yearly switch depends only on the brand used this year, so the process is Markov.

#### Solution

##### Step 1. Order the states and fill row by row



$$
P=\begin{array}{c|cc} & X & Y\\\hline X & 0.75 & 0.25\\ Y & 0.40 & 0.60\end{array}\qquad\text{i.e. } P=\begin{bmatrix}0.75&0.25\\0.40&0.60\end{bmatrix}
$$



##### Step 2. Check the rows

Row X: 0.75 + 0.25 = 1. Row Y: 0.40 + 0.60 = 1. Valid.

##### Step 3. Draw the diagram

Swipe across the diagram to read its labels ↔

![Self-loops carry the retention probabilities (0.75, 0.6); the arrows between states carry the switching probabilities.](https://deep-learning-study-room.vercel.app/is2/fig/mk_brand.c2c4be3e6a.svg)

Diagram: Self-loops carry the retention probabilities (0.75, 0.6); the arrows between states carry the switching probabilities.. Labels: Brand switching each year | 0.25 | 0.4 | 0.75 | 0.6 | X | Y

Self-loops carry the retention probabilities (0.75, 0.6); the arrows between states carry the switching probabilities.

**Final answer.** 

$$
P=\begin{bmatrix}0.75&0.25\\0.40&0.60\end{bmatrix}
$$

 with the diagram above.

Marking in the official key: matrix 3 marks, diagram 2 marks.

**Question. A bank offers Savings and Current accounts. Each year 20% of Savings holders switch to Current and 80% stay; 10% of Current holders switch to Savings and 90% stay. (a) Construct the transition probability matrix. (b) Draw the state diagram.** [5 marks · Re-exam Jan 2026 Q1d]

#### Given

For Savings: stay 80%, switch 20%. For Current: switch to Savings 10%, stay 90%. State order: Savings, Current.

#### To find

The transition matrix and labelled state diagram.

#### Formula and why it applies



$$
P_{ij}=P(S_{t+1}=j\mid S_t=i)
$$



Convert percentages to fractions of 100. A row fixes the present state, while columns list possible destinations.

#### Solution

##### Step 1. Matrix (rows = this year, columns = next year)



$$
P=\begin{array}{c|cc} & S & C\\\hline S & 0.80 & 0.20\\ C & 0.10 & 0.90\end{array}
$$



##### Step 2. Diagram

Swipe across the diagram to read its labels ↔

![Savings (S) and Current (C) accounts per year](https://deep-learning-study-room.vercel.app/is2/fig/mk_bank.879499f6eb.svg)

Diagram: Savings (S) and Current (C) accounts per year. Labels: Savings (S) and Current (C) accounts per year | 0.2 | 0.1 | 0.8 | 0.9 | S | C

**Final answer.** 

$$
P=\begin{bmatrix}0.8&0.2\\0.1&0.9\end{bmatrix}
$$

; diagram as shown. Each part carries 2.5 marks in the key.

**Yaad rakho:** Row = “abhi kahan ho”, column = “kal kahan jaoge”. Har row ka total 1.

---

## TEE · Next-step and n-step distributions

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-markov--next-step/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-markov/next-step

Unit 4 · Markov processes · asked in every recent paper (5 and 10 marks)

**A bank has 60 Savings customers and 40 Current customers. In one period, 80% of Savings stay and 20% switch to Current; 10% of Current switch to Savings and 90% stay. Find expected counts after one and two periods.** [3 marks · Worked example]

#### Given



$$
P=\begin{bmatrix}0.8&0.2\\0.1&0.9\end{bmatrix}
$$



Row/column order is Savings, Current; initial counts [60,40].

#### To find

Two successive count vectors.

#### Formula and why it applies

Each destination receives incoming contributions from every origin. Multiply origin count by the corresponding transition probability, then add.

#### Solution

##### Step 1. Period 1: contributions to Savings



$$
60\times0.8=48\qquad40\times0.1=4
$$





$$
S_1=48+4=52
$$



##### Step 2. Period 1: contributions to Current



$$
60\times0.2=12\qquad40\times0.9=36
$$





$$
C_1=12+36=48
$$



##### Step 3. Period 2: use the new counts [52,48]



$$
S_2=52\times0.8+48\times0.1=41.6+4.8=46.4
$$



##### Step 4. Period 2: second destination



$$
C_2=52\times0.2+48\times0.9=10.4+43.2=53.6
$$



**Final answer.** After one period [52,48]; after two [46.4,53.6]. Each total is 100. Fractional counts are expectations, not split people.

Matrix notation [60,40]P is shorthand for these destination-column calculations. P² means P multiplied by P using row-by-column multiplication; it does not mean squaring every individual entry.

**In one line:** write today's numbers as a row, multiply by the matrix, and you get tomorrow's numbers.

## The rule

Let 

$$
x_t
$$

 be a **row vector** of today's shares (or counts) in each state, in the same order as the matrix rows. Then



$$
x_{t+1}=x_t\,P,\qquad x_{t+n}=x_t\,P^{\,n}
$$



Entry 

$$
j
$$

 of 

$$
x_{t+1}
$$

 is the **column 

$$
j
$$

** calculation: everyone who arrives in 

$$
j
$$

, from every state.



$$
x_{t+1}(j)=\sum_i x_t(i)\,P_{ij}
$$





$$
P^{\,n}
$$

 is the **n-step transition matrix**: 

$$
(P^{\,n})_{ij}
$$

 is the probability of being in 

$$
j
$$

 after 

$$
n
$$

 steps when starting in 

$$
i
$$

 (the Chapman–Kolmogorov result). Counts stay counts (the total is preserved); shares stay shares (they still add to 1).

**Exam trap.** Multiply the row vector by the *columns* of 

$$
P
$$

, not its rows. A quick check: the answer's total must equal the starting total (100 guests stay 100 guests).

**Question. A hotel chain has properties in Paris (P), London (L) and Rome (R). Daily movement: from Paris 60% stay, 25% to London, 15% to Rome; from London 30% to Paris, 50% stay, 20% to Rome; from Rome 20% to Paris, 30% to London, 50% stay. Today's guest counts are [50, 30, 20] in P, L, R. Find the expected counts tomorrow.** [part of 10 marks · Final Nov 2025 Q5a]

#### Given



$$
P=\begin{bmatrix}0.60&0.25&0.15\\0.30&0.50&0.20\\0.20&0.30&0.50\end{bmatrix},\qquad x_0=[50,\;30,\;20]
$$



#### To find



$$
x_1=x_0P
$$

.

#### Formula and why it applies



$$
x_{t+1}=x_tP,\qquad x_{t+2}=(x_tP)P
$$



For each destination, multiply each present-state share by its probability of arriving there, then add all arrivals.

#### Solution

##### Step 1. Paris tomorrow (column 1)



$$
50(0.60)+30(0.30)+20(0.20)=30+9+4=43
$$



##### Step 2. London tomorrow (column 2)



$$
50(0.25)+30(0.50)+20(0.30)=12.5+15+6=33.5
$$



##### Step 3. Rome tomorrow (column 3)



$$
50(0.15)+30(0.20)+20(0.50)=7.5+6+10=23.5
$$



##### Step 4. Check the total

43 + 33.5 + 23.5 = 100 = 50 + 30 + 20. Correct.

**Final answer.** Expected guests tomorrow: Paris 43, London 33.5, Rome 23.5.

**Question. Using the brand-switching matrix 

$$
P=\begin{bmatrix}0.75&0.25\\0.40&0.60\end{bmatrix}
$$

, a customer uses Brand X this year. Find the probability that the customer uses each brand after two years.** [practice · 3 marks]

#### Given

Transition matrix P is printed in the question. For the two-year brand example the initial state is certainly X, so x₀=[1,0].

#### To find

The requested next-step or two-step distribution.

#### Formula and why it applies



$$
x_{t+1}=x_tP,\qquad x_{t+2}=(x_tP)P
$$



For each destination, multiply each present-state share by its probability of arriving there, then add all arrivals.

#### Solution

##### Step 1. Start vector



$$
x_0=[1,\;0]
$$

 (certainly X now).

##### Step 2. One year



$$
x_1=[1,0]P=[0.75,\;0.25]
$$



##### Step 3. Two years



$$
x_2=x_1P=[0.75(0.75)+0.25(0.40),\;0.75(0.25)+0.25(0.60)]=[0.6625,\;0.3375]
$$



**Final answer.** After two years: X with probability 0.6625, Y with probability 0.3375. (Equivalently, row X of 

$$
P^2=\begin{bmatrix}0.6625&0.3375\\0.54&0.46\end{bmatrix}
$$

.)

## Other next-step results, with full working in Solved papers

| Paper question | Start | Next step |
| --- | --- | --- |
| Learning levels B, I, A (Final Q6b) | [50, 30, 20] | [36, 32, 32] |
| Booking channels W, A, C (Re-exam Q5b) | [0.40, 0.35, 0.25] | [0.39, 0.335, 0.275] |
| Aircraft at hubs A, B, C (Re-exam Q6b) | [30, 40, 30] | [38.5, 32.5, 29] |

The complete working for each is in [Solved papers](https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q6b/).

**Yaad rakho:** Kal ka number = har jagah se aane wale log jodo (column ke saath multiply).

---

## TEE · Steady state and long-run gain or loss

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-markov--steady-state/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-markov/steady-state

Unit 4 · Markov processes · asked in every recent paper (5 and 10 marks)

**For transitions Savings→Current=0.2 and Current→Savings=0.1, derive the stationary shares.** [3 marks · Worked example]

#### Given

Savings→Current=0.2, so Savings→Savings=0.8. Current→Savings=0.1, so Current→Current=0.9. Let s and c be the Savings and Current shares; s+c=1.

#### To find

s and c that remain unchanged after a step.

#### Formula and why it applies

At stationarity total incoming share equals current share.

#### Solution

##### Step 1. Write Savings balance



$$
s=0.8s+0.1c
$$



##### Step 2. Subtract 0.8s from both sides



$$
s-0.8s=0.1c\quad\Rightarrow\quad0.2s=0.1c
$$



##### Step 3. Divide both sides by 0.1



$$
2s=c
$$



##### Step 4. Use the total share



$$
s+c=1\quad\Rightarrow\quad s+2s=1\quad\Rightarrow\quad3s=1
$$



##### Step 5. Divide and recover the other share



$$
s=1/3\qquad c=2s=2/3
$$



**Final answer.** Stationary shares [1/3,2/3].

**In one line:** a stationary distribution is unchanged by one transition; that fixed row 

$$
\pi
$$

 satisfies 

$$
\pi=\pi P
$$

, and comparing it with today's shares tells you who gains and who loses in the long run.

## Definition

A **steady-state (stationary) distribution** is a row vector 

$$
\pi=[\pi_1,\dots,\pi_n]
$$

 such that



$$
\pi=\pi P,\qquad \sum_i \pi_i=1,\qquad \pi_i\ge 0
$$



Once the system has these shares, one more step leaves them unchanged. For a chain in which every state can reach every other state and that does not cycle with a fixed period (true for every paper question so far), 

$$
x_t\to\pi
$$

 from *any* starting distribution.

## Method for any number of states

1. Write one balance equation per column: 

$$
\pi_j=\sum_i\pi_iP_{ij}
$$

.
2. For the irreducible examples here, keep n−1 independent balance equations and add 

$$
\sum\pi_i=1
$$

.
3. Express every 

$$
\pi
$$

 in terms of one of them, then use the sum to find it.

**Two-state shortcut.** When a+b>0, if 

$$
P=\begin{bmatrix}1-a&a\\b&1-b\end{bmatrix}
$$

 then



$$
\pi=\left[\frac{b}{a+b},\;\frac{a}{a+b}\right]
$$



Brand switching: 

$$
a=0.25,\;b=0.40\Rightarrow\pi=[0.40/0.65,\;0.25/0.65]=[0.6154,\;0.3846]
$$

. Bank: 

$$
a=0.2,\;b=0.1\Rightarrow\pi=[1/3,\;2/3]
$$

.

## How to interpret a transition matrix (asked as a 2–3 mark part)

- **Diagonal entries 

$$
P_{ii}
$$

** = **retention**: the fraction that stays.
- **Off-diagonal entries 

$$
P_{ij}
$$

** = **transfer/loss** from 

$$
i
$$

 to 

$$
j
$$

; looking down column 

$$
j
$$

 shows **inflow (gain)** into 

$$
j
$$

.
- **Long-run gainer/loser**: compare 

$$
\pi_j
$$

 with the current share. Larger → gains; smaller → loses.
- An **absorbing state** has 

$$
P_{ii}=1
$$

: once entered it is never left.

**Question. Learners move daily between Beginner (B), Intermediate (I) and Advanced (A): from B 60% stay, 30% to I, 10% to A; from I 20% to B, 50% stay, 30% to A; from A 10% drop to I, 80% stay and 10% stop learning (treated as remaining in A). Find the steady-state proportions and the level with the largest long-run share.** [part of 10 marks · Final Nov 2025 Q6b]

#### Given



$$
P=\begin{bmatrix}0.6&0.3&0.1\\0.2&0.5&0.3\\0&0.1&0.9\end{bmatrix}
$$



Row A is 0 + 0.1 + (0.8 + 0.1) = 1.

#### To find



$$
\pi=[\pi_B,\pi_I,\pi_A]
$$

.

#### Formula and why it applies



$$
\pi=\pi P,\quad\sum_i\pi_i=1
$$



At stationarity each destination receives exactly its current share. Solve the balance equations together with the total-probability equation.

#### Solution

##### Step 1. Column B balance



$$
\pi_B=0.6\pi_B+0.2\pi_I+0\cdot\pi_A\;\Rightarrow\;0.4\pi_B=0.2\pi_I\;\Rightarrow\;\pi_I=2\pi_B
$$



##### Step 2. Column A balance



$$
\pi_A=0.1\pi_B+0.3\pi_I+0.9\pi_A\;\Rightarrow\;0.1\pi_A=0.1\pi_B+0.3(2\pi_B)=0.7\pi_B\;\Rightarrow\;\pi_A=7\pi_B
$$



##### Step 3. Use the sum



$$
\pi_B+2\pi_B+7\pi_B=1\;\Rightarrow\;\pi_B=0.1,\quad\pi_I=0.2,\quad\pi_A=0.7
$$



##### Step 4. Check with column I



$$
0.3(0.1)+0.5(0.2)+0.1(0.7)=0.03+0.10+0.07=0.20=\pi_I\;\checkmark
$$



**Final answer.** Long run: 10% Beginner, 20% Intermediate, 70% Advanced. Advanced holds the largest share. It is not strictly absorbing (10% drop back to I each day), but it is the dominant level.

**Official key correction.** The key prints 16.3%, 25.5%, 58.2%. Those numbers do not satisfy 

$$
\pi=\pi P
$$

 (column B gives 

$$
0.6(0.163)+0.2(0.255)=0.149\ne0.163
$$

). The correct steady state is 0.1, 0.2, 0.7.

**Question. For the hotel chain (Paris, London, Rome) with today's counts [50, 30, 20], find the long-run distribution and say which city gains or loses guests.** [part of 10 marks · Final Nov 2025 Q5a]

#### Given



$$
P=\begin{bmatrix}0.60&0.25&0.15\\0.30&0.50&0.20\\0.20&0.30&0.50\end{bmatrix}
$$



#### To find

Stationary shares and the requested comparison with the initial distribution.

#### Formula and why it applies



$$
\pi=\pi P,\quad\sum_i\pi_i=1
$$



At stationarity each destination receives exactly its current share. Solve the balance equations together with the total-probability equation.

#### Solution

##### Step 1. Column P balance



$$
\pi_P=0.6\pi_P+0.3\pi_L+0.2\pi_R\;\Rightarrow\;\pi_P=0.75\pi_L+0.5\pi_R
$$



##### Step 2. Column L balance



$$
\pi_L=0.25\pi_P+0.5\pi_L+0.3\pi_R\;\Rightarrow\;0.5\pi_L=0.25\pi_P+0.3\pi_R
$$



Substitute Step 1: 

$$
0.5\pi_L=0.1875\pi_L+0.125\pi_R+0.3\pi_R\Rightarrow0.3125\pi_L=0.425\pi_R\Rightarrow\pi_L=1.36\,\pi_R
$$

.

Then 

$$
\pi_P=0.75(1.36\pi_R)+0.5\pi_R=1.52\,\pi_R
$$

.

##### Step 3. Use the sum



$$
(1.52+1.36+1)\pi_R=3.88\,\pi_R=1\Rightarrow\pi_R=0.2577,\;\pi_L=0.3505,\;\pi_P=0.3918
$$



Exactly: 

$$
\pi=[38/97,\;34/97,\;25/97]
$$

.

##### Step 4. Compare with today's shares [0.50, 0.30, 0.20]

| City | Today | Long run | Verdict |
| --- | --- | --- | --- |
| Paris | 0.50 | 0.392 | Loses guests |
| London | 0.30 | 0.351 | Gains |
| Rome | 0.20 | 0.258 | Gains |

**Final answer.** 

$$
\pi\approx[0.392,\;0.351,\;0.258]
$$

: Paris loses share; London and Rome gain. (The key's 0.3928 for Paris is a rounding slip; the three values must add to 1.)

## Other steady states from the papers

| Question | Steady state | Compared with now |
| --- | --- | --- |
| Brand X/Y (Final Q1d) | [8/13, 5/13] = [0.615, 0.385] | — |
| Savings/Current (Re-exam Q1d) | [1/3, 2/3] | Current dominates |
| Booking W, A, C (Re-exam Q5b) | [8/21, 1/3, 2/7] = [0.381, 0.333, 0.286] | Now [0.40, 0.35, 0.25]: Website and App shrink slightly; Counter grows. |
| Aircraft A, B, C (Re-exam Q6b) | [25/63, 20/63, 2/7] = [0.397, 0.317, 0.286] | Now [0.3, 0.4, 0.3]: A gains; B loses; C loses slightly. |

**Official key correction (Re-exam Q5b).** The key says the Website “may grow”. Its steady share 0.381 is below today's 0.40, so the Website actually shrinks slightly; Counter is the one that grows.

**Yaad rakho:** Steady state = “ab kuch nahi badlega”: 

$$
\pi = \pi P
$$

 aur total 1. Gain/loss = steady share vs aaj ka share.

---

## TEE · Markov reward process, return and discount

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--mrp-return/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-bellman/mrp-return

Unit 4 · Markov reward process, Markov decision process, value functions, Bellman equations, applications

## Discounting changes the weight of later rewards

γ (gamma) is a discount factor. Immediate reward has weight 1; one-step-later reward has weight γ; two-step-later reward has weight γ². This is repeated multiplication, not subtracting γ from a reward. An expectation averages possible future trajectories. A return G is the discounted total along one realised trajectory.

**In one line:** a Markov reward process is a Markov chain that also pays a reward in each state; the return adds those rewards, shrinking later ones by γ.

## Definition

A **Markov reward process (MRP)** is a tuple 

$$
\langle\mathcal S,P,R,\gamma\rangle
$$

:

- 

$$
\mathcal S
$$

: finite set of states; 

$$
P
$$

: transition matrix, 

$$
P_{ss'}=P(S_{t+1}=s'\mid S_t=s)
$$

;
- 

$$
R
$$

: reward function, 

$$
R(s)=\mathbb E[R_{t+1}\mid S_t=s]
$$

 (the expected reward for leaving 

$$
s
$$

);
- 

$$
\gamma\in[0,1]
$$

: the **discount factor**.

There are no actions yet; the process simply drifts and collects rewards. (Add actions and you get an MDP.)

## Return

The **return** 

$$
G_t
$$

 is the total discounted reward from time 

$$
t
$$

:



$$
G_t=R_{t+1}+\gamma R_{t+2}+\gamma^2R_{t+3}+\dots=\sum_{k=0}^{\infty}\gamma^kR_{t+k+1}
$$



**Why discount?** (1) With bounded rewards, it keeps the infinite discounted sum finite when 

$$
\gamma<1
$$

. (2) Future rewards are uncertain. (3) Immediate rewards are usually preferred (like interest on money). 

$$
\gamma=0
$$

 makes the agent short-sighted (only the next reward counts); 

$$
\gamma\to1
$$

 makes it far-sighted.

**Question. An episode gives rewards 

$$
R_1=-2,\;R_2=-1,\;R_3=-2,\;R_4=0
$$

 and then ends. Find 

$$
G_0
$$

 with 

$$
\gamma=0.9
$$

.** [practice · 2 marks]

#### Given

Rewards [−2,−1,−2,0]; discount γ=0.9; episode ends after the fourth reward.

#### To find

Return G₀.

#### Formula and why it applies

The first reward is undiscounted. Each later reward receives one extra factor of γ.



$$
G_0=R_1+\gamma R_2+\gamma^2R_3+\gamma^3R_4
$$



#### Solution

##### Step 1. Write the discounted sum



$$
G_0=R_1+\gamma R_2+\gamma^2R_3+\gamma^3R_4
$$



##### Step 2. Substitute



$$
G_0=-2+0.9(-1)+0.81(-2)+0.729(0)=-2-0.9-1.62=-4.52
$$



**Final answer.** 

$$
G_0=-4.52
$$

.

## State-value function of an MRP

The **value** of a state is the expected return when starting there:



$$
v(s)=\mathbb E\,[\,G_t\mid S_t=s\,]
$$



The return of one episode is random; the value is its average over all possible futures.

**Yaad rakho:** Return = aaj ka reward + γ × kal ka + γ² × parson ka… γ chhota = jaldi chahiye, γ bada = lambi soch.

**An episode gives rewards [2, 4, 8] and then ends. Find the return from the start with γ=0.5.** [2 marks · Worked example]

#### Given

Rewards in order: R₁=2, R₂=4, R₃=8. Discount factor γ=0.5. The episode then ends, so there are no later rewards.

#### To find

G₀: the discounted sum of all three rewards, measured from the start.

#### Formula and why it applies



$$
G_0=R_1+\gamma R_2+\gamma^2R_3
$$



Keep the first reward undiscounted; multiply each later reward by the appropriate power.

#### Solution

##### Step 1. First reward contribution



$$
1\times(2)=2
$$



##### Step 2. Second reward contribution



$$
0.5\times(4)=2
$$



##### Step 3. Third reward contribution



$$
0.5^2\times(8)=2
$$



##### Step 4. Add contributions



$$
G_0=(2)+(2)+(2)=6
$$



**Final answer.** 6.



**An episode gives rewards [-1, 5, 2] and then ends. Find the return from the start with γ=0.9.** [2 marks · Worked example]

#### Given

Rewards in order: R₁=-1, R₂=5, R₃=2. Discount factor γ=0.9. The episode then ends, so there are no later rewards.

#### To find

G₀: the discounted sum of all three rewards, measured from the start.

#### Formula and why it applies



$$
G_0=R_1+\gamma R_2+\gamma^2R_3
$$



Keep the first reward undiscounted; multiply each later reward by the appropriate power.

#### Solution

##### Step 1. First reward contribution



$$
1\times(-1)=-1
$$



##### Step 2. Second reward contribution



$$
0.9\times(5)=4.5
$$



##### Step 3. Third reward contribution



$$
0.9^2\times(2)=1.62
$$



##### Step 4. Add contributions



$$
G_0=(-1)+(4.5)+(1.62)=5.12
$$



**Final answer.** 5.12.



**An episode gives rewards [2, 4, 8] and then ends. Find the return from the start with γ=0.** [2 marks · Worked example]

#### Given

Rewards in order: R₁=2, R₂=4, R₃=8. Discount factor γ=0. The episode then ends, so there are no later rewards.

#### To find

G₀: the discounted sum of all three rewards, measured from the start.

#### Formula and why it applies



$$
G_0=R_1+\gamma R_2+\gamma^2R_3
$$



Keep the first reward undiscounted; multiply each later reward by the appropriate power.

#### Solution

##### Step 1. First reward contribution



$$
1\times(2)=2
$$



##### Step 2. Second reward contribution



$$
0\times(4)=0
$$



##### Step 3. Third reward contribution



$$
0^2\times(8)=0
$$



##### Step 4. Add contributions



$$
G_0=(2)+(0)+(0)=2
$$



**Final answer.** 2.

---

## TEE · Bellman equation for an MRP (with a solved example)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--bellman-mrp/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-bellman/bellman-mrp

Unit 4 · Markov reward process, Markov decision process, value functions, Bellman equations, applications

**A state pays immediate reward 2. Next it reaches a state of value 10 with probability 0.6 or a state of value 0 with probability 0.4. With γ=0.5, calculate its Bellman value.** [2 marks · Worked example]

#### Given

Immediate reward R=2; discount γ=0.5. Next-state possibilities: value 10 with probability 0.6, or value 0 with probability 0.4. These supplied continuation values already include rewards after reaching those states.

#### To find

Immediate reward plus discounted expected next value.

#### Formula and why it applies



$$
v(s)=R(s)+\gamma\sum_{s'}P(s'\mid s)v(s')
$$



s′ is read “next state”; the prime is not a derivative. The sum is a weighted average of next-state values.

#### Solution

##### Step 1. First branch contribution



$$
0.6\times10=6
$$



##### Step 2. Second branch contribution



$$
0.4\times0=0
$$



##### Step 3. Average, then discount



$$
6+0=6\qquad0.5\times6=3
$$



##### Step 4. Add immediate reward



$$
v(s)=2+3=5
$$



**Final answer.** v(s)=5.

In the matrix expression, I is the identity matrix (ones on the diagonal and zero elsewhere); multiplying by I leaves a vector unchanged. The inverse solves simultaneous equations when it exists. For the small exam examples below, ordinary substitution is sufficient.

**In one line:** the value of a state = the reward you get now + γ × the average value of where you land next.

## Derivation (short and examinable)



$$
\begin{aligned}v(s)&=\mathbb E[G_t\mid S_t=s]\\&=\mathbb E[R_{t+1}+\gamma(R_{t+2}+\gamma R_{t+3}+\dots)\mid S_t=s]\\&=\mathbb E[R_{t+1}+\gamma G_{t+1}\mid S_t=s]\\&=R(s)+\gamma\sum_{s'\in\mathcal S}P_{ss'}\,v(s')\end{aligned}
$$



The key step is 

$$
G_t=R_{t+1}+\gamma G_{t+1}
$$

: the return splits into the immediate reward plus the discounted return from the next state. That recursive split is the whole idea of every Bellman equation.

**Matrix form.** Stack the values in a column 

$$
v
$$

: 

$$
v=R+\gamma Pv\Rightarrow (I-\gamma P)v=R\Rightarrow v=(I-\gamma P)^{-1}R
$$

. For small problems just solve the linear equations.

Swipe across the diagram to read its labels ↔

![Done is terminal (it loops to itself with reward 0), so v(Done) = 0.](https://deep-learning-study-room.vercel.app/is2/fig/mrp_student.be69eb4eb6.svg)

Diagram: Done is terminal (it loops to itself with reward 0), so v(Done) = 0.. Labels: A three-state Markov reward process (rewards: Class −2, Lab −1, Done 0) | 0.5 | 0.5 | 0.4 | 0.6 | 1 | Class | Lab | Done

Done is terminal (it loops to itself with reward 0), so v(Done) = 0.

**Question. In the MRP shown, Class pays −2 and Lab pays −1 when left; Done pays 0 and is terminal. From Class: 0.5 to Lab, 0.5 to Done. From Lab: 0.4 to Class, 0.6 to Done. With 

$$
\gamma=0.9
$$

, find v(Class) and v(Lab).** [practice · 5 marks]

#### Given



$$
R(C)=-2,\;R(L)=-1,\;v(D)=0,\;\gamma=0.9
$$

.

#### To find



$$
v(C),\;v(L)
$$

.

#### Formula and why it applies



$$
v(s)=R(s)+\gamma\sum_{s'}P_{ss'}v(s')
$$



It holds for every state, so we get one equation per non-terminal state.

#### Solution

##### Step 1. Equation for Class



$$
v(C)=-2+0.9\,[\,0.5\,v(L)+0.5\,(0)\,]=-2+0.45\,v(L)
$$



##### Step 2. Equation for Lab



$$
v(L)=-1+0.9\,[\,0.4\,v(C)+0.6\,(0)\,]=-1+0.36\,v(C)
$$



##### Step 3. Substitute Step 2 into Step 1



$$
v(C)=-2+0.45(-1+0.36\,v(C))=-2.45+0.162\,v(C)\Rightarrow0.838\,v(C)=-2.45
$$



##### Step 4. Solve



$$
v(C)=\frac{-2.45}{0.838}=-2.9236,\qquad v(L)=-1+0.36(-2.9236)=-2.0525
$$



##### Step 5. Check Class



$$
-2+0.45(-2.0525)=-2-0.9236=-2.9236\;\checkmark
$$



**Final answer.** 

$$
v(\text{Class})\approx-2.924,\;v(\text{Lab})\approx-2.053,\;v(\text{Done})=0
$$

. Lab is “less bad” because it is more likely to finish quickly.

**Yaad rakho:** Bellman = “abhi ka reward + γ × aage ka average value”. Har state ki ek equation, phir solve.

## The substitution algebra in slow motion



$$
v_C=-2+0.45(-1+0.36v_C)
$$



Multiply .45 into both bracket terms: .45×(−1)=−.45 and .45×.36=.162.



$$
v_C=-2-0.45+0.162v_C=-2.45+0.162v_C
$$



Subtract .162vC from both sides; the coefficient on the left is 1−.162=.838.



$$
0.838v_C=-2.45\quad\Rightarrow\quad v_C=-2.45/0.838\approx-2.923627685
$$



Now use the Lab equation: .36×(−2.923627685)≈−1.052505967; adding −1 gives vL≈−2.052505967.

---

## TEE · Markov decision process, policies and value functions

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--mdp-policy/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-bellman/mdp-policy

Unit 4 · Markov reward process, Markov decision process, value functions, Bellman equations, applications

| Read this | Meaning | Concrete example |
| --- | --- | --- |
| π(a|s) | Probability the policy chooses action a in state s | In room A: left .3, right .7 |
| P(s′|s,a) | Probability of the environment’s next state after that action | Right action reaches room B with probability .8 |
| vπ(s) | Expected return starting in state s and following policy π | A number scoring the state |
| qπ(s,a) | Expected return if action a is taken first, then policy π is followed | One score for each possible first action |
| π in this chapter | A policy | Unlike π in a Markov-chain stationary distribution; context distinguishes them |

The policy chooses an action; the transition model describes what happens after the action. They are two separate probability distributions. The worked examples use stationary Markov policies, depending on the current state and unchanged over time. More general policies may depend on time or history.

**In one line:** an MDP is an MRP in which the agent chooses actions; a policy says which action to choose, and value functions score how good a state or a state–action pair is under that policy.

## Markov decision process

A **Markov decision process (MDP)** is a tuple 

$$
\langle\mathcal S,\mathcal A,P,R,\gamma\rangle
$$

:

- 

$$
\mathcal S
$$

: states; 

$$
\mathcal A
$$

: actions;
- 

$$
P^{a}_{ss'}=P(S_{t+1}=s'\mid S_t=s,A_t=a)
$$

: transition probabilities, now depending on the action;
- 

$$
R^{a}_{s}=\mathbb E[R_{t+1}\mid S_t=s,A_t=a]
$$

: expected reward for taking 

$$
a
$$

 in 

$$
s
$$

;
- 

$$
\gamma
$$

: discount factor.

The Markov property still holds: the next state and reward depend only on the current state and action. An MDP is a common model for RL when the chosen state captures the relevant information; partially observed problems require additional treatment.

Swipe across the diagram to read its labels ↔

![In s₁ the agent chooses “stay” or “go” (black dots). The environment then decides the outcome: “go” reaches s₂ with probability 0.8 (reward +5) or falls back to s₁ with 0.2 (reward 0).](https://deep-learning-study-room.vercel.app/is2/fig/mdp_two.331bc03880.svg)

Diagram: In s₁ the agent chooses “stay” or “go” (black dots). The environment then decides the outcome: “go” reaches s₂ with probability 0.8 (reward +5) or falls back to s₁ with 0.2 (reward 0).. Labels: A two-state MDP: actions branch, then the environment decides the next state | s₁ | s₂ | a = stay | a = go | p = 1, r = +1 | p = 0.8, r = +5 | p = 0.2, r = 0

In s₁ the agent chooses “stay” or “go” (black dots). The environment then decides the outcome: “go” reaches s₂ with probability 0.8 (reward +5) or falls back to s₁ with 0.2 (reward 0).

## Policy

A **policy** 

$$
\pi
$$

 is a distribution over actions given states:



$$
\pi(a\mid s)=P(A_t=a\mid S_t=s)
$$



- **Deterministic** policy: one fixed action per state, 

$$
a=\pi(s)
$$

.
- **Stochastic** policy: probabilities, e.g. 

$$
\pi(\text{stay}\mid s_1)=0.5,\;\pi(\text{go}\mid s_1)=0.5
$$

.

The policies used in these examples are stationary Markov policies. The term policy more generally also permits time-dependent or history-dependent decision rules.

## Value functions

**State-value function**: expected return from state 

$$
s
$$

 when following 

$$
\pi
$$

:



$$
v_\pi(s)=\mathbb E_\pi[G_t\mid S_t=s]
$$



**Action-value function (Q-function)**: expected return when taking action 

$$
a
$$

 in 

$$
s
$$

 and following 

$$
\pi
$$

 afterwards:



$$
q_\pi(s,a)=\mathbb E_\pi[G_t\mid S_t=s,A_t=a]
$$



They are linked by averaging over the policy's choices:



$$
v_\pi(s)=\sum_{a\in\mathcal A}\pi(a\mid s)\,q_\pi(s,a)
$$



**Optimal** value functions take the best policy: 

$$
v_*(s)=\max_\pi v_\pi(s)
$$

 and 

$$
q_*(s,a)=\max_\pi q_\pi(s,a)
$$

. An optimal policy acts greedily on 

$$
q_*
$$

: 

$$
\pi_*(s)=\arg\max_a q_*(s,a)
$$

.

|  | Markov process | MRP | MDP |
| --- | --- | --- | --- |
| Tuple | 

$$
\langle\mathcal S,P\rangle
$$

 | 

$$
\langle\mathcal S,P,R,\gamma\rangle
$$

 | 

$$
\langle\mathcal S,\mathcal A,P,R,\gamma\rangle
$$

 |
| Rewards | No | Yes | Yes |
| Decisions | No | No | Yes (actions) |
| Value | — | 

$$
v(s)
$$

 | 

$$
v_\pi(s),\;q_\pi(s,a)
$$

 |

**Yaad rakho:** MP → +reward = MRP → +action = MDP. v = “state kitni achhi”, q = “is state mein yeh action kitna achha”.

---

## TEE · Bellman expectation and optimality equations (worked)

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--bellman-equations/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-bellman/bellman-equations

Unit 4 · Markov reward process, Markov decision process, value functions, Bellman equations, applications

**At a state, action Left has value 3 and action Right has value 7. A policy chooses Left with probability 0.25 and Right with probability 0.75. Find the value under this policy, the maximum action value and the greedy action.** [2 marks · Worked example]

#### Given

Action values: Left=3 and Right=7. Policy probabilities: Left=0.25 and Right=0.75. The supplied action values already include subsequent returns.

#### To find

A weighted average, a maximum and the label attaining that maximum.

#### Formula and why it applies



$$
v_\pi(s)=\sum_a\pi(a\mid s)q_\pi(s,a)
$$



The expectation averages according to policy; maximisation selects a largest action score.

#### Solution

##### Step 1. Weight Left



$$
0.25\times3=0.75
$$



##### Step 2. Weight Right



$$
0.75\times7=5.25
$$



##### Step 3. Add for the policy value



$$
v_\pi=0.75+5.25=6
$$



##### Step 4. Read max and argmax

max(3,7)=7 is a number. argmax is Right, the action with that number.

**Final answer.** Policy value 6; maximum action value 7; greedy action Right.

**In one line:** the expectation equations score a given policy; the optimality equations replace the policy's average by a max and describe the best possible behaviour.

## Bellman expectation equations

Split the return into “reward now + discounted value later”, and average over the policy and the environment:



$$
v_\pi(s)=\sum_{a}\pi(a\mid s)\sum_{s'}P(s'\mid s,a)\,\big[\,R(s,a,s')+\gamma\,v_\pi(s')\,\big]
$$





$$
q_\pi(s,a)=\sum_{s'}P(s'\mid s,a)\,\Big[\,R(s,a,s')+\gamma\sum_{a'}\pi(a'\mid s')\,q_\pi(s',a')\,\Big]
$$



Read the first one aloud: *for each action the policy might take, for each next state the environment might give, add the reward and γ × the next state's value, weighted by both probabilities.*

## Bellman optimality equations



$$
v_*(s)=\max_{a}\sum_{s'}P(s'\mid s,a)\,\big[\,R(s,a,s')+\gamma\,v_*(s')\,\big]
$$





$$
q_*(s,a)=\sum_{s'}P(s'\mid s,a)\,\big[\,R(s,a,s')+\gamma\max_{a'}q_*(s',a')\,\big]
$$



The only change is 

$$
\sum_a\pi(a\mid s)\to\max_a
$$

: the optimal agent picks the best action instead of averaging. These equations are non-linear (because of max), so they are solved iteratively (value iteration, policy iteration, Q-learning).

**Question. In the two-state MDP (figure in the previous lesson), s₂ is terminal with 

$$
v(s_2)=0
$$

 and 

$$
\gamma=0.9
$$

. In s₁, “stay” returns to s₁ with reward +1; “go” reaches s₂ with probability 0.8 and reward +5, or returns to s₁ with probability 0.2 and reward 0. (a) Find 

$$
v_\pi(s_1)
$$

 for the random policy 

$$
\pi(\text{stay})=\pi(\text{go})=0.5
$$

. (b) Find 

$$
v_*(s_1)
$$

 and the optimal action.** [practice · 6 marks]

#### Given



$$
q(s_1,\text{stay})=1+0.9\,v(s_1)
$$

; 

$$
q(s_1,\text{go})=0.8(5+0.9\cdot0)+0.2(0+0.9\,v(s_1))=4+0.18\,v(s_1)
$$

.

#### To find

The value under the random policy, the optimal value and the optimal action.

#### Formula and why it applies



$$
v_\pi(s)=\sum_a\pi(a\mid s)q_\pi(s,a),\qquad v_*(s)=\max_a q_*(s,a)
$$



The expectation equation averages actions using the given policy. The optimality equation chooses the largest action value. Each action value already includes its expected immediate reward and discounted continuation.

#### Solution

##### Step 1. (a) Expectation equation for the random policy



$$
v=0.5(1+0.9v)+0.5(4+0.18v)=2.5+0.54v\Rightarrow0.46v=2.5\Rightarrow v_\pi(s_1)=5.4348
$$



##### Step 2. (b) Try “go” always



$$
v=4+0.18v\Rightarrow v=4/0.82=4.878
$$



Check whether switching helps: 

$$
q(\text{stay})=1+0.9(4.878)=5.390>4.878
$$

. So “go” is not optimal.

##### Step 3. Try “stay” always



$$
v=1+0.9v\Rightarrow v=10
$$



Check: 

$$
q(\text{go})=4+0.18(10)=5.8<10=q(\text{stay})
$$

. No improvement possible.

**Final answer.** (a) 

$$
v_\pi(s_1)\approx5.43
$$

. (b) 

$$
v_*(s_1)=10
$$

 with 

$$
q_*(s_1,\text{stay})=10
$$

, 

$$
q_*(s_1,\text{go})=5.8
$$

: the optimal action is **stay**. A steady +1 forever is worth 

$$
1/(1-0.9)=10
$$

, more than a one-time +5.

## Seeing the max at work: value iteration

Start with 

$$
v_0(s_1)=0
$$

 and apply the optimality equation repeatedly: 

$$
v_{k+1}=\max(1+0.9v_k,\;4+0.18v_k)
$$

.

| k | stay = 1 + 0.9vₖ | go = 4 + 0.18vₖ | vₖ₊₁ | best |
| --- | --- | --- | --- | --- |
| 0 | 1.000 | 4.000 | 4.000 | go |
| 1 | 4.600 | 4.720 | 4.720 | go |
| 2 | 5.248 | 4.850 | 5.248 | stay |
| 3 | 5.723 | 4.945 | 5.723 | stay |
| … | converges | | 10 | stay |

Early on the agent prefers the quick +5; as it “looks further ahead”, the steady reward wins. This is why γ and long-term value matter.

**Yaad rakho:** Expectation = policy ka average (Σπ). Optimality = best action (max). Baaki sab same: reward + γ × next value.

## Expand the random-policy equation

For the full MDP question above, “stay” gives 1+.9v. “Go” has two possible transitions: .8×(5+.9×0)=4 and .2×(0+.9v)=.18v, so its total is 4+.18v. The random policy then averages these two action values.



$$
v=0.5(1+0.9v)+0.5(4+0.18v)
$$





$$
v=0.5+0.45v+2+0.09v=2.5+0.54v
$$



Subtract .54v from both sides, then divide by .46.



$$
(1-0.54)v=2.5\quad0.46v=2.5\quad v=2.5/0.46\approx5.434782609
$$



---

## TEE · Using Bellman equations: policy and value iteration

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--solving/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-bellman/solving

Unit 4 · Markov reward process, Markov decision process, value functions, Bellman equations, applications

A **backup** means applying the Bellman equation once to improve a value estimate. In value iteration, each sweep uses the previous sweep’s values for all states. In policy iteration, first solve values for the current policy; then choose the action with the largest one-step action value using those solved continuation values. Repeat if the policy changes. The “try go, then improve to stay” calculation in the previous lesson is one complete policy-improvement example.

**In one line:** policy/value iteration use Bellman equations with a model; Q-learning uses sampled experience. These are examples of methods, not a claim about every RL algorithm.

## 1. Policy evaluation

Given 

$$
\pi
$$

, compute 

$$
v_\pi
$$

 by repeatedly applying the expectation equation until values stop changing:



$$
v_{k+1}(s)\leftarrow\sum_a\pi(a\mid s)\sum_{s'}P(s'\mid s,a)\,[R+\gamma v_k(s')]
$$



## 2. Policy iteration

Start with any policy π

→

Evaluate: find 

$$
v_\pi
$$



→

Improve: 

$$
\pi'(s)=\arg\max_a q_\pi(s,a)
$$



→

Repeat until the policy stops changing

For a finite discounted MDP with exact policy evaluation and consistent tie handling, policy improvement does not reduce value and policy iteration can terminate at an optimal policy.

## 3. Value iteration

Skip full evaluation; apply the optimality equation directly:



$$
v_{k+1}(s)\leftarrow\max_a\sum_{s'}P(s'\mid s,a)\,[R+\gamma v_k(s')]
$$



Stop when the change is tiny, then act greedily. The table in the previous lesson is value iteration on one state.

Optional extension: Q-learning (not an observed PYQ)

The two supplied TEE papers do not ask a Q-learning update. The January 2026 paper asks an explanation of the Bellman equation and RL applications. This extra worked example can wait until those requirements are covered.

## Q-learning

Q-learning is included to illustrate a Bellman target; it is not separately named in the supplied introductory RL syllabus.

When 

$$
P
$$

 and 

$$
R
$$

 are unknown, the agent learns 

$$
q_*
$$

 from its own experience 

$$
(s,a,r,s')
$$

:



$$
Q(s,a)\leftarrow Q(s,a)+\alpha\,\big[\,r+\gamma\max_{a'}Q(s',a')-Q(s,a)\,\big]
$$





$$
\alpha
$$

 is the learning rate. The bracket is the **temporal-difference error**: (Bellman target) − (current guess). The agent usually explores with ε-greedy actions while learning.

**Question. A Q-table has 

$$
Q(s,a)=2
$$

. The agent takes 

$$
a
$$

 in 

$$
s
$$

, receives 

$$
r=3
$$

 and lands in 

$$
s'
$$

 where 

$$
\max_{a'}Q(s',a')=5
$$

. With 

$$
\alpha=0.5,\;\gamma=0.9
$$

, find the updated 

$$
Q(s,a)
$$

.** [Optional authored example]

#### Given

Old Q=2, reward=3, best next-state Q=5, α=0.5, γ=0.9; the next state is nonterminal.

#### To find

The updated Q estimate.

#### Formula and why it applies

Move partway from the old estimate toward the one-step Bellman target.



$$
Q_{new}=Q_{old}+\alpha[r+\gamma\max Q_{next}-Q_{old}]
$$



#### Solution

##### Step 1. Target



$$
r+\gamma\max_{a'}Q(s',a')=3+0.9(5)=7.5
$$



##### Step 2. Update



$$
Q\leftarrow2+0.5(7.5-2)=2+2.75=4.75
$$



**Final answer.** 

$$
Q(s,a)=4.75
$$

.

**Yaad rakho:** Model pata hai → policy/value iteration. Model nahi pata → Q-learning (experience se seekho).

---

## TEE · 10-mark answer: Bellman equation and applications of RL

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--ten-mark-answer/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/read/u4-bellman/ten-mark-answer

Unit 4 · Markov reward process, Markov decision process, value functions, Bellman equations, applications

**Asked as:** “Explain Bellman equation in reinforcement learning. Also give applications of reinforcement learning.” [10 marks · Re-exam Jan 2026 Q7b; marking: Bellman explanation 5, applications 5]

Write the answer below in this order. It fits in about two pages.

### Part A · Bellman equation (5 marks)

**1. Setting.** Reinforcement learning problems are modelled as a Markov decision process 

$$
\langle\mathcal S,\mathcal A,P,R,\gamma\rangle
$$

. The agent follows a policy 

$$
\pi(a\mid s)
$$

 and wants to maximise the return 

$$
G_t=\sum_{k\ge0}\gamma^kR_{t+k+1}
$$

.

**2. Value functions.** 

$$
v_\pi(s)=\mathbb E_\pi[G_t\mid S_t=s]
$$

 and 

$$
q_\pi(s,a)=\mathbb E_\pi[G_t\mid S_t=s,A_t=a]
$$

.

**3. Key idea.** The return is recursive: 

$$
G_t=R_{t+1}+\gamma G_{t+1}
$$

. Taking expectations gives the **Bellman expectation equation**:



$$
v_\pi(s)=\sum_a\pi(a\mid s)\sum_{s'}P(s'\mid s,a)\,[R(s,a,s')+\gamma v_\pi(s')]
$$





$$
q_\pi(s,a)=\sum_{s'}P(s'\mid s,a)\,\Big[R(s,a,s')+\gamma\sum_{a'}\pi(a'\mid s')q_\pi(s',a')\Big]
$$



**4. Optimality.** For the optimal policy the average over actions becomes a maximum (**Bellman optimality equation**):



$$
v_*(s)=\max_a\sum_{s'}P(s'\mid s,a)\,[R+\gamma v_*(s')],\qquad q_*(s,a)=\sum_{s'}P(s'\mid s,a)\,[R+\gamma\max_{a'}q_*(s',a')]
$$



**5. Meaning and use.** The value of a state equals the immediate reward plus the discounted value of the successor state. This breaks a long-horizon problem into one-step sub-problems (dynamic programming). It is the basis of policy evaluation, policy iteration, value iteration and Q-learning; the optimal policy is 

$$
\pi_*(s)=\arg\max_a q_*(s,a)
$$

.

**6. Small illustration** (adds clarity): if staying in a state gives +1 each step with 

$$
\gamma=0.9
$$

, then 

$$
v=1+0.9v\Rightarrow v=10
$$

.

### Part B · Applications of reinforcement learning (5 marks)

1. **Game playing**: AlphaGo (defeated Lee Sedol, 2016), Atari agents (DQN), and the Mario agent built in this course's lab.
2. **Robotics**: walking, grasping and balancing learned by trial and error in simulation.
3. **Autonomous driving**: lane changing, merging and parking decisions.
4. **Recommendation systems**: choosing content to maximise long-term engagement rather than single clicks.
5. **Finance**: trading and portfolio rebalancing as sequential decisions.
6. **Healthcare**: dynamic treatment regimes (dose adjustment over time).
7. **Resource and energy management**: data-centre cooling control, traffic-signal timing, inventory control.
8. **Language models**: reinforcement learning from human feedback (RLHF) for chatbots.

#### One application in detail: traffic-signal control

|  |  |
| --- | --- |
| Agent | Controller at an intersection. |
| State | Queue length and waiting time on each approach, current signal phase. |
| Actions | Keep the current phase or switch to the next green phase. |
| Reward | Negative of total waiting time (or vehicles cleared per cycle). |
| Learning | Q-learning updates 

$$
Q(s,a)
$$

 from observed traffic; ε-greedy exploration tries alternative timings. |
| Benefit | Adapts to rush hours and incidents; fixed timers cannot. |
| Challenge | Safety during exploration, so agents are trained in simulation first. |

**Yaad rakho:** Bellman ka sar: “value = reward abhi + γ × value aage”. Application likho to S, A, R batao: examiner ko yahi chahiye.

---

## TEE · Fuzzy formulas, with meanings and worked-example links

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/formulas/m2-formulas-v2--fuzzy/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/formulas/m2-formulas-v2/fuzzy

One place for the formulas, meanings, conditions and links to full worked examples.

## Fuzzy formulas

### Triangular membership



$$
\mu(x)=\max\left(0,\min\left(\frac{x-a}{b-a},\frac{c-x}{c-b}\right)\right)
$$



a=left zero, b=peak, c=right zero, with a<b<c. Locate x before choosing the rising/falling branch.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--triangle/)

### Union and intersection



$$
\mu_{A\cup B}=\max(\mu_A,\mu_B)\quad\mu_{A\cap B}=\min(\mu_A,\mu_B)
$$



Compare memberships at the same element. These formulas use standard max–min operations.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--set-operations/)

### Complement and difference



$$
\mu_{A^c}=1-\mu_A\quad\mu_{A\setminus B}=\min(\mu_A,1-\mu_B)
$$



A difference means A AND NOT B; it is not ordinary subtraction.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--set-operations/)

### Rule strength, clipping and aggregation



$$
\alpha_r=\min(a_r,b_r)\quad\mu_r(z)=\min(\alpha_r,\mu_{C_r}(z))\quad\mu_{out}(z)=\max_r\mu_r(z)
$$



a,b are input degrees; α is the strength; z is a candidate output value. OR conditions use max instead.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--rules-clipping/)

### Mean of maxima



$$
z^*=\frac{\sum_{z_i\in M}z_i}{|M|}\quad\text{one plateau }[a,b]:\ z^*=(a+b)/2
$$



M is the set of discrete output locations attaining maximum membership. The plateau shortcut is for one continuous maximum interval.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--mom/)

### Discrete / continuous centroid



$$
z^*=\frac{\sum_i z_i\mu_i}{\sum_i\mu_i}\qquad z^*=\frac{\int z\mu(z)\,dz}{\int\mu(z)\,dz}
$$



Use actual discrete memberships or the full continuous aggregate. Denominator must be positive.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--centroid/)

### Specified representative-weighted output



$$
z^*=\frac{\sum_r\alpha_r c_r}{\sum_r\alpha_r}
$$



c is a supplied representative such as a peak. Do not call this the exact area centroid of a clipped Mamdani aggregate without justification.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--weighted-average/)

### Cartesian product and max–min composition



$$
R_{ij}=\min(A_i,B_j)\quad T_{ik}=\max_j\min(R_{ij},S_{jk})
$$



Relations must have a common middle domain in the same order. Min along a path, max across paths.

[Read the explanation and worked sums →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-relations--composition/)

## Other membership formulas from the reading lessons

### Trapezoid with distinct breakpoints



$$
\mu(x)=\max\left(0,\min\left(\frac{x-a}{b-a},1,\frac{d-x}{d-c}\right)\right)
$$



For a<b≤c<d: a is the left zero, b the start of the height-1 plateau, c its end and d the right zero. Vertical shoulder edges need the specified piecewise definition. [Branch examples →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--trapezoid-intuition/)

### Gaussian membership



$$
\mu(x)=e^{-(x-c)^2/(2\sigma^2)}
$$



c is the centre and σ>0 sets the width. At x=c the exponent is zero and membership is 1. [Worked exponential calculations →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--smooth-memberships/)

### Generalised bell membership



$$
\mu(x)=\frac{1}{1+|(x-c)/a|^{2b}}
$$



a>0 controls width; b>0 controls steepness; c is the centre. First subtract c, divide by a, take absolute value, apply the power, add 1, then take its reciprocal.

### Alpha-cut



$$
A_\alpha=\{x:\mu_A(x)\ge\alpha\}
$$



α is the chosen membership threshold. For 0<α≤1 keep inputs meeting or exceeding it, including threshold-equality endpoints. [Discrete and triangular examples →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/fuzzy-core--properties/)

---

## TEE · GA and PSO formulas, symbols and memory rules

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/formulas/m2-formulas-v2--ga-pso/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/formulas/m2-formulas-v2/ga-pso

One place for the formulas, meanings, conditions and links to full worked examples.

### Binary decoding



$$
x=\sum_{i=1}^{n}b_i2^{n-i}
$$



bᵢ is a bit; the maximum n-bit unsigned integer is 2ⁿ−1.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--encoding/)

### Roulette selection



$$
P_i=F_i/\sum_jF_j\quad C_i=\sum_{j=1}^iP_j
$$



Fitness weights must be nonnegative with a positive total. For minimisation use the specified transformation or selection method. C is cumulative probability.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--selection/)

### Population average



$$
\bar f=\frac{f_1+\cdots+f_N}{N}
$$



N is the number of individuals. Compare both best and average; mutation need not improve either.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--two-generations/)

### PSO velocity



$$
v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)
$$



w weights inertia; c₁r₁ weights personal pull; c₂r₂ weights social pull. Apply the same equation separately to each coordinate.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--equation/)

### PSO position



$$
x^{t+1}=x^t+v^{t+1}
$$



Use the new velocity, not the old one. Then reevaluate the objective.

[Full explanation and worked solutions →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/pso-core--two-particles/)

**Memory updates:** minimise → replace a pbest only for a lower score; maximise → only for a higher score. gbest is a position selected from the personal bests. Store the corresponding objective score alongside it. Keep previous best on ties unless instructed otherwise.

**Yaad rakho:** Formula ke pehle objective direction aur old state likho. Iteration 2 mein fresh positions aur retained memories use karo.

## Encoding and minimisation conventions



$$
x=L+\frac{d}{2^n-1}(U-L)
$$



For the specified uniform real-range encoding: decode n bits into unsigned integer d first. L and U are the physical limits. [Endpoint examples →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--encoding/)



$$
F=\frac{1}{1+f(x)}
$$



This is the stated roulette transformation in our nonnegative-cost minimisation example. It is not required for every GA. It converts a smaller cost into a larger selection weight. [Complete minimisation example →](https://deep-learning-study-room.vercel.app/read/is2/m2/read/ga-core--minimisation/)

---

## TEE · Unit 1 formulas: probability, Bayes, naive Bayes, Bayesian networks, GMM

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/formulas/tee-formulas--unit1/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/formulas/tee-formulas/unit1

Probability, Bayes, GMM/EM, Markov chains and Bellman equations (Units 2–3 are in the M2 sheet)

## Conditions and notation for this revision sheet

Conditional probabilities require nonzero evidence probability. “Prior” means the class probability before the features; “likelihood” is the feature probability given a class; “posterior” is the class probability after evidence. Σ adds alternatives; Π multiplies factors; argmax returns the winning label. For Laplace smoothing, Nc is the class count and k is the number of possible values of the particular feature.

For the Jensen expression below, λ weights are nonnegative, sum to 1, and the logged arguments are positive. For a Gaussian, σ>0. GMM weights πk are nonnegative and sum to 1; γik or λki are responsibilities, not the mixing weights themselves.

Worked explanations: [Naive Bayes](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-nb--model/) · [CPTs and Bayesian networks](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-bn--semantics/) · [Mean, variance and likelihood](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-gmm--centre-spread/) · [EM update](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u1-gmm--em/).

|  |  |
| --- | --- |
| Conditional | 

$$
P(a\mid b)=P(a\land b)/P(b)
$$

 |
| Product rule | 

$$
P(a\land b)=P(a\mid b)P(b)
$$

 |
| Marginalisation | 

$$
P(Y)=\sum_zP(Y,z)
$$

 |
| Normalisation | 

$$
\mathbf P(X\mid e)=\alpha\,\mathbf P(X,e),\;\alpha=1/\sum_xP(x,e)
$$

 |
| Bayes' rule | 

$$
P(A\mid B)=\dfrac{P(B\mid A)P(A)}{P(B\mid A)P(A)+P(B\mid\lnot A)P(\lnot A)}
$$

 |
| Naive Bayes | 

$$
v_{NB}=\arg\max_cP(c)\prod_iP(a_i\mid c)
$$

; Laplace: 

$$
\frac{n_{ic}+1}{N_c+k}
$$

 |
| BN chain rule | 

$$
P(x_1..x_n)=\prod_iP(x_i\mid parents(X_i))
$$

 |
| BN query | 

$$
P(X\mid e)=\alpha\sum_{\text{hidden}}\prod P(\cdot\mid parents)
$$

 |
| CPT size | Boolean node with k Boolean parents: independent probability parameters = 

$$
2^k
$$

 numbers |
| GMM density | 

$$
p(x)=\sum_k\pi_k\mathcal N(x\mid\mu_k,\sigma_k^2)
$$

 |
| Gaussian | 

$$
\mathcal N(x\mid\mu,\sigma^2)=\frac1{\sqrt{2\pi}\sigma}e^{-\frac{(x-\mu)^2}{2\sigma^2}}
$$

 |
| Log-likelihood | 

$$
\log L=\sum_i\log\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)
$$

 |
| Jensen (log concave) | 

$$
\log\sum_k\lambda_ka_k\ge\sum_k\lambda_k\log a_k
$$

 |
| E-step | 

$$
\lambda_k^i=\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)/\sum_l\pi_l\mathcal N(x_i\mid\mu_l,\sigma_l^2)
$$

 |
| M-step | 

$$
\mu_k=\frac{\sum\lambda_k^ix_i}{\sum\lambda_k^i},\;\sigma_k^2=\frac{\sum\lambda_k^i(x_i-\mu_k)^2}{\sum\lambda_k^i},\;\pi_k=\frac{\sum_i\lambda_k^i}{n}
$$

 |
| GMM parameters | 1-D: 

$$
3K-1
$$

 (K = 5 → 14) |

---

## TEE · Unit 4 formulas: Markov chains, MRP, MDP, Bellman

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/formulas/tee-formulas--unit4/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/formulas/tee-formulas/unit4

Probability, Bayes, GMM/EM, Markov chains and Bellman equations (Units 2–3 are in the M2 sheet)

## Read these symbols in context

P is a transition matrix with origin rows and destination columns. π denotes a stationary distribution in the first equations, but a policy in the MDP equations. s′ is a next state; a′ a next action. R is the specified immediate or expected reward; γ discounts future rewards. E means expectation (probability-weighted average). I is the identity matrix.

The two-state stationary shortcut needs a+b>0. The inverse (I−γP)⁻¹ exists for a finite stochastic P with 0≤γ<1; at γ=1, check the problem’s terminal structure instead of assuming the full matrix is invertible. The continuing discounted-return examples use γ<1. A finite episode can also use γ=1.

Q-learning is supplementary here; the explicitly listed course focus is the Markov/MDP and Bellman material. α in Q-learning is a learning rate; α in Bayes normalisation was a different constant.

Worked explanations: [Matrix multiplication](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-markov--next-step/) · [Stationary algebra](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-markov--steady-state/) · [Discounted return](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--mrp-return/) · [Bellman equations](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--bellman-equations/).

|  |  |
| --- | --- |
| Markov property | 

$$
P(S_{t+1}\mid S_t,\dots,S_1)=P(S_{t+1}\mid S_t)
$$

 |
| Transition matrix | 

$$
P_{ij}=P(\text{next}=j\mid\text{now}=i)
$$

; rows sum to 1 |
| Next step | 

$$
x_{t+1}=x_tP
$$

 (row vector); 

$$
x_{t+n}=x_tP^n
$$

 |
| Steady state | 

$$
\pi=\pi P,\;\sum\pi_i=1
$$

; two states 

$$
\begin{bmatrix}1-a&a\\b&1-b\end{bmatrix}\Rightarrow\pi=\left[\frac b{a+b},\frac a{a+b}\right]
$$

 |
| Return | 

$$
G_t=\sum_{k\ge0}\gamma^kR_{t+k+1}
$$

 |
| MRP Bellman | 

$$
v(s)=R(s)+\gamma\sum_{s'}P_{ss'}v(s')
$$

; 

$$
v=(I-\gamma P)^{-1}R
$$

 |
| Policy | 

$$
\pi(a\mid s)=P(A_t=a\mid S_t=s)
$$

 |
| Value functions | 

$$
v_\pi(s)=\mathbb E_\pi[G_t\mid s]
$$

; 

$$
q_\pi(s,a)=\mathbb E_\pi[G_t\mid s,a]
$$

; 

$$
v_\pi=\sum_a\pi(a\mid s)q_\pi(s,a)
$$

 |
| Bellman expectation | 

$$
v_\pi(s)=\sum_a\pi(a\mid s)\sum_{s'}P(s'\mid s,a)[R+\gamma v_\pi(s')]
$$

 |
| Bellman optimality | 

$$
v_*(s)=\max_a\sum_{s'}P(s'\mid s,a)[R+\gamma v_*(s')]
$$

; 

$$
q_*(s,a)=\sum_{s'}P(s'\mid s,a)[R+\gamma\max_{a'}q_*(s',a')]
$$

 |

Optional further reading: the [Q-learning extension](https://deep-learning-study-room.vercel.app/read/is2/tee/read/u4-bellman--solving/) is kept with the Bellman lesson, outside this core formula list.

---

## TEE · TEE-only formulas: ACO and GA for TSP

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/formulas/tee-formulas--aco-tsp/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/formulas/tee-formulas/aco-tsp

Probability, Bayes, GMM/EM, Markov chains and Bellman equations (Units 2–3 are in the M2 sheet)

## Ant colony optimisation

|  |  |
| --- | --- |
| Transition probability | 

$$
P_{ij}=\dfrac{\tau_{ij}^\alpha\eta_{ij}^\beta}{\sum_{l\in\text{allowed}}\tau_{il}^\alpha\eta_{il}^\beta},\;\eta_{ij}=1/d_{ij}
$$

 |
| Choice rule | cumulative probabilities in **city order**; first city with cumulative ≥ r |
| Pheromone update | 

$$
\tau_{ij}\leftarrow(1-\rho)\tau_{ij}+\sum_{k:\,ij\in tour_k} Q/L_k
$$

 on every edge ant k used (return edge included); symmetric only for an undirected symmetric TSP |
| Values assumed in the worked PYQs | 

$$
\alpha=\beta=1,\;\rho=0.5,\;Q=1,\;\tau_0=1
$$

 |

α weights pheromone influence; β weights inverse-distance influence; ρ is the evaporation rate; Q is the deposit constant; L is the complete tour length. These must be supplied or explicitly assumed. Do not treat the example values as universal defaults.



$$
L=\sum_{i=1}^{n-1}d(c_i,c_{i+1})+d(c_n,c_1)
$$





$$
F_{TSP}=1/L
$$



The return edge is part of the tour. Permutation crossover/mutation must keep each city exactly once. For positive lengths, shorter length gives larger reciprocal fitness.

---

## TEE · Q1(a) Joint probability table [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q1a

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. A supermarket recorded the joint distribution of Product type (Y: premium = 1, regular = 0), Payment mode (X: credit = 1, debit = 0) and Gender (Z: female = 1, male = 0). (a) If a customer bought a premium item, find the probability that (1) they are female, (2) they paid by credit card. (b) Find (1) P(premium) and (2) P(credit card). (c) Given a male customer paid by debit card, find the probability he bought a regular item.** [5 marks]

### Answer

#### Given

The printed eight entries are reproduced below. Their total is 1.002, not 1. Therefore the table is inconsistent as a probability distribution.

|  | Credit, female | Credit, male | Debit, female | Debit, male |
| --- | --- | --- | --- | --- |
| **Premium (Y=1)** | 0.08 | 0.10 | 0.072 | 0.05 |
| **Regular (Y=0)** | 0.10 | 0.15 | 0.25 | 0.20 |

#### To find

The five requested probabilities, stating how the inconsistent data are interpreted.

#### Formula and why it applies

For this worked solution, treat all printed entries as nonnegative weights and normalise by their total 1.002. This preserves the printed ratios. It is a declared interpretation, not a claim about the examiner’s intended correction.



$$
P(E)=\frac{\text{sum of weights for }E}{\text{sum of all weights}}
$$





$$
P(A\mid E)=\frac{\text{sum of weights for }A\cap E}{\text{sum of weights for }E}
$$



#### Solution

##### Step 1. Validate the full table



$$
0.08+0.10+0.072+0.05+0.10+0.15+0.25+0.20=1.002
$$



Use total weight 1.002 consistently for unconditional probabilities.

##### Step 2. Premium row total



$$
w(premium)=0.08+0.10+0.072+0.05=0.302
$$



##### Step 3. Female given premium



$$
P(female\mid premium)=\frac{0.08+0.072}{0.302}=\frac{0.152}{0.302}\approx0.503311
$$



##### Step 4. Credit given premium



$$
P(credit\mid premium)=\frac{0.08+0.10}{0.302}=\frac{0.18}{0.302}\approx0.596026
$$



##### Step 5. Normalised premium marginal



$$
P(premium)=\frac{0.302}{1.002}\approx0.301397
$$



##### Step 6. Normalised credit marginal



$$
P(credit)=\frac{0.08+0.10+0.10+0.15}{1.002}=\frac{0.43}{1.002}\approx0.429142
$$



##### Step 7. Regular given male and debit



$$
P(regular\mid male,debit)=\frac{0.20}{0.05+0.20}=0.8
$$



**Final answer.** Under common normalisation: (a) 0.503311 and 0.596026; (b) 0.301397 and 0.429142; (c) 0.8.

**Alternative correction:** if 0.072 is corrected to 0.070, the total becomes 1 and the corresponding answers are (a) 0.50 and 0.60; (b) 0.30 and 0.43; (c) 0.8. This agrees with the interpretation used in the supplied key. State the correction; do not call raw totals 0.302 and 0.43 valid marginals of the original inconsistent table.

---

## TEE · Q1(b) Applications of ACO [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q1b

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**List the applications of Ant Colony Optimization and explain any one application in detail.** [5 marks]

### Answer

### Definition (1 line)

Ant Colony Optimization is a probabilistic, population-based metaheuristic (Dorigo, 1992) in which artificial ants build solutions on a graph and communicate through pheromone trails. In the update rule used here, evaporation reduces all stored trails; deposits then reinforce edges of selected tours according to solution quality. Evaporation does not occur only on poor paths.

### Applications

1. **Travelling salesman problem**: shortest tour visiting every city once.
2. **Vehicle routing**: delivery routes for a fleet with capacity and time windows (minimising distance, time, fuel).
3. **Network routing**: adaptive routing of data packets in communication and sensor networks (AntNet).
4. **Job-shop and project scheduling**: assigning jobs to machines to minimise completion time.
5. **Image processing**: edge detection, with ants moving over pixel-intensity graphs.
6. **Assignment problems**: quadratic assignment, timetabling, graph colouring.
7. **Feature selection and data mining**: Ant-Miner for classification rules.
8. **Load balancing** in distributed systems and cloud task allocation.

### One application in detail: vehicle routing (or TSP)

1. **Graph.** Depot and customers are nodes; travel times or distances are edge weights.
2. **Ants.** Each ant builds a complete set of routes. From its current customer it chooses the next with probability 

$$
\propto\tau_{ij}\,(1/d_{ij})
$$

, skipping customers already served or that would exceed the vehicle capacity; when the vehicle is full it returns to the depot.
3. **Evaluation.** Total distance (plus penalties for late deliveries).
4. **Learning.** Pheromone evaporates everywhere and is added in proportion to 

$$
Q/L
$$

 on the routes of good solutions, so short connections are reinforced.
5. **Result.** Repeated iterations search for low-cost routes; finite-run convergence to the optimum is not guaranteed. Companies use this for parcel delivery, waste collection and school-bus routing.

### Advantages and limitations

| Advantages | Limitations |
| --- | --- |
| Naturally suited to graph and routing problems | Several parameters to tune (α, β, ρ, number of ants) |
| Can share useful route information and adapt search to changing graphs | Convergence time is uncertain; may stagnate on a sub-optimal path |
| Positive feedback + parallel ants | Theoretical analysis is difficult |

**Yaad rakho:** ACO = “raaste wale problems” (TSP, routing, scheduling). PSO = “numbers wale problems” (continuous function, weights).

---

## TEE · Q1(c) Fuzzy set operations [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q1c

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Consider two fuzzy sets X = {(c1, 0.6), (c2, 0.8), (c3, 0.3), (c4, 0.5), (c5, 0.7)} and Y = {(c1, 0.4), (c2, 0.5), (c3, 0.9), (c4, 0.6), (c5, 0.2)}. Find 1) X ∪ Y 2) X ∩ Y 3) ¬X ∪ ¬Y 4) ¬X ∩ ¬Y.** [5 marks]

### Answer

#### Given

The aligned X and Y memberships printed in this question.

#### To find

The four requested membership lists in the original element order.

#### Formula and why it applies

Use max for OR, min for AND, and 1−μ for NOT.



$$
\mu_{X\cup Y}=\max(\mu_X,\mu_Y),\quad\mu_{X\cap Y}=\min(\mu_X,\mu_Y)
$$



Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.

#### Solution

##### Step 1. Complements

¬X = {0.4, 0.2, 0.7, 0.5, 0.3}; ¬Y = {0.6, 0.5, 0.1, 0.4, 0.8}.

##### Step 2. Table

|  | c1 | c2 | c3 | c4 | c5 |
| --- | --- | --- | --- | --- | --- |
| X | 0.6 | 0.8 | 0.3 | 0.5 | 0.7 |
| Y | 0.4 | 0.5 | 0.9 | 0.6 | 0.2 |
| **X ∪ Y = max** | 0.6 | 0.8 | 0.9 | 0.6 | 0.7 |
| **X ∩ Y = min** | 0.4 | 0.5 | 0.3 | 0.5 | 0.2 |
| **¬X ∪ ¬Y** | 0.6 | 0.5 | 0.7 | 0.5 | 0.8 |
| **¬X ∩ ¬Y** | 0.4 | 0.2 | 0.1 | 0.4 | 0.3 |

##### Step 3. Check with De Morgan's law

¬X ∪ ¬Y must equal 1 − (X ∩ Y) = {0.6, 0.5, 0.7, 0.5, 0.8} ✓, and ¬X ∩ ¬Y must equal 1 − (X ∪ Y) = {0.4, 0.2, 0.1, 0.4, 0.3} ✓.

**Final answer.** X ∪ Y = {(c1,0.6),(c2,0.8),(c3,0.9),(c4,0.6),(c5,0.7)}; X ∩ Y = {(c1,0.4),(c2,0.5),(c3,0.3),(c4,0.5),(c5,0.2)}; ¬X ∪ ¬Y = {(c1,0.6),(c2,0.5),(c3,0.7),(c4,0.5),(c5,0.8)}; ¬X ∩ ¬Y = {(c1,0.4),(c2,0.2),(c3,0.1),(c4,0.4),(c5,0.3)}.

Official marking: 1 + 1 + 1.5 + 1.5.

## Calculate every element separately

### Element c1



$$
\neg X:1-0.6=0.4\qquad\neg Y:1-0.4=0.6
$$





$$
X\cup Y:\max(0.6,0.4)=0.6
$$





$$
X\cap Y:\min(0.6,0.4)=0.4
$$





$$
\neg X\cup\neg Y:\max(0.4,0.6)=0.6
$$





$$
\neg X\cap\neg Y:\min(0.4,0.6)=0.4
$$



### Element c2



$$
\neg X:1-0.8=0.2\qquad\neg Y:1-0.5=0.5
$$





$$
X\cup Y:\max(0.8,0.5)=0.8
$$





$$
X\cap Y:\min(0.8,0.5)=0.5
$$





$$
\neg X\cup\neg Y:\max(0.2,0.5)=0.5
$$





$$
\neg X\cap\neg Y:\min(0.2,0.5)=0.2
$$



### Element c3



$$
\neg X:1-0.3=0.7\qquad\neg Y:1-0.9=0.1
$$





$$
X\cup Y:\max(0.3,0.9)=0.9
$$





$$
X\cap Y:\min(0.3,0.9)=0.3
$$





$$
\neg X\cup\neg Y:\max(0.7,0.1)=0.7
$$





$$
\neg X\cap\neg Y:\min(0.7,0.1)=0.1
$$



### Element c4



$$
\neg X:1-0.5=0.5\qquad\neg Y:1-0.6=0.4
$$





$$
X\cup Y:\max(0.5,0.6)=0.6
$$





$$
X\cap Y:\min(0.5,0.6)=0.5
$$





$$
\neg X\cup\neg Y:\max(0.5,0.4)=0.5
$$





$$
\neg X\cap\neg Y:\min(0.5,0.4)=0.4
$$



### Element c5



$$
\neg X:1-0.7=0.3\qquad\neg Y:1-0.2=0.8
$$





$$
X\cup Y:\max(0.7,0.2)=0.7
$$





$$
X\cap Y:\min(0.7,0.2)=0.2
$$





$$
\neg X\cup\neg Y:\max(0.3,0.8)=0.8
$$





$$
\neg X\cap\neg Y:\min(0.3,0.8)=0.3
$$



---

## TEE · Q1(d) Brand-switching Markov chain [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q1d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q1d

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Users switch between Brand X and Brand Y each year: 25% of X users switch to Y and 75% stay; 40% of Y users switch to X and 60% stay. (a) Write the transition probability matrix. (b) Draw the state transition diagram.** [5 marks]

### Answer

#### Given

All transition values are given in the full question. State order: X, Y.

#### To find

The transition matrix and state diagram.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.

#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | X | Y |
| --- | --- | --- |
| X | 0.75 | 0.25 |
| Y | 0.4 | 0.6 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_brand.c2c4be3e6a.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Brand switching each year | 0.25 | 0.4 | 0.75 | 0.6 | X | Y

Each arrow is labelled with the probability of that transition.

**Final answer.** The transition matrix and state diagram are given above.

---

## TEE · Q2(a) PSO, one iteration [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q2a

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Maximize 

$$
F(x_1,x_2)=2x_1^2-3x_1x_2+x_2^2+5x_1+2x_2+7
$$

 using Particle Swarm Optimization. 

$$
X=\begin{bmatrix}2.5&-3.0\\3.5&-1.5\end{bmatrix},\;V=\begin{bmatrix}0.2&0.3\\0.1&0.25\end{bmatrix}
$$

. Take 

$$
W=0.9,\;c_1=c_2=1.5,\;r_1=0.5949,\;r_2=0.0855
$$

. Optimize and give the solution after 1 iteration showing the step-by-step process.** [10 marks]

### Answer

#### Given

Particle 1: 

$$
x=(2.5,\,-3.0)
$$

, 

$$
v=(0.2,\,0.3)
$$

. Particle 2: 

$$
x=(3.5,\,-1.5)
$$

, 

$$
v=(0.1,\,0.25)
$$

.



$$
c_1r_1=1.5\times0.5949=0.89235,\qquad c_2r_2=1.5\times0.0855=0.12825
$$



#### To find

Fitness, pbest, gbest; new velocities and positions; updated pbest and gbest.

#### Formula and why it applies



$$
v_{ij}\leftarrow wv_{ij}+c_1r_1(p^b_{ij}-x_{ij})+c_2r_2(p^g_j-x_{ij}),\qquad x_{ij}\leftarrow x_{ij}+v_{ij}
$$



Each particle is pulled by its own memory and by the swarm's best; we maximise, so the larger 

$$
F
$$

 is better.

#### Solution

##### Step 1. Fitness of particle 1



$$
F(2.5,-3)=2(6.25)-3(2.5)(-3)+9+5(2.5)+2(-3)+7=12.5+22.5+9+12.5-6+7=57.5
$$



##### Step 2. Fitness of particle 2



$$
F(3.5,-1.5)=2(12.25)-3(3.5)(-1.5)+2.25+17.5-3+7=24.5+15.75+2.25+17.5-3+7=64
$$



##### Step 3. pbest and gbest

| Particle | Position | F | pbest |
| --- | --- | --- | --- |
| 1 | (2.5, −3.0) | 57.5 | (2.5, −3.0) |
| 2 | (3.5, −1.5) | 64 | (3.5, −1.5) |

No previous iteration, so pbest = current position. Largest fitness is 64, so **gbest = (3.5, −1.5)**.

##### Step 4. Velocity and position of particle 1



$$
v_{11}=0.9(0.2)+0.89235(2.5-2.5)+0.12825(3.5-2.5)=0.18+0+0.12825=0.30825
$$





$$
x_{11}=2.5+0.30825=2.80825
$$





$$
v_{12}=0.9(0.3)+0.89235(0)+0.12825(-1.5-(-3.0))=0.27+0.192375=0.462375
$$





$$
x_{12}=-3.0+0.462375=-2.537625
$$



##### Step 5. Velocity and position of particle 2 (it is gbest, so both pull terms are 0)



$$
v_{21}=0.9(0.1)+0+0=0.09,\qquad x_{21}=3.5+0.09=3.59
$$





$$
v_{22}=0.9(0.25)+0+0=0.225,\qquad x_{22}=-1.5+0.225=-1.275
$$



##### Step 6. New fitness



$$
F(2.80825,-2.537625)=15.772536+21.378856+6.439541+14.04125-5.07525+7=59.5569
$$





$$
F(3.59,-1.275)=25.7762+13.73175+1.625625+17.95-2.55+7=63.5336
$$



##### Step 7. Update pbest and gbest

| Particle | New position | New F | Old pbest F | pbest after iteration |
| --- | --- | --- | --- | --- |
| 1 | (2.80825, −2.537625) | 59.5569 | 57.5 | (2.80825, −2.537625) — improved |
| 2 | (3.59, −1.275) | 63.5336 | 64 | (3.5, −1.5) — kept |

The best pbest fitness is still 64, so gbest stays (3.5, −1.5).

**Final answer.** 

$$
V=\begin{bmatrix}0.30825&0.462375\\0.09&0.225\end{bmatrix}
$$

, 

$$
X=\begin{bmatrix}2.80825&-2.537625\\3.59&-1.275\end{bmatrix}
$$

. After one iteration particle 1 improved to F = 59.5569; the best solution so far is gbest = (3.5, −1.5) with F = 64.

Official key: fitness and gbest (5 marks), velocity and position updates (5 marks). The calculations above use the question data. The key's summary matrix writes 0.462 in place of 2.808 for 

$$
x_{11}
$$

; that is a copying slip.

---

## TEE · Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q2b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q2b

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**With reference to the Gaussian Mixture Model (GMM): compare GMM with the k-means algorithm; derive the equation for the log-likelihood function; state the number of parameters to be computed if K = 5.** [10 marks]

### Answer

## Read the derivation’s symbols first

“i.i.d.” means the observations are modelled as independent draws from the same distribution. The product Π runs over observations; the inner sum Σ runs over components. λki in some notes is the same responsibility that other sections call γik. A superscript i here labels the observation, not an exponent.

Jensen’s inequality gives a lower bound on the log of the component sum. EM chooses responsibilities making that bound touch the current likelihood, then updates the parameters to maximise the bound with those responsibilities fixed. This explains the two alternating steps; λ values are not arbitrary new model parameters.

| Parameter | Number in a 1D K-component GMM | Why |
| --- | --- | --- |
| Means | K | One centre for each component |
| Variances | K | One spread for each component |
| Independent mixing weights | K−1 | The last weight is 1 minus the others |
| Total | 3K−1 | K+K+(K−1) |

For K=2, choose μ₁,μ₂,σ₁²,σ₂² and π₁: five free numbers. Then π₂=1−π₁. For K=5, 5+5+4=14. In 2D with a full covariance matrix, each component instead has two means and three independent covariance entries (two variances and one shared off-diagonal covariance). Five such components have 5×(2+3)+4=29 free parameters.

### 1. GMM versus k-means

| Aspect | k-means | GMM |
| --- | --- | --- |
| Assignment | Hard: each point in exactly one cluster | Soft: probability 

$$
\lambda_k^i
$$

 of belonging to each cluster |
| Model | Geometric: nearest centroid | Probabilistic generative model 

$$
\sum_k\pi_k\mathcal N(\mu_k,\Sigma_k)
$$

 |
| Cluster shape | Spherical, similar size | Elliptical, any size/orientation; overlapping clusters |
| Parameters | K centroids | Weights, means, covariances (1-D: 3K − 1) |
| Algorithm / objective | Assign–update; minimise squared distances | EM; maximise log-likelihood |
| Output | Hard labels and fitted centroids | Labels, membership probabilities and a density (useful for anomaly detection) |
| Relation | The hard-assignment, equal spherical variance, small-variance limit of a Gaussian-mixture objective leads to the k-means objective. Ordinary finite-variance EM is not the same algorithm as k-means. Both need K in advance and depend on initialisation. | |

### 2. Derivation of the log-likelihood

**Step 1. Model.** Each point is generated by choosing component k with probability 

$$
\pi_k
$$

 and drawing 

$$
x_i\sim\mathcal N(\mu_k,\sigma_k^2)
$$

, so its density is 

$$
f_{mix}(x_i)=\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)
$$

.

**Step 2. Likelihood.** Points are i.i.d., so the likelihood is a product (θ = all parameters):



$$
L(\theta)=\prod_{i=1}^{n}\Big[\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big]
$$



**Step 3. Log-likelihood.** Logs turn the product into a sum:



$$
\log L(\theta)=\sum_{i=1}^{n}\log\Big(\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big)
$$



**Step 4. Why it cannot be solved directly.** The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.

**Step 5. Jensen's inequality.** log is concave, so for weights 

$$
\lambda_k\ge0,\;\sum\lambda_k=1
$$

: 

$$
\log\big(\sum_k\lambda_ka_k\big)\ge\sum_k\lambda_k\log a_k
$$

. Introduce 

$$
\lambda_k^i
$$

 for every point (

$$
\sum_k\lambda_k^i=1
$$

), multiply and divide inside the log:



$$
\log L(\theta)=\sum_i\log\Big(\sum_k\lambda_k^i\,\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}\Big)\;\ge\;\sum_i\sum_k\lambda_k^i\log\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}
$$



**Step 6. Estimation (EM).** Maximise the lower bound alternately. Fixing θ gives the E-step 

$$
\lambda_k^i=\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)/\sum_l\pi_l\mathcal N(x_i\mid\mu_l,\sigma_l^2)
$$

. Fixing λ and differentiating (with a Lagrange multiplier for 

$$
\sum\pi_k=1
$$

) gives the M-step:



$$
\hat\mu_k=\frac{\sum_i\lambda_k^ix_i}{\sum_i\lambda_k^i},\qquad\hat\sigma_k^2=\frac{\sum_i\lambda_k^i(x_i-\hat\mu_k)^2}{\sum_i\lambda_k^i},\qquad\hat\pi_k=\frac{\sum_i\lambda_k^i}{n}
$$



### 3. Number of parameters for K = 5

The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:



$$
2K+(K-1)=3K-1=3(5)-1=\mathbf{14}
$$



(5 means + 5 variances + 4 free weights, since the 5 weights must add to 1.) In two dimensions with full covariance it would be 29.

**Slide note.** One slide puts the convex inequality under the “concave” heading. Correct: log is *concave*, so 

$$
f(\sum\lambda a)\ge\sum\lambda f(a)
$$

 (≥, not >).

---

## TEE · Q3(a) Bayesian network: wet grass given no rain [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q3a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q3a

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Cloudy → Sprinkler, Cloudy → Rain, Sprinkler and Rain → Wet Grass. P(Cloudy) = 0.5; P(Sprinkler | C) = 0.10, P(Sprinkler | ¬C) = 0.50; P(Rain | C) = 0.80, P(Rain | ¬C) = 0.20; P(Wet | S, R) = 0.99, P(Wet | S, ¬R) = 0.90, P(Wet | ¬S, R) = 0.90, P(Wet | ¬S, ¬R) = 0.01. Calculate the probability of the grass being wet given it doesn't rain.** [10 marks]

### Answer

The following table enumerates the values of Cloudy and Sprinkler that were not fixed by the question. Two Boolean choices give four rows: true/true, true/false, false/true, false/false. Each row is one mutually exclusive complete case. Read the CPT entry using that row’s parent values, multiply its factors, and add the resulting row weights. The denominator must include all cases matching the evidence, including both possible values of the queried outcome.

#### Given

C→S, C→R, (S,R)→W. Root and conditional probabilities are listed in the question. Evidence R=false.

#### To find

P(W=true | R=false). Hidden variables C and S must be summed out.

#### Formula and why it applies

Use the network joint and divide by the evidence probability.



$$
P(W\mid\neg R)=\frac{\sum_{c,s}P(c)P(s\mid c)P(\neg R\mid c)P(W\mid s,\neg R)}{\sum_cP(c)P(\neg R\mid c)}
$$



#### Solution

Swipe across the diagram to read its labels ↔

![Final 2025 Q3a: sprinkler network](https://deep-learning-study-room.vercel.app/is2/fig/bn_sprinkler.a251583272.svg)

Diagram: Final 2025 Q3a: sprinkler network. Labels: Final 2025 Q3a: sprinkler network | Cloudy | P(C) = 0.5 | Sprinkler | P(S|C) = 0.1, P(S|¬C) = 0.5 | Rain | P(R|C) = 0.8, P(R|¬C) = 0.2 | Wet grass | P(W|S,R): .99 · .90 · .90 · .01 | (TT · TF · FT · FF)

##### Step 1. Joint by the chain rule



$$
P(C,S,R,W)=P(C)\,P(S\mid C)\,P(R\mid C)\,P(W\mid S,R)
$$



##### Step 2. Sum over C and S with R = false, W = true

| C | S | P(C) | P(S|C) | P(¬R|C) | P(W|S,¬R) | Product |
| --- | --- | --- | --- | --- | --- | --- |
| T | T | 0.5 | 0.1 | 0.2 | 0.90 | 0.0090 |
| T | F | 0.5 | 0.9 | 0.2 | 0.01 | 0.0009 |
| F | T | 0.5 | 0.5 | 0.8 | 0.90 | 0.1800 |
| F | F | 0.5 | 0.5 | 0.8 | 0.01 | 0.0020 |
| **P(W, ¬R)** | | | | | | **0.1919** |

##### Step 3. Evidence



$$
P(\lnot R)=P(C)P(\lnot R\mid C)+P(\lnot C)P(\lnot R\mid\lnot C)=0.5(0.2)+0.5(0.8)=0.5
$$



##### Step 4. Divide



$$
P(W\mid\lnot R)=\frac{0.1919}{0.5}=0.3838
$$



**Final answer.** P(grass wet | no rain) ≈ **0.384**. Without rain, the grass is wet mainly when the sprinkler runs (more likely on non-cloudy days).

**Keep the requested conditional probability separate.** The supplied key discusses P(Wet) and P(Rain | Wet), whereas this question asks P(Wet | no rain). The answer to the printed question is 0.3838. For comparison, the exact marginal from the printed CPT is calculated below; it is not 0.6505.

#### Optional comparison: calculate P(Wet) from the same network

The four no-rain cases already total 0.1919. Now add the four rain cases, keeping the same Cloudy/Sprinkler order.



$$
P(W,R)=0.5(0.1)(0.8)(0.99)+0.5(0.9)(0.8)(0.90)+0.5(0.5)(0.2)(0.99)+0.5(0.5)(0.2)(0.90)
$$





$$
P(W,R)=0.0396+0.324+0.0495+0.045=0.4581
$$





$$
P(W)=P(W,R)+P(W,\neg R)=0.4581+0.1919=0.6500
$$





$$
P(R\mid W)=\frac{0.4581}{0.6500}\approx0.704769231
$$



**Meaning:** the unconditional chance of Wet is 0.65, the chance of Rain among wet cases is about 0.704769, and the requested chance of Wet among no-rain cases is 0.3838. These are three different questions.

**Trap.** Do not plug in the marginal P(Sprinkler) = 0.3; sprinkler and rain both depend on Cloudy, so you must sum over Cloudy (given no rain, P(S) = 0.42).

---

## TEE · Q3(b) Fuzzy loan-approval system [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q3b

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**A bank uses fuzzy decision support with Credit Score and Income Stability, both on 1–100. Loan Approval is a score on 1–100 with labels Reject, Consider and Approve. Define triangular membership functions, construct nine rules, explain Mamdani inference and defuzzify for Credit Score=55 and Income Stability=35.** [10 marks]

### Answer

#### Given

| Variable | Crisp value |
| --- | --- |
| Credit Score | 55 |
| Income Stability | 35 |

The question asks us to design the membership functions. This solution chooses Low=Tri(1,25,50), Medium=Tri(25,50,75), High=Tri(50,75,100) for both inputs. Output labels use the same triangles in their respective order. These are explicit design choices, not additional printed givens.

#### To find

A complete stated design and its continuous Mamdani centroid.

#### Formula and why it applies

Use min for AND and implication, max for aggregation and the true area centroid of the resulting shape. A peak-only weighted average is a different defuzzifier.



$$
z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

##### Step 1. Specify the membership functions

| Input / output position | Triangle | Peak |
| --- | --- | --- |
| Low / Reject | (1,25,50) | 25 |
| Medium / Consider | (25,50,75) | 50 |
| High / Approve | (50,75,100) | 75 |

Use 0 outside each triangle, the rising fraction before the peak and the falling fraction after it. This design is evaluated at the requested input; a deployed controller would also need coverage/fallback at all boundary values.

##### Step 2. Write all nine rules

| Credit Score / Income Stability | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Reject | Reject | Consider |
| Medium | Reject | Consider | Approve |
| High | Consider | Approve | Approve |

Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.

##### Step 3. Fuzzify Credit Score = 55



$$
\mu_{Low}(55)=0
$$





$$
\mu_{Medium}(55)=\frac{75-55}{75-50}=0.8
$$





$$
\mu_{High}(55)=\frac{55-50}{75-50}=0.2
$$



##### Step 4. Fuzzify Income Stability = 35



$$
\mu_{Low}(35)=\frac{50-35}{50-25}=0.6
$$





$$
\mu_{Medium}(35)=\frac{35-25}{50-25}=0.4
$$





$$
\mu_{High}(35)=0
$$



##### Step 5. Evaluate all rules and aggregate matching consequents

| Credit Score | Income Stability | Firing strength | Consequent |
| --- | --- | --- | --- |
| Low | Low | min(0,0.6) = 0 | Reject |
| Low | Medium | min(0,0.4) = 0 | Reject |
| Low | High | min(0,0) = 0 | Consider |
| Medium | Low | min(0.8,0.6) = 0.6 | Reject |
| Medium | Medium | min(0.8,0.4) = 0.4 | Consider |
| Medium | High | min(0.8,0) = 0 | Approve |
| High | Low | min(0.2,0.6) = 0.2 | Consider |
| High | Medium | min(0.2,0.4) = 0.2 | Approve |
| High | High | min(0.2,0) = 0 | Approve |

Aggregated label strengths: Reject = 0.6, Consider = 0.4, Approve = 0.2.



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



##### Step 6. Draw the aggregated output

Swipe across the diagram to read its labels ↔

![The shaded upper envelope counts any overlap only once.](https://deep-learning-study-room.vercel.app/is2/fig/v2_loan_aggregate.2c5ffa32a7.svg)

Diagram: The shaded upper envelope counts any overlap only once.. Labels: Chosen triangular output sets and their max-aggregate | 0 | 0.5 | 1 | 1 | 25 | 50 | 75 | 100 | μ | Output score | Reject | Consider | Approve | centroid ≈ 42.78

The shaded upper envelope counts any overlap only once.

##### Step 7. Calculate area and moment of each straight-line strip

For a strip from a to b with endpoint heights u and v, its trapezoid area is A. Its first moment M is the integral of z times the line height.



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}\big[(2a+b)u+(a+2b)v\big]
$$



| a | b | u | v | Area A | Moment M |
| --- | --- | --- | --- | --- | --- |
| 1 | 15.4 | 0 | 0.6 | 4.32 | 45.792 |
| 15.4 | 25 | 0.6 | 0.6 | 5.76 | 116.352 |
| 25 | 35 | 0.6 | 0.6 | 6 | 180 |
| 35 | 40 | 0.6 | 0.4 | 2.5 | 93.333333333 |
| 40 | 50 | 0.4 | 0.4 | 4 | 180 |
| 50 | 55 | 0.4 | 0.4 | 2 | 105 |
| 55 | 65 | 0.4 | 0.4 | 4 | 240 |
| 65 | 70 | 0.4 | 0.2 | 1.5 | 100.833333333 |
| 70 | 75 | 0.2 | 0.2 | 1 | 72.5 |
| 75 | 95 | 0.2 | 0.2 | 4 | 340 |
| 95 | 100 | 0.2 | 0 | 0.5 | 48.333333333 |

##### Step 8. Divide total moment by total area



$$
\sum A=35.58
$$





$$
\sum M=1522.144
$$





$$
z^*=\frac{1522.144}{35.58}\approx42.780888139
$$



**Final answer.** For these stated triangles and rules, the centroid is 42.780888139. This is a fuzzy suitability score; the category memberships can be evaluated at this score. The model alone is not a complete loan-decision policy.

Because the paper asks for a design, a different explicitly specified membership/rule system can yield a different numerical output. Explain the choices and use the chosen defuzzification method consistently; no particular examiner mark outcome is promised.

## How the centroid table’s breakpoints are obtained

For each output triangle, solve “line height = clip height”. Reject is clipped at .6: rising endpoint 1+.6(25−1)=15.4 and falling endpoint 50−.6(50−25)=35. Consider is clipped at .4: endpoints 25+.4(50−25)=35 and 75−.4(75−50)=65. Approve is clipped at .2: endpoints 50+.2(75−50)=55 and 100−.2(100−75)=95.

Now take the maximum of the three clipped curves. The declining Reject edge reaches the Consider height .4 at (50−z)/25=.4, hence z=40. The declining Consider edge reaches the Approve height .2 at (75−z)/25=.2, hence z=70. These crossover locations must be included when splitting the aggregate. Original peaks and other clip endpoints may add extra splits without changing the total area.

**For the first aggregate strip from a=1 to b=15.4, endpoint heights are u=0 and v=0.6. Find its area and first moment.** [3 marks · Worked example]

#### Given

Strip endpoints a=1 and b=15.4; left height u=0 and right height v=0.6. This is a straight rising edge of the clipped Reject set.

#### To find

A and M for one table row.

#### Formula and why it applies



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}[(2a+b)u+(a+2b)v]
$$



A is trapezoid area. M weights every small area by its horizontal position; this formula integrates a straight line.

#### Solution

##### Step 1. Width and height sum



$$
b-a=15.4-1=14.4\qquad u+v=0.6
$$



##### Step 2. Area



$$
A=14.4\times0.6/2=8.64/2=4.32
$$



##### Step 3. First bracket term



$$
(2a+b)u=(2+15.4)\times0=0
$$



##### Step 4. Second bracket term



$$
(a+2b)v=(1+30.8)\times0.6=31.8\times0.6=19.08
$$



##### Step 5. Moment



$$
M=(14.4/6)(0+19.08)=2.4\times19.08=45.792
$$



**Final answer.** Area=4.32; moment=45.792. Repeat the same arithmetic for each row, then sum the areas and moments separately.

### Interpret the loan result using an explicit decision rule

Choose the output label having the greatest membership at the centroid; this is an additional stated interpretation rule. At z=42.780888139:



$$
\mu_{Reject}=(50-z)/25\approx0.288764474,\quad\mu_{Consider}=(z-25)/25\approx0.711235526,\quad\mu_{Approve}=0
$$



The resulting recommendation is **Consider / manual review**; this design does not recommend automatic approval. If a binary approve/reject answer is required, the question must supply a threshold or you must state the threshold you adopt. A different decision threshold is separate from defuzzification.

---

## TEE · Q4(a) Cartesian product and max–min composition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q4a

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Consider fuzzy sets A = {0.4/small + 0.3/medium + 0.1/large} and B = {0.2/slow + 0.7/moderate + 0.3/fast}. 1. Find R = A × B. 2. Given C = {0.3/small + 0.1/medium + 0.4/large}, find S = C × B. 3. Calculate the max–min composition S ∘ R.** [10 marks]

### Answer

#### Given

The fuzzy sets or relation matrices and their listed row/column order.

#### To find

The relation matrix/matrices and the composition specified in the question.

#### Formula and why it applies

For Cartesian products take min of row and column membership. For the ordered matrix composition shown here:



$$
T_{ik}=\max_j\min(S_{ij},R_{jk})
$$



If max–product is asked instead, replace the inner min by multiplication.

#### Solution

##### Step 1. R = A × B (rows small, medium, large; columns slow, moderate, fast)



$$
R=\begin{bmatrix}\min(.4,.2)&\min(.4,.7)&\min(.4,.3)\\\min(.3,.2)&\min(.3,.7)&\min(.3,.3)\\\min(.1,.2)&\min(.1,.7)&\min(.1,.3)\end{bmatrix}=\begin{bmatrix}0.2&0.4&0.3\\0.2&0.3&0.3\\0.1&0.1&0.1\end{bmatrix}
$$



##### Step 2. S = C × B



$$
S=\begin{bmatrix}0.2&0.3&0.3\\0.1&0.1&0.1\\0.2&0.4&0.3\end{bmatrix}
$$



##### Step 3. S ∘ R by max–min (row of S with column of R)

The printed relation domains do not directly compose: both relate size to speed. For the numerical exercise, explicitly assume positional alignment and compute row of S with column of R. Equal dimensions alone are not a justification for semantic relation composition.



$$
(1,1)=\max[\min(.2,.2),\min(.3,.2),\min(.3,.1)]=\max(.2,.2,.1)=0.2
$$





$$
(1,2)=\max[\min(.2,.4),\min(.3,.3),\min(.3,.1)]=\max(.2,.3,.1)=0.3
$$





$$
(1,3)=\max[\min(.2,.3),\min(.3,.3),\min(.3,.1)]=0.3
$$



Row 2 of S is all 0.1, so every entry of row 2 is 0.1.



$$
(3,1)=\max[\min(.2,.2),\min(.4,.2),\min(.3,.1)]=0.2,\;(3,2)=\max[.2,.3,.1]=0.3,\;(3,3)=\max[.2,.3,.1]=0.3
$$



**Final answer.** 

$$
S\circ R=\begin{bmatrix}0.2&0.3&0.3\\0.1&0.1&0.1\\0.2&0.3&0.3\end{bmatrix}
$$

.

**Official key note.** The key first printed a wrong matrix with row 2 = (0.2, 0.3, 0.3), then corrected it by hand to (0.1, 0.1, 0.1). The corrected matrix above is right. Marking: R 3, S 3, composition 4.

**A careful remark you can add.** Strictly, composition needs S: X → Y and R: Y → Z, while here both relate size to speed. The numerical matrix calculation above assumes positional identification of the three middle labels; that is a declared repair, not a valid size-to-speed relation composition without an extra mapping.

## Every cell without the row shortcuts

Both printed relations run from size to speed; their middle labels do not match for genuine relation composition. The numerical working below follows the question’s intended row-of-S with column-of-R operation using explicitly assumed positional alignment of the three middle entries.

### R: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| R11 | 0.4 | 0.2 | 0.2 |
| R12 | 0.4 | 0.7 | 0.4 |
| R13 | 0.4 | 0.3 | 0.3 |
| R21 | 0.3 | 0.2 | 0.2 |
| R22 | 0.3 | 0.7 | 0.3 |
| R23 | 0.3 | 0.3 | 0.3 |
| R31 | 0.1 | 0.2 | 0.1 |
| R32 | 0.1 | 0.7 | 0.1 |
| R33 | 0.1 | 0.3 | 0.1 |

### S: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| S11 | 0.3 | 0.2 | 0.2 |
| S12 | 0.3 | 0.7 | 0.3 |
| S13 | 0.3 | 0.3 | 0.3 |
| S21 | 0.1 | 0.2 | 0.1 |
| S22 | 0.1 | 0.7 | 0.1 |
| S23 | 0.1 | 0.3 | 0.1 |
| S31 | 0.4 | 0.2 | 0.2 |
| S32 | 0.4 | 0.7 | 0.4 |
| S33 | 0.4 | 0.3 | 0.3 |

**Result cell (1,1)**



$$
\max\{\min(0.2,0.2),\min(0.3,0.2),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (1,2)**



$$
\max\{\min(0.2,0.4),\min(0.3,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (1,3)**



$$
\max\{\min(0.2,0.3),\min(0.3,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (2,1)**



$$
\max\{\min(0.1,0.2),\min(0.1,0.2),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (2,2)**



$$
\max\{\min(0.1,0.4),\min(0.1,0.3),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (2,3)**



$$
\max\{\min(0.1,0.3),\min(0.1,0.3),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (3,1)**



$$
\max\{\min(0.2,0.2),\min(0.4,0.2),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (3,2)**



$$
\max\{\min(0.2,0.4),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (3,3)**



$$
\max\{\min(0.2,0.3),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



---

## TEE · Q4(b) Naive Bayes: flu [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q4b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q4b

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. A hospital wants to predict flu from Fever (Yes/No), Cough (Yes/No) and Temperature Level (Low/Normal/High). Training data: (Yes, Yes, High, Yes), (No, No, Normal, No), (Yes, No, Low, No), (Yes, Yes, High, Yes), (No, Yes, Normal, No), (Yes, Yes, High, Yes), (No, No, Low, No), (Yes, No, Normal, No). Using naive Bayes, predict whether a patient with Fever = Yes, Cough = Yes, Temperature = Normal has flu.** [10 marks]

### Answer

#### Given

The full training data are in Step 1. Query: Fever=Yes, Cough=Yes, Temperature=Normal. The main calculation uses unsmoothed counts.

#### To find

Both class scores and the predicted class.

#### Formula and why it applies



$$
score(C)=P(C)\prod_jP(a_j\mid C)
$$



C is a class label. Each aⱼ is one query feature value. First count inside a class, then multiply the prior and all three likelihoods.

#### Solution

##### Step 1. Write the training rows as a table

| Row | Fever | Cough | Temperature | Class |
| --- | --- | --- | --- | --- |
| 1 | Yes | Yes | High | Yes |
| 2 | No | No | Normal | No |
| 3 | Yes | No | Low | No |
| 4 | Yes | Yes | High | Yes |
| 5 | No | Yes | Normal | No |
| 6 | Yes | Yes | High | Yes |
| 7 | No | No | Low | No |
| 8 | Yes | No | Normal | No |

##### Step 2. Separate the two class groups

| Class | Rows in this group | Class count | Prior |
| --- | --- | --- | --- |
| Yes | 1, 4, 6 | 3 | 3/8 = 0.375 |
| No | 2, 3, 5, 7, 8 | 5 | 5/8 = 0.625 |

##### Step 3. For class Yes, count Fever=Yes

Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.



$$
P(\text{Fever}=\text{Yes}\mid C=\text{Yes})=\frac{3}{3}=1
$$



##### Step 4. For class Yes, count Cough=Yes

Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.



$$
P(\text{Cough}=\text{Yes}\mid C=\text{Yes})=\frac{3}{3}=1
$$



##### Step 5. For class Yes, count Temperature=Normal

Look only at class Yes rows 1, 4, 6. No row in this class has that feature value.



$$
P(\text{Temperature}=\text{Normal}\mid C=\text{Yes})=\frac{0}{3}=0
$$



##### Step 6. Multiply the Yes score one factor at a time



$$
P(Yes)=3/8=0.375
$$





$$
0.375\times1=0.375
$$





$$
0.375\times1=0.375
$$





$$
0.375\times0=0
$$



##### Step 7. For class No, count Fever=Yes

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 3, 8.



$$
P(\text{Fever}=\text{Yes}\mid C=\text{No})=\frac{2}{5}=0.4
$$



##### Step 8. For class No, count Cough=Yes

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Cough}=\text{Yes}\mid C=\text{No})=\frac{1}{5}=0.2
$$



##### Step 9. For class No, count Temperature=Normal

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 2, 5, 8.



$$
P(\text{Temperature}=\text{Normal}\mid C=\text{No})=\frac{3}{5}=0.6
$$



##### Step 10. Multiply the No score one factor at a time



$$
P(No)=5/8=0.625
$$





$$
0.625\times0.4=0.25
$$





$$
0.25\times0.2=0.05
$$





$$
0.05\times0.6=0.03
$$



##### Step 11. Compare the scores



$$
score(Yes)=0\qquad score(No)=0.03
$$



The larger score belongs to No. Normalise only if a posterior probability is requested: divide each score by their total 0.03.

**Final answer.** Predict No. Yes score=0; No score=0.03.

The zero Yes score is caused by an absent training combination. If Laplace smoothing is explicitly required, apply it to all feature likelihoods in both classes. That is a different calculation and may change the prediction; do not mix smoothed and unsmoothed sides.

**Yaad rakho:** Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.

---

## TEE · Q5(a) Hotel guest movement (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q5a

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. A hotel chain has properties in Paris (P), London (L) and Rome (R). Of guests in Paris, 60% stay, 25% go to London, 15% to Rome; in London 30% go to Paris, 50% stay, 20% go to Rome; in Rome 20% go to Paris, 30% to London, 50% stay. 1. Construct the transition matrix. 2. Explain the diagonal and off-diagonal entries. 3. Draw the state diagram. 4. Today's counts are [50, 30, 20]; find tomorrow's expected counts. 5. Which city gains or loses guests in the long run?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: P, L, R. Initial vector [50, 30, 20].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | P | L | R |
| --- | --- | --- | --- |
| P | 0.6 | 0.25 | 0.15 |
| L | 0.3 | 0.5 | 0.2 |
| R | 0.2 | 0.3 | 0.5 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_hotel.55f5204329.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Daily guest movement: Paris, London, Rome | 0.25 | 0.15 | 0.3 | 0.2 | 0.2 | 0.3 | 0.6 | 0.5 | 0.5 | P | L | R

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to P

| Origin | Current count/share | Transition to P | Contribution |
| --- | --- | --- | --- |
| P | 50 | 0.6 | 50 × 0.6 = 30 |
| L | 30 | 0.3 | 30 × 0.3 = 9 |
| R | 20 | 0.2 | 20 × 0.2 = 4 |



$$
P_{new}=30+9+4=43
$$



##### Step 4. Next step: collect all contributions to L

| Origin | Current count/share | Transition to L | Contribution |
| --- | --- | --- | --- |
| P | 50 | 0.25 | 50 × 0.25 = 12.5 |
| L | 30 | 0.5 | 30 × 0.5 = 15 |
| R | 20 | 0.3 | 20 × 0.3 = 6 |



$$
L_{new}=12.5+15+6=33.5
$$



##### Step 5. Next step: collect all contributions to R

| Origin | Current count/share | Transition to R | Contribution |
| --- | --- | --- | --- |
| P | 50 | 0.15 | 50 × 0.15 = 7.5 |
| L | 30 | 0.2 | 30 × 0.2 = 6 |
| R | 20 | 0.5 | 20 × 0.5 = 10 |



$$
R_{new}=7.5+6+10=23.5
$$



##### Step 6. Stationarity: write the Paris equation



$$
p=0.6p+0.3l+0.2r
$$





$$
0.4p=0.3l+0.2r
$$



Divide every term by .4.



$$
p=0.75l+0.5r
$$



##### Step 7. Write the London equation and substitute p



$$
l=0.25p+0.5l+0.3r
$$





$$
0.5l=0.25(0.75l+0.5r)+0.3r
$$





$$
0.5l=0.1875l+0.125r+0.3r
$$



##### Step 8. Collect like terms



$$
(0.5-0.1875)l=(0.125+0.3)r
$$





$$
0.3125l=0.425r\quad\Rightarrow\quad l=1.36r
$$





$$
p=0.75(1.36r)+0.5r=1.52r
$$



##### Step 9. Use total probability to get all three shares



$$
p+l+r=1\quad\Rightarrow\quad1.52r+1.36r+r=1
$$





$$
3.88r=1\quad r=1/3.88=25/97
$$





$$
l=1.36(25/97)=34/97\quad p=1.52(25/97)=38/97
$$



##### Step 10. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| P | 0.5 | 0.391752577 | -0.108247423 | Loses |
| L | 0.3 | 0.350515464 | 0.050515464 | Gains |
| R | 0.2 | 0.257731959 | 0.057731959 | Gains |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [43.0, 33.5, 23.5]. Stationary shares ≈ [0.391752577, 0.350515464, 0.257731959]. P loses, L gains, R gains.

---

## TEE · Q5(b) Genetic algorithm [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q5b

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Implement a GA to maximise 

$$
f(x)=2x^3-5x^2+7x
$$

 for x in [0,15]. Take 4-bit representations of 13, 22, 18, 23. Crossover after the second bit and mutate by flipping any one bit. Produce two offspring and comment on fitness.** [10 marks]

### Answer

**The printed data are inconsistent.** 22, 18 and 23 are outside 0–15 and cannot fit into four bits. Increasing the bit count would encode the numbers but would still violate the stated range. There is no single exact solution satisfying all printed conditions.

The complete worked variant below explicitly changes the invalid parents to their last four bits (values modulo 16), producing [13,6,2,7]. This is one declared repair, not a silent interpretation of the printed question. If the instructor clarifies different corrected data, follow those data.

#### Given

Printed parents: [13, 22, 18, 23]. Worked variant: [13, 6, 2, 7] with 4 bits. For the unspecified selection step, select the two highest-fitness candidates. For the unspecified mutation location, flip the last bit of each child. Crossover is after bit 2.

#### To find

Two valid children under the declared assumptions and their fitness.

#### Formula and why it applies

Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.



$$
f(x)=2x^3-5x^2+7x
$$



#### Solution

##### Step 1. Encode and evaluate the declared parent population

| x | Binary | Fitness substitution |
| --- | --- | --- |
| 13 | 1101 | 2(13³) − 5(13²) + 7(13) = 3640 |
| 6 | 0110 | 2(6³) − 5(6²) + 7(6) = 294 |
| 2 | 0010 | 2(2³) − 5(2²) + 7(2) = 10 |
| 7 | 0111 | 2(7³) − 5(7²) + 7(7) = 490 |

##### Step 2. Select the two fittest under the stated assumption

[13, 7] with fitness [3640, 490].

##### Step 3. Cut after bit 2 and exchange tails

| Parent 1 | Parent 2 | Child 1 | Child 2 |
| --- | --- | --- | --- |
| 11 | 01 | 01 | 11 | 1111 | 0101 |

##### Step 4. Flip the last bit of each child

| Before | After | Decoded x |
| --- | --- | --- |
| 1111 | 1110 | 14 |
| 0101 | 0100 | 4 |

##### Step 5. Evaluate both children

| x | Fitness calculation |
| --- | --- |
| 14 | 2(2744) − 5(196) + 7(14) = 4606 |
| 4 | 2(64) − 5(16) + 7(4) = 76 |

##### Step 6. Compare with the selected parents

Best parent score = 3640; best child score = 4606. Parent average = 2065; child average = 2341. Both the best score and the average score increased in this worked variant. An individual child can still be worse than a parent; GA does not guarantee improvement after every random operator.

**Final answer.** Under these declared repairs and operator choices, children are [14, 4] with fitness [4606, 76]. These are not unique answers to the inconsistent and under-specified original question.

The printed wording about “two offspring” is not an explicit requirement for two complete generations. The M2 examples separately work two full generations because your class update asks for iteration 2.

## Evaluate the polynomial without skipping the powers

Calculate x²=x×x, then x³=x²×x. Multiply each by its coefficient and combine with the written signs. A bit-string repair in the worked answer is an explicitly stated response to inconsistent printed givens; it is not a new instruction in the original paper.

### x=13



$$
x^2=13\times13=169\qquad x^3=169\times13=2197
$$





$$
2x^3=4394\quad 5x^2=845\quad 7x=91
$$





$$
f(13)=4394-845+91=3640
$$



### x=6



$$
x^2=6\times6=36\qquad x^3=36\times6=216
$$





$$
2x^3=432\quad 5x^2=180\quad 7x=42
$$





$$
f(6)=432-180+42=294
$$



### x=2



$$
x^2=2\times2=4\qquad x^3=4\times2=8
$$





$$
2x^3=16\quad 5x^2=20\quad 7x=14
$$





$$
f(2)=16-20+14=10
$$



### x=7



$$
x^2=7\times7=49\qquad x^3=49\times7=343
$$





$$
2x^3=686\quad 5x^2=245\quad 7x=49
$$





$$
f(7)=686-245+49=490
$$



### x=15



$$
x^2=15\times15=225\qquad x^3=225\times15=3375
$$





$$
2x^3=6750\quad 5x^2=1125\quad 7x=105
$$





$$
f(15)=6750-1125+105=5730
$$



### x=5



$$
x^2=5\times5=25\qquad x^3=25\times5=125
$$





$$
2x^3=250\quad 5x^2=125\quad 7x=35
$$





$$
f(5)=250-125+35=160
$$



### x=14



$$
x^2=14\times14=196\qquad x^3=196\times14=2744
$$





$$
2x^3=5488\quad 5x^2=980\quad 7x=98
$$





$$
f(14)=5488-980+98=4606
$$



### x=4



$$
x^2=4\times4=16\qquad x^3=16\times4=64
$$





$$
2x^3=128\quad 5x^2=80\quad 7x=28
$$





$$
f(4)=128-80+28=76
$$



“Modulo 16” means keep the remainder after dividing by 16: 22=1×16+6, so its remainder is 6; 18=1×16+2; 23=1×16+7. This is only the declared repair used here, not an unspoken general encoding rule.

---

## TEE · Q6(a) Applications of fuzzy logic [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q6a

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**List the applications of fuzzy logic. Explain any one application in detail.** [10 marks]

### Answer

### Definition

Fuzzy logic is a multi-valued logic, introduced by Lotfi Zadeh (1965), in which truth values range over [0, 1]; it lets machines reason with vague, human-like terms such as “slightly dirty” or “very hot”.

### Applications

| Area | Examples |
| --- | --- |
| Home appliances | Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners |
| Automotive | Automatic transmission, anti-lock braking (ABS), cruise control, engine control |
| Transportation | Traffic-signal control, Sendai subway train control (smooth braking and acceleration) |
| Consumer electronics | Camera autofocus and auto-exposure, image stabilisation |
| Industrial control | Cement kilns, pH, temperature and distillation control in chemical plants |
| Aerospace | Satellite and spacecraft attitude control |
| Medicine | Diagnosis support, anaesthesia dosage control |
| Finance and decisions | Loan approval, credit and fire-risk scoring, stock trading rules |
| AI and robotics | Robot navigation, natural-language interfaces, expert systems |

### One application in detail: fuzzy washing machine

1. **Problem.** Wash time depends on how dirty and how greasy the clothes are. These are vague (“a bit dirty”), and a fixed timer wastes water and power.
2. **Inputs and outputs.** Sensors measure dirt (turbidity of water) and grease; the output is wash time. Each is described by fuzzy sets: dirt Small/Medium/High, grease Small/Medium/High, time Very Short … Very Long.
3. **Fuzzification.** Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.
4. **Rule base.** 9 expert rules, e.g. IF dirt is High AND grease is High THEN time is Very Long; IF dirt is Small AND grease is Small THEN time is Very Short.
5. **Inference.** Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.
6. **Defuzzification.** Use the specified defuzzifier. For a separate representative-weighted illustration, strengths [.6,.4,.2] at times [25,40,60] give (.6×25+.4×40+.2×60)/(.6+.4+.2)=(15+16+12)/1.2≈35.833 minutes. These illustrative strengths are supplied here, not derived from unspecified input graphs. A Mamdani area centroid requires the full aggregate shape.
7. **Benefits.** Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.

### Advantages and disadvantages (bonus)

**Advantages:** handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. **Disadvantages:** rules and membership functions depend on expert judgement; results are hard to verify formally; tuning can take time; not suited where very high precision is required.

**Yaad rakho:** Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.

---

## TEE · Q6(b) Learner progression (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q6b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q6b

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Students are Beginner (B), Intermediate (I) or Advanced (A). Of Beginners, 60% remain, 30% become Intermediate, 10% go to Advanced. Of Intermediates, 20% fall back, 50% remain, 30% progress. Of Advanced, 10% drop to Intermediate, 80% remain and 10% stop (treated as remaining in A). 1. Construct the matrix. 2. Interpret retention, progression and regression. 3. Draw the diagram. 4. For [50, 30, 20], find the distribution after one day. 5. Which level has the largest steady-state share?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: B, I, A. Initial vector [50, 30, 20].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | B | I | A |
| --- | --- | --- | --- |
| B | 0.6 | 0.3 | 0.1 |
| I | 0.2 | 0.5 | 0.3 |
| A | 0 | 0.1 | 0.9 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_learning.61a789edc7.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Daily learner movement: Beginner, Intermediate, Advanced | 0.3 | 0.1 | 0.2 | 0.3 | 0.1 | 0.6 | 0.5 | 0.9 | B | I | A

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to B

| Origin | Current count/share | Transition to B | Contribution |
| --- | --- | --- | --- |
| B | 50 | 0.6 | 50 × 0.6 = 30 |
| I | 30 | 0.2 | 30 × 0.2 = 6 |
| A | 20 | 0 | 20 × 0 = 0 |



$$
B_{new}=30+6+0=36
$$



##### Step 4. Next step: collect all contributions to I

| Origin | Current count/share | Transition to I | Contribution |
| --- | --- | --- | --- |
| B | 50 | 0.3 | 50 × 0.3 = 15 |
| I | 30 | 0.5 | 30 × 0.5 = 15 |
| A | 20 | 0.1 | 20 × 0.1 = 2 |



$$
I_{new}=15+15+2=32
$$



##### Step 5. Next step: collect all contributions to A

| Origin | Current count/share | Transition to A | Contribution |
| --- | --- | --- | --- |
| B | 50 | 0.1 | 50 × 0.1 = 5 |
| I | 30 | 0.3 | 30 × 0.3 = 9 |
| A | 20 | 0.9 | 20 × 0.9 = 18 |



$$
A_{new}=5+9+18=32
$$



##### Step 6. Stationarity: balance the Beginner column



$$
b=0.6b+0.2i
$$





$$
0.4b=0.2i\quad\Rightarrow\quad i=2b
$$



##### Step 7. Balance the Advanced column



$$
a=0.1b+0.3i+0.9a
$$





$$
0.1a=0.1b+0.3(2b)=0.7b
$$





$$
a=0.7b/0.1=7b
$$



##### Step 8. Use the sum of shares



$$
b+i+a=1\quad b+2b+7b=1
$$





$$
10b=1\quad b=0.1\quad i=0.2\quad a=0.7
$$



Advanced is not an absorbing state: its self-transition is .9, not 1.

##### Step 9. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| B | 0.5 | 0.1 | -0.4 | Loses |
| I | 0.3 | 0.2 | -0.1 | Loses |
| A | 0.2 | 0.7 | 0.5 | Gains |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [36.0, 32.0, 32.0]. Stationary shares ≈ [0.1, 0.2, 0.7]. B loses, I loses, A gains.

---

## TEE · Q7(a) Applications of PSO [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q7a

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**List the applications of Particle Swarm Optimization and explain any one application in detail.** [10 marks]

### Answer

### Definition (1 line)

Particle Swarm Optimization is a population-based metaheuristic, inspired by bird flocking and fish schooling, in which particles move through the search space using their own best position (pbest) and the swarm's best position (gbest) to find optimal or near-optimal solutions.

### Applications

1. **Function optimisation**: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.
2. **Neural-network training**: optimising weights and biases (your Lab 8 uses the pyswarms library for this).
3. **Hyper-parameter tuning** of ML models (learning rate, number of hidden units, SVM C and γ).
4. **Feature selection**: choosing the most useful subset of features (binary PSO).
5. **Image processing**: threshold selection for segmentation, edge detection, image enhancement.
6. **Path planning** for robots and drones: shortest collision-free path.
7. **Power systems**: economic load dispatch, optimal placement of capacitors.
8. **Control engineering**: tuning PID controller gains.
9. **Scheduling and wireless sensor networks**: job scheduling, sensor node placement and clustering.

### One application in detail: training a neural network with PSO

Training data

→

Neural network with weights = particle position

→

Error (fitness)

→

PSO moves the weights

→

Best weights = gbest

1. **Encoding.** Flatten all weights and biases of the network into one vector. Each particle is one complete set of weights; a network with 50 weights gives a 50-dimensional search space.
2. **Fitness.** Run the training data through the network with that particle's weights and compute the error (for example mean squared error or cross-entropy). Lower error = better particle (minimisation).
3. **Search.** Apply the velocity and position updates. Each particle is pulled towards the weight set that gave its own lowest error (pbest) and towards the lowest-error weights found by the swarm (gbest).
4. **Stop** after a fixed number of iterations or when the error stops improving; gbest is the trained network.
5. **Why PSO here:** it needs no gradients, so it works with non-differentiable activations and can explore candidate weights without differentiating the objective. It can still stagnate; comparison with gradient methods depends on the problem. **Limitation:** large networks create a high-dimensional search space, and evaluating many complete candidate networks can be computationally expensive. Gradient-based training is often more efficient when useful gradients are available; there is no universal speed ordering for every problem and implementation.

### Advantages and disadvantages (add for 10 marks)

| Advantages | Disadvantages |
| --- | --- |
| Simple to implement; few parameters (w, c₁, c₂) | Can converge prematurely to a local optimum |
| No derivatives needed | Sensitive to parameter choice |
| Fast convergence in early iterations; memory (pbest, gbest) | No guarantee of the global optimum |
| Objective evaluations can be parallel; particles share information through gbest | Less suited to discrete problems without modification |

Marking pattern used for ACO in the same paper: listing 3 marks + explanation 2 marks (5-mark version); listing 5 + explanation 5 (10-mark version).

**Yaad rakho:** Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.

---

## TEE · Q7(b) ACO for TSP [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-final-2025--q7b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-final-2025/q7b

Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. For the four-city travelling salesman problem, the distance and pheromone matrices (A, B, C, D) are given. Apply Ant Colony Optimization. Calculate the path travelled by 2 ants to cover all cities starting from city A. Random numbers for Ant 1 are 0.3, 0.8 and for Ant 2 are 0.5, 0.7. Also update the pheromone matrix after 1 iteration.** [10 marks]

### Answer

#### Given



$$
D=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&4&2&4\\B&4&0&3&6\\C&2&3&0&2\\D&4&6&2&0\end{array}\qquad \tau=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&1&1&1\\B&1&0&1&1\\C&1&1&0&1\\D&1&1&1&0\end{array}
$$



Assume 

$$
\alpha=\beta=1
$$

, 

$$
\rho=0.5
$$

, 

$$
Q=1
$$

 (class convention; not stated in the question).

#### To find

Tour of each ant, tour lengths, updated pheromone matrix.

Swipe across the diagram to read its labels ↔

![Final 2025 Q7b: distances (all pheromones start at 1)](https://deep-learning-study-room.vercel.app/is2/fig/aco_final_graph.ac3cd4aeac.svg)

Diagram: Final 2025 Q7b: distances (all pheromones start at 1). Labels: Final 2025 Q7b: distances (all pheromones start at 1) | 4 | 2 | 4 | 3 | 6 | 2 | A | B | C | D

#### Formula and why it applies



$$
P_{ij}=\frac{\tau_{ij}\,\eta_{ij}}{\sum_{l\in\text{allowed}}\tau_{il}\,\eta_{il}},\qquad\eta_{ij}=\frac1{d_{ij}}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}+\sum_{k:\,ij\in\mathrm{tour}_k}\frac{Q}{L_k}
$$



The sum includes **only ants whose completed tour contains edge ij**. An unused edge receives no deposit but still evaporates. Here distances are symmetric, so a traversed edge updates both symmetric matrix cells. Both ants construct their tours using the old pheromones; update after both finish, including their return to A.

#### Solution

##### Step 1. Probabilities from A (both ants start at A)



$$
\tau\eta:\;A\to B=1\times\tfrac14=0.25,\quad A\to C=1\times\tfrac12=0.5,\quad A\to D=1\times\tfrac14=0.25;\quad\text{sum}=1
$$



| Move | P | Cumulative | Range |
| --- | --- | --- | --- |
| A→B | 0.25 | 0.25 | 0–0.25 |
| A→C | 0.50 | 0.75 | 0.25–0.75 |
| A→D | 0.25 | 1.00 | 0.75–1 |

Ant 1: r = 0.3 → **C**. Ant 2: r = 0.5 → **C**.

##### Step 2. Probabilities from C (B and D left)



$$
C\to B=\tfrac13=0.3333,\quad C\to D=\tfrac12=0.5;\quad\text{sum}=0.8333\Rightarrow P_{CB}=0.4,\;P_{CD}=0.6
$$



Cumulative in city order: B 0–0.4, D 0.4–1. Ant 1: r = 0.8 → **D**. Ant 2: r = 0.7 → **D**.

##### Step 3. Complete the tours

Only B is left, then return to A.



$$
\text{Ant 1}=\text{Ant 2}:\;A\to C\to D\to B\to A,\qquad L=2+2+6+4=14
$$



Swipe across the diagram to read its labels ↔

![Both ants: A → C → D → B → A, length 14](https://deep-learning-study-room.vercel.app/is2/fig/aco_final_tour.1dbfdb8b98.svg)

Diagram: Both ants: A → C → D → B → A, length 14. Labels: Both ants: A → C → D → B → A, length 14 | 4 | 2 | 4 | 3 | 6 | 2 | A | B | C | D

##### Step 4. Pheromone update

Each ant deposits 

$$
Q/L=1/14=0.0714
$$

 on each edge of its tour; two ants used the same four edges (AC, CD, DB, BA), so each gets 

$$
2/14=0.1429
$$

.



$$
\text{used edge: }(1-0.5)(1)+0.1429=0.6429\qquad\text{unused edge (AD, BC): }(1-0.5)(1)+0=0.5
$$





$$
\tau_{\text{new}}=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&0.6429&0.6429&0.5\\B&0.6429&0&0.5&0.6429\\C&0.6429&0.5&0&0.6429\\D&0.5&0.6429&0.6429&0\end{array}
$$



**Final answer.** Both ants: A → C → D → B → A, length 14. Updated pheromone: 0.6429 on AB, AC, CD, BD; 0.5 on AD and BC. In the next iteration the ants will prefer the edges of this tour.

**Official key note.** The key's matrix shows 0.643 on AC, CD and BD but leaves AB at 0.5, i.e. it forgot to deposit on the return edge B → A even though it counted its length (4) in L = 14. Your slides deposit on the return edge, so AB = 0.6429 is correct. If you wish, write one line: “the return edge B–A is part of the tour, so it also receives Q/L.”

Official marking: path of Ant 1 (3) + path of Ant 2 (3) + pheromone matrix (4).

---

## TEE · Q1(a) Disease, fever and test joint table [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q1a

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. For a disease Y with fever X as a symptom, a test Z is conducted. Joint probabilities: Disease (Y=1): fever & test+ 0.576, fever & test− 0.144, no fever & test+ 0.072, no fever & test− 0.016; No disease (Y=0): 0.008, 0.064, 0.012, 0.108. (1) If fever occurs and the test is positive, what is the probability of disease? (2) What is the probability that a random person tests positive? (3) Given no fever, what is the probability of still having the disease?** [5 marks]

### Answer

#### Given

The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.

#### To find

All requested marginal and conditional probabilities.

#### Formula and why it applies

Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum.



$$
P(A\mid E)=\frac{P(A\cap E)}{P(E)},\quad P(E)>0
$$



#### Solution

##### Step 1. (1)



$$
P(Y{=}1\mid X{=}1,Z{=}1)=\frac{0.576}{0.576+0.008}=\frac{0.576}{0.584}=0.986
$$



##### Step 2. (2) Add every test-positive cell



$$
P(Z{=}1)=0.576+0.072+0.008+0.012=0.668
$$



##### Step 3. (3)



$$
P(X{=}0)=0.072+0.016+0.012+0.108=0.208,\qquad P(Y{=}1\mid X{=}0)=\frac{0.072+0.016}{0.208}=\frac{0.088}{0.208}=0.423
$$



**Final answer.** (1) 0.986; (2) 0.668; (3) 0.423.

**Key correction.** The key writes 0.088/0.076 = 1.158 for part (3). A probability cannot exceed 1; the denominator must be P(no fever) = 0.208.

---

## TEE · Q1(b) Applications of PSO [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q1b

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**List the applications of Particle Swarm Optimization and explain any one application in detail.** [5 marks]

### Answer

### Definition (1 line)

Particle Swarm Optimization is a population-based metaheuristic, inspired by bird flocking and fish schooling, in which particles move through the search space using their own best position (pbest) and the swarm's best position (gbest) to find optimal or near-optimal solutions.

### Applications

1. **Function optimisation**: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.
2. **Neural-network training**: optimising weights and biases (your Lab 8 uses the pyswarms library for this).
3. **Hyper-parameter tuning** of ML models (learning rate, number of hidden units, SVM C and γ).
4. **Feature selection**: choosing the most useful subset of features (binary PSO).
5. **Image processing**: threshold selection for segmentation, edge detection, image enhancement.
6. **Path planning** for robots and drones: shortest collision-free path.
7. **Power systems**: economic load dispatch, optimal placement of capacitors.
8. **Control engineering**: tuning PID controller gains.
9. **Scheduling and wireless sensor networks**: job scheduling, sensor node placement and clustering.

### One application in detail: training a neural network with PSO

Training data

→

Neural network with weights = particle position

→

Error (fitness)

→

PSO moves the weights

→

Best weights = gbest

1. **Encoding.** Flatten all weights and biases of the network into one vector. Each particle is one complete set of weights; a network with 50 weights gives a 50-dimensional search space.
2. **Fitness.** Run the training data through the network with that particle's weights and compute the error (for example mean squared error or cross-entropy). Lower error = better particle (minimisation).
3. **Search.** Apply the velocity and position updates. Each particle is pulled towards the weight set that gave its own lowest error (pbest) and towards the lowest-error weights found by the swarm (gbest).
4. **Stop** after a fixed number of iterations or when the error stops improving; gbest is the trained network.
5. **Why PSO here:** it needs no gradients, so it works with non-differentiable activations and can explore candidate weights without differentiating the objective. It can still stagnate; comparison with gradient methods depends on the problem. **Limitation:** large networks create a high-dimensional search space, and evaluating many complete candidate networks can be computationally expensive. Gradient-based training is often more efficient when useful gradients are available; there is no universal speed ordering for every problem and implementation.

### Advantages and disadvantages (add for 10 marks)

| Advantages | Disadvantages |
| --- | --- |
| Simple to implement; few parameters (w, c₁, c₂) | Can converge prematurely to a local optimum |
| No derivatives needed | Sensitive to parameter choice |
| Fast convergence in early iterations; memory (pbest, gbest) | No guarantee of the global optimum |
| Objective evaluations can be parallel; particles share information through gbest | Less suited to discrete problems without modification |

Marking pattern used for ACO in the same paper: listing 3 marks + explanation 2 marks (5-mark version); listing 5 + explanation 5 (10-mark version).

**Yaad rakho:** Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.

---

## TEE · Q1(c) Fuzzy set operations [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q1c

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. X = {(c1, 0.7), (c2, 0.9), (c3, 0.2), (c4, 0.4), (c5, 0.9)}, Y = {(c1, 0.6), (c2, 0.3), (c3, 0.8), (c4, 0.7), (c5, 0.1)}. Find X ∪ Y, X ∩ Y, ¬X ∪ ¬Y, ¬X ∩ ¬Y.** [5 marks]

### Answer

#### Given

The aligned X and Y memberships printed in this question.

#### To find

The four requested membership lists in the original element order.

#### Formula and why it applies

Use max for OR, min for AND, and 1−μ for NOT.



$$
\mu_{X\cup Y}=\max(\mu_X,\mu_Y),\quad\mu_{X\cap Y}=\min(\mu_X,\mu_Y)
$$



Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.

#### Solution

|  | c1 | c2 | c3 | c4 | c5 |
| --- | --- | --- | --- | --- | --- |
| ¬X | 0.3 | 0.1 | 0.8 | 0.6 | 0.1 |
| ¬Y | 0.4 | 0.7 | 0.2 | 0.3 | 0.9 |
| **X ∪ Y** | 0.7 | 0.9 | 0.8 | 0.7 | 0.9 |
| **X ∩ Y** | 0.6 | 0.3 | 0.2 | 0.4 | 0.1 |
| **¬X ∪ ¬Y** | 0.4 | 0.7 | 0.8 | 0.6 | 0.9 |
| **¬X ∩ ¬Y** | 0.3 | 0.1 | 0.2 | 0.3 | 0.1 |

**Final answer.** As in the last four rows. De Morgan check: ¬X ∪ ¬Y = 1 − (X ∩ Y) and ¬X ∩ ¬Y = 1 − (X ∪ Y) ✓.

## Calculate every element separately

### Element c1



$$
\neg X:1-0.7=0.3\qquad\neg Y:1-0.6=0.4
$$





$$
X\cup Y:\max(0.7,0.6)=0.7
$$





$$
X\cap Y:\min(0.7,0.6)=0.6
$$





$$
\neg X\cup\neg Y:\max(0.3,0.4)=0.4
$$





$$
\neg X\cap\neg Y:\min(0.3,0.4)=0.3
$$



### Element c2



$$
\neg X:1-0.9=0.1\qquad\neg Y:1-0.3=0.7
$$





$$
X\cup Y:\max(0.9,0.3)=0.9
$$





$$
X\cap Y:\min(0.9,0.3)=0.3
$$





$$
\neg X\cup\neg Y:\max(0.1,0.7)=0.7
$$





$$
\neg X\cap\neg Y:\min(0.1,0.7)=0.1
$$



### Element c3



$$
\neg X:1-0.2=0.8\qquad\neg Y:1-0.8=0.2
$$





$$
X\cup Y:\max(0.2,0.8)=0.8
$$





$$
X\cap Y:\min(0.2,0.8)=0.2
$$





$$
\neg X\cup\neg Y:\max(0.8,0.2)=0.8
$$





$$
\neg X\cap\neg Y:\min(0.8,0.2)=0.2
$$



### Element c4



$$
\neg X:1-0.4=0.6\qquad\neg Y:1-0.7=0.3
$$





$$
X\cup Y:\max(0.4,0.7)=0.7
$$





$$
X\cap Y:\min(0.4,0.7)=0.4
$$





$$
\neg X\cup\neg Y:\max(0.6,0.3)=0.6
$$





$$
\neg X\cap\neg Y:\min(0.6,0.3)=0.3
$$



### Element c5



$$
\neg X:1-0.9=0.1\qquad\neg Y:1-0.1=0.9
$$





$$
X\cup Y:\max(0.9,0.1)=0.9
$$





$$
X\cap Y:\min(0.9,0.1)=0.1
$$





$$
\neg X\cup\neg Y:\max(0.1,0.9)=0.9
$$





$$
\neg X\cap\neg Y:\min(0.1,0.9)=0.1
$$



---

## TEE · Q1(d) Savings and current accounts (Markov chain) [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q1d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q1d

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Each year 20% of Savings holders switch to Current and 80% stay; 10% of Current holders switch to Savings and 90% stay. (a) Construct the transition matrix. (b) Draw the state diagram.** [5 marks]

### Answer

#### Given

All transition values are given in the full question. State order: S, C.

#### To find

The transition matrix and state diagram.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.

#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | S | C |
| --- | --- | --- |
| S | 0.8 | 0.2 |
| C | 0.1 | 0.9 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_bank.879499f6eb.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Savings (S) and Current (C) accounts per year | 0.2 | 0.1 | 0.8 | 0.9 | S | C

Each arrow is labelled with the probability of that transition.

**Final answer.** The transition matrix and state diagram are given above.

---

## TEE · Q2(a) Fuzzy fire-hazard system [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q2a

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**A building safety department wants a fuzzy logic system to predict fire hazards. Inputs are Temperature (1–100°C) and Smoke Level (1–100). The output Fire Risk (1–100) has labels Low, Moderate and High. Define triangular membership functions, construct at least nine rules, explain Mamdani inference and defuzzify for Temperature=65°C and Smoke=80.** [10 marks]

### Answer

#### Given

| Variable | Crisp value |
| --- | --- |
| Temperature | 65 |
| Smoke Level | 80 |

The question asks us to design the membership functions. This solution chooses Low=Tri(1,25,50), Medium=Tri(25,50,75), High=Tri(50,75,100) for both inputs. Output labels use the same triangles in their respective order. These are explicit design choices, not additional printed givens.

#### To find

A complete stated design and its continuous Mamdani centroid.

#### Formula and why it applies

Use min for AND and implication, max for aggregation and the true area centroid of the resulting shape. A peak-only weighted average is a different defuzzifier.



$$
z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

##### Step 1. Specify the membership functions

| Input / output position | Triangle | Peak |
| --- | --- | --- |
| Low / Low | (1,25,50) | 25 |
| Medium / Moderate | (25,50,75) | 50 |
| High / High | (50,75,100) | 75 |

Use 0 outside each triangle, the rising fraction before the peak and the falling fraction after it. This design is evaluated at the requested input; a deployed controller would also need coverage/fallback at all boundary values.

##### Step 2. Write all nine rules

| Temperature / Smoke Level | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Low | Low | Moderate |
| Medium | Low | Moderate | High |
| High | Moderate | High | High |

Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.

##### Step 3. Fuzzify Temperature = 65



$$
\mu_{Low}(65)=0
$$





$$
\mu_{Medium}(65)=\frac{75-65}{75-50}=0.4
$$





$$
\mu_{High}(65)=\frac{65-50}{75-50}=0.6
$$



##### Step 4. Fuzzify Smoke Level = 80



$$
\mu_{Low}(80)=0
$$





$$
\mu_{Medium}(80)=0
$$





$$
\mu_{High}(80)=\frac{100-80}{100-75}=0.8
$$



##### Step 5. Evaluate all rules and aggregate matching consequents

| Temperature | Smoke Level | Firing strength | Consequent |
| --- | --- | --- | --- |
| Low | Low | min(0,0) = 0 | Low |
| Low | Medium | min(0,0) = 0 | Low |
| Low | High | min(0,0.8) = 0 | Moderate |
| Medium | Low | min(0.4,0) = 0 | Low |
| Medium | Medium | min(0.4,0) = 0 | Moderate |
| Medium | High | min(0.4,0.8) = 0.4 | High |
| High | Low | min(0.6,0) = 0 | Moderate |
| High | Medium | min(0.6,0) = 0 | High |
| High | High | min(0.6,0.8) = 0.6 | High |

Aggregated label strengths: Low = 0, Moderate = 0, High = 0.6.



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



##### Step 6. Draw the aggregated output

Swipe across the diagram to read its labels ↔

![The shaded upper envelope counts any overlap only once.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fire_aggregate.e0cab4ad42.svg)

Diagram: The shaded upper envelope counts any overlap only once.. Labels: Chosen triangular output sets and their max-aggregate | 0 | 0.5 | 1 | 1 | 25 | 50 | 75 | 100 | μ | Output score | Low | Moderate | High | centroid ≈ 75

The shaded upper envelope counts any overlap only once.

##### Step 7. Calculate area and moment of each straight-line strip

For a strip from a to b with endpoint heights u and v, its trapezoid area is A. Its first moment M is the integral of z times the line height.



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}\big[(2a+b)u+(a+2b)v\big]
$$



| a | b | u | v | Area A | Moment M |
| --- | --- | --- | --- | --- | --- |
| 50 | 65 | 0 | 0.6 | 4.5 | 270 |
| 65 | 85 | 0.6 | 0.6 | 12 | 900 |
| 85 | 100 | 0.6 | 0 | 4.5 | 405 |

##### Step 8. Divide total moment by total area



$$
\sum A=21
$$





$$
\sum M=1575
$$





$$
z^*=\frac{1575}{21}\approx75
$$



**Final answer.** For these stated triangles and rules, the centroid is 75. This is in the high-risk region of this illustrative fuzzy design.

Because the paper asks for a design, a different explicitly specified membership/rule system can yield a different numerical output. Explain the choices and use the chosen defuzzification method consistently; no particular examiner mark outcome is promised.

## Why the clipped High shape is symmetric about 75

Only the High output survives, at height .6. Its triangle is (50,75,100). Solve its rising edge: (z−50)/25=.6, so z=50+15=65. Solve its falling edge: (100−z)/25=.6, so z=100−15=85.

| Piece | Area calculation | Centre | Moment |
| --- | --- | --- | --- |
| Left triangle [50,65] | ½×15×.6=4.5 | (50+65+65)/3=60 | 4.5×60=270 |
| Rectangle [65,85] | 20×.6=12 | (65+85)/2=75 | 12×75=900 |
| Right triangle [85,100] | ½×15×.6=4.5 | (85+85+100)/3=90 | 4.5×90=405 |

The horizontal centroid of a triangle is the average of the three vertex x-coordinates. Add areas: 4.5+12+4.5=21. Add moments:270+900+405=1575. Divide 1575/21=75, agreeing with symmetry.

---

## TEE · Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q2b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q2b

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**With reference to the Gaussian Mixture Model (GMM): compare GMM with the k-means algorithm; derive the equation for the log-likelihood function; state the number of parameters to be computed if K = 5.** [10 marks]

### Answer

## Read the derivation’s symbols first

“i.i.d.” means the observations are modelled as independent draws from the same distribution. The product Π runs over observations; the inner sum Σ runs over components. λki in some notes is the same responsibility that other sections call γik. A superscript i here labels the observation, not an exponent.

Jensen’s inequality gives a lower bound on the log of the component sum. EM chooses responsibilities making that bound touch the current likelihood, then updates the parameters to maximise the bound with those responsibilities fixed. This explains the two alternating steps; λ values are not arbitrary new model parameters.

| Parameter | Number in a 1D K-component GMM | Why |
| --- | --- | --- |
| Means | K | One centre for each component |
| Variances | K | One spread for each component |
| Independent mixing weights | K−1 | The last weight is 1 minus the others |
| Total | 3K−1 | K+K+(K−1) |

For K=2, choose μ₁,μ₂,σ₁²,σ₂² and π₁: five free numbers. Then π₂=1−π₁. For K=5, 5+5+4=14. In 2D with a full covariance matrix, each component instead has two means and three independent covariance entries (two variances and one shared off-diagonal covariance). Five such components have 5×(2+3)+4=29 free parameters.

### 1. GMM versus k-means

| Aspect | k-means | GMM |
| --- | --- | --- |
| Assignment | Hard: each point in exactly one cluster | Soft: probability 

$$
\lambda_k^i
$$

 of belonging to each cluster |
| Model | Geometric: nearest centroid | Probabilistic generative model 

$$
\sum_k\pi_k\mathcal N(\mu_k,\Sigma_k)
$$

 |
| Cluster shape | Spherical, similar size | Elliptical, any size/orientation; overlapping clusters |
| Parameters | K centroids | Weights, means, covariances (1-D: 3K − 1) |
| Algorithm / objective | Assign–update; minimise squared distances | EM; maximise log-likelihood |
| Output | Hard labels and fitted centroids | Labels, membership probabilities and a density (useful for anomaly detection) |
| Relation | The hard-assignment, equal spherical variance, small-variance limit of a Gaussian-mixture objective leads to the k-means objective. Ordinary finite-variance EM is not the same algorithm as k-means. Both need K in advance and depend on initialisation. | |

### 2. Derivation of the log-likelihood

**Step 1. Model.** Each point is generated by choosing component k with probability 

$$
\pi_k
$$

 and drawing 

$$
x_i\sim\mathcal N(\mu_k,\sigma_k^2)
$$

, so its density is 

$$
f_{mix}(x_i)=\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)
$$

.

**Step 2. Likelihood.** Points are i.i.d., so the likelihood is a product (θ = all parameters):



$$
L(\theta)=\prod_{i=1}^{n}\Big[\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big]
$$



**Step 3. Log-likelihood.** Logs turn the product into a sum:



$$
\log L(\theta)=\sum_{i=1}^{n}\log\Big(\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big)
$$



**Step 4. Why it cannot be solved directly.** The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.

**Step 5. Jensen's inequality.** log is concave, so for weights 

$$
\lambda_k\ge0,\;\sum\lambda_k=1
$$

: 

$$
\log\big(\sum_k\lambda_ka_k\big)\ge\sum_k\lambda_k\log a_k
$$

. Introduce 

$$
\lambda_k^i
$$

 for every point (

$$
\sum_k\lambda_k^i=1
$$

), multiply and divide inside the log:



$$
\log L(\theta)=\sum_i\log\Big(\sum_k\lambda_k^i\,\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}\Big)\;\ge\;\sum_i\sum_k\lambda_k^i\log\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}
$$



**Step 6. Estimation (EM).** Maximise the lower bound alternately. Fixing θ gives the E-step 

$$
\lambda_k^i=\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)/\sum_l\pi_l\mathcal N(x_i\mid\mu_l,\sigma_l^2)
$$

. Fixing λ and differentiating (with a Lagrange multiplier for 

$$
\sum\pi_k=1
$$

) gives the M-step:



$$
\hat\mu_k=\frac{\sum_i\lambda_k^ix_i}{\sum_i\lambda_k^i},\qquad\hat\sigma_k^2=\frac{\sum_i\lambda_k^i(x_i-\hat\mu_k)^2}{\sum_i\lambda_k^i},\qquad\hat\pi_k=\frac{\sum_i\lambda_k^i}{n}
$$



### 3. Number of parameters for K = 5

The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:



$$
2K+(K-1)=3K-1=3(5)-1=\mathbf{14}
$$



(5 means + 5 variances + 4 free weights, since the 5 weights must add to 1.) In two dimensions with full covariance it would be 29.

**Slide note.** One slide puts the convex inequality under the “concave” heading. Correct: log is *concave*, so 

$$
f(\sum\lambda a)\ge\sum\lambda f(a)
$$

 (≥, not >).

---

## TEE · Q3(a) Bayesian network: fever given no flu [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q3a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q3a

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Weather → Flu, Weather → Cough, Flu and Cough → Fever. P(Weather) = 0.75; P(Flu | W) = 0.2, P(Flu | ¬W) = 0.5; P(Cough | W) = 0.70, P(Cough | ¬W) = 0.25; P(Fever | Flu, Cough) = 0.60, P(Fever | Flu, ¬Cough) = 0.02, P(Fever | ¬Flu, Cough) = 0.60, P(Fever | ¬Flu, ¬Cough) = 0.01. Calculate the probability of a person having fever given he doesn't have flu.** [10 marks]

### Answer

The following table enumerates the values of Weather and Cough that were not fixed by the question. Two Boolean choices give four rows: true/true, true/false, false/true, false/false. Each row is one mutually exclusive complete case. Read the CPT entry using that row’s parent values, multiply its factors, and add the resulting row weights. The denominator must include all cases matching the evidence, including both possible values of the queried outcome.

#### Given

W→F, W→C, (F,C)→V. The complete probabilities are in the question. Evidence F=false.

#### To find

P(V=true | F=false), summing hidden W and C.

#### Formula and why it applies

Use the network joint and normalise by the no-Flu evidence.



$$
P(V\mid\neg F)=\frac{\sum_{w,c}P(w)P(\neg F\mid w)P(c\mid w)P(V\mid\neg F,c)}{\sum_wP(w)P(\neg F\mid w)}
$$



#### Solution

Swipe across the diagram to read its labels ↔

![Re-exam 2026 Q3a: weather–flu–cough–fever network](https://deep-learning-study-room.vercel.app/is2/fig/bn_flu.1d732f0fb6.svg)

Diagram: Re-exam 2026 Q3a: weather–flu–cough–fever network. Labels: Re-exam 2026 Q3a: weather–flu–cough–fever network | Weather | P(W) = 0.75 | Flu | P(F|W) = 0.2, P(F|¬W) = 0.5 | Cough | P(C|W) = 0.7, P(C|¬W) = 0.25 | Fever | P(V|F,C): .60 · .02 · .60 · .01 | (TT · TF · FT · FF)

##### Step 1. Chain rule



$$
P(W,F,C,V)=P(W)\,P(F\mid W)\,P(C\mid W)\,P(V\mid F,C)
$$



##### Step 2. Sum over W and C with F = false, V = true

| W | C | P(W) | P(¬F|W) | P(C|W) | P(V|¬F,C) | Product |
| --- | --- | --- | --- | --- | --- | --- |
| T | T | 0.75 | 0.8 | 0.70 | 0.60 | 0.252 |
| T | F | 0.75 | 0.8 | 0.30 | 0.01 | 0.0018 |
| F | T | 0.25 | 0.5 | 0.25 | 0.60 | 0.01875 |
| F | F | 0.25 | 0.5 | 0.75 | 0.01 | 0.0009375 |
| **P(V, ¬F)** | | | | | | **0.2734875** |

##### Step 3. Evidence



$$
P(\lnot F)=0.75(0.8)+0.25(0.5)=0.6+0.125=0.725
$$



##### Step 4. Divide



$$
P(V\mid\lnot F)=\frac{0.2734875}{0.725}=0.3772
$$



**Final answer.** P(fever | no flu) ≈ **0.377** (fever without flu comes mostly from cough).

**Key correction.** The key uses P(Flu) = 0.05 and P(Fever | ¬Flu) = 0.2, which are not in this network, and answers 0.2. Marking scheme (still applies): write the equation with hidden variables (2), take true/false cases (3), substitute (2), answer (3).

---

## TEE · Q3(b) Fuzzy relations and composition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q3b

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. A = {0.6/small + 0.4/medium + 0.1/large}, B = {0.4/slow + 0.8/moderate + 0.3/fast}, C = {0.5/small + 0.2/medium + 0.4/large}. Find R = A × B, S = C × B and the max–min composition S ∘ R.** [10 marks]

### Answer

#### Given

The fuzzy sets or relation matrices and their listed row/column order.

#### To find

The relation matrix/matrices and the composition specified in the question.

#### Formula and why it applies

For Cartesian products take min of row and column membership. For the ordered matrix composition shown here:



$$
T_{ik}=\max_j\min(S_{ij},R_{jk})
$$



If max–product is asked instead, replace the inner min by multiplication.

#### Solution

##### Step 1. R and S



$$
R=\begin{bmatrix}0.4&0.6&0.3\\0.4&0.4&0.3\\0.1&0.1&0.1\end{bmatrix},\qquad S=\begin{bmatrix}0.4&0.5&0.3\\0.2&0.2&0.2\\0.4&0.4&0.3\end{bmatrix}
$$



##### Step 2. S ∘ R



$$
(1,1)=\max[\min(.4,.4),\min(.5,.4),\min(.3,.1)]=\max(.4,.4,.1)=0.4
$$





$$
(1,2)=\max[\min(.4,.6),\min(.5,.4),\min(.3,.1)]=\max(.4,.4,.1)=0.4
$$





$$
(1,3)=\max[\min(.4,.3),\min(.5,.3),\min(.3,.1)]=0.3
$$





$$
\text{row 2 (all 0.2)}=(0.2,0.2,0.2);\quad(3,1)=\max(.4,.4,.1)=0.4,\;(3,2)=\max(.4,.4,.1)=0.4,\;(3,3)=0.3
$$



**Final answer.** 

$$
R=\begin{bmatrix}.4&.6&.3\\.4&.4&.3\\.1&.1&.1\end{bmatrix}
$$

, 

$$
S=\begin{bmatrix}.4&.5&.3\\.2&.2&.2\\.4&.4&.3\end{bmatrix}
$$

, 

$$
S\circ R=\begin{bmatrix}0.4&0.4&0.3\\0.2&0.2&0.2\\0.4&0.4&0.3\end{bmatrix}
$$

. (The key gives R and S only.)

## Every cell without the row shortcuts

Both printed relations run from size to speed; their middle labels do not match for genuine relation composition. The numerical working below follows the question’s intended row-of-S with column-of-R operation using explicitly assumed positional alignment of the three middle entries.

### R: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| R11 | 0.6 | 0.4 | 0.4 |
| R12 | 0.6 | 0.8 | 0.6 |
| R13 | 0.6 | 0.3 | 0.3 |
| R21 | 0.4 | 0.4 | 0.4 |
| R22 | 0.4 | 0.8 | 0.4 |
| R23 | 0.4 | 0.3 | 0.3 |
| R31 | 0.1 | 0.4 | 0.1 |
| R32 | 0.1 | 0.8 | 0.1 |
| R33 | 0.1 | 0.3 | 0.1 |

### S: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| S11 | 0.5 | 0.4 | 0.4 |
| S12 | 0.5 | 0.8 | 0.5 |
| S13 | 0.5 | 0.3 | 0.3 |
| S21 | 0.2 | 0.4 | 0.2 |
| S22 | 0.2 | 0.8 | 0.2 |
| S23 | 0.2 | 0.3 | 0.2 |
| S31 | 0.4 | 0.4 | 0.4 |
| S32 | 0.4 | 0.8 | 0.4 |
| S33 | 0.4 | 0.3 | 0.3 |

**Result cell (1,1)**



$$
\max\{\min(0.4,0.4),\min(0.5,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (1,2)**



$$
\max\{\min(0.4,0.6),\min(0.5,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (1,3)**



$$
\max\{\min(0.4,0.3),\min(0.5,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.3,0.3,0.1\}=0.3
$$



**Result cell (2,1)**



$$
\max\{\min(0.2,0.4),\min(0.2,0.4),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (2,2)**



$$
\max\{\min(0.2,0.6),\min(0.2,0.4),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (2,3)**



$$
\max\{\min(0.2,0.3),\min(0.2,0.3),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (3,1)**



$$
\max\{\min(0.4,0.4),\min(0.4,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (3,2)**



$$
\max\{\min(0.4,0.6),\min(0.4,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (3,3)**



$$
\max\{\min(0.4,0.3),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.3,0.3,0.1\}=0.3
$$



---

## TEE · Q4(a) PSO, one iteration [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q4a

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Maximize 

$$
F(x)=x_1^2-x_1x_2+x_2^2+3x_1+4x_2+5
$$

 using Particle Swarm Optimization. 

$$
X=\begin{bmatrix}3.1472&-4.0246\\4.0579&-2.2150\end{bmatrix},\;V=\begin{bmatrix}0.2194&0.2449\\0.1908&0.2228\end{bmatrix}
$$

. Take 

$$
W=0.9,\;c_1=c_2=1.5,\;r_1=0.5949,\;r_2=0.0855
$$

. Optimize and give the solution after 1 iteration showing the step-by-step process.** [10 marks]

### Answer

#### Given

P1: 

$$
x=(3.1472,\,-4.0246)
$$

, 

$$
v=(0.2194,\,0.2449)
$$

. P2: 

$$
x=(4.0579,\,-2.2150)
$$

, 

$$
v=(0.1908,\,0.2228)
$$

. 

$$
c_1r_1=0.89235
$$

, 

$$
c_2r_2=0.12825
$$

.

#### To find

Updated velocities, positions, pbest and gbest after one iteration.

#### Formula and why it applies



$$
v^{new}=wv+c_1r_1(pbest-x)+c_2r_2(gbest-x),\quad x^{new}=x+v^{new}
$$



Initial personal bests equal the starting positions. Use one frozen global best for all particles. This question maximises fitness, so keep a memory only when its score is larger.

#### Solution

##### Step 1. Fitness of P1 (term by term)



$$
x_1^2=9.904868,\;-x_1x_2=+12.666221,\;x_2^2=16.197405,\;3x_1=9.4416,\;4x_2=-16.0984
$$





$$
F_1=9.904868+12.666221+16.197405+9.4416-16.0984+5=37.1117
$$



##### Step 2. Fitness of P2



$$
F_2=16.466552+8.988249+4.906225+12.1737-8.86+5=38.6747
$$



##### Step 3. pbest and gbest

pbest = current positions. 

$$
38.6747>37.1117
$$

, so **gbest = P2 = (4.0579, −2.2150)**.

##### Step 4. Particle 1 updates



$$
v_{11}=0.9(0.2194)+0+0.12825(4.0579-3.1472)=0.19746+0.116797=0.314257
$$





$$
x_{11}=3.1472+0.314257=3.461457
$$





$$
v_{12}=0.9(0.2449)+0+0.12825(-2.2150+4.0246)=0.22041+0.232081=0.452491
$$





$$
x_{12}=-4.0246+0.452491=-3.572109
$$



##### Step 5. Particle 2 updates (gbest particle: only inertia acts)



$$
v_{21}=0.9(0.1908)=0.17172,\quad x_{21}=4.22962;\qquad v_{22}=0.9(0.2228)=0.20052,\quad x_{22}=-2.01448
$$



##### Step 6. New fitness and bests

Use the same objective at each new position. Keep full precision internally; displayed coordinates are rounded.



$$
F(3.461457275,-3.5721088)=(3.461457275)^2-(3.461457275)(-3.5721088)+(-3.5721088)^2+3(3.461457275)+4(-3.5721088)+5
$$





$$
=11.981686467+12.364701993+12.759961279+10.384371825+(-14.2884352)+5\approx38.202286364
$$





$$
F(4.22962,-2.01448)=(4.22962)^2-(4.22962)(-2.01448)+(-2.01448)^2+3(4.22962)+4(-2.01448)+5
$$





$$
=17.889685344+8.520484898+4.05812967+12.68886+(-8.05792)+5\approx40.099239912
$$



| Particle | New position | New F | Old F | pbest |
| --- | --- | --- | --- | --- |
| 1 | (3.461457, −3.572109) | 38.2023 | 37.1117 | updated |
| 2 | (4.22962, −2.01448) | 40.0992 | 38.6747 | updated |

The best pbest is now P2's with F = 40.0992, so gbest moves to (4.22962, −2.01448).

**Final answer.** 

$$
V=\begin{bmatrix}0.314257&0.452491\\0.17172&0.20052\end{bmatrix}
$$

, 

$$
X=\begin{bmatrix}3.461457&-3.572109\\4.22962&-2.01448\end{bmatrix}
$$

. Both particles improved; new gbest = (4.22962, −2.01448) with F = 40.0992.

**Official key warning.** The re-exam answer key solves a *different* problem: particles (0.4, 0.3) and (0.3, 0.4) with velocities (0.1, −0.2) and (−0.2, 0.1), giving fitness 7.53 and 7.86. Do not copy it. The numbers above solve the question as printed.

This X and V are particles 1 and 2 of your lecture's five-particle example; only the function differs (+3x₁ and +5 here instead of +2x₁ and +3).

---

## TEE · Q4(b) Naive Bayes: job offer [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q4b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q4b

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Predict whether a candidate accepts a job offer from Experience (Fresher/Mid/Senior), Expected Salary (Low/Medium/High) and Company Reputation (Good/Average). Data: (Fresher, Low, Good, Yes), (Mid, High, Good, Yes), (Senior, High, Average, No), (Fresher, Medium, Average, Yes), (Senior, Low, Good, No), (Mid, Medium, Good, Yes), (Fresher, High, Average, No), (Senior, Medium, Average, No). New candidate: Mid, Low, Good.** [10 marks]

### Answer

#### Given

The full training data are in Step 1. Query: Experience=Mid, Salary=Low, Reputation=Good. The main calculation uses unsmoothed counts.

#### To find

Both class scores and the predicted class.

#### Formula and why it applies



$$
score(C)=P(C)\prod_jP(a_j\mid C)
$$



C is a class label. Each aⱼ is one query feature value. First count inside a class, then multiply the prior and all three likelihoods.

#### Solution

##### Step 1. Write the training rows as a table

| Row | Experience | Salary | Reputation | Class |
| --- | --- | --- | --- | --- |
| 1 | Fresher | Low | Good | Yes |
| 2 | Mid | High | Good | Yes |
| 3 | Senior | High | Average | No |
| 4 | Fresher | Medium | Average | Yes |
| 5 | Senior | Low | Good | No |
| 6 | Mid | Medium | Good | Yes |
| 7 | Fresher | High | Average | No |
| 8 | Senior | Medium | Average | No |

##### Step 2. Separate the two class groups

| Class | Rows in this group | Class count | Prior |
| --- | --- | --- | --- |
| Yes | 1, 2, 4, 6 | 4 | 4/8 = 0.5 |
| No | 3, 5, 7, 8 | 4 | 4/8 = 0.5 |

##### Step 3. For class Yes, count Experience=Mid

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 2, 6.



$$
P(\text{Experience}=\text{Mid}\mid C=\text{Yes})=\frac{2}{4}=0.5
$$



##### Step 4. For class Yes, count Salary=Low

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1.



$$
P(\text{Salary}=\text{Low}\mid C=\text{Yes})=\frac{1}{4}=0.25
$$



##### Step 5. For class Yes, count Reputation=Good

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1, 2, 6.



$$
P(\text{Reputation}=\text{Good}\mid C=\text{Yes})=\frac{3}{4}=0.75
$$



##### Step 6. Multiply the Yes score one factor at a time



$$
P(Yes)=4/8=0.5
$$





$$
0.5\times0.5=0.25
$$





$$
0.25\times0.25=0.0625
$$





$$
0.0625\times0.75=0.046875
$$



##### Step 7. For class No, count Experience=Mid

Look only at class No rows 3, 5, 7, 8. No row in this class has that feature value.



$$
P(\text{Experience}=\text{Mid}\mid C=\text{No})=\frac{0}{4}=0
$$



##### Step 8. For class No, count Salary=Low

Look only at class No rows 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Salary}=\text{Low}\mid C=\text{No})=\frac{1}{4}=0.25
$$



##### Step 9. For class No, count Reputation=Good

Look only at class No rows 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Reputation}=\text{Good}\mid C=\text{No})=\frac{1}{4}=0.25
$$



##### Step 10. Multiply the No score one factor at a time



$$
P(No)=4/8=0.5
$$





$$
0.5\times0=0
$$





$$
0\times0.25=0
$$





$$
0\times0.25=0
$$



##### Step 11. Compare the scores



$$
score(Yes)=0.046875\qquad score(No)=0
$$



The larger score belongs to Yes. Normalise only if a posterior probability is requested: divide each score by their total 0.046875.

**Final answer.** Predict Yes. Yes score=0.046875; No score=0.

**Official key note.** The key gives No = 0.0068 and P(Yes) = 0.873. That No value comes from Laplace smoothing (1/7 × 2/7 × 2/6 × 0.5), but the key did not smooth the Yes side. If you smooth, smooth both: Yes = 0.5 × 3/7 × 2/7 × 4/6 = 0.0408, No = 0.0068, P(Yes) = 0.857. The prediction is Yes either way.

**Yaad rakho:** Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.

---

## TEE · Q5(a) Genetic algorithm [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q5a

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Implement a GA to maximise 

$$
f(x)=2x^3-3x^2+8x
$$

 for x in [0,50]. Take 4-bit representations of 12, 20, 17, 13. Crossover after the second bit and mutate by flipping any one bit. Produce two offspring and comment on fitness.** [10 marks]

### Answer

**The printed data are inconsistent.** 20 and 17 do not fit into four bits, and covering 0–50 needs six bits. We use six-bit encoding to preserve the supplied parent values and the stated range.

#### Given

Printed parents: [12, 20, 17, 13]. Worked variant: [12, 20, 17, 13] with 6 bits. For the unspecified selection step, select the two highest-fitness candidates. For the unspecified mutation location, flip the last bit of each child. Crossover is after bit 2.

#### To find

Two valid children under the declared assumptions and their fitness.

#### Formula and why it applies

Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.



$$
f(x)=2x^3-3x^2+8x
$$



#### Solution

##### Step 1. Encode and evaluate the declared parent population

| x | Binary | Fitness substitution |
| --- | --- | --- |
| 12 | 001100 | 2(12³) − 3(12²) + 8(12) = 3120 |
| 20 | 010100 | 2(20³) − 3(20²) + 8(20) = 14960 |
| 17 | 010001 | 2(17³) − 3(17²) + 8(17) = 9095 |
| 13 | 001101 | 2(13³) − 3(13²) + 8(13) = 3991 |

##### Step 2. Select the two fittest under the stated assumption

[20, 17] with fitness [14960, 9095].

##### Step 3. Cut after bit 2 and exchange tails

| Parent 1 | Parent 2 | Child 1 | Child 2 |
| --- | --- | --- | --- |
| 01 | 0100 | 01 | 0001 | 010001 | 010100 |

##### Step 4. Flip the last bit of each child

| Before | After | Decoded x |
| --- | --- | --- |
| 010001 | 010000 | 16 |
| 010100 | 010101 | 21 |

##### Step 5. Evaluate both children

| x | Fitness calculation |
| --- | --- |
| 16 | 2(4096) − 3(256) + 8(16) = 7552 |
| 21 | 2(9261) − 3(441) + 8(21) = 17367 |

##### Step 6. Compare with the selected parents

Best parent score = 14960; best child score = 17367. Parent average = 12027.5; child average = 12459.5. Both the best score and the average score increased in this worked variant. An individual child can still be worse than a parent; GA does not guarantee improvement after every random operator.

**Final answer.** Under these declared repairs and operator choices, children are [16, 21] with fitness [7552, 17367]. These are not unique answers to the inconsistent and under-specified original question.

The printed wording about “two offspring” is not an explicit requirement for two complete generations. The M2 examples separately work two full generations because your class update asks for iteration 2.

## Evaluate the polynomial without skipping the powers

Calculate x²=x×x, then x³=x²×x. Multiply each by its coefficient and combine with the written signs. A bit-string repair in the worked answer is an explicitly stated response to inconsistent printed givens; it is not a new instruction in the original paper.

### x=12



$$
x^2=12\times12=144\qquad x^3=144\times12=1728
$$





$$
2x^3=3456\quad 3x^2=432\quad 8x=96
$$





$$
f(12)=3456-432+96=3120
$$



### x=20



$$
x^2=20\times20=400\qquad x^3=400\times20=8000
$$





$$
2x^3=16000\quad 3x^2=1200\quad 8x=160
$$





$$
f(20)=16000-1200+160=14960
$$



### x=17



$$
x^2=17\times17=289\qquad x^3=289\times17=4913
$$





$$
2x^3=9826\quad 3x^2=867\quad 8x=136
$$





$$
f(17)=9826-867+136=9095
$$



### x=13



$$
x^2=13\times13=169\qquad x^3=169\times13=2197
$$





$$
2x^3=4394\quad 3x^2=507\quad 8x=104
$$





$$
f(13)=4394-507+104=3991
$$



### x=16



$$
x^2=16\times16=256\qquad x^3=256\times16=4096
$$





$$
2x^3=8192\quad 3x^2=768\quad 8x=128
$$





$$
f(16)=8192-768+128=7552
$$



### x=21



$$
x^2=21\times21=441\qquad x^3=441\times21=9261
$$





$$
2x^3=18522\quad 3x^2=1323\quad 8x=168
$$





$$
f(21)=18522-1323+168=17367
$$



---

## TEE · Q5(b) Hotel booking channels (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q5b

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Bookings come via Website (W), App (A) or Counter (C). From W: 50% W, 30% A, 20% C. From A: 40% A, 40% W, 20% C. From C: 20% W, 30% A, 50% C. 1. Develop the transition matrix. 2. Interpret retention and gain/loss. 3. Draw the diagram. 4. If now 40% W, 35% A, 25% C, estimate next week. 5. Which channel grows or shrinks in the long term?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: W, A, C. Initial vector [0.4, 0.35, 0.25].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | W | A | C |
| --- | --- | --- | --- |
| W | 0.5 | 0.3 | 0.2 |
| A | 0.4 | 0.4 | 0.2 |
| C | 0.2 | 0.3 | 0.5 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_booking.a7176dff51.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Weekly booking channel: Website, App, Counter | 0.3 | 0.2 | 0.4 | 0.2 | 0.2 | 0.3 | 0.5 | 0.4 | 0.5 | W | A | C

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to W

| Origin | Current count/share | Transition to W | Contribution |
| --- | --- | --- | --- |
| W | 0.4 | 0.5 | 0.4 × 0.5 = 0.2 |
| A | 0.35 | 0.4 | 0.35 × 0.4 = 0.14 |
| C | 0.25 | 0.2 | 0.25 × 0.2 = 0.05 |



$$
W_{new}=0.2+0.14+0.05=0.39
$$



##### Step 4. Next step: collect all contributions to A

| Origin | Current count/share | Transition to A | Contribution |
| --- | --- | --- | --- |
| W | 0.4 | 0.3 | 0.4 × 0.3 = 0.12 |
| A | 0.35 | 0.4 | 0.35 × 0.4 = 0.14 |
| C | 0.25 | 0.3 | 0.25 × 0.3 = 0.075 |



$$
A_{new}=0.12+0.14+0.075=0.335
$$



##### Step 5. Next step: collect all contributions to C

| Origin | Current count/share | Transition to C | Contribution |
| --- | --- | --- | --- |
| W | 0.4 | 0.2 | 0.4 × 0.2 = 0.08 |
| A | 0.35 | 0.2 | 0.35 × 0.2 = 0.07 |
| C | 0.25 | 0.5 | 0.25 × 0.5 = 0.125 |



$$
C_{new}=0.08+0.07+0.125=0.275
$$



##### Step 6. Stationarity: find Counter first



$$
c=0.2w+0.2a+0.5c
$$



Since w+a+c=1, replace w+a with 1−c.



$$
c=0.2(1-c)+0.5c=0.2+0.3c
$$





$$
0.7c=0.2\quad c=2/7
$$



##### Step 7. Find App in terms of Website



$$
a=0.3w+0.4a+0.3c
$$





$$
0.6a=0.3w+0.3c\quad a=0.5w+0.5c
$$



##### Step 8. Use the sum to isolate Website



$$
w+(0.5w+0.5c)+c=1
$$





$$
1.5w=1-1.5c=1-3/7=4/7
$$





$$
w=(4/7)/1.5=8/21
$$





$$
a=1-w-c=1-8/21-6/21=7/21=1/3
$$



##### Step 9. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| W | 0.4 | 0.380952381 | -0.019047619 | Loses |
| A | 0.35 | 0.333333333 | -0.016666667 | Loses |
| C | 0.25 | 0.285714286 | 0.035714286 | Gains |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [0.39, 0.335, 0.275]. Stationary shares ≈ [0.380952381, 0.333333333, 0.285714286]. W loses, A loses, C gains.

---

## TEE · Q6(a) ACO for TSP [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q6a

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. For the four-city travelling salesman problem the distance matrix and pheromone matrix are given (all pheromones 1). Apply Ant Colony Optimization. Calculate the path travelled by 2 ants starting from city A; random numbers for Ant 1 are 0.3, 0.8 and for Ant 2 are 0.5, 0.7. Also update the pheromone matrix after 1 iteration.** [10 marks]

### Answer

#### Given



$$
D=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&1&2&3\\B&1&0&4&5\\C&2&4&0&6\\D&3&5&6&0\end{array},\qquad\tau_{ij}=1\;(i\ne j)
$$



Assume 

$$
\alpha=\beta=1,\;\rho=0.5,\;Q=1
$$

.

#### To find

Both tours, their lengths and the pheromone matrix after one iteration.

#### Formula and why it applies



$$
P_{ij}=\frac{\tau_{ij}^{\alpha}(1/d_{ij})^\beta}{\sum_{k\in allowed}\tau_{ik}^{\alpha}(1/d_{ik})^\beta}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}+\sum_{k:\,ij\in tour_k}\frac{Q}{L_k}
$$



Use unvisited cities in alphabetical order for cumulative selection. Every ant completes its tour using old pheromones; then evaporate and deposit on each undirected edge, including the return edge.

#### Solution

##### Step 1. From A



$$
\eta:\;B=1,\;C=0.5,\;D=0.3333;\;\text{sum}=1.8333\Rightarrow P=0.5455,\;0.2727,\;0.1818
$$



Cumulative: B 0–0.5455, C 0.5455–0.8182, D 0.8182–1. Ant 1 (0.3) → **B**; Ant 2 (0.5) → **B**.

##### Step 2. From B (C and D left)



$$
\eta:\;C=0.25,\;D=0.2;\;\text{sum}=0.45\Rightarrow P_{BC}=0.5556,\;P_{BD}=0.4444
$$



Cumulative: C 0–0.5556, D 0.5556–1. Ant 1 (0.8) → **D**; Ant 2 (0.7) → **D**.

##### Step 3. Complete the tours



$$
A\to B\to D\to C\to A,\qquad L=1+5+6+2=14\;\text{(both ants)}
$$



Swipe across the diagram to read its labels ↔

![Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14](https://deep-learning-study-room.vercel.app/is2/fig/aco_reexam_graph.02195c6ee9.svg)

Diagram: Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14. Labels: Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14 | 1 | 2 | 3 | 4 | 5 | 6 | A | B | C | D

##### Step 4. Pheromone update

Used edges AB, BD, DC, CA get 

$$
0.5(1)+2\times\frac1{14}=0.6429
$$

; unused edges AD and BC become 

$$
0.5
$$

.



$$
\tau_{\text{new}}=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&0.6429&0.6429&0.5\\B&0.6429&0&0.5&0.6429\\C&0.6429&0.5&0&0.6429\\D&0.5&0.6429&0.6429&0\end{array}
$$



**Final answer.** Both ants: A → B → D → C → A, length 14. Pheromone 0.6429 on AB, BD, CD, AC; 0.5 on AD, BC.

**Official key note.** This key applies *no evaporation* (

$$
1+0.1428=1.1428
$$

) and its matrix is inconsistent: it increases the unused edge A–D, leaves the used return edge C–A at 1, and gives B–D and D–B different values. If your examiner follows the no-evaporation idea, the consistent version is 1.1429 on AB, BD, CD, AC and 1 on AD, BC. The paper does not specify ρ. State the convention you use; the resulting matrix depends on it. Grading depends on the examiner’s intended convention.

---

## TEE · Q6(b) Aircraft movement between hubs (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q6b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q6b

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Question. Planes at A: 50% stay, 30% to B, 20% to C. At B: 40% to A, 40% stay, 20% to C. At C: 25% to A, 25% to B, 50% stay. 1. Construct the matrix. 2. Interpret retention and movement. 3. Draw the diagram. 4. For [30, 40, 30] find the next night's distribution. 5. Which airport is a long-term net gainer or loser?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: A, B, C. Initial vector [30, 40, 30].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | A | B | C |
| --- | --- | --- | --- |
| A | 0.5 | 0.3 | 0.2 |
| B | 0.4 | 0.4 | 0.2 |
| C | 0.25 | 0.25 | 0.5 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_airline.779a8c5fd6.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Nightly aircraft movement between hubs | 0.3 | 0.2 | 0.4 | 0.2 | 0.25 | 0.25 | 0.5 | 0.4 | 0.5 | A | B | C

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to A

| Origin | Current count/share | Transition to A | Contribution |
| --- | --- | --- | --- |
| A | 30 | 0.5 | 30 × 0.5 = 15 |
| B | 40 | 0.4 | 40 × 0.4 = 16 |
| C | 30 | 0.25 | 30 × 0.25 = 7.5 |



$$
A_{new}=15+16+7.5=38.5
$$



##### Step 4. Next step: collect all contributions to B

| Origin | Current count/share | Transition to B | Contribution |
| --- | --- | --- | --- |
| A | 30 | 0.3 | 30 × 0.3 = 9 |
| B | 40 | 0.4 | 40 × 0.4 = 16 |
| C | 30 | 0.25 | 30 × 0.25 = 7.5 |



$$
B_{new}=9+16+7.5=32.5
$$



##### Step 5. Next step: collect all contributions to C

| Origin | Current count/share | Transition to C | Contribution |
| --- | --- | --- | --- |
| A | 30 | 0.2 | 30 × 0.2 = 6 |
| B | 40 | 0.2 | 40 × 0.2 = 8 |
| C | 30 | 0.5 | 30 × 0.5 = 15 |



$$
C_{new}=6+8+15=29
$$



##### Step 6. Stationarity: find C first



$$
c=0.2(a+b)+0.5c
$$





$$
c=0.2(1-c)+0.5c=0.2+0.3c
$$





$$
0.7c=0.2\quad c=2/7
$$



##### Step 7. Find B in terms of A



$$
b=0.3a+0.4b+0.25c
$$





$$
0.6b=0.3a+0.25c
$$





$$
b=0.5a+\frac5{12}c
$$



##### Step 8. Use a+b=1−c



$$
a+0.5a+\frac5{12}\frac27=1-\frac27=\frac57
$$





$$
1.5a=\frac57-\frac5{42}=\frac{25}{42}
$$





$$
a=\frac{25}{42}\div\frac32=\frac{25}{63}
$$





$$
b=1-\frac{25}{63}-\frac{18}{63}=\frac{20}{63}
$$



##### Step 9. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| A | 0.3 | 0.396825397 | 0.096825397 | Gains |
| B | 0.4 | 0.317460317 | -0.082539683 | Loses |
| C | 0.3 | 0.285714286 | -0.014285714 | Loses |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [38.5, 32.5, 29.0]. Stationary shares ≈ [0.396825397, 0.317460317, 0.285714286]. A gains, B loses, C loses.

---

## TEE · Q7(a) Applications of fuzzy logic [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q7a

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**List the applications of fuzzy logic. Explain any one application in detail.** [10 marks]

### Answer

### Definition

Fuzzy logic is a multi-valued logic, introduced by Lotfi Zadeh (1965), in which truth values range over [0, 1]; it lets machines reason with vague, human-like terms such as “slightly dirty” or “very hot”.

### Applications

| Area | Examples |
| --- | --- |
| Home appliances | Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners |
| Automotive | Automatic transmission, anti-lock braking (ABS), cruise control, engine control |
| Transportation | Traffic-signal control, Sendai subway train control (smooth braking and acceleration) |
| Consumer electronics | Camera autofocus and auto-exposure, image stabilisation |
| Industrial control | Cement kilns, pH, temperature and distillation control in chemical plants |
| Aerospace | Satellite and spacecraft attitude control |
| Medicine | Diagnosis support, anaesthesia dosage control |
| Finance and decisions | Loan approval, credit and fire-risk scoring, stock trading rules |
| AI and robotics | Robot navigation, natural-language interfaces, expert systems |

### One application in detail: fuzzy washing machine

1. **Problem.** Wash time depends on how dirty and how greasy the clothes are. These are vague (“a bit dirty”), and a fixed timer wastes water and power.
2. **Inputs and outputs.** Sensors measure dirt (turbidity of water) and grease; the output is wash time. Each is described by fuzzy sets: dirt Small/Medium/High, grease Small/Medium/High, time Very Short … Very Long.
3. **Fuzzification.** Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.
4. **Rule base.** 9 expert rules, e.g. IF dirt is High AND grease is High THEN time is Very Long; IF dirt is Small AND grease is Small THEN time is Very Short.
5. **Inference.** Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.
6. **Defuzzification.** Use the specified defuzzifier. For a separate representative-weighted illustration, strengths [.6,.4,.2] at times [25,40,60] give (.6×25+.4×40+.2×60)/(.6+.4+.2)=(15+16+12)/1.2≈35.833 minutes. These illustrative strengths are supplied here, not derived from unspecified input graphs. A Mamdani area centroid requires the full aggregate shape.
7. **Benefits.** Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.

### Advantages and disadvantages (bonus)

**Advantages:** handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. **Disadvantages:** rules and membership functions depend on expert judgement; results are hard to verify formally; tuning can take time; not suited where very high precision is required.

**Yaad rakho:** Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.

---

## TEE · Q7(b) Bellman equation and applications of RL [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-reexam-2026--q7b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-reexam-2026/q7b

Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)

**Explain the Bellman equation in reinforcement learning. Also give applications of reinforcement learning.** [10 marks]

### Answer

Write the answer below in this order. It fits in about two pages.

### Part A · Bellman equation (5 marks)

**1. Setting.** Reinforcement learning problems are modelled as a Markov decision process 

$$
\langle\mathcal S,\mathcal A,P,R,\gamma\rangle
$$

. The agent follows a policy 

$$
\pi(a\mid s)
$$

 and wants to maximise the return 

$$
G_t=\sum_{k\ge0}\gamma^kR_{t+k+1}
$$

.

**2. Value functions.** 

$$
v_\pi(s)=\mathbb E_\pi[G_t\mid S_t=s]
$$

 and 

$$
q_\pi(s,a)=\mathbb E_\pi[G_t\mid S_t=s,A_t=a]
$$

.

**3. Key idea.** The return is recursive: 

$$
G_t=R_{t+1}+\gamma G_{t+1}
$$

. Taking expectations gives the **Bellman expectation equation**:



$$
v_\pi(s)=\sum_a\pi(a\mid s)\sum_{s'}P(s'\mid s,a)\,[R(s,a,s')+\gamma v_\pi(s')]
$$





$$
q_\pi(s,a)=\sum_{s'}P(s'\mid s,a)\,\Big[R(s,a,s')+\gamma\sum_{a'}\pi(a'\mid s')q_\pi(s',a')\Big]
$$



**4. Optimality.** For the optimal policy the average over actions becomes a maximum (**Bellman optimality equation**):



$$
v_*(s)=\max_a\sum_{s'}P(s'\mid s,a)\,[R+\gamma v_*(s')],\qquad q_*(s,a)=\sum_{s'}P(s'\mid s,a)\,[R+\gamma\max_{a'}q_*(s',a')]
$$



**5. Meaning and use.** The value of a state equals the immediate reward plus the discounted value of the successor state. This breaks a long-horizon problem into one-step sub-problems (dynamic programming). It is the basis of policy evaluation, policy iteration, value iteration and Q-learning; the optimal policy is 

$$
\pi_*(s)=\arg\max_a q_*(s,a)
$$

.

**6. Small illustration** (adds clarity): if staying in a state gives +1 each step with 

$$
\gamma=0.9
$$

, then 

$$
v=1+0.9v\Rightarrow v=10
$$

.

### Part B · Applications of reinforcement learning (5 marks)

1. **Game playing**: AlphaGo (defeated Lee Sedol, 2016), Atari agents (DQN), and the Mario agent built in this course's lab.
2. **Robotics**: walking, grasping and balancing learned by trial and error in simulation.
3. **Autonomous driving**: lane changing, merging and parking decisions.
4. **Recommendation systems**: choosing content to maximise long-term engagement rather than single clicks.
5. **Finance**: trading and portfolio rebalancing as sequential decisions.
6. **Healthcare**: dynamic treatment regimes (dose adjustment over time).
7. **Resource and energy management**: data-centre cooling control, traffic-signal timing, inventory control.
8. **Language models**: reinforcement learning from human feedback (RLHF) for chatbots.

#### One application in detail: traffic-signal control

|  |  |
| --- | --- |
| Agent | Controller at an intersection. |
| State | Queue length and waiting time on each approach, current signal phase. |
| Actions | Keep the current phase or switch to the next green phase. |
| Reward | Negative of total waiting time (or vehicles cleared per cycle). |
| Learning | Q-learning updates 

$$
Q(s,a)
$$

 from observed traffic; ε-greedy exploration tries alternative timings. |
| Benefit | Adapts to rush hours and incidents; fixed timers cannot. |
| Challenge | Safety during exploration, so agents are trained in simulation first. |

**Yaad rakho:** Bellman ka sar: “value = reward abhi + γ × value aage”. Application likho to S, A, R batao: examiner ko yahi chahiye.

---

## TEE · Q1(a) Joint masses, normalization and conditional probability [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q1a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(a)** [5 marks · 2025-04-28]

| Machine | No Fault (X = 0) | Fault (X = 1) |
| --- | --- | --- |
| Machine A | 0.40 | 0.05 |
| Machine B | 0.25 | 0.10 |
| Machine C | 0.20 | 0.08 |
| Machine D | 0.05 | 0.07 |

A factory uses four machines (Machine A, Machine B, Machine C, and Machine D) for production. The above table shows the joint probability distribution of a fault occurring (X) and the machine type (Y).

- If a fault occurs, what is the probability that it came from Machine C?
- What is the probability that a randomly selected product has a fault?
- Given the product is from Machine B, what is the probability that it has a fault?

### Answer

### Given

The eight printed entries are used exactly as shown. X=1 means fault; Y identifies the machine.

### To find

P(C | fault), P(fault), and P(fault | B).

### Formula and why



$$
P(A\mid B)=\frac{P(A\cap B)}{P(B)}
$$



Conditioning restricts the denominator to the given group. Before treating a whole table as a joint probability distribution, its entries must sum to 1.

### Step 1. Check the printed total



$$
\text{No-fault total}=0.40+0.25+0.20+0.05=0.90
$$





$$
\text{Fault total}=0.05+0.10+0.08+0.07=0.30
$$





$$
\text{Grand total}=0.90+0.30=1.20\ne1
$$



**Source inconsistency:** as printed, this is not a valid normalized probability table. Treating the entries as proportional nonnegative masses is one explicit repair; dividing every entry by 1.20 preserves conditional ratios.

### Step 2. Machine C, given a fault



$$
P(C\mid X=1)=\frac{0.08/1.20}{0.30/1.20}=\frac{0.08}{0.30}=\frac4{15}\approx0.266667
$$



Among all fault mass, 0.08 belongs to C. The common normalization factor cancels.

### Step 3. Overall fault probability under the stated repair



$$
P(X=1)=\frac{0.30}{1.20}=0.25
$$



**Answer under mass normalization: 25%.** The raw column sum 0.30 is only the unnormalized fault mass. If the examiner intended another corrected entry, the unconditional probability depends on that correction; 0.30 cannot be asserted as a valid probability while retaining all eight printed numbers.

### Step 4. Fault, given Machine B



$$
P(X=1\mid B)=\frac{0.10}{0.25+0.10}=\frac{0.10}{0.35}=\frac27\approx0.285714
$$



Machine B is the denominator because the product is known to come from B. **Final conditional answers: 26.6667% and 28.5714%.**

---

## TEE · Q1(b) Genetic algorithm applications [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q1b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(b)** [5 marks · 2025-04-28]

List the applications of genetic algorithm and explain any one application in detail.

### Answer

**Genetic algorithm (GA)** is a population-based search method that evolves encoded candidate solutions using fitness evaluation, selection, crossover and mutation.

- Job-shop scheduling and timetable construction.
- Vehicle routing and travelling-salesman-type optimization.
- Feature selection and hyperparameter search in machine learning.
- Engineering design, such as selecting dimensions subject to strength or cost constraints.
- Resource allocation and placement problems.

### Detailed application: examination timetable

| Stage | How it is used |
| --- | --- |
| Representation | A chromosome assigns a time slot and room to every examination. A gene identifies one exam's assignment. |
| Fitness | Penalize student clashes, room-capacity violations and unavailable slots; among feasible schedules, reward spread-out exams and efficient room use. |
| Initial population | Create several different candidate timetables, using random assignments or constructive rules. |
| Selection | Prefer feasible and lower-penalty timetables while retaining diversity. |
| Crossover | Combine assignments from two parents; repair conflicts if the operator can violate feasibility. |
| Mutation | Move an exam to another permitted slot or swap compatible assignments. Recheck constraints. |
| Replacement / stopping | Keep useful candidates, often protecting the best feasible schedule; stop at a generation/time limit or sufficient improvement. |

**Illustrative example:** two exams sharing students cannot occupy the same slot. A candidate with that clash receives a strong penalty or is repaired before acceptance. This shows why fitness must reflect the actual constraints, not merely how many rooms are occupied.

**Benefit:** explores many combinations without exhaustively listing all timetables. **Limitation:** stochastic search can stagnate and does not guarantee a global optimum; poorly designed penalties can reward unusable schedules.

---

## TEE · Q1(c) Fuzzy union, intersection and complements [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q1c

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(c)** [5 marks · 2025-04-28]

Consider two fuzzy sets

X={(c1,0.6),(c2,0.8),(c3,0.3),(c4,0.5),(c5,0.7)}

Y={(c1,0.4),(c2,0.5),(c3,0.9),(c4,0.6),(c5,0.2)}

Find 1) X∪Y 2) X∩Y 3) ¬X∪¬Y 4) ¬X∩¬Y

### Answer

### Given

The same universe {c1, c2, c3, c4, c5} is used for both sets.

### To find

All four membership vectors, keeping the element order fixed.

### Formula and why



$$
\mu_{X\cup Y}(c)=\max(\mu_X(c),\mu_Y(c)),\quad\mu_{X\cap Y}(c)=\min(\mu_X(c),\mu_Y(c))
$$





$$
\mu_{\neg X}(c)=1-\mu_X(c)
$$



Union takes the larger membership, intersection the smaller, and standard complement subtracts from 1. Apply each operation separately at the same element.

### Step 1. Find complements

| Element | X | Y | 1−X | 1−Y |
| --- | --- | --- | --- | --- |
| c1 | 0.6 | 0.4 | 1−0.6=0.4 | 1−0.4=0.6 |
| c2 | 0.8 | 0.5 | 1−0.8=0.2 | 1−0.5=0.5 |
| c3 | 0.3 | 0.9 | 1−0.3=0.7 | 1−0.9=0.1 |
| c4 | 0.5 | 0.6 | 1−0.5=0.5 | 1−0.6=0.4 |
| c5 | 0.7 | 0.2 | 1−0.7=0.3 | 1−0.2=0.8 |

### Step 2. Compute the four results element by element

| Element | X∪Y = max (X, Y) | X∩Y = min (X, Y) | ¬X∪¬Y | ¬X∩¬Y |
| --- | --- | --- | --- | --- |
| c1 | max(0.6,0.4)=0.6 | min(0.6,0.4)=0.4 | max(0.4,0.6)=0.6 | min(0.4,0.6)=0.4 |
| c2 | max(0.8,0.5)=0.8 | min(0.8,0.5)=0.5 | max(0.2,0.5)=0.5 | min(0.2,0.5)=0.2 |
| c3 | max(0.3,0.9)=0.9 | min(0.3,0.9)=0.3 | max(0.7,0.1)=0.7 | min(0.7,0.1)=0.1 |
| c4 | max(0.5,0.6)=0.6 | min(0.5,0.6)=0.5 | max(0.5,0.4)=0.5 | min(0.5,0.4)=0.4 |
| c5 | max(0.7,0.2)=0.7 | min(0.7,0.2)=0.2 | max(0.3,0.8)=0.8 | min(0.3,0.8)=0.3 |

### Step 3. Write the final sets

**X∪Y**={(c1,0.6),(c2,0.8),(c3,0.9),(c4,0.6),(c5,0.7)}.

**X∩Y**={(c1,0.4),(c2,0.5),(c3,0.3),(c4,0.5),(c5,0.2)}.

**¬X∪¬Y**={(c1,0.6),(c2,0.5),(c3,0.7),(c4,0.5),(c5,0.8)}.

**¬X∩¬Y**={(c1,0.4),(c2,0.2),(c3,0.1),(c4,0.4),(c5,0.3)}.

Yaad rakho: union bada, intersection chhota, complement one minus.

---

## TEE · Q1(d) Cable-company Markov matrix and diagram [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q1d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q1d

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(d)** [5 marks · 2025-04-28]

A city is served by two cable TV companies, BestTV and CableCast. Due to their aggressive sales tactics, each year 40% of BestTV customers switch to CableCast; the other 60% of BestTV customers stay with BestTV. On the other hand, 30% of the CableCast customers switch to Best TV. The two states in this example are BestTV and CableCast.

- Express the information above as a transition matrix which displays the probabilities of going from one state into another state.
- Draw the State diagram for the above information.

### Answer

### Given

Order the states as B=BestTV and C=CableCast.

### To find

The one-year transition matrix and all directed state transitions.

### Formula and why



$$
P_{ij}=P(\text{next state}=j\mid\text{current state}=i),\qquad\sum_jP_{ij}=1
$$



Rows mean current state; columns mean next state. Each row includes every possible destination.

### Step 1. Complete the missing stay probability

BestTV stays =1−0.40=0.60. CableCast stays =1−0.30=0.70.

### Step 2. Place each probability in its row



$$
P=\begin{bmatrix}0.60&0.40\\0.30&0.70\end{bmatrix}_{(B,C)}
$$



| Current → next | BestTV | CableCast | Row total |
| --- | --- | --- | --- |
| BestTV | 0.6 | 0.4 | 1 |
| CableCast | 0.3 | 0.7 | 1 |

### Step 3. Draw the state diagram

Swipe across the diagram to read its labels ↔

![BestTV → CableCast:0.40; CableCast → BestTV:0.30. Self-loops:0.60 and 0.70.](https://deep-learning-study-room.vercel.app/is2/fig/legacy25-cable.c15b41f741.svg)

Diagram: BestTV → CableCast:0.40; CableCast → BestTV:0.30. Self-loops:0.60 and 0.70.. Labels: Cable-company transition probabilities | BestTV | CableCast | 0.40 | 0.30 | 0.60 | 0.70

BestTV → CableCast:0.40; CableCast → BestTV:0.30. Self-loops:0.60 and 0.70.

---

## TEE · Q2(a) Fuzzy investment-controller design and centroid [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q2a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q2(a)** [10 marks · 2025-04-28]

Create a fuzzy logic system to assist in investment decision-making. The system should consider variables such as risk tolerance, and historical performance to provide recommendations on asset allocation and investment strategies.

Input variables: Risk Tolerance (range 1-100) and historical performance (range 1-100). Output variable is Asset allocation (range 1-100) (Conservative, Balanced and Aggressive). Use 3 descriptors for input as well as output. Set rules to accurately predict the output. Show defuzzification for risk 40 and historical performance 8.

### Answer

### Given

**Printed inputs:** risk=40, historical performance=8, both on 1–100; output allocation score on 1–100. Membership shapes, breakpoints, rules and inference method are design choices, not printed data.

### To find

One fully specified fuzzy system and the crisp output for these inputs.

### Formula and why

Use a Mamdani system: fuzzify inputs → apply min for AND → clip each output membership at its rule strength → aggregate by max → centroid. The result is a defined model output, not a guaranteed real investment return.



$$
z^*=\frac{\int_1^{100}z\mu_{agg}(z)\,dz}{\int_1^{100}\mu_{agg}(z)\,dz}
$$



### Step 1. Specify all membership functions

For either input t∈[1,100], choose Low as a left shoulder, Medium as a triangle and High as a right shoulder:



$$
\mu_L(t)=\begin{cases}(50-t)/49&1\le t\le50\\0&50<t\le100\end{cases}
$$





$$
\mu_M(t)=\begin{cases}(t-1)/49&1\le t\le50\\(100-t)/50&50<t\le100\end{cases}
$$





$$
\mu_H(t)=\begin{cases}0&1\le t\le50\\(t-50)/50&50<t\le100\end{cases}
$$



Use the same three shapes on output z, named Conservative, Balanced and Aggressive. The score is an increasing aggressiveness index; it is not automatically a percentage in one specified asset. Higher scores recommend a more aggressive strategy within this illustrative model.

Swipe across the diagram to read its labels ↔

![Declared membership design. Both inputs and the output use the same breakpoints 1,50,100, with different linguistic labels.](https://deep-learning-study-room.vercel.app/is2/fig/legacy25-memberships.904ed2cacf.svg)

Diagram: Declared membership design. Both inputs and the output use the same breakpoints 1,50,100, with different linguistic labels.. Labels: Declared shoulder triangular and shoulder membership functions | Input value / allocation score | μ | 0 | 1 | 1 | 50 | 100 | Low / Conservative | Medium / Balanced | High / Aggressive

Declared membership design. Both inputs and the output use the same breakpoints 1,50,100, with different linguistic labels.

### Step 2. State the nine rules

| Risk tolerance | Historical performance | Output |
| --- | --- | --- |
| Low | Low | Conservative |
| Low | Medium | Conservative |
| Low | High | Conservative |
| Medium | Low | Conservative |
| Medium | Medium | Balanced |
| Medium | High | Balanced |
| High | Low | Balanced |
| High | Medium | Aggressive |
| High | High | Aggressive |

The rule base respects low risk tolerance even if past performance is high. Medium risk plus poor past performance moves towards Conservative. High risk with medium/high performance allows Aggressive. These are declared illustrative design judgments; other valid designs can yield other outputs.

### Step 3. Fuzzify the two printed numbers

| Input | Low | Medium | High |
| --- | --- | --- | --- |
| Risk 40 | (50−40)/49=10/49=0.204082 | (40−1)/49=39/49=0.795918 | 0 |
| Performance 8 | (50−8)/49=42/49=0.857143 | (8−1)/49=7/49=1/7=0.142857 | 0 |

**8 is retained exactly; it is not replaced with 80.**

### Step 4. Evaluate all nonzero rules

| Rule | AND calculation | Firing strength | Consequent |
| --- | --- | --- | --- |
| Low & Low | min(10/49,42/49) | 10/49 | Conservative |
| Low & Medium | min(10/49,7/49) | 7/49 | Conservative |
| Medium & Low | min(39/49,42/49) | 39/49 | Conservative |
| Medium & Medium | min(39/49,7/49) | 7/49 | Balanced |

The other five rules have a zero antecedent and do not fire. Maximum aggregation gives Conservative height 39/49, Balanced height 1/7 and Aggressive height 0.

### Step 5. Construct the aggregated output



$$
\mu_{agg}(z)=\max\{\min(39/49,\mu_L(z)),\min(1/7,\mu_M(z))\}
$$



The Conservative clip meets its descending slope at z=11. It falls to 1/7 at z=43. The Balanced descending side reaches 1/7 at z=650/7≈92.857143.



$$
\mu_{agg}(z)=\begin{cases}39/49&1\le z\le11\\(50-z)/49&11<z\le43\\1/7&43<z\le650/7\\(100-z)/50&650/7<z\le100\end{cases}
$$



Swipe across the diagram to read its labels ↔

![Actual max-aggregated output for risk 40 and performance 8. The shaded area has centroid 30.379571.](https://deep-learning-study-room.vercel.app/is2/fig/legacy25-centroid.6d2be43cdb.svg)

Diagram: Actual max-aggregated output for risk 40 and performance 8. The shaded area has centroid 30.379571.. Labels: Mamdani aggregated output and centroid for risk40 history8 | Input value / allocation score | μ | 0 | 1 | 1 | 50 | 100 | Centroid z\* =30.379571

Actual max-aggregated output for risk 40 and performance 8. The shaded area has centroid 30.379571.

### Step 6. Calculate area and first moment for each segment

For a segment µ(z)=mz+c between a and b, integrate its area A and first moment M as follows:



$$
A=\frac m2(b^2-a^2)+c(b-a),\qquad M=\frac m3(b^3-a^3)+\frac c2(b^2-a^2)
$$



| Interval | Membership | Area A | First moment M |
| --- | --- | --- | --- |
| 1 to 11 | 39/49 | 7.959183673 | 47.755102041 |
| 11 to 43 | (50−z)/49 | 15.020408163 | 349.823129252 |
| 43 to 650/7 | 1/7 | 7.122448980 | 483.817784257 |
| 650/7 to 100 | (100−z)/50 | 0.510204082 | 48.590864917 |

For example, the first rectangle has area (11−1)×39/49=390/49 and moment (39/49)×(11²−1²)/2=2340/49. The other areas and moments follow explicitly: interval 11–43 has A=[−z²/98+50z/49] from 11 to 43=15.020408163 and M=[−z³/147+25z²/49] from 11 to 43=349.823129252. Interval 43–650/7 has A=(650/7−43)/7=7.122448980 and M=((650/7)²−43²)/14=483.817784257. Interval 650/7–100 has A=[2z−z²/100] from 650/7 to 100=0.510204082 and M=[z²−z³/150] from 650/7 to 100=48.590864917.

### Step 7. Divide moment by area and interpret



$$
\sum A=1500/49\approx30.612244898
$$





$$
\sum M=637971/686\approx929.986880466
$$





$$
z^*=\frac{637971/686}{1500/49}=\frac{212657}{7000}\approx\boxed{30.379571}
$$



The resulting allocation score leans Conservative for this declared rule base. A centroid is obtained from the aggregated area; do not replace this Mamdani calculation with an unexplained weighted average of label names.

---

## TEE · Q2(b) GMM versus k-means, log likelihood and parameter count [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q2b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q2b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q2(b)** [10 marks · 2025-04-28]

With reference to Gaussian Mixture model (GMM), answer the following

- Compare GMM with K-means algorithm
- Derive the equation for Log likelihood function.
- What will be the no of parameters to be computed if K=5

### Answer

**Gaussian mixture model:** a probability density formed by a weighted sum of K Gaussian components. Each observation has a latent component label; its membership is generally represented by responsibilities rather than a single compulsory hard assignment.

| Aspect | K-means | GMM |
| --- | --- | --- |
| Assignment | Hard: choose one closest centroid | Soft: a posterior responsibility for each component |
| Parameters | K centroid vectors | Mixture weights, mean vectors and covariance matrices |
| Objective | Minimize within-cluster squared Euclidean distances | Maximize data likelihood or log likelihood |
| Shape | Nearest-centroid partitions suit roughly spherical/equal-scale groups | Full covariance allows tilted ellipsoids; restricted covariance gives simpler shapes |
| Updates | Alternate assignment and centroid averaging | EM: responsibility calculation and weighted parameter updates |
| Uncertainty | No probability from basic assignment alone | Responsibilities quantify ambiguity under the fitted model |

### Log-likelihood derivation

### Step 1. Write one observation's density



$$
p(x_i\mid\theta)=\sum_{k=1}^K\pi_k\,\mathcal N(x_i\mid\mu_k,\Sigma_k),\quad \pi_k\ge0,\quad\sum_k\pi_k=1
$$





$$
\mathcal N(x\mid\mu,\Sigma)=\frac{\exp[-\frac12(x-\mu)^T\Sigma^{-1}(x-\mu)]}{(2\pi)^{d/2}|\Sigma|^{1/2}}
$$



πk is the probability of component k; µk is its centre; Σk describes spread and correlation. Assume positive-definite full covariances for this density.

### Step 2. Multiply independent observations



$$
\mathcal L(\theta)=\prod_{i=1}^{N}\left[\sum_{k=1}^{K}\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)\right]
$$



The product follows from the usual independent, identically distributed training-sample assumption. The sum inside handles the unobserved component choice.

### Step 3. Take the natural logarithm



$$
\ell(\theta)=\log\mathcal L(\theta)=\sum_{i=1}^{N}\log\left[\sum_{k=1}^{K}\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)\right]
$$



Log turns the product across samples into a sum. It does **not** turn the mixture sum inside each logarithm into a sum of logarithms. The coupled terms motivate iterative optimization such as EM.

### Step 4. Count parameters and state the missing assumption

The question gives K=5 but does not give dimension d or covariance structure, so one universal integer cannot be determined.

| Component | Independent parameters |
| --- | --- |
| Means | Kd |
| Full symmetric covariances | K d (d+1)/2 |
| Mixture weights | K−1, because their sum is 1 |



$$
n_{free}=Kd+K\frac{d(d+1)}2+(K-1)
$$





$$
K=5:\quad n_{free}=5d+\frac{5d(d+1)}2+4
$$



**If one-dimensional data are intended:** five means+five variances+four independent weights=**14 free parameters**. One implementation stores 15 numbers (including all five weights), but the sum-to-one constraint removes one independent degree of freedom. For d-dimensional diagonal covariances the count is 10d+4; state the selected covariance assumption.

---

## TEE · Q3(a) Bayesian-network conditional cough probability [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q3a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q3a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q3(a)** [10 marks · 2025-04-28]Swipe across the diagram to read its labels ↔

![Original graph: Smoking→Lung Cancer→Cough; Pneumonia→Cough and Pneumonia→Fever.](https://deep-learning-study-room.vercel.app/is2/fig/legacy25-bayes.7f566dbf34.svg)

Diagram: Original graph: Smoking→Lung Cancer→Cough; Pneumonia→Cough and Pneumonia→Fever.. Labels: Original smoking cancer pneumonia cough fever Bayesian network | Smoking S | Lung cancer C | Cough Co | Pneumonia P | Fever F

Original graph: Smoking→Lung Cancer→Cough; Pneumonia→Cough and Pneumonia→Fever.

| Smoking S | P(S) |
| --- | --- |
| T | 0.3 |
| F | 0.7 |

| Smoking S | P(C=T|S) | P(C=F|S) |
| --- | --- | --- |
| T | 0.1 | 0.9 |
| F | 0.01 | 0.99 |

| Pneumonia P | P(P) |
| --- | --- |
| T | 0.3 |
| F | 0.7 |

| C | P | P(Co=T|C, P) | P(Co=F|C, P) |
| --- | --- | --- | --- |
| T | T | 0.95 | 0.05 |
| T | F | 0.8 | 0.2 |
| F | T | 0.7 | 0.3 |
| F | F | 0.1 | 0.9 |

| P | P(Fever=T|P) | P(Fever=F|P) |
| --- | --- | --- |
| T | 0.9 | 0.1 |
| F | 0.01 | 0.99 |

Given the above tables for the Bayesian network, calculate Probability of a person having cough given he doesn’t have lung cancer but Smokes.

### Answer

### Given

Evidence: C=F (no lung cancer), S=T (smokes). Query: Co=T. Pneumonia is not observed; sum over its two states.

### To find

P(Co=T | C=F, S=T).

### Formula and why



$$
P(Co\mid\neg C,S)=\sum_{p\in\{T,F\}}P(Co\mid\neg C,S,P=p)P(P=p\mid\neg C,S)
$$



The network says cough depends on its parents C and P. Once they are known, smoking provides no additional direct information about cough. The pneumonia root is independent of S and C in this network when no descendant evidence such as cough/fever is conditioned on.

### Step 1. Write the network factorization



$$
P(S,C,P,Co,F)=P(S)P(C\mid S)P(P)P(Co\mid C,P)P(F\mid P)
$$



This factorization expresses the model, not a general medical truth. Fever is unobserved and its two conditional probabilities sum to 1.

### Step 2. Select the correct cough rows

| Hidden pneumonia state | Cough probability with C=F | Pneumonia weight |
| --- | --- | --- |
| P=T | P(Co=T|C=F, P=T)=0.70 | 0.30 |
| P=F | P(Co=T|C=F, P=F)=0.10 | 0.70 |

Do not use 0.95 or 0.80: those rows assume lung cancer is present, which contradicts the given evidence.

### Step 3. Multiply each conditional probability by its weight



$$
0.70\times0.30=0.21,\qquad0.10\times0.70=0.07
$$



### Step 4. Add the mutually exclusive pneumonia cases



$$
P(Co=T\mid C=F,S=T)=0.21+0.07=\boxed{0.28}
$$



**Final answer:28%.** We do not multiply the final answer byP(smoking)=0.3: smoking is already a condition, not an additional joint event.

### Step 5. Verify using joint-over-evidence



$$
P(\neg C,S)=0.9\times0.3=0.27
$$





$$
P(Co,\neg C,S)=0.27\times0.28=0.0756
$$





$$
P(Co\mid\neg C,S)=0.0756/0.27=0.28
$$



---

## TEE · Q3(b) Fuzzy Cartesian relations and composition-domain ambiguity [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q3b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q3(b)** [10 marks · 2025-04-28]

Consider 2 fuzzy sets

A={0.8/small+0.5/medium+0.2/large}

B={0.6/slow+0.9/moderate+0.4/fast}

- Find the fuzzy relation R=A×B (Cartesian Product)
- Given another fuzzy set C={0.7/small+0.3/medium+0.5/large}. Find the fuzzy relation S=C×B
- Calculate the max-min composition S∘R

### Answer

### Given

A and C use size universe X={small, medium, large}; B uses speed universe Y={slow, moderate, fast}. Use the listed orders for rows and columns.

### To find

R and S; then explain and resolve the composition convention explicitly.

### Formula and why



$$
\mu_{A\times B}(x,y)=\min(\mu_A(x),\mu_B(y)),\quad T_{ij}=\max_k\min(U_{ik},V_{kj})
$$



Fuzzy Cartesian product uses minimum here, not multiplication. A relation composition additionally needs the first relation's output universe to match the second's input universe.

### Step 1. Calculate all entries of R

| Size / speed | slow 0.6 | moderate 0.9 | fast 0.4 |
| --- | --- | --- | --- |
| small 0.8 | min(0.8,0.6)=0.6 | min(0.8,0.9)=0.8 | min(0.8,0.4)=0.4 |
| medium 0.5 | min(0.5,0.6)=0.5 | min(0.5,0.9)=0.5 | min(0.5,0.4)=0.4 |
| large 0.2 | min(0.2,0.6)=0.2 | min(0.2,0.9)=0.2 | min(0.2,0.4)=0.2 |



$$
R=\begin{bmatrix}0.6&0.8&0.4\\0.5&0.5&0.4\\0.2&0.2&0.2\end{bmatrix}
$$



### Step 2. Calculate all entries of S

| Size / speed | slow 0.6 | moderate 0.9 | fast 0.4 |
| --- | --- | --- | --- |
| small 0.7 | min(0.7,0.6)=0.6 | min(0.7,0.9)=0.7 | min(0.7,0.4)=0.4 |
| medium 0.3 | min(0.3,0.6)=0.3 | min(0.3,0.9)=0.3 | min(0.3,0.4)=0.3 |
| large 0.5 | min(0.5,0.6)=0.5 | min(0.5,0.9)=0.5 | min(0.5,0.4)=0.4 |



$$
S=\begin{bmatrix}0.6&0.7&0.4\\0.3&0.3&0.3\\0.5&0.5&0.4\end{bmatrix}
$$



### Step 3. State the source-domain problem

**As typed relations, both R and S map X→Y.** S cannot directly follow R because S expects a size while R ends in a speed. Equal matrix dimensions do not make the universes equal. Thus the requested composition has no unique meaningful typed interpretation as written.

### Step 4. If the examiner intends an indexed matrix operation, state it first

**Conditional classroom calculation:** temporarily identify intermediate labels by position 1,2,3 and define the requested notation here as T=S⊙R, where⊙ is max–min matrix multiplication. This is an index convention, not a claim that “slow” equals “small”.

| Entry | Three minimum terms | Maximum |
| --- | --- | --- |
| T11 | min(0.6,0.6)=0.6, min(0.7,0.5)=0.5, min(0.4,0.2)=0.2 | 0.6 |
| T12 | min(0.6,0.8)=0.6, min(0.7,0.5)=0.5, min(0.4,0.2)=0.2 | 0.6 |
| T13 | min(0.6,0.4)=0.4, min(0.7,0.4)=0.4, min(0.4,0.2)=0.2 | 0.4 |
| T21 | min(0.3,0.6)=0.3, min(0.3,0.5)=0.3, min(0.3,0.2)=0.2 | 0.3 |
| T22 | min(0.3,0.8)=0.3, min(0.3,0.5)=0.3, min(0.3,0.2)=0.2 | 0.3 |
| T23 | min(0.3,0.4)=0.3, min(0.3,0.4)=0.3, min(0.3,0.2)=0.2 | 0.3 |
| T31 | min(0.5,0.6)=0.5, min(0.5,0.5)=0.5, min(0.4,0.2)=0.2 | 0.5 |
| T32 | min(0.5,0.8)=0.5, min(0.5,0.5)=0.5, min(0.4,0.2)=0.2 | 0.5 |
| T33 | min(0.5,0.4)=0.4, min(0.5,0.4)=0.4, min(0.4,0.2)=0.2 | 0.4 |



$$
T=S\odot R=\begin{bmatrix}0.6&0.6&0.4\\0.3&0.3&0.3\\0.5&0.5&0.4\end{bmatrix}
$$



If the course instead writes S∘R to mean first R then S, its untyped matrix computation is R⊙S, which yields rows(0.6,0.6,0.4), (0.5,0.5,0.4), (0.2,0.2,0.2) for these values. The convention must be declared; silently reversing the factors changes the answer.

### Step 5. Show a mathematically valid typed repair

One possible corrected task is to compose R:X→Y with the inverse relation Sᵀ:Y→X. Then compare size elements through a common speed:



$$
U=R\odot S^T=\begin{bmatrix}0.7&0.3&0.5\\0.5&0.3&0.5\\0.2&0.2&0.2\end{bmatrix}
$$





$$
U_{11}=\max\{\min(0.6,0.6),\min(0.8,0.7),\min(0.4,0.4)\}=0.7
$$



This last matrix answers the explicitly repaired task, not an unannounced correction to the printed question.

---

## TEE · Q4(a) PSO one iteration with missing initialization [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q4a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q4(a)** [10 marks · 2025-04-28]

Maximize the F(x) = x1² − x1.x2 + x2² + 3x1 + 4x2 + 5 using Particle Swarm Optimization.

Take values W=0.9, c1=c2=1.5, r1=0.5949, r2=0.0855. Optimize and give solution after 1 iteration showing step by step process.

### Answer

### Given

F(x1, x2)=x1²−x1x2+x2²+3x1+4x2+5; inertia 0.9; c1=c2=1.5; r1=0.5949; r2=0.0855.

### To find

One PSO update, while stating why the printed information does not determine a unique swarm result.

### Formula and why



$$
v_{ij}^{t+1}=wv_{ij}^t+c_1r_1(pbest_{ij}-x_{ij}^t)+c_2r_2(gbest_j-x_{ij}^t)
$$





$$
x_{ij}^{t+1}=x_{ij}^t+v_{ij}^{t+1}
$$



Velocity combines inertia, attraction to a particle's own best and attraction to the swarm's best. For maximization, a larger objective updates the best memories.

### Step 1. Identify missing data and the unbounded objective

The question gives no population size, initial positions, velocities, pbest/gbest or coordinate bounds. Different initializations therefore give different one-iteration results. Also, along x1=x2=t:



$$
F(t,t)=t^2+7t+5\longrightarrow+\infty\quad(t\to+\infty)
$$



**There is no finite global maximum on an unrestricted plane.** A bounded domain would be required for a finite maximization target.

### Step 2. Declare a permissible illustrative initialization

Using the paper's instruction to assume suitable data where necessary, assume two particles: A=(0,0), B=(1,1); both velocities=(0,0); initial pbest equals the starting position. Use the printed random values in both coordinates and freeze the old gbest during this synchronous update.

| Particle | Position | Velocity | Objective | Initial pbest |
| --- | --- | --- | --- | --- |
| A | (0,0) | (0,0) | 5 | (0,0) |
| B | (1,1) | (0,0) | 1−1+1+3+4+5=13 | (1,1) |

The old gbest is B=(1,1), with value 13. These particle coordinates are assumptions, not data from the scan.

### Step 3. Compute the attraction coefficients



$$
c_1r_1=1.5(0.5949)=0.89235,\quad c_2r_2=1.5(0.0855)=0.12825
$$



The cognitive term is zero for both particles because each starts at its own pbest.

### Step 4. Update particle A, coordinate by coordinate



$$
v_{A1}^{1}=0.9(0)+0.89235(0-0)+0.12825(1-0)=0.12825
$$





$$
v_{A2}^{1}=0.9(0)+0.89235(0-0)+0.12825(1-0)=0.12825
$$





$$
x_A^1=(0+0.12825,0+0.12825)=(0.12825,0.12825)
$$





$$
F(x_A^1)=(0.12825)^2+7(0.12825)+5=5.9141980625
$$



This exceeds 5, so A's pbest becomes its new position.

### Step 5. Update particle B and select the new swarm best



$$
v_{B1}^{1}=v_{B2}^{1}=0.9(0)+0.89235(1-1)+0.12825(1-1)=0
$$



B remains at(1,1), with objective 13. Compare 13 against 5.9141980625: the best found after this assumed iteration is still **(1,1), F=13**. This is only the best of the two evaluated particles, not the nonexistent unrestricted global maximum.

---

## TEE · Q4(b) Naive Bayes product-purchase classification [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q4b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q4b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q4(b)** [10 marks · 2025-04-28]

| Age | Income Level | Previous Purchase | Buy Product |
| --- | --- | --- | --- |
| Young | Low | No | No |
| Middle-aged | Medium | Yes | Yes |
| Senior | High | No | No |
| Young | Medium | Yes | Yes |
| Senior | Low | No | No |
| Middle-aged | High | Yes | Yes |
| Young | Low | Yes | Yes |
| Senior | Medium | No | No |

A company wants to predict whether a customer will buy a product, based on the following features: Age (Young, Middle-aged, Senior), Income Level (Low, Medium, High), Previous Purchase (Yes, No). The output is Buy Product (Yes, No). Given a new customer with the following attributes: Age=Young, Income Level=High, Previous Purchase=No. Use Naive Bayes to predict whether this customer will buy the product.

### Answer

### Given

Eight training rows; query=(Young, High, No). No smoothing instruction is printed.

### To find

The two class scores and the larger-posterior class.

### Formula and why



$$
s_c=P(c)P(Young\mid c)P(High\mid c)P(PreviousNo\mid c)
$$



Naive Bayes assumes conditional independence of these features given the class. The evidence denominator is common to both classes, so compare the unnormalized scores first.

### Step 1. Count the classes

Yes occurs in rows 2,4,6,7:4 rows. No occurs in rows 1,3,5,8:4 rows.



$$
P(Yes)=4/8=1/2,\quad P(No)=4/8=1/2
$$



### Step 2. Count each query feature within each class

| Query feature | Count among Yes /4 | Count among No /4 |
| --- | --- | --- |
| Young | 2/4 | 1/4 |
| High income | 1/4 | 1/4 |
| Previous purchase No | 0/4 | 4/4 |

The denominator is the class count 4, not the full dataset 8.

### Step 3. Multiply the Yes score



$$
s_{Yes}=\frac12\times\frac24\times\frac14\times\frac04=0
$$



The zero comes from no training Yes row having Previous Purchase=No.

### Step 4. Multiply the No score



$$
s_{No}=\frac12\times\frac14\times\frac14\times\frac44=\frac1{32}=0.03125
$$



### Step 5. Normalize and predict



$$
P(Yes\mid x)=\frac0{0+0.03125}=0,\quad P(No\mid x)=\frac{0.03125}{0.03125}=1
$$



**Predicted class: No, under the unsmoothed model.** A posterior of 1 here is a consequence of tiny-data maximum-likelihood estimates and a zero conditional count; it is not certain knowledge about a real customer.

### Step 6. If smoothing is explicitly required, state the alternative

With add-one smoothing, Age and Income each have 3 categories and Previous Purchase has 2. Keep the class priors 1/2. Then:



$$
s_{Yes}^{(+1)}=\frac12\frac37\frac27\frac16=\frac1{98},\quad s_{No}^{(+1)}=\frac12\frac27\frac27\frac56=\frac5{147}
$$





$$
P_{+1}(Yes\mid x)=3/13,\quad P_{+1}(No\mid x)=10/13
$$



The decision is still No. This is a labeled alternative, not a silent change to the printed task.

---

## TEE · Q5(a) Binary GA crossover, one-bit mutation and fitness [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q5a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q5(a)** [10 marks · 2025-04-28]

Implement genetic algorithm to maximize the function f (x)=x³−4x²+6x with x in the range [0,15]. Take 4 bit representation of 10,12,7 and 3 as the parent chromosomes. Crossover is after 2 nd bit and mutation is by flipping any one bit. Repeat the process for 2 offspring also comment on the fitness of the offspring.

### Answer

### Given

Parents 10,12,7,3; unsigned 4-bit encoding; crossover after the second bit; one bit may be flipped. Pairing and mutation positions are not specified.

### To find

Crossover children, explicit mutated chromosomes and objective comparison.

### Formula and why



$$
x=8b_1+4b_2+2b_3+b_4,\qquad f(x)=x^3-4x^2+6x
$$



Split after the second bit, swap the right halves, then flip exactly the declared mutation bit. Fitness is the stated objective; maximize it.

### Step 1. Encode and evaluate the four parents

| Parent x | 4-bit code | Fitness calculation | f (x) |
| --- | --- | --- | --- |
| 10 | 1010 | 10³−4(10²)+6(10) | 660 |
| 12 | 1100 | 12³−4(12²)+6(12) | 1224 |
| 7 | 0111 | 7³−4(7²)+6(7) | 189 |
| 3 | 0011 | 3³−4(3²)+6(3) | 9 |

### Step 2. Declare pairing and form children

Pair the parents in their listed order: (10,12) and(7,3). Each pair produces two reciprocal children. This uses all four supplied parents; “2 offspring” is interpreted as the two children from a crossover pair, not as two complete generations.

| Pair | Split parents | Child 1 | Child 2 |
| --- | --- | --- | --- |
| 10 with 12 | 10|10 and 11|00 | 10|00=1000₂=8 | 11|10=1110₂=14 |
| 7 with 3 | 01|11 and 00|11 | 01|11=0111₂=7 | 00|11=0011₂=3 |

### Step 3. Perform one explicitly chosen bit flip per child

Choose the rightmost bit (bit 4 from the left, weight 1) for every child. This is allowed by “any one bit”; it is not the only possible mutation outcome.

| Before mutation | Flip bit 4 | After mutation | Decimal |
| --- | --- | --- | --- |
| 1000 | 0→1 | 1001 | 9 |
| 1110 | 0→1 | 1111 | 15 |
| 0111 | 1→0 | 0110 | 6 |
| 0011 | 1→0 | 0010 | 2 |

### Step 4. Evaluate every offspring and compare

| Child x before mutation | f (x) before | Child x after mutation | f (x) after |
| --- | --- | --- | --- |
| 8 | 304 | 9 | 459 |
| 14 | 2044 | 15 | 2565 |
| 7 | 189 | 6 | 108 |
| 3 | 9 | 2 | 4 |



$$
f(15)=15^3-4(15^2)+6(15)=3375-900+90=2565
$$



The best supplied parent is 12 with 1224. The best mutated child is 15 with 2565, an improvement. Mutation did not help every child:7→6 lowers 189 to 108, and 3→2 lowers 9 to 4. Crossover/mutation generate candidates; fitness evaluation decides which are retained.

### Step 5. State the result without hiding stochastic choices

**For these declared pairings and mutations, offspring are 9,15,6,2 and the best is 15.** Different allowed mutation positions can give different offspring. If only two children are requested in a short answer, the fully worked first pair supplies 9 and 15; the second pair shows how the remaining supplied parents are handled. On the finite integer domain 0…15, direct evaluation confirms 15 gives the largest objective, but one generic GA generation is not a proof of global optimality for arbitrary problems.

---

## TEE · Q5(b) Bike-sharing Markov transitions, retention and gains [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q5b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q5(b)** [10 marks · 2025-04-28]

Around 600 cities globally have bike-share programs where users borrow and return bikes at various stations. The distribution of bikes changes daily as they move between stations. Considering three stations (A, B, C), we can track bike movement from midnight to the next midnight.

- Out of the bikes borrowed from station A,30% are returned to station A,50% end up at station B, and 20% end up at station C.
- Out of the bikes borrowed from station B,10% end up at station A,60% have been returned to station B, and 30% end up at station C.
- Out of the bikes borrowed from station C,10% end up at station A,10% end up at station B, and 80% are returned to station C.

- Develop a Transition Probability matrix
- Interpret the state transition matrix regarding a) Retention & loss b) Retention & gain
- Draw the State transition diagram

### Answer

### Given

States ordered A, B, C; one step is one day. The “around 600 cities” sentence is preserved as historical question context, not asserted as a current statistic.

### To find

Transition matrix, retention/outflow/inflow interpretation and state diagram.

### Formula and why



$$
\mathbf n_{t+1}=\mathbf n_tP
$$



Use row vectors: rows of P are departure stations, columns arrival stations. Multiplying the initial counts by P gives expected next-day counts. Without starting counts, incoming percentages from different source groups cannot simply be added as a station's probability of gain.

### Step 1. Write the transition matrix



$$
P=\begin{bmatrix}0.30&0.50&0.20\\0.10&0.60&0.30\\0.10&0.10&0.80\end{bmatrix}
$$



Each row sums to 1:0.3+0.5+0.2=1;0.1+0.6+0.3=1;0.1+0.1+0.8=1.

### Step 2. Interpret retention and loss from each station

| Origin | Retained at origin | Leaves origin | Where the losses go |
| --- | --- | --- | --- |
| A | 30% | 70% | 50% toB;20% toC |
| B | 60% | 40% | 10% toA;30% toC |
| C | 80% | 20% | 10% toA;10% toB |

### Step 3. Express retention and incoming gains correctly

Let a, b, c be the starting numbers of bikes. Then:



$$
a_{next}=0.30a+0.10b+0.10c
$$





$$
b_{next}=0.50a+0.60b+0.10c
$$





$$
c_{next}=0.20a+0.30b+0.80c
$$



| Station | Retained component | Incoming gain from other stations | Net change |
| --- | --- | --- | --- |
| A | 0.30a | 0.10b+0.10c | −0.70a+0.10b+0.10c |
| B | 0.60b | 0.50a+0.10c | 0.50a−0.40b+0.10c |
| C | 0.80c | 0.20a+0.30b | 0.20a+0.30b−0.20c |

Whether a station gains bikes overall depends on a, b, c. A column need not sum to 1 because it combines conditional probabilities from different origins.

### Step 4. Illustrate only if initial counts are explicitly assumed

For illustration, assume 100 bikes initially at each station. Then next counts areA=30+10+10=50;B=50+60+10=120;C=20+30+80=130. Total remains 300. These initial counts are not printed data.

### Step 5. Draw all directed transitions

Swipe across the diagram to read its labels ↔

![Three-state diagram with all six cross-station probabilities and self-loop retention 0.30,0.60,0.80.](https://deep-learning-study-room.vercel.app/is2/fig/legacy25-bikes.7db03f5dcb.svg)

Diagram: Three-state diagram with all six cross-station probabilities and self-loop retention 0.30,0.60,0.80.. Labels: Three bike-station Markov states and all transition probabilities | A | B | C | 0.50 | 0.10 | 0.20 | 0.10 | 0.30 | 0.10 | 0.30 | 0.60 | 0.80

Three-state diagram with all six cross-station probabilities and self-loop retention 0.30,0.60,0.80.

---

## TEE · Q6(a) ACO tour lengths, evaporation and pheromone deposition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q6a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q6(a)** [10 marks · 2025-04-28]

For the four city Travelling salesman problem, the pheromone and cost matrix (A, B, C, D in that order given by row no, and column no) are given by

| Pheromone | A | B | C | D |
| --- | --- | --- | --- | --- |
| A | 0 | 15 | 5 | 4 |
| B | 15 | 0 | 4 | 8 |
| C | 5 | 4 | 0 | 1 |
| D | 4 | 8 | 1 | 0 |

| Cost | A | B | C | D |
| --- | --- | --- | --- | --- |
| A | 0 | 10 | 4 | 3 |
| B | 10 | 0 | 1 | 2 |
| C | 4 | 1 | 0 | 1 |
| D | 3 | 2 | 1 | 0 |

Ant L1 travels from A-B-C-D-A and Ant L1 travels from A-C-B-D-A and Taking vaporization co-efficient as 0.5, calculate the following:1.The length of each path 2.Pheromone level for each path

### Answer

### Given

Initial pheromones and symmetric costs are printed above; evaporationρ=0.5. The two listed tours are treated as ant 1 and ant 2, although the scan repeats the nameL 1. Deposit constantQ is not supplied.

### To find

Tour lengths and updated edge pheromones after evaporation and both deposits.

### Formula and why



$$
L_k=\sum_{(i,j)\in tour_k}d_{ij},\quad\Delta\tau_{ij}^{k}=\begin{cases}Q/L_k&(i,j)\in tour_k\\0&\text{otherwise}\end{cases}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}^{old}+\sum_k\Delta\tau_{ij}^{k}
$$



Declare the standard Ant System update: evaporate once, then add both ants' deposits. Because the matrices are symmetric, treat each city pair as an undirected edge. Give the answer inQ, then illustrateQ=1; noQ value is silently attributed to the paper.

### Step 1. Compute tour 1 from the cost matrix



$$
L_1=d_{AB}+d_{BC}+d_{CD}+d_{DA}=10+1+1+3=15
$$



### Step 2. Compute tour 2 from the cost matrix



$$
L_2=d_{AC}+d_{CB}+d_{BD}+d_{DA}=4+1+2+3=10
$$



Tour 2 is shorter and deposits more per used edge:Q/10 instead ofQ/15. Use the cost matrix for lengths, not the pheromone matrix.

### Step 3. List which ants use each undirected edge

| Edge | Old τ | After evaporation 0.5τ | Deposits | New τ |
| --- | --- | --- | --- | --- |
| AB | 15 | 7.5 | Q/15 | 7.5+Q/15 |
| AC | 5 | 2.5 | Q/10 | 2.5+Q/10 |
| AD | 4 | 2 | Q/15+Q/10=Q/6 | 2+Q/6 |
| BC | 4 | 2 | Q/15+Q/10=Q/6 | 2+Q/6 |
| BD | 8 | 4 | Q/10 | 4+Q/10 |
| CD | 1 | 0.5 | Q/15 | 0.5+Q/15 |

BC andCB are the same undirected edge here; both tours also useDA. Both deposits must be included on those shared edges.

### Step 4. If Q=1 is assumed, substitute



$$
\tau^{new}\approx\begin{bmatrix}0&7.566667&2.600000&2.166667\\7.566667&0&2.166667&4.100000\\2.600000&2.166667&0&0.566667\\2.166667&4.100000&0.566667&0\end{bmatrix}
$$



For example,τAD=0.5×4+1/15+1/10=2+1/6=2.166667. Pheromone is maintained on edges; a single scalar “pheromone of the whole tour” is not defined by this rule. Each path's edge levels can be read from the matrix. The diagonal stays unused at 0.

---

## TEE · Q6(b) Two-step walking/cycling Markov transition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q6b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q6b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q6(b)** [10 marks · 2025-04-28]

A student walks to school, or he rides his bicycle. If he walks to school one day, then the next day he will walk or cycle with equal probability. But if he bicycles one day, then the probability that he will walk next day is 1/4.

- Express this information in a transition matrix.
- if it is assumed that the initial day is Monday, write a matrix that gives probabilities of a transition from Monday to Wednesday.

### Answer

### Given

State orderW=walk, C=cycle. One transition is one day.

### To find

P for one day andP² for Monday→Wednesday.

### Formula and why



$$
(P^2)_{ij}=\sum_kP_{ik}P_{kj}
$$



There are two transitions, Monday→Tuesday and Tuesday→Wednesday. Multiply along each possible intermediate Tuesday state and add the alternatives.

### Step 1. Complete the one-day rows

From walking:W→W=1/2 andW→C=1/2. From cycling:C→W=1/4, soC→C=1−1/4=3/4.



$$
P=\begin{bmatrix}1/2&1/2\\1/4&3/4\end{bmatrix}
$$



### Step 2. Compute all four two-day entries

| Monday→Wednesday | Sum over Tuesday W or C | Result |
| --- | --- | --- |
| W→W | (1/2)(1/2)+(1/2)(1/4)=1/4+1/8 | 3/8 |
| W→C | (1/2)(1/2)+(1/2)(3/4)=1/4+3/8 | 5/8 |
| C→W | (1/4)(1/2)+(3/4)(1/4)=1/8+3/16 | 5/16 |
| C→C | (1/4)(1/2)+(3/4)(3/4)=1/8+9/16 | 11/16 |

### Step 3. Write the requested matrix



$$
P^2=\begin{bmatrix}3/8&5/8\\5/16&11/16\end{bmatrix}=\begin{bmatrix}0.375&0.625\\0.3125&0.6875\end{bmatrix}
$$



Rows still specify the Monday state; columns specify Wednesday. Each row sums to 1. If Monday's actual state is not given, this conditional matrix is the complete answer; an unconditional Wednesday distribution additionally requires Monday's starting distribution.

---

## TEE · Q7(a) Fuzzy logic applications and complete controller example [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q7a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(a)** [10 marks · 2025-04-28]

List the applications of Fuzzy logic. Explain one in detail.

### Answer

**Fuzzy logic** represents gradual membership in linguistic categories and reasons with graded rules. A temperature can partly belong to both “warm” and “hot”; this is degree of membership, not a probability that a hidden label is true.

- Air-conditioning and automatic fan-speed control.
- Washing-machine adjustment of wash time, agitation or water use.
- Camera autofocus/exposure control.
- Vehicle and industrial process control.
- Decision support and multicriteria scoring when judgments are linguistic.
- Pattern recognition and fuzzy clustering.

### Detailed example: room-temperature fan controller

Swipe across the diagram to read its labels ↔

![Crisp measurements → fuzzification → rule evaluation → output aggregation/defuzzification → fan command. The rule base defines linguistic responses.](https://deep-learning-study-room.vercel.app/is2/fig/legacy25-controller.80f7bae29e.svg)

Diagram: Crisp measurements → fuzzification → rule evaluation → output aggregation/defuzzification → fan command. The rule base defines linguistic responses.. Labels: Fuzzy controller architecture | Sensors | temperature, occupancy | Fuzzification | membership degrees | Rule evaluation | IF–THEN strengths | Output calculation | one fan command | Membership functions + rule base define the controller | Mamdani: aggregated fuzzy area → centroid | Sugeno: weighted consequent values → crisp output

Crisp measurements → fuzzification → rule evaluation → output aggregation/defuzzification → fan command. The rule base defines linguistic responses.

| Block | Role in this example |
| --- | --- |
| Sensors / crisp input | Measure room temperature and occupancy |
| Fuzzifier | Convert each measurement to memberships such asCool, Warm, Hot andLow, High occupancy |
| Knowledge base | Store membership-function definitions and IF–THEN rules |
| Inference engine | Evaluate each rule's antecedent strength using the stated AND/OR operations |
| Defuzzifier / output computation | Convert the activated outputs to one fan command |
| Actuator | Apply the bounded fan-speed command; sensors provide fresh input for the next cycle |

### Illustrative rules and a transparent calculation

For a simple single-input numerical illustration, hold occupancy fixed. On 20≤T≤40°C chooseµWarm=(40−T)/20 andµHot=(T−20)/20. AtT=30°C both memberships are 0.5.

- IF temperature isWarm THEN fan command=50%.
- IF temperature isHot THEN fan command=90%.

Use a **zero-order Sugeno** design with these constant consequents, so its weighted output is:



$$
fan=\frac{0.5(50)+0.5(90)}{0.5+0.5}=\frac{25+45}{1}=70\%
$$



Here 50% and 90% are explicit illustrative output constants, not discovered from a source dataset. A Mamdani controller instead defines fuzzy output shapes and may use their aggregated centroid; the two procedures must not be mixed without saying which design is used.

### Advantages and limitations

- Smooth transitions avoid an abrupt full-speed jump at one fixed threshold.
- Rules are interpretable and can incorporate expert knowledge without requiring an exact plant equation.
- Membership functions and rules still require validation; poor design can create unsuitable or unstable behavior.
- More inputs and linguistic sets can make the rule base large. Safety limits and fallback behavior must be engineered separately.

Yaad rakho: measured number→kitnaWarm/Hot→rules→one usable fan command.

---

## TEE · Q7(b) Bellman equations and reinforcement-learning applications [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2025-april--q7b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2025-april/q7b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(b)** [10 marks · 2025-04-28]

Explain Bellman equation in reinforcement learning. Also give applications of reinforcement learning.

### Answer

**Reinforcement learning (RL)** studies an agent that chooses actions, receives rewards and learns a policy to maximize expected cumulative reward through interaction. A policyπ(a|s) describes which action is chosen in a state; the value function measures expected future return, not only the immediate reward.

| Symbol | Meaning |
| --- | --- |
| s, a | Current state and selected action |
| s′, r | Next state and one-step reward |
| γ | Discount factor; usually 0≤γ<1 for discounted continuing tasks |
| π(a|s) | Probability of actiona under the policy |
| Vπ(s) | Expected discounted return starting in state s and followingπ |
| Qπ(s, a) | Expected discounted return after first choosinga in s, then followingπ |

### Step 1. Split the return into present reward and remaining future



$$
G_t=R_{t+1}+\gamma R_{t+2}+\gamma^2R_{t+3}+\cdots=R_{t+1}+\gamma G_{t+1}
$$



This one-step decomposition is the basis of the Bellman equation: value now equals expected immediate reward plus discounted value of what follows.

### Step 2. Write the Bellman expectation equation



$$
V^\pi(s)=\sum_a\pi(a\mid s)\sum_{s',r}p(s',r\mid s,a)\left[r+\gamma V^\pi(s')\right]
$$



The inner sum averages over uncertain transitions and rewards. The outer sum averages over the policy's actions. For a deterministic action and transition, it reduces toV(s)=r+γV(s′).

### Step 3. Write the optimality form



$$
V^*(s)=\max_a\sum_{s',r}p(s',r\mid s,a)\left[r+\gamma V^*(s')\right]
$$





$$
Q^*(s,a)=\sum_{s',r}p(s',r\mid s,a)\left[r+\gamma\max_{a'}Q^*(s',a')\right]
$$



Expectation evaluates a given policy; the maximum chooses the best available action. Value iteration applies this backup repeatedly. Q-learning estimates a corresponding action-value backup from sampled transitions instead of requiring the complete transition model.

### Step 4. Use a concrete numerical example

Assumeγ=0.9 and deterministic transitions. ActionA gives reward 2 and a next-state value 10. ActionB gives reward 5 and a next-state value 4.

| Action | Bellman backup | Value |
| --- | --- | --- |
| A | 2+0.9×10 | 11 |
| B | 5+0.9×4 | 8.6 |

The optimality backup choosesA because 11>8.6, even thoughB gives the larger immediate reward. Under a policy selecting both equally, the expectation backup is 0.5×11+0.5×8.6=9.8. These are one-step backups using the given continuation values.

### Applications

| Application | State / action / reward example |
| --- | --- |
| Robot navigation | State:location/sensors; action:move; reward:goal reached with penalties for collision and delay |
| Game playing | State:board configuration; action:legal move; reward:win/loss or a carefully designed game score |
| Traffic-signal control | State:queue lengths; action:signal phase; reward:reduced delay with safety constraints |
| Resource scheduling | State:workload/resources; action:allocate jobs; reward:throughput or energy objective |
| Adaptive recommendation | State:user/context history; action:recommend an item; reward:measured engagement or another validated long-term outcome |

Rewards and exploration policies matter. An agent can optimize the wrong behavior if the reward ignores safety, fairness or the true task objective. A Bellman equation defines the value relation; it does not guarantee that a learned policy is already optimal.

---

## TEE · Q1(a) Traditional versus evolutionary optimization [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q1a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(a)** [5 marks · 2024-06-25]

Compare traditional optimization and evolutionary optimization algorithms. Illustrate the basic framework of evolutionary algorithms.

### Answer

**Optimization** searches for a feasible candidate that maximizes or minimizes an objective. Evolutionary algorithms use a population, fitness-based selection and variation inspired by evolution.

| Aspect | Traditional methods (typical examples) | Evolutionary methods |
| --- | --- | --- |
| Search state | Often one current candidate, e.g. gradient descent | Usually a population of candidates |
| Information | Gradient/Hessian in derivative methods; not required by all traditional methods | Primarily objective/fitness evaluations |
| Variation | A mathematically derived step or deterministic search rule | Crossover and mutation with stochastic choices |
| Landscape | Strong efficiency/guarantees possible under assumptions such as convexity | Useful for discrete, non-smooth, mixed or multimodal search |
| Guarantee | Depends on the algorithm and assumptions | No general finite-run global-optimum guarantee |
| Cost | May require fewer evaluations on suitable smooth problems | Often needs many evaluations and parameter tuning |

**Framework:** encode candidates → initialize feasible population → evaluate fitness → select parents → crossover → mutate → evaluate offspring → choose survivors → repeat until stopping criterion → return best observed candidate.

For example, in a delivery-route GA a chromosome is a permutation of cities; fitness can be inverse route length. Shorter valid tours are favored. A swap mutation preserves city uniqueness. Selection exploits good candidates, while variation introduces exploration. Do not claim every traditional method requires derivatives or every evolutionary method escapes all local optima.

---

## TEE · Q1(b) Bayes posterior for red ball [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q1b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(b)** [5 marks · 2024-06-25]

Bag A contains 3 red and 4 green balls. Bag B contains 4 red and 5 green balls. One ball is drawn at random from one of the bags and found red. Find the probability it came from Bag A.

### Answer

#### Given

A has 7 balls, B has 9; red likelihoods 3/7 and 4/9.

#### To find

P(A|red).

#### Formula and why it applies

Reverse the direction of the evidence using Bayes. The probability of choosing each bag is a prior; the probability of red inside a chosen bag is a likelihood.



$$
P(A\mid R)=\frac{P(R\mid A)P(A)}{P(R\mid A)P(A)+P(R\mid B)P(B)}
$$



#### Solution

**Source / assumption note.** Assume a bag is chosen uniformly, then a ball uniformly within that bag. Choosing a ball uniformly from all 16 balls would be a different experiment.

##### Step 1. Weight each red likelihood by its bag prior



$$
P(R,A)=\frac37\frac12=\frac3{14},\quad P(R,B)=\frac49\frac12=\frac29
$$



##### Step 2. Add all ways to see red



$$
P(R)=\frac3{14}+\frac29=\frac{27+28}{126}=\frac{55}{126}
$$



##### Step 3. Normalize the A contribution



$$
P(A\mid R)=\frac{3/14}{55/126}=\frac{27}{55}\approx0.490909
$$



**Final answer.** 27/55 ≈ 0.490909 under equal bag-selection priors.

---

## TEE · Q1(c) Fuzzy union, intersection and complements [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q1c

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(c)** [5 marks · 2024-06-25]

A={(x₁,.7),(x₂,.3),(x₃,.9),(x₄,.1)} and B={(x₁,.2),(x₂,.5),(x₃,.7),(x₄,.4)}. Find (1) A∪B, (2) A∩B, (3) Ā∩B̄, (4) Ā∪B̄.

### Answer

#### Given

Memberships A and B as printed; use the listed element order.

#### To find

Union, intersection and the requested operations on the complements.

#### Formula and why it applies

Membership is a degree between 0 and 1. Union means choose the larger membership; intersection means choose the smaller. Complement means subtract the membership from 1.



$$
\mu_{A\cup B}(x)=\max(\mu_A(x),\mu_B(x)),\quad \mu_{A\cap B}(x)=\min(\mu_A(x),\mu_B(x)),\quad \mu_{\bar A}(x)=1-\mu_A(x)
$$



#### Solution

##### Step 1. Compute complements before combining them

At x₁: 1−0.7=0.3, and 1−0.2=0.8. Never subtract the element label; subtract its membership.

##### Step 2. Work element by element

| Element | A | B | 1−A | 1−B | max (A, B) | min (A, B) | max(1−A,1−B) | min(1−A,1−B) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| x₁ | 0.7 | 0.2 | 0.3 | 0.8 | 0.7 | 0.2 | 0.8 | 0.3 |
| x₂ | 0.3 | 0.5 | 0.7 | 0.5 | 0.5 | 0.3 | 0.7 | 0.5 |
| x₃ | 0.9 | 0.7 | 0.1 | 0.3 | 0.9 | 0.7 | 0.3 | 0.1 |
| x₄ | 0.1 | 0.4 | 0.9 | 0.6 | 0.4 | 0.1 | 0.9 | 0.6 |

##### Step 3. Read the requested columns in the original order

Keep the labels unchanged. Only the membership next to each label changes. De Morgan checks: complement of the union equals intersection of complements; complement of the intersection equals union of complements.

**Final answer.** (1) A∪B=[0.7, 0.5, 0.9, 0.4]; (2) A∩B=[0.2, 0.3, 0.7, 0.1]; (3) Ā∩B̄=[0.3, 0.5, 0.1, 0.6]; (4) Ā∪B̄=[0.8, 0.7, 0.3, 0.9].

---

## TEE · Q1(d) Irreducibility and stationary distribution [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q1d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q1d

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(d)** [5 marks · 2024-06-25]

For a two-state Markov chain with P=[[0.8,0.2],[0.3,0.7]], (a) is the chain irreducible? (b) find its stationary distribution.

### Answer

#### Given

Two states, row-stochastic matrix [[.8,.2],[.3,.7]].

#### To find

Mutual reachability and a probability row vector π with πP=π.

#### Formula and why it applies

Irreducible means every state can reach every other with positive probability in some number of steps. Stationary means one transition leaves the distribution unchanged.



$$
\pi=\pi P,\quad\pi_1+\pi_2=1
$$



#### Solution

##### Step 1. Check both directions

Swipe across the diagram to read its labels ↔

![Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24r-stationary.41b587e21f.svg)

Diagram: Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.. Labels: legacy24r-stationary | 0.8 | 0.2 | 0.3 | 0.7 | 1 | 2

Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.

1→2 has probability .2>0 and 2→1 has probability .3>0. Each state reaches the other in one step; the chain is irreducible. Self-loops also make it aperiodic.

##### Step 2. Balance probability entering state 1



$$
\pi_1=0.8\pi_1+0.3\pi_2\Rightarrow0.2\pi_1=0.3\pi_2\Rightarrow\pi_1=1.5\pi_2
$$



##### Step 3. Normalize



$$
1.5\pi_2+\pi_2=1\Rightarrow\pi_2=0.4,\quad\pi_1=0.6
$$



##### Step 4. Verify both columns



$$
[0.6,0.4]P=[0.48+0.12,\;0.12+0.28]=[0.6,0.4]
$$



**Final answer.** Yes, irreducible; π=[0.6,0.4].

---

## TEE · Q2(a) GMM modified log likelihood and parameters [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q2a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q2(a)** [10 marks · 2024-06-25]

With reference to the Gaussian mixture model: (1) explain the need for the modified log-likelihood function; (2) how is it solved? (3) for K=6 Gaussian distributions estimate the number of parameters to compute.

### Answer

A Gaussian mixture models a population using K Gaussian components. A hidden component label says which component generated a sample. The labels are not observed, so the likelihood sums over all possible components.



$$
p(x_i\mid\theta)=\sum_{k=1}^{K}\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k),\quad \pi_k\geq0,\quad\sum_k\pi_k=1
$$



##### Step 1. Form the observed-data log likelihood

For independent observations multiply their densities; taking the logarithm turns the product over observations into a sum. The sum over mixture components remains inside the log. This log-of-sum is why a direct closed-form joint maximization is difficult.



$$
\ell(\theta)=\log\prod_{i=1}^{N}\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)=\sum_i\log\left[\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)\right]
$$



##### Step 2. E-step: estimate component membership

Initialize valid weights, means and covariances. Using the old parameters, compute responsibility γᵢₖ: the posterior fraction of sample i assigned to component k. Each row of responsibilities adds to 1.



$$
\gamma_{ik}=\frac{\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)}{\sum_j\pi_j\mathcal N(x_i\mid\mu_j,\Sigma_j)}
$$



##### Step 3. Use the expected complete-data log likelihood

The “modified” objective in EM is the expectation of the complete-data log likelihood. During this M-step the responsibilities are fixed, so the difficult log of a component sum is replaced by a weighted sum of component log densities.



$$
Q(\theta\mid\theta^{old})=\sum_i\sum_k\gamma_{ik}\left[\log\pi_k+\log\mathcal N(x_i\mid\mu_k,\Sigma_k)\right]
$$



##### Step 4. M-step: weighted estimates



$$
N_k=\sum_i\gamma_{ik},\quad \pi_k^{new}=\frac{N_k}{N},\quad\mu_k^{new}=\frac{\sum_i\gamma_{ik}x_i}{N_k}
$$





$$
\Sigma_k^{new}=\frac{\sum_i\gamma_{ik}(x_i-\mu_k^{new})(x_i-\mu_k^{new})^T}{N_k}
$$



Repeat E and M until the observed log likelihood changes by less than a chosen tolerance or an iteration limit is reached. EM improves or preserves likelihood under exact steps, but can converge to a local optimum. Try several initializations and avoid singular covariance matrices.

##### Step 5. Count parameters without inventing the dimension

The question gives K=6, but not the data dimension d or covariance type. For full covariance, each component has d mean entries and d (d+1)/2 independent covariance entries. There are K−1 independent mixture weights.



$$
n_{free}=Kd+K\frac{d(d+1)}2+(K-1)
$$



For a stated one-dimensional assumption: 6 means + 6 variances + 5 independent weights = **17 free parameters**. A table may store all 6 weights, giving 18 stored values, but their sum-to-one constraint removes one degree of freedom. With diagonal covariance the general count is 2 Kd+K−1.

---

## TEE · Q2(b) Fuzzy washing-machine controller [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q2b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q2b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q2(b)** [10 marks · 2024-06-25]

Design a domestic washing-machine controller with Dirt and Grease inputs, both 0–100, and Wash time output 0–100. Use low/medium/high input terms and very short/short/medium/high/very high output terms. Derive rules, support the design with graphs and show that larger dirt gives longer wash time. Defuzzify for Dirt=60% and Grease=70%.

### Answer

#### Given

Dirt=60, Grease=70; ranges 0–100; three input terms and five output terms.

#### To find

A complete controller: membership graphs, rules, inference and crisp output.

#### Formula and why it applies

Fuzzification translates measured values into degrees. Min implements AND, max combines rules, and centroid converts the fuzzy output to one numerical command.



$$
\alpha_r=\min(\mu_{A_r}(x),\mu_{B_r}(y)),\quad z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

**Source / assumption note.** This is a design question: membership coordinates, full rule table and decision threshold are not prescribed. The following is one explicitly specified valid Mamdani design, not the only possible numerical output. Never copy its result if you choose different triangles or rules.

##### Step 1. Specify the inputs and output

Dirt and Grease each span 0–100. Use low=left shoulder (0,0,50), medium=triangle (0,50,100), high=right shoulder (50,100,100). Output is wash-time index on 0–100; larger means longer washing. The question gives no physical time unit, so do not invent minutes.

Swipe across the diagram to read its labels ↔

![Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-wash-inputs.c512a5765f.svg)

Diagram: Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.. Labels: Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range. | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 0 | 0.25 | 0.5 | 0.75 | 1 | Low | Medium | High | μ(x)

Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.

Swipe across the diagram to read its labels ↔

![Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-wash-outputs.bb86080be7.svg)

Diagram: Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.. Labels: Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered. | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 0 | 0.25 | 0.5 | 0.75 | 1 | Very short | Short | Medium | High | Very high | μ(x)

Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.

##### Step 2. Define all nine IF–THEN rules

| Dirt / Grease | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Very short | Short | Medium |
| Medium | Short | Medium | High |
| High | Medium | High | Very high |

Greater dirt or grease never reduces the rule consequent. This implements the requested monotonic relationship.

##### Step 3. Fuzzify the two crisp readings

| Input | Low membership | Medium membership | High membership |
| --- | --- | --- | --- |
| Dirt=60 | 0 | 4/5 | 1/5 |
| Grease=70 | 0 | 3/5 | 2/5 |

For Dirt=60: low=max(0,(50−60)/50)=0; medium=(100−60)/50=0.8; high=max(0,(60−50)/50)=0.2. For Grease=70: low=0, medium=(100−70)/50=0.6, high=(70−50)/50=0.4.

##### Step 4. Fire every active rule with minimum

| Dirt | Grease | AND strength | Output descriptor |
| --- | --- | --- | --- |
| Medium | Medium | min(0.8, 0.6) = 0.6 | Medium |
| Medium | High | min(0.8, 0.4) = 0.4 | High |
| High | Medium | min(0.2, 0.6) = 0.2 | High |
| High | High | min(0.2, 0.4) = 0.2 | Very high |

The other rules have a zero antecedent membership and therefore fire at zero.

##### Step 5. Aggregate rules and clip each output membership

| Descriptor | Maximum firing strength |
| --- | --- |
| Very short | 0.0 |
| Short | 0.0 |
| Medium | 0.6 |
| High | 0.4 |
| Very high | 0.2 |



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{B_r}(z))
$$



Swipe across the diagram to read its labels ↔

![Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-wash-aggregate.b750073d41.svg)

Diagram: Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.. Labels: Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid. | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 0 | 0.25 | 0.5 | 0.75 | 1 | Aggregated output | μ(x)

Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.

##### Step 6. Calculate centroid area and first moment

Split the upper outline at every corner and intersection. On a segment [a, b] with endpoint heights u and v, integrate the straight line. This counts overlap once.



$$
A=(b-a)\frac{u+v}{2},\qquad M=aA+\frac{(b-a)^2(u+2v)}6,\qquad z^*=\frac{\sum M}{\sum A}
$$



| Segment [a, b] | Heights [u, v] | Area A | Moment M |
| --- | --- | --- | --- |
| [25, 40] | [0, 0.6] | 4.500000 | 157.500000 |
| [40, 50] | [0.6, 0.6] | 6.000000 | 270.000000 |
| [50, 60] | [0.6, 0.6] | 6.000000 | 330.000000 |
| [60, 65] | [0.6, 0.4] | 2.500000 | 155.833333 |
| [65, 75] | [0.4, 0.4] | 4.000000 | 280.000000 |
| [75, 80] | [0.4, 0.4] | 2.000000 | 155.000000 |
| [80, 90] | [0.4, 0.4] | 4.000000 | 340.000000 |
| [90, 95] | [0.4, 0.2] | 1.500000 | 138.333333 |
| [95, 100] | [0.2, 0.2] | 1.000000 | 97.500000 |



$$
z^*=\frac{1924.166667}{31.500000}\approx 61.084656
$$



##### Step 7. Demonstrate the longer-wash response

Hold grease fixed at 70 and repeat the same minimum, maximum and centroid steps for three dirt readings. This compares outputs without changing the rules or membership graphs.

| Dirt | Grease | Exact centroid | Wash-time index |
| --- | --- | --- | --- |
| 20 | 70 | 1925/41 | 46.951220 |
| 60 | 70 | 11545/189 | 61.084656 |
| 80 | 70 | 6580/99 | 66.464646 |

The calculated wash-time index increases from 46.951220 to 61.084656 to 66.464646 as dirt rises from 20 to 60 to 80. These comparisons demonstrate the requested behavior for the stated test inputs. At the target reading (60,70), only medium, high and very-high consequents fire.

**Final answer.** With the stated membership functions and rules, the output is 61.084656 on the given 0–100 scale.

---

## TEE · Q3(a) Fuzzy relation and max-product comparison [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q3a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q3a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q3(a)** [10 marks · 2024-06-25]

D={0.3/0 + 0.7/1 + 1/2}, I={0.5/20 + 0.6/30 + 0.8/40}, V={0.6/20 + 0.5/30 + 0.4/40}. Determine (1) R=D×I, (2) max–min composition of V∘R, (3) max–product composition of V∘R.

### Answer

#### Given

D labels 0,1,2; I and V labels 20,30,40.

#### To find

The 3×3 relation and the two resulting memberships on D’s universe.

#### Formula and why it applies

R connects a D label to an I label. V supplies a membership on the I side. For each D row, combine its three relation memberships with V at the same I labels, then take the maximum. Max–product changes only the inner operation.



$$
R_{ij}=\min(D_i,I_j),\quad t_i=\max_j\min(R_{ij},V_j),\quad u_i=\max_j(R_{ij}V_j)
$$



#### Solution

##### Step 1. Create each Cartesian-product row

| D label | D membership | Min with.5 | Min with.6 | Min with.8 |
| --- | --- | --- | --- | --- |
| 0 | 0.3 | 0.3 | 0.3 | 0.3 |
| 1 | 0.7 | 0.5 | 0.6 | 0.7 |
| 2 | 1 | 0.5 | 0.6 | 0.8 |



$$
R=\begin{bmatrix}0.3&0.3&0.3\\0.5&0.6&0.7\\0.5&0.6&0.8\end{bmatrix}
$$



##### Step 2. Max–min: pair each row with V

| Output cell | Compare every matching middle index | Take the largest result |
| --- | --- | --- |
| (1, 1) | min(0.3, 0.6) = 0.3, min(0.3, 0.5) = 0.3, min(0.3, 0.4) = 0.3 | max(0.3, 0.3, 0.3) = 0.3 |
| (2, 1) | min(0.5, 0.6) = 0.5, min(0.6, 0.5) = 0.5, min(0.7, 0.4) = 0.4 | max(0.5, 0.5, 0.4) = 0.5 |
| (3, 1) | min(0.5, 0.6) = 0.5, min(0.6, 0.5) = 0.5, min(0.8, 0.4) = 0.4 | max(0.5, 0.5, 0.4) = 0.5 |

##### Step 3. Max–product: multiply instead of taking the minimum

| Output cell | Compare every matching middle index | Take the largest result |
| --- | --- | --- |
| (1, 1) | 0.3 × 0.6 = 0.18, 0.3 × 0.5 = 0.15, 0.3 × 0.4 = 0.12 | max(0.18, 0.15, 0.12) = 0.18 |
| (2, 1) | 0.5 × 0.6 = 0.3, 0.6 × 0.5 = 0.3, 0.7 × 0.4 = 0.28 | max(0.3, 0.3, 0.28) = 0.3 |
| (3, 1) | 0.5 × 0.6 = 0.3, 0.6 × 0.5 = 0.3, 0.8 × 0.4 = 0.32 | max(0.3, 0.3, 0.32) = 0.32 |

##### Step 4. Attach the original D labels

The max–min output is {0.3/0 + 0.5/1 + 0.5/2}. The max–product output is {0.18/0 + 0.30/1 + 0.32/2}. These are fuzzy sets, so the slash notation means membership/label, not division.

**Final answer.** R=[[.3,.3,.3],[.5,.6,.7],[.5,.6,.8]]; max–min=[.3,.5,.5]; max–product=[.18,.30,.32].

---

## TEE · Q3(b) PSO maximization, supplied parameters [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q3b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q3(b)** [10 marks · 2024-06-25]

Find the maximum of f (x)=−x²+5x+20 on −6≤x≤4 using PSO. Use four initial positions −5.6,−5.2,−1.1,2.3. Show detailed computations for iteration 1, with c₁=c₂=1, r₁=r₂=.5, w=1 and all initial velocities zero.

### Answer

#### Given

The four x values; zero velocities; w=1, c₁=c₂=1, r₁=r₂=.5; bounded domain[−6,4].

#### To find

One iteration and the best value actually reached.

#### Formula and why it applies



$$
v_i^{new}=wv_i+c_1r_1(pbest_i-x_i)+c_2r_2(gbest-x_i),\quad x_i^{new}=x_i+v_i^{new}
$$



This is maximization: larger f is better. Initialize each pbest to its own initial position, and freeze the old gbest for the whole simultaneous update.

#### Solution

##### Step 1. Find initial fitness and gbest

| Particle | Position | −x² | 5x | f (x) |
| --- | --- | --- | --- | --- |
| 1 | -5.6 | -31.36 | -28.0 | -39.36 |
| 2 | -5.2 | -27.04 | -26.0 | -33.04 |
| 3 | -1.1 | -1.21 | -5.5 | 13.29 |
| 4 | 2.3 | -5.29 | 11.5 | 26.21 |

Initial values [−39.36,−33.04,13.29,26.21]. Maximum 26.21 occurs at x=2.3.

##### Step 2. Compute new velocities

The first two terms are zero: old velocity=0 and pbest−x=0. Thus vnew=.5(2.3−x).

| Particle | Social difference | Velocity | New position |
| --- | --- | --- | --- |
| 1 | 2.3−(-5.6)=7.9 | .5×(7.9)=3.95 | -5.6 + (3.95)=-1.65 |
| 2 | 2.3−(-5.2)=7.5 | .5×(7.5)=3.75 | -5.2 + (3.75)=-1.45 |
| 3 | 2.3−(-1.1)=3.4 | .5×(3.4)=1.7 | -1.1 + (1.7)=0.6 |
| 4 | 2.3−(2.3)=0 | .5×(0)=0 | 2.3 + (0)=2.3 |

##### Step 3. Evaluate the new positions

| New x | −x²+5x+20 | New fitness |
| --- | --- | --- |
| -1.65 | −(-1.65)²+5(-1.65)+20 | 9.0275 |
| -1.4500000000000002 | −(-1.45)²+5(-1.45)+20 | 10.6475 |
| 0.5999999999999999 | −(0.6)²+5(0.6)+20 | 22.64 |
| 2.3 | −(2.3)²+5(2.3)+20 | 26.21 |

All new positions are in [−6,4], so no boundary repair is required.

##### Step 4. Update pbest and gbest

New positions [−1.65,−1.45,.6,2.3] give fitness [9.0275,10.6475,22.64,26.21]. The first three replace their worse personal records; the fourth ties its record. Global best remains 2.3 with 26.21.

As a separate analytical check, f (x)=26.25−(x−2.5)² has true maximum 26.25 at 2.5. PSO has not reached that point after this one iteration.

**Final answer.** After iteration 1: positions[−1.65,−1.45,.6,2.3], gbest=2.3, achieved fitness 26.21.

---

## TEE · Q4(a) Naive Bayes and Laplace smoothing [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q4a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q4(a)** [10 marks · 2024-06-25]

(1) Use Naive Bayes on the dataset to predict whether a person buys a computer for Age=Old, Income=Medium, Freelancer=Yes. (2) Explain Laplacian smoothing, whether it is required here and its impact.

| ID | Age | Income | Freelancer | Buys computer |
| --- | --- | --- | --- | --- |
| 1 | Young | High | No | No |
| 2 | Young | High | No | No |
| 3 | Middle Age | High | No | Yes |
| 4 | Old | Medium | No | Yes |
| 5 | Old | Low | Yes | Yes |
| 6 | Old | Low | Yes | No |
| 7 | Middle Age | Low | Yes | Yes |
| 8 | Young | Medium | No | No |
| 9 | Young | Low | Yes | Yes |
| 10 | Young | Medium | Yes | Yes |

### Answer

#### Given

Ten records; query (Old, Medium, Yes). Class counts Yes 6, No 4.

#### To find

Class scores, normalized comparison and smoothing impact.

#### Formula and why it applies

Naive Bayes multiplies the class prior and feature likelihoods, assuming features are conditionally independent given the class. The same evidence denominator cancels when comparing classes.



$$
s(c)=P(c)\prod_j P(x_j\mid c),\qquad P(c\mid x)=\frac{s(c)}{\sum_{k}s(k)}
$$



#### Solution

##### Step 1. Count query-feature matches within each class

| Class | N | Old | Medium income | FreelancerYes |
| --- | --- | --- | --- | --- |
| Yes | 6 | 2 | 2 | 4 |
| No | 4 | 1 | 1 | 1 |

Yes records are 3,4,5,7,9,10; No records 1,2,6,8. Count within the chosen class, not among all ten records.

##### Step 2. Compute unsmoothed Yes score



$$
s(Y)=\frac6{10}\frac26\frac26\frac46=\frac2{45}\approx0.0444444
$$



##### Step 3. Compute unsmoothed No score



$$
s(N)=\frac4{10}\frac14\frac14\frac14=\frac1{160}=0.00625
$$



##### Step 4. Normalize and classify



$$
P(Y\mid x)=\frac{2/45}{2/45+1/160}=\frac{64}{73}\approx0.876712
$$





$$
P(N\mid x)=\frac9{73}\approx0.123288
$$



Predict Yes because its score is larger.

##### Step 5. Explain add-one smoothing

A zero likelihood would make the whole class product zero, even if other features favor the class. Add-one smoothing prevents that by adding one to each category count and adding the number of possible categories to the denominator. No query likelihood is zero here, so smoothing is not needed to rescue a zero score; it still changes the estimates.



$$
P(x_j=v\mid c)=\frac{N_{jvc}+1}{N_c+K_j}
$$



There are 3 age categories,3 income categories and 2 freelancer categories. Retaining empirical priors:



$$
s_{+1}(Y)=\frac6{10}\frac{2+1}{6+3}\frac{2+1}{6+3}\frac{4+1}{6+2}=\frac1{24}\approx0.0416667
$$





$$
s_{+1}(N)=\frac4{10}\frac{1+1}{4+3}\frac{1+1}{4+3}\frac{1+1}{4+2}=\frac8{735}\approx0.0108844
$$



##### Step 6. Compare the smoothed result



$$
P_{+1}(Y\mid x)=\frac{1/24}{1/24+8/735}=\frac{245}{309}\approx0.792880
$$



The predicted class remains Yes, while certainty decreases. Stating whether priors are smoothed matters; here only feature likelihoods were add-one smoothed.

**Final answer.** Unsmoothed predictionYes, posterior 64/73. Add-one feature smoothing still predictsYes, posterior 245/309.

---

## TEE · Q4(b) Transition matrix properties and two-step probabilities [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q4b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q4b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q4(b)** [10 marks · 2024-06-25]

(1) Discuss how state transitions are represented by a transition matrix. (2) Cite and illustrate any 3 properties. (3) Given P=[[1/2,1/2],[3/4,1/4]] and initial row distribution p⁽⁰⁾=[1/4,3/4], define and find (a) P₂₁⁽²⁾, (b) P₁₂⁽²⁾, (c) P⁽²⁾, (d) p₁⁽²⁾.

### Answer

#### Given

P and p⁽⁰⁾ as printed; row-vector convention.

#### To find

Two-step conditional transition probabilities, the full two-step matrix and unconditional state 1 probability at time 2.

#### Formula and why it applies

Pᵢⱼ is next-state j probability given current-state i. Entries lie in[0,1], rows sum to 1, and the n-step matrix is Pⁿ for a time-homogeneous chain. Row sums need not equal column sums; a transition matrix need not be symmetric.



$$
(P^2)_{ij}=\sum_kP_{ik}P_{kj},\qquad p^{(2)}=p^{(0)}P^2
$$



#### Solution

##### Step 1. Sum every possible two-step path

| Entry | Via state 1 | Via state 2 | Sum |
| --- | --- | --- | --- |
| (P²)11 | (1/2)(1/2)=1/4 | (1/2)(3/4)=3/8 | 5/8 |
| (P²)12 | (1/2)(1/2)=1/4 | (1/2)(1/4)=1/8 | 3/8 |
| (P²)21 | (3/4)(1/2)=3/8 | (1/4)(3/4)=3/16 | 9/16 |
| (P²)22 | (3/4)(1/2)=3/8 | (1/4)(1/4)=1/16 | 7/16 |

##### Step 2. Write the transition matrix and requested entries



$$
P^2=\begin{bmatrix}5/8&3/8\\9/16&7/16\end{bmatrix}
$$



Therefore (a) P₂₁⁽²⁾=9/16 and (b) P₁₂⁽²⁾=3/8. Each entry conditions on a specific starting state.

##### Step 3. Mix over the supplied initial distribution



$$
p_1^{(2)}=\frac14\frac58+\frac34\frac9{16}=\frac{10+27}{64}=\frac{37}{64}=0.578125
$$





$$
p_2^{(2)}=1-37/64=27/64=0.421875
$$



##### Step 4. Keep matrix and distribution notation separate

P² is 2×2 and gives two-step probabilities for either starting state. p⁽²⁾ is one row of two probabilities after averaging those starting states using p⁽⁰⁾. If part (c) was intended as the distribution rather than capital-P matrix, the supplied distribution is [37/64,27/64]. Both objects are shown.

**Final answer.** P₂₁⁽²⁾=9/16; P₁₂⁽²⁾=3/8; P²=[[5/8,3/8],[9/16,7/16]]; p⁽²⁾=[37/64,27/64].

---

## TEE · Q5(a) GA selection, crossover and survivor replacement [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q5a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q5(a)** [10 marks · 2024-06-25]

Use the population table. (1) Rank-select the best two, then one-point crossover in the middle. (2) A three-way tournament on individuals 1,3,5 selects parent 1; a two-way tournament on 2,4 selects parent 2. Again crossover in the middle. (3) Replace using fitness-based survivor selection and compute the new average. (4) Repeat replacement from the original population using age-based survivor selection and compute its average.

| No. | Chromosome | Fitness | Age |
| --- | --- | --- | --- |
| 1 | 01000000 | 64 | 8 |
| 2 | 01011111 | 95 | 2 |
| 3 | 01010000 | 80 | 13 |
| 4 | 01011001 | 89 | 9 |
| 5 | 01011110 | 94 | 4 |
| 6 | 01001111 | 79 | 10 |
| 7 | 01010001 | 81 | 12 |
| 8 | 01000001 | 65 | 15 |
| 9 | 01011000 | 88 | 10 |
| 10 | 01000000 | 64 | 20 |

### Answer

#### Given

Ten 8-bit chromosomes with supplied fitness and ages; larger fitness is better.

#### To find

Four offspring and two independent survivor-selection outcomes.

#### Formula and why it applies

Rank or tournament selection chooses parents. Crossover exchanges suffixes after bit 4. Fitness-based replacement removes the weakest; age-based replacement removes the oldest. Treat the two requested replacements as separate experiments starting from the same initial population.

#### Solution

##### Step 1. Rank and choose the top two

| Fitness rank | Individual | Fitness |
| --- | --- | --- |
| 1 | 2 | 95 |
| 2 | 5 | 94 |
| 3 | 4 | 89 |
| 4 | 9 | 88 |
| 5 | 7 | 81 |
| 6 | 3 | 80 |
| 7 | 6 | 79 |
| 8 | 8 | 65 |
| 9 | 1 | 64 |
| 10 | 10 | 64 |

Select 2(95) and 5(94). Split 0101|1111 and 0101|1110. Swapping suffixes gives 01011110(94) and 01011111(95).

##### Step 2. Conduct the specified tournaments

Tournament{1,3,5}: fitness 64,80,94 → choose 5. Tournament{2,4}:95,89 → choose 2. Split 0101|1110 and 0101|1111. Children are 01011111(95) and 01011110(94). No mutation is specified.

The four child fitnesses are 94,95,95,94, sum 378. Their strings already exist in the supplied table, so their supplied fitness values can be used directly; no new fitness function is invented.

##### Step 3. Fitness-based survivor replacement

Remove the four lowest-fitness originals:1(64),10(64),8(65),6(79). Keep 2,3,4,5,7,9 with fitness 95,80,89,94,81,88. Keep duplicates because the question does not impose uniqueness.



$$
\text{retained sum}=95+80+89+94+81+88=527
$$





$$
\bar f_{fitness}=\frac{527+378}{10}=90.5
$$



##### Step 4. Age-based replacement, reset to the original table first

Remove the oldest four:10(age 20),8(age 15),3(age 13),7(age 12). Keep 1,2,4,5,6,9 with fitness 64,95,89,94,79,88. Add the same four offspring.



$$
\text{retained sum}=64+95+89+94+79+88=509
$$





$$
\bar f_{age}=\frac{509+378}{10}=88.7
$$



##### Step 5. Explain the difference



$$
\bar f_{original}=799/10=79.9
$$



Fitness-based replacement improves the average more in this example because it directly removes weaker individuals. Age-based replacement promotes turnover, but age is not the same as quality. “Rank-based” selection is usually probabilistic; here the question explicitly says choose the best two, so that deterministic instruction is followed.

**Final answer.** Children have fitness 94,95,95,94. New mean 90.5 under fitness replacement and 88.7 under age replacement.

---

## TEE · Q5(b) Mean of maxima and centroid of trapezoids [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q5b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q5(b)** [10 marks · 2024-06-25]

For the given membership functions determine the crisp output using (1) Mean of Maxima and (2) Centroid / Center of Area.

Swipe across the diagram to read its labels ↔

![First printed membership function: height 0.75, corners x=0,2,3,4.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24r-defuzz-a.4cd4ea6810.svg)

Diagram: First printed membership function: height 0.75, corners x=0,2,3,4.. Labels: First printed membership function: height0.75, corners x=0,2,3,4. | 0 | 0.7 | 1.4 | 2.1 | 2.8 | 3.5 | 4.2 | 4.9 | 5.6 | 6.3 | 7 | 0 | 0.25 | 0.5 | 0.75 | 1 | First graph | μ(x)

First printed membership function: height 0.75, corners x=0,2,3,4.

Swipe across the diagram to read its labels ↔

![Second printed membership function: height 1, corners x=0,3,4,7.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24r-defuzz-b.b1f504dbf4.svg)

Diagram: Second printed membership function: height 1, corners x=0,3,4,7.. Labels: Second printed membership function: height1, corners x=0,3,4,7. | 0 | 0.7 | 1.4 | 2.1 | 2.8 | 3.5 | 4.2 | 4.9 | 5.6 | 6.3 | 7 | 0 | 0.25 | 0.5 | 0.75 | 1 | Second graph | μ(x)

Second printed membership function: height 1, corners x=0,3,4,7.

### Answer

#### Given

Two separate printed graphs; graph 1 corners(0,0),(2,.75),(3,.75),(4,0); graph 2 corners(0,0),(3,1),(4,1),(7,0).

#### To find

MOM and centroid for each graph.

#### Formula and why it applies

MOM averages the x-values where membership reaches its greatest height. For a continuous flat maximum[a, b], MOM=(a+b)/2. Centroid uses all area: divide the sum of area moments by total area.



$$
z_{MOM}=\frac{a+b}{2},\qquad z_{COA}=\frac{\int x\mu(x)dx}{\int\mu(x)dx}=\frac{\sum A_ic_i}{\sum A_i}
$$



#### Solution

##### Step 1. MOM of the first graph

Maximum height.75 occurs throughout[2,3].



$$
z_{MOM,1}=(2+3)/2=2.5
$$



##### Step 2. Centroid of the first graph

| Piece | Area | x centroid | Moment |
| --- | --- | --- | --- |
| Triangle 0–2 | ½×2×.75=.75 | (0+2+2)/3=4/3 | 1 |
| Rectangle 2–3 | 1×.75=.75 | 2.5 | 1.875 |
| Triangle 3–4 | ½×1×.75=.375 | (3+3+4)/3=10/3 | 1.25 |



$$
z_{COA,1}=\frac{1+1.875+1.25}{.75+.75+.375}=\frac{4.125}{1.875}=2.2
$$



##### Step 3. MOM of the second graph



$$
z_{MOM,2}=(3+4)/2=3.5
$$



##### Step 4. Centroid of the second graph

| Piece | Area | x centroid | Moment |
| --- | --- | --- | --- |
| Triangle 0–3 | 1.5 | 2 | 3 |
| Rectangle 3–4 | 1 | 3.5 | 3.5 |
| Triangle 4–7 | 1.5 | 5 | 7.5 |



$$
z_{COA,2}=\frac{3+3.5+7.5}{1.5+1+1.5}=\frac{14}{4}=3.5
$$



The second graph is symmetric about 3.5, so its area centroid and plateau midpoint coincide. The first graph is asymmetric;2.2 and 2.5 need not agree.

**Source / assumption note.** The source draws the two functions on separate axes and does not state a combined aggregation. Answers above are per graph. If the intended task is the centroid of their max-union, explicitly aggregate first: upper envelope switches at x=2.25, total area=131/32, moment=1809/128, centroid=1809/524≈3.452290; maximum remains on[3,4], MOM=3.5.

**Final answer.** Graph 1:MOM 2.5, centroid 2.2. Graph 2:MOM 3.5, centroid 3.5.

---

## TEE · Q6(a) Genetic algorithm for four-city TSP [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q6a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q6(a)** [10 marks · 2024-06-25]

For a genetic algorithm applied to a4-city TSP: (1) cite how to initialize a population; (2) explain fitness calculation; (3) describe common crossover and mutation operators.

### Answer

**Representation.** A chromosome is a permutation of the cities. [A, B, C, D] means A→B→C→D→A; the return edge is implied. Each city appears exactly once before returning.

##### Step 1. Initialize distinct valid tours

Example population:[A, B, C, D], [A, C, B, D], [A, B, D, C], [A, D, B, C]. Fix A at the start to avoid counting rotations as different encodings. Randomly shuffle the other cities or include a heuristic tour; check feasibility.

##### Step 2. Evaluate route length and fitness



$$
L=d_{AB}+d_{BC}+d_{CD}+d_{DA},\qquad fitness=1/L\quad(L>0)
$$



For an illustrative symmetric distance table AB 10, AC 4, AD 3, BC 1, BD 2, CD 1: tour A–B–C–D–A has length 15 and fitness 1/15; A–C–B–D–A has length 10 and fitness 1/10. The shorter tour has larger inverse-distance fitness. These sample costs illustrate the method; the question itself supplies no cost table.

##### Step 3. Use permutation-preserving crossover

Order crossover (OX) copies a segment from one parent, then fills empty positions with cities from the other parent in cyclic order, skipping copied cities. Example P1=A B C D, P2=C D A B. Copy P1 positions 2–3(B C), then scan P2 from position 4:B(skip), C(skip), D, A. Fill child positions 4 then 1 to obtain A B C D. A different cut or parent can yield a different valid tour. Partially matched crossover (PMX) uses a mapping to resolve duplicates. Ordinary bit-string crossover can give repeated/missing cities and is not automatically valid.

##### Step 4. Mutate without losing cities

Swap: A B C D→A D C B by swapping B, D. Inversion: A | B C D→A | D C B. Insertion: remove D from A B C D and insert after A→A D B C. These preserve city uniqueness. Evaluate every child again because a valid route may still be longer.

##### Step 5. Select, replace and stop

Choose parents favoring shorter tours, apply crossover/mutation, evaluate offspring, retain a fixed-size population and optionally preserve the best tour (elitism). Stop after a generation limit or lack of improvement. Return the best observed tour, without claiming a guaranteed optimum unless all feasible tours have been checked.

---

## TEE · Q6(b) Markov process and homework transition paths [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q6b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q6b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q6(b)** [10 marks · 2024-06-25]

(I) Define the Markov process and list applications. (II) A professor assigns full-credit F, half-credit H and no-credit N homework according to the transition diagram. (a) Construct the TPM; (b) find P(X₃=F|X₂=N); (c) P(X₂=N|X₁=H); (d) P(X₄=H|X₂=F).

Swipe across the diagram to read its labels ↔

![Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24r-homework.4001dfd62e.svg)

Diagram: Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.. Labels: legacy24r-homework | 0.3 | 0.25 | 0.45 | 0.45 | 0.4 | 0.15 | 0.65 | 0.25 | 0.1 | Full F | Half H | None N

Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.

### Answer

#### Given

The labeled arrows in the original diagram; state orderF, H, N.

#### To find

The transition matrix and one-step/two-step probabilities.

#### Formula and why it applies

A Markov process predicts the next state using the current state, conditionally independent of earlier history. Applications include weather regimes, brand switching, reliability, queueing and movement among locations. Here a state records the homework-credit category.



$$
P(X_{t+n}=j\mid X_t=i)=(P^n)_{ij}
$$



#### Solution

##### Step 1. Read all outgoing arrows into rows



$$
P=\begin{bmatrix}0.3&0.25&0.45\\0.45&0.4&0.15\\0.65&0.25&0.1\end{bmatrix}
$$



| Row | Sum |
| --- | --- |
| F | .30+.25+.45=1 |
| H | .45+.40+.15=1 |
| N | .65+.25+.10=1 |

##### Step 2. Part (b): one transition N→F



$$
P(X_3=F\mid X_2=N)=P_{NF}=0.65
$$



##### Step 3. Part (c): one transition H→N



$$
P(X_2=N\mid X_1=H)=P_{HN}=0.15
$$



##### Step 4. Part (d): two transitions F→?→H

The time difference is 4−2=2. Sum three mutually exclusive intermediate-state routes.

| Intermediate state | Path product |
| --- | --- |
| F | .30×.25=.075 |
| H | .25×.40=.100 |
| N | .45×.25=.1125 |



$$
(P^2)_{FH}=.075+.100+.1125=.2875
$$



**Final answer.** (b).65; (c).15; (d).2875; TPM shown above.

---

## TEE · Q7(a) Expectation Maximization algorithm [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q7a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(a)** [5 marks · 2024-06-25]

Discuss the Expectation Maximization (EM) algorithm.

### Answer

A Gaussian mixture models a population using K Gaussian components. A hidden component label says which component generated a sample. The labels are not observed, so the likelihood sums over all possible components.



$$
p(x_i\mid\theta)=\sum_{k=1}^{K}\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k),\quad \pi_k\geq0,\quad\sum_k\pi_k=1
$$



##### Step 1. Form the observed-data log likelihood

For independent observations multiply their densities; taking the logarithm turns the product over observations into a sum. The sum over mixture components remains inside the log. This log-of-sum is why a direct closed-form joint maximization is difficult.



$$
\ell(\theta)=\log\prod_{i=1}^{N}\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)=\sum_i\log\left[\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)\right]
$$



##### Step 2. E-step: estimate component membership

Initialize valid weights, means and covariances. Using the old parameters, compute responsibility γᵢₖ: the posterior fraction of sample i assigned to component k. Each row of responsibilities adds to 1.



$$
\gamma_{ik}=\frac{\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k)}{\sum_j\pi_j\mathcal N(x_i\mid\mu_j,\Sigma_j)}
$$



##### Step 3. Use the expected complete-data log likelihood

The “modified” objective in EM is the expectation of the complete-data log likelihood. During this M-step the responsibilities are fixed, so the difficult log of a component sum is replaced by a weighted sum of component log densities.



$$
Q(\theta\mid\theta^{old})=\sum_i\sum_k\gamma_{ik}\left[\log\pi_k+\log\mathcal N(x_i\mid\mu_k,\Sigma_k)\right]
$$



##### Step 4. M-step: weighted estimates



$$
N_k=\sum_i\gamma_{ik},\quad \pi_k^{new}=\frac{N_k}{N},\quad\mu_k^{new}=\frac{\sum_i\gamma_{ik}x_i}{N_k}
$$





$$
\Sigma_k^{new}=\frac{\sum_i\gamma_{ik}(x_i-\mu_k^{new})(x_i-\mu_k^{new})^T}{N_k}
$$



Repeat E and M until the observed log likelihood changes by less than a chosen tolerance or an iteration limit is reached. EM improves or preserves likelihood under exact steps, but can converge to a local optimum. Try several initializations and avoid singular covariance matrices.

**Small responsibility example.** If one sample has unnormalized component contributions 0.12 and 0.08, total 0.20 gives responsibilities 0.6 and 0.4. Its mean-update contribution is 0.6x for component 1 and 0.4x for component 2; it is not forced entirely into one cluster. This is why EM is called soft assignment in a GMM.

---

## TEE · Q7(b) Lambda-cut of a fuzzy relation [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q7b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(b)** [5 marks · 2024-06-25]

For the fuzzy relation R below, find the λ-cut relations for λ=.003 and λ=.5.



$$
R=\begin{bmatrix}1&0.1&0&0.4\\0.001&0.5&0.5&0.6\\0.3&1&0.5&0\\0&0.4&0.002&0.1\end{bmatrix}
$$



### Answer

#### Given

A4×4 fuzzy relation with entries between 0 and 1.

#### To find

Two crisp 0/1 relations retaining entries at or above the threshold.

#### Formula and why it applies

A weak λ-cut includes an ordered pair when its membership is at least λ. Replace included entries by 1 and excluded entries by 0. A strong cut would use a strict inequality, but that is not requested.



$$
(R_\lambda)_{ij}=\begin{cases}1&R_{ij}\geq\lambda\\0&R_{ij}<\lambda\end{cases}
$$



#### Solution

##### Step 1. Threshold at.003

Zero,.001 and.002 are below.003 and become 0. All other positive entries are at least.1, so become 1.



$$
R_{.003}=\begin{bmatrix}1&1&0&1\\0&1&1&1\\1&1&1&0\\0&1&0&1\end{bmatrix}
$$



##### Step 2. Threshold at.5, including equality

Entries equal to.5 are retained. Values 1,.5,.6 become 1; values.4,.3,.1,.002,.001,0 become 0.



$$
R_{.5}=\begin{bmatrix}1&0&0&0\\0&1&1&1\\0&1&1&0\\0&0&0&0\end{bmatrix}
$$



##### Step 3. Verify one included and one excluded entry

R₂₃=.5≥.5, so output(2,3)=1. R₄₃=.002<.003, so output(4,3)=0. The row/column labels and 4×4 shape do not change.

**Final answer.** The two crisp matrices above are the weak λ-cuts.

---

## TEE · Q7(c) ACO path length and pheromone update [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q7c

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(c)** [5 marks · 2024-06-25]

For the four-city travelling salesman problem, row and column order is A, B, C, D. The pheromone and cost matrices are:



$$
\tau=\begin{bmatrix}0&15&5&4\\15&0&4&8\\5&4&0&1\\4&8&1&0\end{bmatrix}
$$





$$
D=\begin{bmatrix}0&10&4&3\\10&0&1&2\\4&1&0&1\\3&2&1&0\end{bmatrix}
$$



Ant L₁ travels A–B–C–D–A and ant L₂ travels A–C–B–D–A. Taking the vaporization coefficient as 0.5, calculate (1) the length of each path and (2) pheromone level for each path.

### Answer

#### Given

Two tours: A–B–C–D–A and A–C–B–D–A; evaporation ρ=0.5; printed matrices above.

#### To find

Both tour lengths and updated pheromone on every edge.

#### Formula and why it applies

Distance is read from the COST matrix, not the pheromone matrix. Sum all edges including the return home. Under the standard Ant System update, evaporate the old trail once, then add deposits from every ant that traversed the edge.



$$
L_k=\sum_{(i,j)\in tour_k}d_{ij},\qquad \tau_{ij}^{new}=(1-\rho)\tau_{ij}^{old}+\sum_k\Delta\tau_{ij}^{k},\quad \Delta\tau_{ij}^{k}=Q/L_k
$$



#### Solution

**Source / assumption note.** The deposit constant Q is not supplied. The numerical answer below explicitly assumes Q=1 and undirected, symmetric edges. If your examiner specifies another Q, multiply each deposit by that Q. Pheromone is an edge quantity, not one scalar for a whole path.

##### Step 1. Calculate tour 1 length



$$
L_1=d_{AB}+d_{BC}+d_{CD}+d_{DA}=10+1+1+3=15
$$



##### Step 2. Calculate tour 2 length



$$
L_2=d_{AC}+d_{CB}+d_{BD}+d_{DA}=4+1+2+3=10
$$



##### Step 3. Calculate deposit per used edge



$$
\Delta\tau_1=1/15\approx0.0666667,\qquad\Delta\tau_2=1/10=0.1
$$



The shorter tour receives the larger deposit. Shared edges BC and AD receive both deposits; unused-by-an-ant edges receive zero from that ant.

##### Step 4. Update each distinct undirected edge

| Edge | Old pheromone | After evaporation | Deposit from tour 1 | Deposit from tour 2 | New pheromone |
| --- | --- | --- | --- | --- | --- |
| AB | 15 | 7.5 | 1/15 | 0 | 7.566667 |
| AC | 5 | 2.5 | 0 | 1/10 | 2.600000 |
| AD | 4 | 2 | 1/15 | 1/10 | 2.166667 |
| BC | 4 | 2 | 1/15 | 1/10 | 2.166667 |
| BD | 8 | 4 | 0 | 1/10 | 4.100000 |
| CD | 1 | 0.5 | 1/15 | 0 | 0.566667 |

##### Step 5. Assemble the symmetric matrix



$$
\begin{bmatrix}0&7.566667&2.6&2.166667\\7.566667&0&2.166667&4.1\\2.6&2.166667&0&0.566667\\2.166667&4.1&0.566667&0\end{bmatrix}
$$



The diagonal remains zero because an ant does not travel from a city to itself.

**Final answer.** Tour lengths are 15 and 10. The table and matrix give all updated edge pheromones under Q=1.

---

## TEE · Q7(d) Bellman equation [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-reexam--q7d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-reexam/q7d

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(d)** [5 marks · 2024-06-25]

Explain the Bellman equation in reinforcement learning.

### Answer

The **Bellman equation** expresses a state’s long-term value as immediate expected reward plus discounted value of the next state. It follows by splitting the return into its first reward and the remaining return.



$$
G_t=R_{t+1}+\gamma G_{t+1}
$$





$$
V^\pi(s)=\sum_a\pi(a\mid s)\sum_{s\prime}P(s\prime\mid s,a)\left[R(s,a,s\prime)+\gamma V^\pi(s\prime)\right]
$$



| Symbol | Meaning |
| --- | --- |
| s, a, s′ | Current state, chosen action, next state |
| π(a|s) | Policy probability of choosing actiona |
| P(s′|s, a) | Environment transition probability |
| R(s, a, s′) | Expected immediate reward for that transition |
| γ | Discount factor, usually 0≤γ<1 for continuing tasks |
| Vπ(s) | Expected discounted return following policyπ |

For a fixed policy, average over its action probabilities. For the optimal value, replace the policy-weighted average by the best action:



$$
V^*(s)=\max_a\sum_{s\prime}P(s\prime\mid s,a)\left[R(s,a,s\prime)+\gamma V^*(s\prime)\right]
$$



**Numerical illustration.** An action gives reward 2, then reaches a value 10 state with probability.6 or a value 4 state with probability.4. With γ=.9, its value is.6(2+.9×10)+.4(2+.9×4)=.6×11+.4×5.6=6.6+2.24=8.84. If another action has value 8, the optimality update chooses 8.84. An action value is not just the immediate reward. Bellman recursion underlies policy evaluation, value iteration and many temporal-difference methods.

---

## TEE · Q1(a) Conditional probability from fruit counts [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q1a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(a)** [5 marks · 2024-04-17]

Consider the given dataset, apply Bayes rule and predict if a fruit has the following properties. Find (a) P(Yellow | Mango), (b) P(Sweet | Banana).

| Fruit | Yellow | Sweet | Long | Total |
| --- | --- | --- | --- | --- |
| Mango | 350 | 450 | 0 | 650 |
| Banana | 400 | 300 | 350 | 400 |
| Others | 50 | 100 | 50 | 150 |
| Total | 800 | 850 | 400 | 1200 |

### Answer

#### Given

650 mangoes, of which 350 are yellow; 400 bananas, of which 300 are sweet.

#### To find

The two probabilities in the printed order.

#### Formula and why it applies

The condition after the vertical bar restricts the denominator. For Yellow given Mango, only mangoes are eligible. This is direct conditional probability; reversing the condition would answer a different question.



$$
P(A\mid B)=\frac{P(A\cap B)}{P(B)}=\frac{\text{count satisfying A and B}}{\text{count satisfying B}}
$$



#### Solution

##### Step 1. Restrict to mangoes



$$
P(Yellow\mid Mango)=\frac{350}{650}=\frac7{13}\approx0.538462
$$



##### Step 2. Restrict to bananas



$$
P(Sweet\mid Banana)=\frac{300}{400}=\frac34=0.75
$$



##### Step 3. Check the direction of the condition

Using 800 in the first denominator would instead calculate P(Mango | Yellow)=350/800. Using 850 in the second would calculate P(Banana | Sweet)=300/850. Neither is the requested probability. The total 1200 cancels if you first convert every count to a joint/marginal probability.

**Final answer.** P(Yellow | Mango)=7/13 ≈ 0.538462; P(Sweet | Banana)=0.75.

---

## TEE · Q1(b) Membership function and age sketch [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q1b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(b)** [5 marks · 2024-04-17]

Define a membership function in the context of fuzzy logic. Using your intuition, sketch fuzzy membership functions for the “age of people”.

### Answer

A **membership function** assigns each element x of a universe X a degree μA(x) between 0 and 1, indicating compatibility with a linguistic concept A.



$$
\mu_A:X\rightarrow[0,1]
$$



A value of 0 means no membership, 1 means full membership, and intermediate values represent partial membership. This is a degree of a vague property, not automatically a probability of a random event.

Swipe across the diagram to read its labels ↔

![Illustrative age memberships, not universal demographic boundaries. An age can belong partly to two terms.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-age.140e92bbb3.svg)

Diagram: Illustrative age memberships, not universal demographic boundaries. An age can belong partly to two terms.. Labels: Illustrative age memberships, not universal demographic boundaries. An age can belong partly to two terms. | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 0 | 0.25 | 0.5 | 0.75 | 1 | Young | Middle-aged | Old | μ(x)

Illustrative age memberships, not universal demographic boundaries. An age can belong partly to two terms.

| Term | One explicit assumed shape |
| --- | --- |
| Young | 1 until age 20; then decreases linearly to 0 at age 40. |
| Middle-aged | 0 up to 25; rises to 1 at 45; falls to 0 at 65. |
| Old | 0 up to 50; rises to 1 at 70; then remains 1. |

For age 35, μYoung=(40−35)/(40−20)=0.25 and μMiddle=(35−25)/(45−25)=0.5. The person is partly young and partly middle-aged. Overlap permits smooth decisions; a crisp boundary would abruptly change the label at one exact birthday.

**Remember:** membership = “kitna fit hota hai is label mein”. State the axis labels and the assumed age breakpoints when sketching.

---

## TEE · Q1(c) Mutation operators [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q1c

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(c)** [5 marks · 2024-04-17]

Cite and illustrate various mutation operators in the genetic algorithm.

### Answer

**Mutation** randomly changes one or more genes to introduce diversity and explore solutions not obtained by crossover alone. Apply a small specified mutation probability; excessive mutation can destroy good structures.

| Operator | Before → after | Suitable representation |
| --- | --- | --- |
| Bit flip | 10110 → 10010 (third bit 1→0) | Binary chromosome |
| Random resetting | [2,7,4] → [2,3,4] (replace gene 2 by a valid value) | Integer/discrete |
| Swap | A B C D E → A D C B E (swap positions 2 and 4) | Permutation / TSP |
| Inversion | A | B C D | E → A | D C B | E | Permutation / TSP |
| Insertion | A B C D E → A D B C E (remove D and insert after A) | Permutation / TSP |
| Gaussian perturbation | [1.2,2.0] → [1.2,2.0+0.1]=[1.2,2.1] | Real-valued; respect bounds |

For a TSP route, arbitrary bit or value replacement can duplicate a city and omit another. Swap/inversion preserve the permutation, so the resulting route remains valid. Mutation changes a chromosome; crossover combines material from two parents.

---

## TEE · Q1(d) Markov chain diagram and path probability [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q1d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q1d

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q1(d)** [5 marks · 2024-04-17]

Consider the Markov chain with S={1,2,3} and transition matrix below. (a) Draw the state transition diagram. (b) The scan prints “P(X₁=1)=(X₂=2)=1/4”; calculate P(X₁=3, X₂=2, X₃=1).



$$
P=\begin{bmatrix}1/2&1/4&1/4\\1/3&0&2/3\\1/2&1/2&0\end{bmatrix}
$$



### Answer

#### Given

The printed matrix; ambiguous condition reproduced above.

#### To find

All nonzero transitions and the joint probability of the path 3→2→1.

#### Formula and why it applies

Rows are current states and columns are next states. A specified path probability is initial-state probability multiplied by each transition along that path.



$$
P(X_1=3,X_2=2,X_3=1)=P(X_1=3)P_{32}P_{21}
$$



#### Solution

##### Step 1. Draw the matrix as arrows

Swipe across the diagram to read its labels ↔

![Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-three-state.d3ab43c06c.svg)

Diagram: Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.. Labels: legacy24-three-state | 0.5 | 0.25 | 0.25 | 0.333333 | 0.666667 | 0.5 | 0.5 | 1 | 2 | 3

Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.

| From | Outgoing destinations |
| --- | --- |
| 1 | 1 with 1/2; 2 with 1/4; 3 with 1/4 |
| 2 | 1 with 1/3; 3 with 2/3 |
| 3 | 1 with 1/2; 2 with 1/2 |

**Source / assumption note.** The source drops the second P and uses X₂ in the second condition. Read literally as P(X₂=2)=1/4, the answer differs from the common intended initial-distribution reading P(X₁=2)=1/4. Both are calculated explicitly; do not silently change the subscript.

##### Step 2. Solve the literal reading

Let p₁=P(X₁=1)=1/4 and p₃=P(X₁=3). To be in state 2 at time 2, arrive from state 1 or state 3; transition 2→2 is zero.



$$
\frac14=p_1P_{12}+p_2P_{22}+p_3P_{32}=\frac14\frac14+0+\frac12p_3
$$





$$
\frac12p_3=\frac14-\frac1{16}=\frac3{16}\quad\Rightarrow\quad p_3=\frac38
$$





$$
P(3,2,1)=\frac38\cdot\frac12\cdot\frac13=\frac1{16}=0.0625
$$



##### Step 3. Show the alternative if the second subscript was a typo

If the intended statement was P(X₁=1)=P(X₁=2)=1/4, then P(X₁=3)=1−1/4−1/4=1/2.



$$
P(3,2,1)=\frac12\cdot\frac12\cdot\frac13=\frac1{12}\approx0.0833333
$$



**Final answer.** Literal time-2 condition gives 1/16. Corrected initial-state condition gives 1/12; the source wording must be clarified.

---

## TEE · Q2(a) Bayesian network joint probabilities [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q2a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q2(a)** [10 marks · 2024-04-17]

Given the task of modelling a student’s marks for an exam, use the Bayesian network and conditional probability tables below. Exam E: 0 easy, 1 difficult. IQ I: 0 low, 1 high. Aptitude S: 0 low, 1 high. (a) Calculate the probability of a difficult exam, low IQ, low aptitude, passing and securing admission. (b) Calculate the probability of high IQ and aptitude, an easy exam, failing and no admission.

Swipe across the diagram to read its labels ↔

![Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-exam-bn.9070a35002.svg)

Diagram: Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.. Labels: legacy24-exam-bn | Exam E | IQ I | Marks M | Aptitude S | Admit A

Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.

| Root | P(0) | P(1) |
| --- | --- | --- |
| E | 0.7 | 0.3 |
| I | 0.8 | 0.2 |

| I | E | P(M=0) | P(M=1) |
| --- | --- | --- | --- |
| 0 | 0 | 0.6 | 0.4 |
| 0 | 1 | 0.9 | 0.1 |
| 1 | 0 | 0.5 | 0.5 |
| 1 | 1 | 0.8 | 0.2 |

| I | P(S=0) | P(S=1) |
| --- | --- | --- |
| 0 | 0.75 | 0.25 |
| 1 | 0.4 | 0.6 |

| M | P(A=0) | P(A=1) |
| --- | --- | --- |
| 0 | 0.6 | 0.4 |
| 1 | 0.9 | 0.1 |

### Answer

#### Given

All five variables and their CPTs are reproduced above.

#### To find

The two complete joint-event probabilities.

#### Formula and why it applies

For a Bayesian network, multiply each node’s probability conditional on its parents. Roots have no parents. Do not multiply an extra marginal for a node whose conditional factor is already present.



$$
P(E,I,M,S,A)=P(E)P(I)P(M\mid E,I)P(S\mid I)P(A\mid M)
$$



#### Solution

**Source / assumption note.** The source defines codes for E, I and S but does not explicitly define pass/admission coding. The calculations below state the conventional assumption M=1 means pass and A=1 means admitted; 0 means fail/not admitted. If the examiner defines reversed coding, select the corresponding CPT columns instead.

##### Step 1. Write event (a) in symbols



$$
(E,I,M,S,A)=(1,0,1,0,1)
$$



##### Step 2. Select one CPT entry for each node

| Factor | Why this entry | Value |
| --- | --- | --- |
| P(E=1) | Difficult | 0.3 |
| P(I=0) | Low IQ | 0.8 |
| P(M=1|E=1, I=0) | Pass, difficult, low IQ | 0.1 |
| P(S=0|I=0) | Low aptitude given low IQ | 0.75 |
| P(A=1|M=1) | Admission given pass | 0.1 |

##### Step 3. Multiply without dropping root probabilities



$$
0.3\times0.8=0.24\quad;\quad0.24\times0.1=0.024
$$





$$
0.024\times0.75=0.018\quad;\quad0.018\times0.1=0.0018
$$



##### Step 4. Write and solve event (b)



$$
(E,I,M,S,A)=(0,1,0,1,0)
$$





$$
0.7\times0.2\times0.5\times0.6\times0.6=0.0252
$$



Intermediate products: 0.7×0.2=0.14; ×0.5=0.07; ×0.6=0.042; ×0.6=0.0252. These are joint probabilities of the whole described event. If E/I/S were explicitly conditioned on, their factors would cancel; the conditional answers would be 0.1×0.1=0.01 and 0.5×0.6=0.30.

**Final answer.** Under the declared coding and joint-event reading: (a) 0.0018, (b) 0.0252.

---

## TEE · Q2(b) Fuzzy Cartesian product and composition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q2b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q2b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q2(b)** [10 marks · 2024-04-17]

A={1/low + 0.2/medium + 0.6/high}; B={0.9/positive + 0.3/zero + 0.8/negative}. (1) Find R=A×B. (2) With C={0.3/low + 0.4/medium + 0.6/high}, find S=C×B. (3) Find S∘R using max–min composition.

### Answer

#### Given

A, B, C memberships as printed. Rows of R/S: low, medium, high; columns: positive, zero, negative.

#### To find

Both Cartesian-product matrices and a carefully stated interpretation of the requested composition.

#### Formula and why it applies

The usual fuzzy Cartesian product uses minimum, not ordinary multiplication. Max–min composition combines a row with a column: take each matching minimum, then the maximum.



$$
R_{ij}=\min(A_i,B_j),\quad S_{ij}=\min(C_i,B_j),\quad T_{ij}=\max_k\min(R_{ik},S_{kj})
$$



#### Solution

##### Step 1. Build R one row at a time

| A row | Min with 0.9 | Min with 0.3 | Min with 0.8 |
| --- | --- | --- | --- |
| 1 | min(1,0.9)=0.9 | min(1,0.3)=0.3 | min(1,0.8)=0.8 |
| 0.2 | min(0.2,0.9)=0.2 | min(0.2,0.3)=0.2 | min(0.2,0.8)=0.2 |
| 0.6 | min(0.6,0.9)=0.6 | min(0.6,0.3)=0.3 | min(0.6,0.8)=0.6 |



$$
R=\begin{bmatrix}0.9&0.3&0.8\\0.2&0.2&0.2\\0.6&0.3&0.6\end{bmatrix}
$$



##### Step 2. Build S the same way

| C row | Min with 0.9 | Min with 0.3 | Min with 0.8 |
| --- | --- | --- | --- |
| 0.3 | min(0.3,0.9)=0.3 | min(0.3,0.3)=0.3 | min(0.3,0.8)=0.3 |
| 0.4 | min(0.4,0.9)=0.4 | min(0.4,0.3)=0.3 | min(0.4,0.8)=0.4 |
| 0.6 | min(0.6,0.9)=0.6 | min(0.6,0.3)=0.3 | min(0.6,0.8)=0.6 |



$$
S=\begin{bmatrix}0.3&0.3&0.3\\0.4&0.3&0.4\\0.6&0.3&0.6\end{bmatrix}
$$



**Source / assumption note.** Both R and S are described from the low/medium/high universe to the positive/zero/negative universe. Their labels do not define a valid typed composition R then S. Equal 3×3 dimensions alone do not fix this. The following is the conventional exam index-matrix calculation after explicitly identifying the middle indices; a semantically typed comparison would instead use Sᵀ.

##### Step 3. State the R-then-S index convention and calculate all nine cells

Here S∘R means apply R first, then S, so use row R and column S.

| Output cell | Compare every matching middle index | Take the largest result |
| --- | --- | --- |
| (1, 1) | min(0.9, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.8, 0.6) = 0.6 | max(0.3, 0.3, 0.6) = 0.6 |
| (1, 2) | min(0.9, 0.3) = 0.3, min(0.3, 0.3) = 0.3, min(0.8, 0.3) = 0.3 | max(0.3, 0.3, 0.3) = 0.3 |
| (1, 3) | min(0.9, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.8, 0.6) = 0.6 | max(0.3, 0.3, 0.6) = 0.6 |
| (2, 1) | min(0.2, 0.3) = 0.2, min(0.2, 0.4) = 0.2, min(0.2, 0.6) = 0.2 | max(0.2, 0.2, 0.2) = 0.2 |
| (2, 2) | min(0.2, 0.3) = 0.2, min(0.2, 0.3) = 0.2, min(0.2, 0.3) = 0.2 | max(0.2, 0.2, 0.2) = 0.2 |
| (2, 3) | min(0.2, 0.3) = 0.2, min(0.2, 0.4) = 0.2, min(0.2, 0.6) = 0.2 | max(0.2, 0.2, 0.2) = 0.2 |
| (3, 1) | min(0.6, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.6, 0.6) = 0.6 | max(0.3, 0.3, 0.6) = 0.6 |
| (3, 2) | min(0.6, 0.3) = 0.3, min(0.3, 0.3) = 0.3, min(0.6, 0.3) = 0.3 | max(0.3, 0.3, 0.3) = 0.3 |
| (3, 3) | min(0.6, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.6, 0.6) = 0.6 | max(0.3, 0.3, 0.6) = 0.6 |



$$
T=\begin{bmatrix}0.6&0.3&0.6\\0.2&0.2&0.2\\0.6&0.3&0.6\end{bmatrix}
$$



##### Step 4. Distinguish the other common notation convention

If your course writes S∘R as the matrix product with S on the left, the index result is instead:



$$
\begin{bmatrix}0.3&0.3&0.3\\0.4&0.3&0.4\\0.6&0.3&0.6\end{bmatrix}
$$



For a correctly typed relation between the input universes, compose R with the inverse relation Sᵀ; the row/column labels then match:



$$
R\circ S^T=\begin{bmatrix}0.3&0.4&0.6\\0.2&0.2&0.2\\0.3&0.4&0.6\end{bmatrix}
$$



**Final answer.** R and S are shown above. The R-then-S index result is [[0.6,0.3,0.6],[0.2,0.2,0.2],[0.6,0.3,0.6]]. The source needs a domain or convention clarification.

---

## TEE · Q3(a) GMM versus K-means [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q3a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q3a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q3(a)** [10 marks · 2024-04-17]

Discuss the significance of using Gaussian Mixture Models (GMMs) over K-means clustering in capturing complex data distributions.

### Answer

**GMM** models the density as a weighted sum of Gaussian components. **K-means** minimizes within-cluster squared Euclidean distance and assigns each point to one nearest centroid.



$$
p(x)=\sum_{k=1}^K\pi_k\mathcal N(x\mid\mu_k,\Sigma_k)
$$



| Aspect | K-means | Gaussian mixture |
| --- | --- | --- |
| Assignment | Hard: one cluster label | Soft: posterior responsibility for each component |
| Cluster shape | Voronoi regions from Euclidean distance; suited to compact roughly spherical groups | Full covariance allows elongated and differently oriented ellipses |
| Spread | No explicit cluster-specific covariance in the standard objective | Separate covariance estimates model unequal spreads |
| Overlap | Boundary points assigned completely to one side | Uncertainty is represented by partial memberships |
| Output | Centroids and assignments | Density, mixing weights, means, covariances and responsibilities |
| Training | Alternate assignment and centroid mean | EM responsibility and parameter updates |
| Cost | Usually simpler and faster | More parameters and cost; can overfit or develop singular covariance |
| Initialization | Can reach local minima | Can reach local likelihood maxima; multiple restarts help |

**Example.** Two customer groups overlap in annual income/spending: one is a narrow diagonal band and one a broad ellipse. A spherical distance-only partition may split the diagonal group badly. Separate covariance matrices can align GMM ellipses with each group. A boundary customer might have responsibilities [0.55,0.45], showing uncertainty instead of an unjustifiably certain label.

**Why this matters.** The mixture can approximate multimodal distributions; unequal mixing weights represent different group sizes. Its density supports likelihood-based anomaly detection and probabilistic downstream decisions. However a Gaussian component is not automatically a real-world class, and arbitrary non-Gaussian shapes may require several components.

**Selection and limitations.** Choose K and covariance restrictions using validation/BIC/AIC as appropriate, scale features, regularize covariance and inspect convergence. K-means remains attractive for large, roughly spherical, similarly scaled clusters when hard assignments are enough. GMM is more flexible, not universally superior.

---

## TEE · Q3(b) Center of sums defuzzification [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q3b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q3(b)** [10 marks · 2024-04-17]

For the given membership functions, determine the defuzzified crisp output using the Center of Sums method.

Swipe across the diagram to read its labels ↔

![Source graph redrawn: A1 corners (1,0),(3,0.5),(7,0.5),(8,0); A2 corners (3,0),(4,0.3),(8,0.3),(9,0).](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-centre-sums.6ec254a338.svg)

Diagram: Source graph redrawn: A1 corners (1,0),(3,0.5),(7,0.5),(8,0); A2 corners (3,0),(4,0.3),(8,0.3),(9,0).. Labels: Source graph redrawn: A1 corners (1,0),(3,0.5),(7,0.5),(8,0); A2 corners (3,0),(4,0.3),(8,0.3),(9,0). | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 0 | 0.25 | 0.5 | 0.75 | 1 | A1 h=0.5 | A2 h=0.3 | μ(x)

Source graph redrawn: A1 corners (1,0),(3,0.5),(7,0.5),(8,0); A2 corners (3,0),(4,0.3),(8,0.3),(9,0).

### Answer

#### Given

A1 has height 0.5 and support [1,8], plateau [3,7]; A2 has height 0.3 and support [3,9], plateau [4,8].

#### To find

Center of sums of the two clipped output sets.

#### Formula and why it applies

Center of sums adds each set’s area and moment separately; overlapping portions are counted once per set. This differs from the centroid of the max-aggregated union. Split each trapezoid into triangles and a rectangle.



$$
z_{COS}=\frac{A_1c_1+A_2c_2}{A_1+A_2}=\frac{M_1+M_2}{A_1+A_2}
$$



#### Solution

##### Step 1. Area and moment of A1

| Piece | Area | Centroid x | Area × centroid |
| --- | --- | --- | --- |
| Left triangle [1,3] | ½×2×0.5=0.5 | (1+3+3)/3=7/3 | 7/6 |
| Rectangle [3,7] | 4×0.5=2 | (3+7)/2=5 | 10 |
| Right triangle [7,8] | ½×1×0.5=0.25 | (7+7+8)/3=22/3 | 11/6 |



$$
A_1=0.5+2+0.25=2.75,\quad M_1=7/6+10+11/6=13,\quad c_1=13/2.75=52/11
$$



##### Step 2. Area and moment of A2

| Piece | Area | Centroid x | Moment |
| --- | --- | --- | --- |
| Left triangle [3,4] | 0.15 | 11/3 | 0.55 |
| Rectangle [4,8] | 1.2 | 6 | 7.2 |
| Right triangle [8,9] | 0.15 | 25/3 | 1.25 |



$$
A_2=0.15+1.2+0.15=1.5,\quad M_2=0.55+7.2+1.25=9,\quad c_2=6
$$



##### Step 3. Weight centroids by areas



$$
z_{COS}=\frac{13+9}{2.75+1.5}=\frac{22}{4.25}=\frac{88}{17}\approx5.176471
$$



Do not simply average 52/11 and 6: A1 has more area and must receive more weight. Do not subtract overlap for Center of Sums.

**Final answer.** Center of Sums = 88/17 ≈ 5.176471.

---

## TEE · Q4(a) Fuzzy quality-control design [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q4a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q4(a)** [10 marks · 2024-04-17]

Design a fuzzy logic-based quality-control system for manufacturing that detects defects and decides whether to reject or accept a product. Inputs: Pressure [0,100] and Quality of material [0,100]. Output: Defect detection [0,100]. Use three descriptors per input and five per output; draw membership functions and derive rules. If pressure and material quality are high, accept; vice versa reject. Show defuzzification for Pressure 40 and Quality 80.

### Answer

#### Given

Pressure=40, Material quality=80; ranges 0–100; three input terms and five output terms.

#### To find

A complete controller: membership graphs, rules, inference and crisp output.

#### Formula and why it applies

Fuzzification translates measured values into degrees. Min implements AND, max combines rules, and centroid converts the fuzzy output to one numerical command.



$$
\alpha_r=\min(\mu_{A_r}(x),\mu_{B_r}(y)),\quad z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

**Source / assumption note.** This is a design question: membership coordinates, full rule table and decision threshold are not prescribed. The following is one explicitly specified valid Mamdani design, not the only possible numerical output. Never copy its result if you choose different triangles or rules.

##### Step 1. Specify the inputs and output

Pressure and Material quality each span 0–100. Use low=left shoulder (0,0,50), medium=triangle (0,50,100), high=right shoulder (50,100,100). Output is defect severity on 0–100; larger means worse quality.

Swipe across the diagram to read its labels ↔

![Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-quality-inputs.c512a5765f.svg)

Diagram: Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.. Labels: Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range. | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 0 | 0.25 | 0.5 | 0.75 | 1 | Low | Medium | High | μ(x)

Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.

Swipe across the diagram to read its labels ↔

![Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-quality-outputs.e8de6dab72.svg)

Diagram: Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.. Labels: Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered. | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 0 | 0.25 | 0.5 | 0.75 | 1 | Very low defect | Low defect | Medium defect | High defect | Very high defect | μ(x)

Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.

##### Step 2. Define all nine IF–THEN rules

| Pressure / Material quality | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Very high defect | High defect | Medium defect |
| Medium | High defect | Medium defect | Low defect |
| High | Medium defect | Low defect | Very low defect |

Higher pressure and better material reduce defect severity, as stipulated in this question. This is an exam design assumption, not a universal manufacturing rule.

##### Step 3. Fuzzify the two crisp readings

| Input | Low membership | Medium membership | High membership |
| --- | --- | --- | --- |
| Pressure=40 | 1/5 | 4/5 | 0 |
| Material quality=80 | 0 | 2/5 | 3/5 |

For Pressure=40: low=max(0,(50−40)/50)=0.2; medium=40/50=0.8; high=max(0,(40−50)/50)=0. For Material quality=80: low=0, medium=(100−80)/50=0.4, high=(80−50)/50=0.6.

##### Step 4. Fire every active rule with minimum

| Pressure | Material quality | AND strength | Output descriptor |
| --- | --- | --- | --- |
| Low | Medium | min(0.2, 0.4) = 0.2 | High defect |
| Low | High | min(0.2, 0.6) = 0.2 | Medium defect |
| Medium | Medium | min(0.8, 0.4) = 0.4 | Medium defect |
| Medium | High | min(0.8, 0.6) = 0.6 | Low defect |

The other rules have a zero antecedent membership and therefore fire at zero.

##### Step 5. Aggregate rules and clip each output membership

| Descriptor | Maximum firing strength |
| --- | --- |
| Very low defect | 0.0 |
| Low defect | 0.6 |
| Medium defect | 0.4 |
| High defect | 0.2 |
| Very high defect | 0.0 |



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{B_r}(z))
$$



Swipe across the diagram to read its labels ↔

![Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-quality-aggregate.dae0d30118.svg)

Diagram: Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.. Labels: Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid. | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 0 | 0.25 | 0.5 | 0.75 | 1 | Aggregated output | μ(x)

Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.

##### Step 6. Calculate centroid area and first moment

Split the upper outline at every corner and intersection. On a segment [a, b] with endpoint heights u and v, integrate the straight line. This counts overlap once.



$$
A=(b-a)\frac{u+v}{2},\qquad M=aA+\frac{(b-a)^2(u+2v)}6,\qquad z^*=\frac{\sum M}{\sum A}
$$



| Segment [a, b] | Heights [u, v] | Area A | Moment M |
| --- | --- | --- | --- |
| [0, 15] | [0, 0.6] | 4.500000 | 45.000000 |
| [15, 25] | [0.6, 0.6] | 6.000000 | 120.000000 |
| [25, 35] | [0.6, 0.6] | 6.000000 | 180.000000 |
| [35, 40] | [0.6, 0.4] | 2.500000 | 93.333333 |
| [40, 50] | [0.4, 0.4] | 4.000000 | 180.000000 |
| [50, 55] | [0.4, 0.4] | 2.000000 | 105.000000 |
| [55, 65] | [0.4, 0.4] | 4.000000 | 240.000000 |
| [65, 70] | [0.4, 0.2] | 1.500000 | 100.833333 |
| [70, 75] | [0.2, 0.2] | 1.000000 | 72.500000 |
| [75, 95] | [0.2, 0.2] | 4.000000 | 340.000000 |
| [95, 100] | [0.2, 0] | 0.500000 | 48.333333 |



$$
z^*=\frac{1525.000000}{36.000000}\approx 42.361111
$$



##### Step 7. Make the accept/reject decision

Choose and state a threshold: accept when defect severity is below 50, reject at or above 50. The calculated output is below 50, so accept. High/high gives very low defects and low/low gives very high defects, satisfying the question.

**Final answer.** With the stated membership functions and rules, the output is 42.361111 on the given 0–100 scale. Under the stated threshold of 50: accept.

---

## TEE · Q4(b) ACO components and roles [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q4b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q4b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q4(b)** [10 marks · 2024-04-17]

Describe the key components of an Ant Colony Optimization algorithm and their respective roles in finding optimal solutions.

### Answer

**Ant Colony Optimization (ACO)** is a population-based stochastic optimization method inspired by ants reinforcing useful paths with pheromone. Artificial ants construct feasible solutions, evaluate them and update a shared pheromone model.

| Component | Role | TSP interpretation |
| --- | --- | --- |
| Problem graph / feasible moves | Defines allowable solution components and constraints | Cities are nodes, travel edges have costs |
| Artificial ants | Construct candidate solutions incrementally | Build tours visiting each city once then return |
| Pheromone τᵢⱼ | Learned desirability from prior successful tours | Strong trails favor often-rewarded edges |
| Heuristic ηᵢⱼ | Problem-specific local guidance | Often 1/dᵢⱼ: shorter edges look attractive |
| Tabu/visited set | Prevents invalid repeat decisions | Do not revisit a city before the closing edge |
| Probabilistic transition | Balances learned and local guidance | Normalize desirabilities over unvisited cities |
| Evaporation ρ | Forgets old trails; helps avoid stagnation | Multiply old pheromone by 1−ρ |
| Deposit / reinforcement | Rewards useful solutions | Ant on tour of length L deposits Q/L |
| Best-tour memory | Retains best solution discovered | Shorter tour replaces incumbent |
| Termination | Bounds computation | Iteration/time/no-improvement limit |



$$
p_{ij}^{(k)}=\frac{\tau_{ij}^{\alpha}\eta_{ij}^{\beta}}{\sum_{h\in allowed_k}\tau_{ih}^{\alpha}\eta_{ih}^{\beta}}
$$



α controls pheromone influence; β controls heuristic influence. If two allowed edges have desirabilities 2 and 6, their probabilities are 2/8=0.25 and 6/8=0.75. The less preferred edge can still be explored.



$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}^{old}+\sum_k Q/L_k\;\text{on edges used by ant }k
$$



**Algorithm flow:** initialize trails → construct all tours → compute lengths → evaporate → deposit → retain best tour → repeat. A population and random choice promote exploration; reinforcement promotes exploitation. High evaporation may forget useful trails too quickly, while too little evaporation can lock the colony into an inferior route. ACO is a heuristic and does not guarantee the global optimum after a fixed iteration count.

---

## TEE · Q5(a) PSO inspiration, parameters and one iteration [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q5a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q5(a)** [10 marks · 2024-04-17]

With reference to PSO: (1) justify its inspiration; (2) list and briefly explain its parameters; (3) minimize f (x)=3x²+4x+10 with five particles initially at −9, −6, −2, 8, 10. Assume suitable parameter values and estimate positions after one iteration.

### Answer

PSO is inspired by coordinated movement in bird flocks/fish schools. Each particle remembers its own best position and responds to the swarm’s best position. A particle is one candidate solution, not one coordinate of a single shared solution.

| Symbol | Meaning |
| --- | --- |
| xᵢ | Current position / candidate solution |
| vᵢ | Velocity / proposed movement |
| pbestᵢ | Best position visited by this particle |
| gbest | Best position visited by the swarm |
| w | Inertia, retains part of previous velocity |
| c₁, c₂ | Cognitive and social acceleration weights |
| r₁, r₂ | Random multipliers in [0,1] |
| N / limit | Number of particles / stopping condition |

#### Given

Five positions and objective as printed. The question explicitly permits parameter assumptions.

#### To find

Updated velocities, positions, fitnesses and best records after one synchronous iteration.

#### Formula and why it applies



$$
v_i^{new}=wv_i+c_1r_1(pbest_i-x_i)+c_2r_2(gbest-x_i),\quad x_i^{new}=x_i+v_i^{new}
$$



For minimization, a smaller objective is better. Freeze gbest while moving the entire swarm; update best records only after evaluating the new positions.

#### Solution

**Source / assumption note.** Assume vᵢ=0, pbestᵢ=xᵢ, w=0.5, c₁=c₂=1 and r₁=r₂=0.5 for all particles during this iteration. Other valid stated assumptions can produce other answers.

##### Step 1. Evaluate all initial candidates

| Particle | x | 3x²+4x+10 |
| --- | --- | --- |
| 1 | -9 | 243 + (-36) + 10 = 217 |
| 2 | -6 | 108 + (-24) + 10 = 94 |
| 3 | -2 | 12 + (-8) + 10 = 14 |
| 4 | 8 | 192 + (32) + 10 = 234 |
| 5 | 10 | 300 + (40) + 10 = 350 |

Smallest value is 14 at x=−2, so freeze gbest=−2.

##### Step 2. Simplify the velocity formula

Initial velocity is zero and pbest equals the current position; therefore inertia and cognitive terms are both zero.



$$
v_i^{new}=0.5(-2-x_i)
$$



##### Step 3. Calculate every new velocity and position

| Particle | Velocity calculation | New position | New fitness |
| --- | --- | --- | --- |
| 1 | 0.5×(−2−(-9))=3.5 | -9+(3.5)=-5.5 | 78.75 |
| 2 | 0.5×(−2−(-6))=2 | -6+(2)=-4 | 42 |
| 3 | 0.5×(−2−(-2))=0 | -2+(0)=-2 | 14 |
| 4 | 0.5×(−2−(8))=-5 | 8+(-5)=3 | 49 |
| 5 | 0.5×(−2−(10))=-6 | 10+(-6)=4 | 74 |

##### Step 4. Update best records

New positions are [−5.5,−4,−2,3,4], with objective values [78.75,42,14,49,74]. Every nonbest particle improves its own value, so its pbest becomes its new position; particle 3 remains −2. gbest is still −2 with value 14.

The analytical minimum is at x=−2/3 with f=26/3, but one PSO iteration has not reached it. Do not report the analytical optimum as the swarm’s achieved result.

**Final answer.** After one stated-assumption iteration: positions [−5.5,−4,−2,3,4]; swarm best x=−2, f=14.

---

## TEE · Q5(b) Brand-switching transition matrix [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q5b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q5(b)** [10 marks · 2024-04-17]

Two cold-drink brands A and B are sold. An A buyer has 80% chance of buying A next. A B buyer has 90% chance of buying B next. (I) Develop the transition matrix. (II) Interpret retention and loss, and retention and gain. (III) Draw the transition diagram.

### Answer

#### Given

A→A=.80; B→B=.90. Two exhaustive states A and B.

#### To find

Transition matrix, diagram, and correct flow interpretation.

#### Formula and why it applies

Every row lists all possible destinations from one origin; its probabilities sum to one. Missing switch probability is 1 minus retention.



$$
P_{ij}=P(\text{next}=j\mid\text{current}=i)
$$



#### Solution

##### Step 1. Find the two switch probabilities



$$
P_{AB}=1-0.8=0.2,\quad P_{BA}=1-0.9=0.1
$$



##### Step 2. Put origins in rows



$$
P=\begin{bmatrix}0.8&0.2\\0.1&0.9\end{bmatrix}
$$



Swipe across the diagram to read its labels ↔

![Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-brands.f41eb4de5f.svg)

Diagram: Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.. Labels: legacy24-brands | 0.8 | 0.2 | 0.1 | 0.9 | A | B

Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.

##### Step 3. Interpret retention, loss and gain with consistent populations

A retains 80% of its own current buyers and loses 20% to B. B retains 90% of its own buyers and loses 10% to A. A gains 10% of B’s current buyers; B gains 20% of A’s current buyers. These percentages have different denominators.



$$
A_{next}=0.8A+0.1B,\quad B_{next}=0.2A+0.9B
$$



For an illustrative 100 buyers of each brand, next counts are A=80+10=90 and B=20+90=110. Without initial counts, “A loses 10% overall” is not justified.

**Final answer.** P=[[0.8,0.2],[0.1,0.9]], with the four labeled arrows above.

---

## TEE · Q6(a) GA ranking and three crossover methods [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q6a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q6(a)** [10 marks · 2024-04-17]

A chromosome x=abcdefghij has ten genes, each a digit 0–9. Fitness f (x)=(a+b)−(c+d)+(e+f)+(g+h)−(i+j). Initial chromosomes: x₁=6541353253; x₂=8712660124; x₃=2392128546; x₄=4185209426. (1) Evaluate and rank fitness. (2) Cross the fittest two at the midpoint. (3) Cross second and third fittest using two points b and f. (4) Cross first and third using arithmetic crossover α=.5. (5) Evaluate all six offspring. (6) Has overall fitness improved?

### Answer

#### Given

Four ten-gene parents and a signed linear fitness function.

#### To find

Ranking, two children per crossover, child fitness and fair population comparison.

#### Formula and why it applies

One-point crossover swaps suffixes. Two-point crossover swaps the middle block. Arithmetic crossover takes weighted gene values.



$$
child_1=\alpha P+(1-\alpha)Q,\quad child_2=(1-\alpha)P+\alpha Q
$$



#### Solution

##### Step 1. Evaluate each signed pair sum

| Parent | (a+b)−(c+d)+(e+f)+(g+h)−(i+j) | Fitness |
| --- | --- | --- |
| x1 | 11−5+8+5−8 | 11 |
| x2 | 15−3+12+1−6 | 19 |
| x3 | 5−11+3+13−10 | 0 |
| x4 | 5−13+2+13−8 | -1 |

Descending order: x₂ (19), x₁ (11), x₃ (0), x₄ (−1).

##### Step 2. One-point crossover after gene 5

x₂=87126 | 60124; x₁=65413 | 53253. Exchange the right blocks.

| Child | Genes | Fitness |
| --- | --- | --- |
| C1 | 8712653253 | 20 |
| C2 | 6541360124 | 10 |

##### Step 3. Two-point crossover after b and after f

State cuts explicitly: positions 2 and 6. The parents are x₁=65 | 4135 | 3253 and x₃=23 | 9212 | 8546. Swap only the four-gene middle blocks.

| Child | Genes | Fitness |
| --- | --- | --- |
| C3 | 6592123253 | 0 |
| C4 | 2341358546 | 11 |

##### Step 4. Arithmetic crossover of x₂ and x₃

| Position | x₂ | x₃ | 0.5x₂+0.5x₃ |
| --- | --- | --- | --- |
| 1 | 8 | 2 | 5.0 |
| 2 | 7 | 3 | 5.0 |
| 3 | 1 | 9 | 5.0 |
| 4 | 2 | 2 | 2.0 |
| 5 | 6 | 1 | 3.5 |
| 6 | 6 | 2 | 4.0 |
| 7 | 0 | 8 | 4.0 |
| 8 | 1 | 5 | 3.0 |
| 9 | 2 | 4 | 3.0 |
| 10 | 4 | 6 | 5.0 |

At α=0.5 both children are identical. C5=C6=[5.0, 5.0, 5.0, 2.0, 3.5, 4.0, 4.0, 3.0, 3.0, 5.0]. Their fitness is 9.5.

**Source / assumption note.** Arithmetic crossover produces half-integer genes here, violating the original digit-only representation. The calculation is shown because it is explicitly asked, but an integer-only implementation needs a stated repair/rounding rule. No repair rule is supplied; rounding silently would change the problem.

##### Step 5. Show every offspring fitness calculation

| Child | Pair sums with signs | Fitness |
| --- | --- | --- |
| C1 | 15−3+11+5−8 | 20 |
| C2 | 11−5+9+1−6 | 10 |
| C3 | 11−11+3+5−8 | 0 |
| C4 | 5−5+8+13−10 | 11 |
| C5 | 10−7+7.5+7−8 | 9.5 |
| C6 | 10−7+7.5+7−8 | 9.5 |

##### Step 6. Compare averages, not totals from different population sizes



$$
\bar f_{old}=(11+19+0-1)/4=7.25
$$





$$
\bar f_{new}=((20)+(10)+(0)+(11)+(9.5)+(9.5))/6=10
$$



Best old fitness is 19; best new fitness is 20. The mean improves, but the best individual may not. A larger total alone is not proof of improvement because six children replace four parents.

**Final answer.** Original mean 7.25; new mean 60/6 = 10. Best fitness improves from 19 to 20. Arithmetic children require a representation-repair decision before an integer-only GA can use them.

---

## TEE · Q6(b) Markov property and weather path [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q6b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q6b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q6(b)** [10 marks · 2024-04-17]

Describe the concept of a Markov process and its use in probabilistic systems. For the given state diagram S, C, R: (a) today is sunny; find probability tomorrow is sunny and the next day rainy. (b) today is cloudy and yesterday rainy; find probability tomorrow is sunny.

Swipe across the diagram to read its labels ↔

![Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.](https://deep-learning-study-room.vercel.app/is2/fig/legacy24-weather.575ab21d0e.svg)

Diagram: Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.. Labels: legacy24-weather | 0.8 | 0.05 | 0.15 | 0.75 | 0.2 | 0.05 | 0.38 | 0.02 | 0.6 | Sunny | Cloudy | Rainy

Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.

### Answer

#### Given

State order Sunny, Cloudy, Rainy. The diagram gives P=[[.8,.05,.15],[.75,.2,.05],[.38,.02,.6]].

#### To find

Definition and both requested conditional probabilities.

#### Formula and why it applies

A Markov process has the memoryless property: after the current state is known, earlier states do not change the next-state probabilities. It models time evolution through a state distribution and transition law.



$$
P(X_{t+1}\mid X_t,X_{t-1},\ldots)=P(X_{t+1}\mid X_t)
$$



#### Solution

##### Step 1. Read origin row and destination column



$$
P=\begin{bmatrix}0.8&0.05&0.15\\0.75&0.2&0.05\\0.38&0.02&0.6\end{bmatrix}
$$



For example P(Sunny→Rainy)=0.15 while P(Rainy→Sunny)=0.38; arrow directions cannot be interchanged. Each row sums to 1.

##### Step 2. Multiply along the specified S→S→R path



$$
P(X_{t+1}=S,X_{t+2}=R\mid X_t=S)=P_{SS}P_{SR}=0.8\times0.15=0.12
$$



Do not sum all two-day routes ending in rain: tomorrow is specifically required to be sunny.

##### Step 3. Use the current cloudy state in part (b)



$$
P(X_{t+1}=S\mid X_t=C,X_{t-1}=R)=P_{CS}=0.75
$$



Yesterday’s rain adds no further information under the stated Markov model. Such models are used for weather regimes, brand switching, queue states and reliability; the chosen state must capture the relevant predictive information.

**Final answer.** (a) 0.12; (b) 0.75.

---

## TEE · Q7(a) Bayes bag posterior [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q7a

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(a)** [5 marks · 2024-04-17]

Bag B₁ contains 3 white and 7 black balls. Bag B₂ contains 5 white and 3 black balls. A ball drawn from one of the bags is white. Find the probability it came from B₁.

### Answer

#### Given

P(W|B₁)=3/10; P(W|B₂)=5/8.

#### To find

P(B₁|W).

#### Formula and why it applies

Bayes reverses the condition. Weight the likelihood for each bag by its prior chance of being chosen, then normalize over all ways to obtain a white ball.



$$
P(B_1\mid W)=\frac{P(W\mid B_1)P(B_1)}{P(W\mid B_1)P(B_1)+P(W\mid B_2)P(B_2)}
$$



#### Solution

**Source / assumption note.** The bag-selection prior is not stated. Assume each bag is equally likely, P(B₁)=P(B₂)=1/2. If bags are chosen by a different rule, this posterior changes.

##### Step 1. Calculate both white-event contributions



$$
P(W,B_1)=\frac3{10}\frac12=\frac3{20}=0.15
$$





$$
P(W,B_2)=\frac58\frac12=\frac5{16}=0.3125
$$



##### Step 2. Find total white probability



$$
P(W)=\frac3{20}+\frac5{16}=\frac{12+25}{80}=\frac{37}{80}=0.4625
$$



##### Step 3. Normalize the B₁ contribution



$$
P(B_1\mid W)=\frac{3/20}{37/80}=\frac3{20}\frac{80}{37}=\frac{12}{37}\approx0.324324
$$



**Final answer.** Under equal bag-selection priors, 12/37 ≈ 0.324324.

---

## TEE · Q7(b) Max–min relational composition [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q7b

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(b)** [5 marks · 2024-04-17]

For the following fuzzy relations R and S, obtain T using max–min composition.



$$
R=\begin{bmatrix}0.6&0.3\\0.2&0.5\end{bmatrix},\quad S=\begin{bmatrix}1&0.4&0.5\\0.8&0.3&0.8\end{bmatrix}
$$



### Answer

#### Given

R is 2×2 and S is 2×3.

#### To find

A 2×3 relation T connecting the first and last universes.

#### Formula and why it applies

Use a row of R and a column of S. The common middle dimension is 2. Take two minima, then the larger of them.



$$
T_{ij}=\max_{k=1,2}\min(R_{ik},S_{kj})
$$



#### Solution

##### Step 1. Verify dimensions

(2×2) composed with (2×3) gives 2×3. Ordinary dot-product addition is not used.

##### Step 2. Calculate every output cell

| Output cell | Compare every matching middle index | Take the largest result |
| --- | --- | --- |
| (1, 1) | min(0.6, 1) = 0.6, min(0.3, 0.8) = 0.3 | max(0.6, 0.3) = 0.6 |
| (1, 2) | min(0.6, 0.4) = 0.4, min(0.3, 0.3) = 0.3 | max(0.4, 0.3) = 0.4 |
| (1, 3) | min(0.6, 0.5) = 0.5, min(0.3, 0.8) = 0.3 | max(0.5, 0.3) = 0.5 |
| (2, 1) | min(0.2, 1) = 0.2, min(0.5, 0.8) = 0.5 | max(0.2, 0.5) = 0.5 |
| (2, 2) | min(0.2, 0.4) = 0.2, min(0.5, 0.3) = 0.3 | max(0.2, 0.3) = 0.3 |
| (2, 3) | min(0.2, 0.5) = 0.2, min(0.5, 0.8) = 0.5 | max(0.2, 0.5) = 0.5 |

##### Step 3. Write the final relation



$$
T=\begin{bmatrix}0.6&0.4&0.5\\0.5&0.3&0.5\end{bmatrix}
$$



**Final answer.** T=[[0.6,0.4,0.5],[0.5,0.3,0.5]].

---

## TEE · Q7(c) Point versus uniform crossover [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q7c

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(c)** [5 marks · 2024-04-17]

Differentiate between point crossover and uniform crossover.

### Answer

**Crossover** recombines genes from two parents to form children. Its purpose is to combine useful building blocks; mutation introduces an independent local change.

| Aspect | Point crossover | Uniform crossover |
| --- | --- | --- |
| Selection mechanism | Choose one or more cut locations; exchange contiguous segments | Choose parent at each position using a binary mask |
| Linkage | Tends to preserve neighboring gene blocks | Mixes genes more independently; may break useful adjacent blocks |
| Control | Number and position of cut points | Mask / per-gene mixing probability |
| Example parents | P1=111100, P2=000011 | Same parents |
| Rule | Cut after position 3: 111|100 and 000|011 | Mask 101010: child 1 takes P1 where mask=1, otherwise P2 |
| Children | 111011 and 000100 | 101001 and 010110 |

For uniform child 1, positions 1–6 are 1(fromP 1),0(P2),1(P1),0(P2),0(P1),1(P2). Child 2 uses the complementary choices. Both methods preserve chromosome length. For permutation encodings such as TSP, naive point/uniform crossover can repeat a city, so use a permutation-preserving method or a declared repair.

---

## TEE · Q7(d) Applications of reinforcement learning [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/papers/paper-2024-final--q7d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/papers/paper-2024-final/q7d

Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.

**Question. Q7(d)** [5 marks · 2024-04-17]

Discuss the applications of reinforcement learning.

### Answer

**Reinforcement learning** learns a policy for sequential decisions by interacting with an environment and maximizing expected cumulative reward. Unlike supervised learning, each state need not have a supplied correct action label.

| Application | State and action | Reward / reason RL fits |
| --- | --- | --- |
| Robot navigation | State: pose/obstacles; action: movement | Reward for reaching goal, penalties for collision; actions affect future states |
| Game playing | State: board; action: legal move | Win/loss and long-term strategy; a weak immediate move may yield a later win |
| Traffic signal control | State: queue lengths; action: phase/timing | Reduced delay and congestion over time |
| Resource scheduling | State: jobs/load; action: allocation | Throughput and latency rewards under changing demand |
| Recommendation sequences | State: interaction history; action: next item | Long-term engagement rather than only one click |

**One worked interpretation:** a delivery robot sees state “near junction”, chooses left/right, receives −1 per travel step and +20 on successful delivery. It learns a route balancing path length and successful arrival, using a discount factor for later rewards. Exploration must be controlled when real actions are costly or unsafe; a simulator can provide initial experience. RL is appropriate when actions influence subsequent opportunities, not merely for every static prediction task.

---

## TEE · Q1(a) Joint probability table [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q1a

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. A supermarket recorded the joint distribution of Product type (Y: premium = 1, regular = 0), Payment mode (X: credit = 1, debit = 0) and Gender (Z: female = 1, male = 0). (a) If a customer bought a premium item, find the probability that (1) they are female, (2) they paid by credit card. (b) Find (1) P(premium) and (2) P(credit card). (c) Given a male customer paid by debit card, find the probability he bought a regular item.** [5 marks]

### Answer

#### Given

The printed eight entries are reproduced below. Their total is 1.002, not 1. Therefore the table is inconsistent as a probability distribution.

|  | Credit, female | Credit, male | Debit, female | Debit, male |
| --- | --- | --- | --- | --- |
| **Premium (Y=1)** | 0.08 | 0.10 | 0.072 | 0.05 |
| **Regular (Y=0)** | 0.10 | 0.15 | 0.25 | 0.20 |

#### To find

The five requested probabilities, stating how the inconsistent data are interpreted.

#### Formula and why it applies

For this worked solution, treat all printed entries as nonnegative weights and normalise by their total 1.002. This preserves the printed ratios. It is a declared interpretation, not a claim about the examiner’s intended correction.



$$
P(E)=\frac{\text{sum of weights for }E}{\text{sum of all weights}}
$$





$$
P(A\mid E)=\frac{\text{sum of weights for }A\cap E}{\text{sum of weights for }E}
$$



#### Solution

##### Step 1. Validate the full table



$$
0.08+0.10+0.072+0.05+0.10+0.15+0.25+0.20=1.002
$$



Use total weight 1.002 consistently for unconditional probabilities.

##### Step 2. Premium row total



$$
w(premium)=0.08+0.10+0.072+0.05=0.302
$$



##### Step 3. Female given premium



$$
P(female\mid premium)=\frac{0.08+0.072}{0.302}=\frac{0.152}{0.302}\approx0.503311
$$



##### Step 4. Credit given premium



$$
P(credit\mid premium)=\frac{0.08+0.10}{0.302}=\frac{0.18}{0.302}\approx0.596026
$$



##### Step 5. Normalised premium marginal



$$
P(premium)=\frac{0.302}{1.002}\approx0.301397
$$



##### Step 6. Normalised credit marginal



$$
P(credit)=\frac{0.08+0.10+0.10+0.15}{1.002}=\frac{0.43}{1.002}\approx0.429142
$$



##### Step 7. Regular given male and debit



$$
P(regular\mid male,debit)=\frac{0.20}{0.05+0.20}=0.8
$$



**Final answer.** Under common normalisation: (a) 0.503311 and 0.596026; (b) 0.301397 and 0.429142; (c) 0.8.

**Alternative correction:** if 0.072 is corrected to 0.070, the total becomes 1 and the corresponding answers are (a) 0.50 and 0.60; (b) 0.30 and 0.43; (c) 0.8. This agrees with the interpretation used in the supplied key. State the correction; do not call raw totals 0.302 and 0.43 valid marginals of the original inconsistent table.

---

## TEE · Q1(b) Applications of ACO [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q1b

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**List the applications of Ant Colony Optimization and explain any one application in detail.** [5 marks]

### Answer

### Definition (1 line)

Ant Colony Optimization is a probabilistic, population-based metaheuristic (Dorigo, 1992) in which artificial ants build solutions on a graph and communicate through pheromone trails. In the update rule used here, evaporation reduces all stored trails; deposits then reinforce edges of selected tours according to solution quality. Evaporation does not occur only on poor paths.

### Applications

1. **Travelling salesman problem**: shortest tour visiting every city once.
2. **Vehicle routing**: delivery routes for a fleet with capacity and time windows (minimising distance, time, fuel).
3. **Network routing**: adaptive routing of data packets in communication and sensor networks (AntNet).
4. **Job-shop and project scheduling**: assigning jobs to machines to minimise completion time.
5. **Image processing**: edge detection, with ants moving over pixel-intensity graphs.
6. **Assignment problems**: quadratic assignment, timetabling, graph colouring.
7. **Feature selection and data mining**: Ant-Miner for classification rules.
8. **Load balancing** in distributed systems and cloud task allocation.

### One application in detail: vehicle routing (or TSP)

1. **Graph.** Depot and customers are nodes; travel times or distances are edge weights.
2. **Ants.** Each ant builds a complete set of routes. From its current customer it chooses the next with probability 

$$
\propto\tau_{ij}\,(1/d_{ij})
$$

, skipping customers already served or that would exceed the vehicle capacity; when the vehicle is full it returns to the depot.
3. **Evaluation.** Total distance (plus penalties for late deliveries).
4. **Learning.** Pheromone evaporates everywhere and is added in proportion to 

$$
Q/L
$$

 on the routes of good solutions, so short connections are reinforced.
5. **Result.** Repeated iterations search for low-cost routes; finite-run convergence to the optimum is not guaranteed. Companies use this for parcel delivery, waste collection and school-bus routing.

### Advantages and limitations

| Advantages | Limitations |
| --- | --- |
| Naturally suited to graph and routing problems | Several parameters to tune (α, β, ρ, number of ants) |
| Can share useful route information and adapt search to changing graphs | Convergence time is uncertain; may stagnate on a sub-optimal path |
| Positive feedback + parallel ants | Theoretical analysis is difficult |

**Yaad rakho:** ACO = “raaste wale problems” (TSP, routing, scheduling). PSO = “numbers wale problems” (continuous function, weights).

---

## TEE · Q1(c) Fuzzy set operations [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q1c

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Consider two fuzzy sets X = {(c1, 0.6), (c2, 0.8), (c3, 0.3), (c4, 0.5), (c5, 0.7)} and Y = {(c1, 0.4), (c2, 0.5), (c3, 0.9), (c4, 0.6), (c5, 0.2)}. Find 1) X ∪ Y 2) X ∩ Y 3) ¬X ∪ ¬Y 4) ¬X ∩ ¬Y.** [5 marks]

### Answer

#### Given

The aligned X and Y memberships printed in this question.

#### To find

The four requested membership lists in the original element order.

#### Formula and why it applies

Use max for OR, min for AND, and 1−μ for NOT.



$$
\mu_{X\cup Y}=\max(\mu_X,\mu_Y),\quad\mu_{X\cap Y}=\min(\mu_X,\mu_Y)
$$



Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.

#### Solution

##### Step 1. Complements

¬X = {0.4, 0.2, 0.7, 0.5, 0.3}; ¬Y = {0.6, 0.5, 0.1, 0.4, 0.8}.

##### Step 2. Table

|  | c1 | c2 | c3 | c4 | c5 |
| --- | --- | --- | --- | --- | --- |
| X | 0.6 | 0.8 | 0.3 | 0.5 | 0.7 |
| Y | 0.4 | 0.5 | 0.9 | 0.6 | 0.2 |
| **X ∪ Y = max** | 0.6 | 0.8 | 0.9 | 0.6 | 0.7 |
| **X ∩ Y = min** | 0.4 | 0.5 | 0.3 | 0.5 | 0.2 |
| **¬X ∪ ¬Y** | 0.6 | 0.5 | 0.7 | 0.5 | 0.8 |
| **¬X ∩ ¬Y** | 0.4 | 0.2 | 0.1 | 0.4 | 0.3 |

##### Step 3. Check with De Morgan's law

¬X ∪ ¬Y must equal 1 − (X ∩ Y) = {0.6, 0.5, 0.7, 0.5, 0.8} ✓, and ¬X ∩ ¬Y must equal 1 − (X ∪ Y) = {0.4, 0.2, 0.1, 0.4, 0.3} ✓.

**Final answer.** X ∪ Y = {(c1,0.6),(c2,0.8),(c3,0.9),(c4,0.6),(c5,0.7)}; X ∩ Y = {(c1,0.4),(c2,0.5),(c3,0.3),(c4,0.5),(c5,0.2)}; ¬X ∪ ¬Y = {(c1,0.6),(c2,0.5),(c3,0.7),(c4,0.5),(c5,0.8)}; ¬X ∩ ¬Y = {(c1,0.4),(c2,0.2),(c3,0.1),(c4,0.4),(c5,0.3)}.

Official marking: 1 + 1 + 1.5 + 1.5.

## Calculate every element separately

### Element c1



$$
\neg X:1-0.6=0.4\qquad\neg Y:1-0.4=0.6
$$





$$
X\cup Y:\max(0.6,0.4)=0.6
$$





$$
X\cap Y:\min(0.6,0.4)=0.4
$$





$$
\neg X\cup\neg Y:\max(0.4,0.6)=0.6
$$





$$
\neg X\cap\neg Y:\min(0.4,0.6)=0.4
$$



### Element c2



$$
\neg X:1-0.8=0.2\qquad\neg Y:1-0.5=0.5
$$





$$
X\cup Y:\max(0.8,0.5)=0.8
$$





$$
X\cap Y:\min(0.8,0.5)=0.5
$$





$$
\neg X\cup\neg Y:\max(0.2,0.5)=0.5
$$





$$
\neg X\cap\neg Y:\min(0.2,0.5)=0.2
$$



### Element c3



$$
\neg X:1-0.3=0.7\qquad\neg Y:1-0.9=0.1
$$





$$
X\cup Y:\max(0.3,0.9)=0.9
$$





$$
X\cap Y:\min(0.3,0.9)=0.3
$$





$$
\neg X\cup\neg Y:\max(0.7,0.1)=0.7
$$





$$
\neg X\cap\neg Y:\min(0.7,0.1)=0.1
$$



### Element c4



$$
\neg X:1-0.5=0.5\qquad\neg Y:1-0.6=0.4
$$





$$
X\cup Y:\max(0.5,0.6)=0.6
$$





$$
X\cap Y:\min(0.5,0.6)=0.5
$$





$$
\neg X\cup\neg Y:\max(0.5,0.4)=0.5
$$





$$
\neg X\cap\neg Y:\min(0.5,0.4)=0.4
$$



### Element c5



$$
\neg X:1-0.7=0.3\qquad\neg Y:1-0.2=0.8
$$





$$
X\cup Y:\max(0.7,0.2)=0.7
$$





$$
X\cap Y:\min(0.7,0.2)=0.2
$$





$$
\neg X\cup\neg Y:\max(0.3,0.8)=0.8
$$





$$
\neg X\cap\neg Y:\min(0.3,0.8)=0.3
$$



---

## TEE · Q1(d) Brand-switching Markov chain [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q1d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q1d

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Users switch between Brand X and Brand Y each year: 25% of X users switch to Y and 75% stay; 40% of Y users switch to X and 60% stay. (a) Write the transition probability matrix. (b) Draw the state transition diagram.** [5 marks]

### Answer

#### Given

All transition values are given in the full question. State order: X, Y.

#### To find

The transition matrix and state diagram.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.

#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | X | Y |
| --- | --- | --- |
| X | 0.75 | 0.25 |
| Y | 0.4 | 0.6 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_brand.c2c4be3e6a.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Brand switching each year | 0.25 | 0.4 | 0.75 | 0.6 | X | Y

Each arrow is labelled with the probability of that transition.

**Final answer.** The transition matrix and state diagram are given above.

---

## TEE · Q2(a) PSO, one iteration [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q2a

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Maximize 

$$
F(x_1,x_2)=2x_1^2-3x_1x_2+x_2^2+5x_1+2x_2+7
$$

 using Particle Swarm Optimization. 

$$
X=\begin{bmatrix}2.5&-3.0\\3.5&-1.5\end{bmatrix},\;V=\begin{bmatrix}0.2&0.3\\0.1&0.25\end{bmatrix}
$$

. Take 

$$
W=0.9,\;c_1=c_2=1.5,\;r_1=0.5949,\;r_2=0.0855
$$

. Optimize and give the solution after 1 iteration showing the step-by-step process.** [10 marks]

### Answer

#### Given

Particle 1: 

$$
x=(2.5,\,-3.0)
$$

, 

$$
v=(0.2,\,0.3)
$$

. Particle 2: 

$$
x=(3.5,\,-1.5)
$$

, 

$$
v=(0.1,\,0.25)
$$

.



$$
c_1r_1=1.5\times0.5949=0.89235,\qquad c_2r_2=1.5\times0.0855=0.12825
$$



#### To find

Fitness, pbest, gbest; new velocities and positions; updated pbest and gbest.

#### Formula and why it applies



$$
v_{ij}\leftarrow wv_{ij}+c_1r_1(p^b_{ij}-x_{ij})+c_2r_2(p^g_j-x_{ij}),\qquad x_{ij}\leftarrow x_{ij}+v_{ij}
$$



Each particle is pulled by its own memory and by the swarm's best; we maximise, so the larger 

$$
F
$$

 is better.

#### Solution

##### Step 1. Fitness of particle 1



$$
F(2.5,-3)=2(6.25)-3(2.5)(-3)+9+5(2.5)+2(-3)+7=12.5+22.5+9+12.5-6+7=57.5
$$



##### Step 2. Fitness of particle 2



$$
F(3.5,-1.5)=2(12.25)-3(3.5)(-1.5)+2.25+17.5-3+7=24.5+15.75+2.25+17.5-3+7=64
$$



##### Step 3. pbest and gbest

| Particle | Position | F | pbest |
| --- | --- | --- | --- |
| 1 | (2.5, −3.0) | 57.5 | (2.5, −3.0) |
| 2 | (3.5, −1.5) | 64 | (3.5, −1.5) |

No previous iteration, so pbest = current position. Largest fitness is 64, so **gbest = (3.5, −1.5)**.

##### Step 4. Velocity and position of particle 1



$$
v_{11}=0.9(0.2)+0.89235(2.5-2.5)+0.12825(3.5-2.5)=0.18+0+0.12825=0.30825
$$





$$
x_{11}=2.5+0.30825=2.80825
$$





$$
v_{12}=0.9(0.3)+0.89235(0)+0.12825(-1.5-(-3.0))=0.27+0.192375=0.462375
$$





$$
x_{12}=-3.0+0.462375=-2.537625
$$



##### Step 5. Velocity and position of particle 2 (it is gbest, so both pull terms are 0)



$$
v_{21}=0.9(0.1)+0+0=0.09,\qquad x_{21}=3.5+0.09=3.59
$$





$$
v_{22}=0.9(0.25)+0+0=0.225,\qquad x_{22}=-1.5+0.225=-1.275
$$



##### Step 6. New fitness



$$
F(2.80825,-2.537625)=15.772536+21.378856+6.439541+14.04125-5.07525+7=59.5569
$$





$$
F(3.59,-1.275)=25.7762+13.73175+1.625625+17.95-2.55+7=63.5336
$$



##### Step 7. Update pbest and gbest

| Particle | New position | New F | Old pbest F | pbest after iteration |
| --- | --- | --- | --- | --- |
| 1 | (2.80825, −2.537625) | 59.5569 | 57.5 | (2.80825, −2.537625) — improved |
| 2 | (3.59, −1.275) | 63.5336 | 64 | (3.5, −1.5) — kept |

The best pbest fitness is still 64, so gbest stays (3.5, −1.5).

**Final answer.** 

$$
V=\begin{bmatrix}0.30825&0.462375\\0.09&0.225\end{bmatrix}
$$

, 

$$
X=\begin{bmatrix}2.80825&-2.537625\\3.59&-1.275\end{bmatrix}
$$

. After one iteration particle 1 improved to F = 59.5569; the best solution so far is gbest = (3.5, −1.5) with F = 64.

Official key: fitness and gbest (5 marks), velocity and position updates (5 marks). The calculations above use the question data. The key's summary matrix writes 0.462 in place of 2.808 for 

$$
x_{11}
$$

; that is a copying slip.

---

## TEE · Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q2b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q2b

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**With reference to the Gaussian Mixture Model (GMM): compare GMM with the k-means algorithm; derive the equation for the log-likelihood function; state the number of parameters to be computed if K = 5.** [10 marks]

### Answer

## Read the derivation’s symbols first

“i.i.d.” means the observations are modelled as independent draws from the same distribution. The product Π runs over observations; the inner sum Σ runs over components. λki in some notes is the same responsibility that other sections call γik. A superscript i here labels the observation, not an exponent.

Jensen’s inequality gives a lower bound on the log of the component sum. EM chooses responsibilities making that bound touch the current likelihood, then updates the parameters to maximise the bound with those responsibilities fixed. This explains the two alternating steps; λ values are not arbitrary new model parameters.

| Parameter | Number in a 1D K-component GMM | Why |
| --- | --- | --- |
| Means | K | One centre for each component |
| Variances | K | One spread for each component |
| Independent mixing weights | K−1 | The last weight is 1 minus the others |
| Total | 3K−1 | K+K+(K−1) |

For K=2, choose μ₁,μ₂,σ₁²,σ₂² and π₁: five free numbers. Then π₂=1−π₁. For K=5, 5+5+4=14. In 2D with a full covariance matrix, each component instead has two means and three independent covariance entries (two variances and one shared off-diagonal covariance). Five such components have 5×(2+3)+4=29 free parameters.

### 1. GMM versus k-means

| Aspect | k-means | GMM |
| --- | --- | --- |
| Assignment | Hard: each point in exactly one cluster | Soft: probability 

$$
\lambda_k^i
$$

 of belonging to each cluster |
| Model | Geometric: nearest centroid | Probabilistic generative model 

$$
\sum_k\pi_k\mathcal N(\mu_k,\Sigma_k)
$$

 |
| Cluster shape | Spherical, similar size | Elliptical, any size/orientation; overlapping clusters |
| Parameters | K centroids | Weights, means, covariances (1-D: 3K − 1) |
| Algorithm / objective | Assign–update; minimise squared distances | EM; maximise log-likelihood |
| Output | Hard labels and fitted centroids | Labels, membership probabilities and a density (useful for anomaly detection) |
| Relation | The hard-assignment, equal spherical variance, small-variance limit of a Gaussian-mixture objective leads to the k-means objective. Ordinary finite-variance EM is not the same algorithm as k-means. Both need K in advance and depend on initialisation. | |

### 2. Derivation of the log-likelihood

**Step 1. Model.** Each point is generated by choosing component k with probability 

$$
\pi_k
$$

 and drawing 

$$
x_i\sim\mathcal N(\mu_k,\sigma_k^2)
$$

, so its density is 

$$
f_{mix}(x_i)=\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)
$$

.

**Step 2. Likelihood.** Points are i.i.d., so the likelihood is a product (θ = all parameters):



$$
L(\theta)=\prod_{i=1}^{n}\Big[\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big]
$$



**Step 3. Log-likelihood.** Logs turn the product into a sum:



$$
\log L(\theta)=\sum_{i=1}^{n}\log\Big(\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big)
$$



**Step 4. Why it cannot be solved directly.** The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.

**Step 5. Jensen's inequality.** log is concave, so for weights 

$$
\lambda_k\ge0,\;\sum\lambda_k=1
$$

: 

$$
\log\big(\sum_k\lambda_ka_k\big)\ge\sum_k\lambda_k\log a_k
$$

. Introduce 

$$
\lambda_k^i
$$

 for every point (

$$
\sum_k\lambda_k^i=1
$$

), multiply and divide inside the log:



$$
\log L(\theta)=\sum_i\log\Big(\sum_k\lambda_k^i\,\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}\Big)\;\ge\;\sum_i\sum_k\lambda_k^i\log\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}
$$



**Step 6. Estimation (EM).** Maximise the lower bound alternately. Fixing θ gives the E-step 

$$
\lambda_k^i=\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)/\sum_l\pi_l\mathcal N(x_i\mid\mu_l,\sigma_l^2)
$$

. Fixing λ and differentiating (with a Lagrange multiplier for 

$$
\sum\pi_k=1
$$

) gives the M-step:



$$
\hat\mu_k=\frac{\sum_i\lambda_k^ix_i}{\sum_i\lambda_k^i},\qquad\hat\sigma_k^2=\frac{\sum_i\lambda_k^i(x_i-\hat\mu_k)^2}{\sum_i\lambda_k^i},\qquad\hat\pi_k=\frac{\sum_i\lambda_k^i}{n}
$$



### 3. Number of parameters for K = 5

The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:



$$
2K+(K-1)=3K-1=3(5)-1=\mathbf{14}
$$



(5 means + 5 variances + 4 free weights, since the 5 weights must add to 1.) In two dimensions with full covariance it would be 29.

**Slide note.** One slide puts the convex inequality under the “concave” heading. Correct: log is *concave*, so 

$$
f(\sum\lambda a)\ge\sum\lambda f(a)
$$

 (≥, not >).

---

## TEE · Q3(a) Bayesian network: wet grass given no rain [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q3a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q3a

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Cloudy → Sprinkler, Cloudy → Rain, Sprinkler and Rain → Wet Grass. P(Cloudy) = 0.5; P(Sprinkler | C) = 0.10, P(Sprinkler | ¬C) = 0.50; P(Rain | C) = 0.80, P(Rain | ¬C) = 0.20; P(Wet | S, R) = 0.99, P(Wet | S, ¬R) = 0.90, P(Wet | ¬S, R) = 0.90, P(Wet | ¬S, ¬R) = 0.01. Calculate the probability of the grass being wet given it doesn't rain.** [10 marks]

### Answer

The following table enumerates the values of Cloudy and Sprinkler that were not fixed by the question. Two Boolean choices give four rows: true/true, true/false, false/true, false/false. Each row is one mutually exclusive complete case. Read the CPT entry using that row’s parent values, multiply its factors, and add the resulting row weights. The denominator must include all cases matching the evidence, including both possible values of the queried outcome.

#### Given

C→S, C→R, (S,R)→W. Root and conditional probabilities are listed in the question. Evidence R=false.

#### To find

P(W=true | R=false). Hidden variables C and S must be summed out.

#### Formula and why it applies

Use the network joint and divide by the evidence probability.



$$
P(W\mid\neg R)=\frac{\sum_{c,s}P(c)P(s\mid c)P(\neg R\mid c)P(W\mid s,\neg R)}{\sum_cP(c)P(\neg R\mid c)}
$$



#### Solution

Swipe across the diagram to read its labels ↔

![Final 2025 Q3a: sprinkler network](https://deep-learning-study-room.vercel.app/is2/fig/bn_sprinkler.a251583272.svg)

Diagram: Final 2025 Q3a: sprinkler network. Labels: Final 2025 Q3a: sprinkler network | Cloudy | P(C) = 0.5 | Sprinkler | P(S|C) = 0.1, P(S|¬C) = 0.5 | Rain | P(R|C) = 0.8, P(R|¬C) = 0.2 | Wet grass | P(W|S,R): .99 · .90 · .90 · .01 | (TT · TF · FT · FF)

##### Step 1. Joint by the chain rule



$$
P(C,S,R,W)=P(C)\,P(S\mid C)\,P(R\mid C)\,P(W\mid S,R)
$$



##### Step 2. Sum over C and S with R = false, W = true

| C | S | P(C) | P(S|C) | P(¬R|C) | P(W|S,¬R) | Product |
| --- | --- | --- | --- | --- | --- | --- |
| T | T | 0.5 | 0.1 | 0.2 | 0.90 | 0.0090 |
| T | F | 0.5 | 0.9 | 0.2 | 0.01 | 0.0009 |
| F | T | 0.5 | 0.5 | 0.8 | 0.90 | 0.1800 |
| F | F | 0.5 | 0.5 | 0.8 | 0.01 | 0.0020 |
| **P(W, ¬R)** | | | | | | **0.1919** |

##### Step 3. Evidence



$$
P(\lnot R)=P(C)P(\lnot R\mid C)+P(\lnot C)P(\lnot R\mid\lnot C)=0.5(0.2)+0.5(0.8)=0.5
$$



##### Step 4. Divide



$$
P(W\mid\lnot R)=\frac{0.1919}{0.5}=0.3838
$$



**Final answer.** P(grass wet | no rain) ≈ **0.384**. Without rain, the grass is wet mainly when the sprinkler runs (more likely on non-cloudy days).

**Keep the requested conditional probability separate.** The supplied key discusses P(Wet) and P(Rain | Wet), whereas this question asks P(Wet | no rain). The answer to the printed question is 0.3838. For comparison, the exact marginal from the printed CPT is calculated below; it is not 0.6505.

#### Optional comparison: calculate P(Wet) from the same network

The four no-rain cases already total 0.1919. Now add the four rain cases, keeping the same Cloudy/Sprinkler order.



$$
P(W,R)=0.5(0.1)(0.8)(0.99)+0.5(0.9)(0.8)(0.90)+0.5(0.5)(0.2)(0.99)+0.5(0.5)(0.2)(0.90)
$$





$$
P(W,R)=0.0396+0.324+0.0495+0.045=0.4581
$$





$$
P(W)=P(W,R)+P(W,\neg R)=0.4581+0.1919=0.6500
$$





$$
P(R\mid W)=\frac{0.4581}{0.6500}\approx0.704769231
$$



**Meaning:** the unconditional chance of Wet is 0.65, the chance of Rain among wet cases is about 0.704769, and the requested chance of Wet among no-rain cases is 0.3838. These are three different questions.

**Trap.** Do not plug in the marginal P(Sprinkler) = 0.3; sprinkler and rain both depend on Cloudy, so you must sum over Cloudy (given no rain, P(S) = 0.42).

---

## TEE · Q3(b) Fuzzy loan-approval system [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q3b

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**A bank uses fuzzy decision support with Credit Score and Income Stability, both on 1–100. Loan Approval is a score on 1–100 with labels Reject, Consider and Approve. Define triangular membership functions, construct nine rules, explain Mamdani inference and defuzzify for Credit Score=55 and Income Stability=35.** [10 marks]

### Answer

#### Given

| Variable | Crisp value |
| --- | --- |
| Credit Score | 55 |
| Income Stability | 35 |

The question asks us to design the membership functions. This solution chooses Low=Tri(1,25,50), Medium=Tri(25,50,75), High=Tri(50,75,100) for both inputs. Output labels use the same triangles in their respective order. These are explicit design choices, not additional printed givens.

#### To find

A complete stated design and its continuous Mamdani centroid.

#### Formula and why it applies

Use min for AND and implication, max for aggregation and the true area centroid of the resulting shape. A peak-only weighted average is a different defuzzifier.



$$
z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

##### Step 1. Specify the membership functions

| Input / output position | Triangle | Peak |
| --- | --- | --- |
| Low / Reject | (1,25,50) | 25 |
| Medium / Consider | (25,50,75) | 50 |
| High / Approve | (50,75,100) | 75 |

Use 0 outside each triangle, the rising fraction before the peak and the falling fraction after it. This design is evaluated at the requested input; a deployed controller would also need coverage/fallback at all boundary values.

##### Step 2. Write all nine rules

| Credit Score / Income Stability | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Reject | Reject | Consider |
| Medium | Reject | Consider | Approve |
| High | Consider | Approve | Approve |

Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.

##### Step 3. Fuzzify Credit Score = 55



$$
\mu_{Low}(55)=0
$$





$$
\mu_{Medium}(55)=\frac{75-55}{75-50}=0.8
$$





$$
\mu_{High}(55)=\frac{55-50}{75-50}=0.2
$$



##### Step 4. Fuzzify Income Stability = 35



$$
\mu_{Low}(35)=\frac{50-35}{50-25}=0.6
$$





$$
\mu_{Medium}(35)=\frac{35-25}{50-25}=0.4
$$





$$
\mu_{High}(35)=0
$$



##### Step 5. Evaluate all rules and aggregate matching consequents

| Credit Score | Income Stability | Firing strength | Consequent |
| --- | --- | --- | --- |
| Low | Low | min(0,0.6) = 0 | Reject |
| Low | Medium | min(0,0.4) = 0 | Reject |
| Low | High | min(0,0) = 0 | Consider |
| Medium | Low | min(0.8,0.6) = 0.6 | Reject |
| Medium | Medium | min(0.8,0.4) = 0.4 | Consider |
| Medium | High | min(0.8,0) = 0 | Approve |
| High | Low | min(0.2,0.6) = 0.2 | Consider |
| High | Medium | min(0.2,0.4) = 0.2 | Approve |
| High | High | min(0.2,0) = 0 | Approve |

Aggregated label strengths: Reject = 0.6, Consider = 0.4, Approve = 0.2.



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



##### Step 6. Draw the aggregated output

Swipe across the diagram to read its labels ↔

![The shaded upper envelope counts any overlap only once.](https://deep-learning-study-room.vercel.app/is2/fig/v2_loan_aggregate.2c5ffa32a7.svg)

Diagram: The shaded upper envelope counts any overlap only once.. Labels: Chosen triangular output sets and their max-aggregate | 0 | 0.5 | 1 | 1 | 25 | 50 | 75 | 100 | μ | Output score | Reject | Consider | Approve | centroid ≈ 42.78

The shaded upper envelope counts any overlap only once.

##### Step 7. Calculate area and moment of each straight-line strip

For a strip from a to b with endpoint heights u and v, its trapezoid area is A. Its first moment M is the integral of z times the line height.



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}\big[(2a+b)u+(a+2b)v\big]
$$



| a | b | u | v | Area A | Moment M |
| --- | --- | --- | --- | --- | --- |
| 1 | 15.4 | 0 | 0.6 | 4.32 | 45.792 |
| 15.4 | 25 | 0.6 | 0.6 | 5.76 | 116.352 |
| 25 | 35 | 0.6 | 0.6 | 6 | 180 |
| 35 | 40 | 0.6 | 0.4 | 2.5 | 93.333333333 |
| 40 | 50 | 0.4 | 0.4 | 4 | 180 |
| 50 | 55 | 0.4 | 0.4 | 2 | 105 |
| 55 | 65 | 0.4 | 0.4 | 4 | 240 |
| 65 | 70 | 0.4 | 0.2 | 1.5 | 100.833333333 |
| 70 | 75 | 0.2 | 0.2 | 1 | 72.5 |
| 75 | 95 | 0.2 | 0.2 | 4 | 340 |
| 95 | 100 | 0.2 | 0 | 0.5 | 48.333333333 |

##### Step 8. Divide total moment by total area



$$
\sum A=35.58
$$





$$
\sum M=1522.144
$$





$$
z^*=\frac{1522.144}{35.58}\approx42.780888139
$$



**Final answer.** For these stated triangles and rules, the centroid is 42.780888139. This is a fuzzy suitability score; the category memberships can be evaluated at this score. The model alone is not a complete loan-decision policy.

Because the paper asks for a design, a different explicitly specified membership/rule system can yield a different numerical output. Explain the choices and use the chosen defuzzification method consistently; no particular examiner mark outcome is promised.

## How the centroid table’s breakpoints are obtained

For each output triangle, solve “line height = clip height”. Reject is clipped at .6: rising endpoint 1+.6(25−1)=15.4 and falling endpoint 50−.6(50−25)=35. Consider is clipped at .4: endpoints 25+.4(50−25)=35 and 75−.4(75−50)=65. Approve is clipped at .2: endpoints 50+.2(75−50)=55 and 100−.2(100−75)=95.

Now take the maximum of the three clipped curves. The declining Reject edge reaches the Consider height .4 at (50−z)/25=.4, hence z=40. The declining Consider edge reaches the Approve height .2 at (75−z)/25=.2, hence z=70. These crossover locations must be included when splitting the aggregate. Original peaks and other clip endpoints may add extra splits without changing the total area.

**For the first aggregate strip from a=1 to b=15.4, endpoint heights are u=0 and v=0.6. Find its area and first moment.** [3 marks · Worked example]

#### Given

Strip endpoints a=1 and b=15.4; left height u=0 and right height v=0.6. This is a straight rising edge of the clipped Reject set.

#### To find

A and M for one table row.

#### Formula and why it applies



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}[(2a+b)u+(a+2b)v]
$$



A is trapezoid area. M weights every small area by its horizontal position; this formula integrates a straight line.

#### Solution

##### Step 1. Width and height sum



$$
b-a=15.4-1=14.4\qquad u+v=0.6
$$



##### Step 2. Area



$$
A=14.4\times0.6/2=8.64/2=4.32
$$



##### Step 3. First bracket term



$$
(2a+b)u=(2+15.4)\times0=0
$$



##### Step 4. Second bracket term



$$
(a+2b)v=(1+30.8)\times0.6=31.8\times0.6=19.08
$$



##### Step 5. Moment



$$
M=(14.4/6)(0+19.08)=2.4\times19.08=45.792
$$



**Final answer.** Area=4.32; moment=45.792. Repeat the same arithmetic for each row, then sum the areas and moments separately.

### Interpret the loan result using an explicit decision rule

Choose the output label having the greatest membership at the centroid; this is an additional stated interpretation rule. At z=42.780888139:



$$
\mu_{Reject}=(50-z)/25\approx0.288764474,\quad\mu_{Consider}=(z-25)/25\approx0.711235526,\quad\mu_{Approve}=0
$$



The resulting recommendation is **Consider / manual review**; this design does not recommend automatic approval. If a binary approve/reject answer is required, the question must supply a threshold or you must state the threshold you adopt. A different decision threshold is separate from defuzzification.

---

## TEE · Q4(a) Cartesian product and max–min composition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q4a

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Consider fuzzy sets A = {0.4/small + 0.3/medium + 0.1/large} and B = {0.2/slow + 0.7/moderate + 0.3/fast}. 1. Find R = A × B. 2. Given C = {0.3/small + 0.1/medium + 0.4/large}, find S = C × B. 3. Calculate the max–min composition S ∘ R.** [10 marks]

### Answer

#### Given

The fuzzy sets or relation matrices and their listed row/column order.

#### To find

The relation matrix/matrices and the composition specified in the question.

#### Formula and why it applies

For Cartesian products take min of row and column membership. For the ordered matrix composition shown here:



$$
T_{ik}=\max_j\min(S_{ij},R_{jk})
$$



If max–product is asked instead, replace the inner min by multiplication.

#### Solution

##### Step 1. R = A × B (rows small, medium, large; columns slow, moderate, fast)



$$
R=\begin{bmatrix}\min(.4,.2)&\min(.4,.7)&\min(.4,.3)\\\min(.3,.2)&\min(.3,.7)&\min(.3,.3)\\\min(.1,.2)&\min(.1,.7)&\min(.1,.3)\end{bmatrix}=\begin{bmatrix}0.2&0.4&0.3\\0.2&0.3&0.3\\0.1&0.1&0.1\end{bmatrix}
$$



##### Step 2. S = C × B



$$
S=\begin{bmatrix}0.2&0.3&0.3\\0.1&0.1&0.1\\0.2&0.4&0.3\end{bmatrix}
$$



##### Step 3. S ∘ R by max–min (row of S with column of R)

The printed relation domains do not directly compose: both relate size to speed. For the numerical exercise, explicitly assume positional alignment and compute row of S with column of R. Equal dimensions alone are not a justification for semantic relation composition.



$$
(1,1)=\max[\min(.2,.2),\min(.3,.2),\min(.3,.1)]=\max(.2,.2,.1)=0.2
$$





$$
(1,2)=\max[\min(.2,.4),\min(.3,.3),\min(.3,.1)]=\max(.2,.3,.1)=0.3
$$





$$
(1,3)=\max[\min(.2,.3),\min(.3,.3),\min(.3,.1)]=0.3
$$



Row 2 of S is all 0.1, so every entry of row 2 is 0.1.



$$
(3,1)=\max[\min(.2,.2),\min(.4,.2),\min(.3,.1)]=0.2,\;(3,2)=\max[.2,.3,.1]=0.3,\;(3,3)=\max[.2,.3,.1]=0.3
$$



**Final answer.** 

$$
S\circ R=\begin{bmatrix}0.2&0.3&0.3\\0.1&0.1&0.1\\0.2&0.3&0.3\end{bmatrix}
$$

.

**Official key note.** The key first printed a wrong matrix with row 2 = (0.2, 0.3, 0.3), then corrected it by hand to (0.1, 0.1, 0.1). The corrected matrix above is right. Marking: R 3, S 3, composition 4.

**A careful remark you can add.** Strictly, composition needs S: X → Y and R: Y → Z, while here both relate size to speed. The numerical matrix calculation above assumes positional identification of the three middle labels; that is a declared repair, not a valid size-to-speed relation composition without an extra mapping.

## Every cell without the row shortcuts

Both printed relations run from size to speed; their middle labels do not match for genuine relation composition. The numerical working below follows the question’s intended row-of-S with column-of-R operation using explicitly assumed positional alignment of the three middle entries.

### R: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| R11 | 0.4 | 0.2 | 0.2 |
| R12 | 0.4 | 0.7 | 0.4 |
| R13 | 0.4 | 0.3 | 0.3 |
| R21 | 0.3 | 0.2 | 0.2 |
| R22 | 0.3 | 0.7 | 0.3 |
| R23 | 0.3 | 0.3 | 0.3 |
| R31 | 0.1 | 0.2 | 0.1 |
| R32 | 0.1 | 0.7 | 0.1 |
| R33 | 0.1 | 0.3 | 0.1 |

### S: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| S11 | 0.3 | 0.2 | 0.2 |
| S12 | 0.3 | 0.7 | 0.3 |
| S13 | 0.3 | 0.3 | 0.3 |
| S21 | 0.1 | 0.2 | 0.1 |
| S22 | 0.1 | 0.7 | 0.1 |
| S23 | 0.1 | 0.3 | 0.1 |
| S31 | 0.4 | 0.2 | 0.2 |
| S32 | 0.4 | 0.7 | 0.4 |
| S33 | 0.4 | 0.3 | 0.3 |

**Result cell (1,1)**



$$
\max\{\min(0.2,0.2),\min(0.3,0.2),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (1,2)**



$$
\max\{\min(0.2,0.4),\min(0.3,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (1,3)**



$$
\max\{\min(0.2,0.3),\min(0.3,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (2,1)**



$$
\max\{\min(0.1,0.2),\min(0.1,0.2),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (2,2)**



$$
\max\{\min(0.1,0.4),\min(0.1,0.3),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (2,3)**



$$
\max\{\min(0.1,0.3),\min(0.1,0.3),\min(0.1,0.1)\}
$$





$$
=\max\{0.1,0.1,0.1\}=0.1
$$



**Result cell (3,1)**



$$
\max\{\min(0.2,0.2),\min(0.4,0.2),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (3,2)**



$$
\max\{\min(0.2,0.4),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



**Result cell (3,3)**



$$
\max\{\min(0.2,0.3),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.2,0.3,0.1\}=0.3
$$



---

## TEE · Q4(b) Naive Bayes: flu [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q4b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q4b

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. A hospital wants to predict flu from Fever (Yes/No), Cough (Yes/No) and Temperature Level (Low/Normal/High). Training data: (Yes, Yes, High, Yes), (No, No, Normal, No), (Yes, No, Low, No), (Yes, Yes, High, Yes), (No, Yes, Normal, No), (Yes, Yes, High, Yes), (No, No, Low, No), (Yes, No, Normal, No). Using naive Bayes, predict whether a patient with Fever = Yes, Cough = Yes, Temperature = Normal has flu.** [10 marks]

### Answer

#### Given

The full training data are in Step 1. Query: Fever=Yes, Cough=Yes, Temperature=Normal. The main calculation uses unsmoothed counts.

#### To find

Both class scores and the predicted class.

#### Formula and why it applies



$$
score(C)=P(C)\prod_jP(a_j\mid C)
$$



C is a class label. Each aⱼ is one query feature value. First count inside a class, then multiply the prior and all three likelihoods.

#### Solution

##### Step 1. Write the training rows as a table

| Row | Fever | Cough | Temperature | Class |
| --- | --- | --- | --- | --- |
| 1 | Yes | Yes | High | Yes |
| 2 | No | No | Normal | No |
| 3 | Yes | No | Low | No |
| 4 | Yes | Yes | High | Yes |
| 5 | No | Yes | Normal | No |
| 6 | Yes | Yes | High | Yes |
| 7 | No | No | Low | No |
| 8 | Yes | No | Normal | No |

##### Step 2. Separate the two class groups

| Class | Rows in this group | Class count | Prior |
| --- | --- | --- | --- |
| Yes | 1, 4, 6 | 3 | 3/8 = 0.375 |
| No | 2, 3, 5, 7, 8 | 5 | 5/8 = 0.625 |

##### Step 3. For class Yes, count Fever=Yes

Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.



$$
P(\text{Fever}=\text{Yes}\mid C=\text{Yes})=\frac{3}{3}=1
$$



##### Step 4. For class Yes, count Cough=Yes

Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.



$$
P(\text{Cough}=\text{Yes}\mid C=\text{Yes})=\frac{3}{3}=1
$$



##### Step 5. For class Yes, count Temperature=Normal

Look only at class Yes rows 1, 4, 6. No row in this class has that feature value.



$$
P(\text{Temperature}=\text{Normal}\mid C=\text{Yes})=\frac{0}{3}=0
$$



##### Step 6. Multiply the Yes score one factor at a time



$$
P(Yes)=3/8=0.375
$$





$$
0.375\times1=0.375
$$





$$
0.375\times1=0.375
$$





$$
0.375\times0=0
$$



##### Step 7. For class No, count Fever=Yes

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 3, 8.



$$
P(\text{Fever}=\text{Yes}\mid C=\text{No})=\frac{2}{5}=0.4
$$



##### Step 8. For class No, count Cough=Yes

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Cough}=\text{Yes}\mid C=\text{No})=\frac{1}{5}=0.2
$$



##### Step 9. For class No, count Temperature=Normal

Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 2, 5, 8.



$$
P(\text{Temperature}=\text{Normal}\mid C=\text{No})=\frac{3}{5}=0.6
$$



##### Step 10. Multiply the No score one factor at a time



$$
P(No)=5/8=0.625
$$





$$
0.625\times0.4=0.25
$$





$$
0.25\times0.2=0.05
$$





$$
0.05\times0.6=0.03
$$



##### Step 11. Compare the scores



$$
score(Yes)=0\qquad score(No)=0.03
$$



The larger score belongs to No. Normalise only if a posterior probability is requested: divide each score by their total 0.03.

**Final answer.** Predict No. Yes score=0; No score=0.03.

The zero Yes score is caused by an absent training combination. If Laplace smoothing is explicitly required, apply it to all feature likelihoods in both classes. That is a different calculation and may change the prediction; do not mix smoothed and unsmoothed sides.

**Yaad rakho:** Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.

---

## TEE · Q5(a) Hotel guest movement (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q5a

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. A hotel chain has properties in Paris (P), London (L) and Rome (R). Of guests in Paris, 60% stay, 25% go to London, 15% to Rome; in London 30% go to Paris, 50% stay, 20% go to Rome; in Rome 20% go to Paris, 30% to London, 50% stay. 1. Construct the transition matrix. 2. Explain the diagonal and off-diagonal entries. 3. Draw the state diagram. 4. Today's counts are [50, 30, 20]; find tomorrow's expected counts. 5. Which city gains or loses guests in the long run?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: P, L, R. Initial vector [50, 30, 20].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | P | L | R |
| --- | --- | --- | --- |
| P | 0.6 | 0.25 | 0.15 |
| L | 0.3 | 0.5 | 0.2 |
| R | 0.2 | 0.3 | 0.5 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_hotel.55f5204329.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Daily guest movement: Paris, London, Rome | 0.25 | 0.15 | 0.3 | 0.2 | 0.2 | 0.3 | 0.6 | 0.5 | 0.5 | P | L | R

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to P

| Origin | Current count/share | Transition to P | Contribution |
| --- | --- | --- | --- |
| P | 50 | 0.6 | 50 × 0.6 = 30 |
| L | 30 | 0.3 | 30 × 0.3 = 9 |
| R | 20 | 0.2 | 20 × 0.2 = 4 |



$$
P_{new}=30+9+4=43
$$



##### Step 4. Next step: collect all contributions to L

| Origin | Current count/share | Transition to L | Contribution |
| --- | --- | --- | --- |
| P | 50 | 0.25 | 50 × 0.25 = 12.5 |
| L | 30 | 0.5 | 30 × 0.5 = 15 |
| R | 20 | 0.3 | 20 × 0.3 = 6 |



$$
L_{new}=12.5+15+6=33.5
$$



##### Step 5. Next step: collect all contributions to R

| Origin | Current count/share | Transition to R | Contribution |
| --- | --- | --- | --- |
| P | 50 | 0.15 | 50 × 0.15 = 7.5 |
| L | 30 | 0.2 | 30 × 0.2 = 6 |
| R | 20 | 0.5 | 20 × 0.5 = 10 |



$$
R_{new}=7.5+6+10=23.5
$$



##### Step 6. Stationarity: write the Paris equation



$$
p=0.6p+0.3l+0.2r
$$





$$
0.4p=0.3l+0.2r
$$



Divide every term by .4.



$$
p=0.75l+0.5r
$$



##### Step 7. Write the London equation and substitute p



$$
l=0.25p+0.5l+0.3r
$$





$$
0.5l=0.25(0.75l+0.5r)+0.3r
$$





$$
0.5l=0.1875l+0.125r+0.3r
$$



##### Step 8. Collect like terms



$$
(0.5-0.1875)l=(0.125+0.3)r
$$





$$
0.3125l=0.425r\quad\Rightarrow\quad l=1.36r
$$





$$
p=0.75(1.36r)+0.5r=1.52r
$$



##### Step 9. Use total probability to get all three shares



$$
p+l+r=1\quad\Rightarrow\quad1.52r+1.36r+r=1
$$





$$
3.88r=1\quad r=1/3.88=25/97
$$





$$
l=1.36(25/97)=34/97\quad p=1.52(25/97)=38/97
$$



##### Step 10. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| P | 0.5 | 0.391752577 | -0.108247423 | Loses |
| L | 0.3 | 0.350515464 | 0.050515464 | Gains |
| R | 0.2 | 0.257731959 | 0.057731959 | Gains |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [43.0, 33.5, 23.5]. Stationary shares ≈ [0.391752577, 0.350515464, 0.257731959]. P loses, L gains, R gains.

---

## TEE · Q5(b) Genetic algorithm [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q5b

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Implement a GA to maximise 

$$
f(x)=2x^3-5x^2+7x
$$

 for x in [0,15]. Take 4-bit representations of 13, 22, 18, 23. Crossover after the second bit and mutate by flipping any one bit. Produce two offspring and comment on fitness.** [10 marks]

### Answer

**The printed data are inconsistent.** 22, 18 and 23 are outside 0–15 and cannot fit into four bits. Increasing the bit count would encode the numbers but would still violate the stated range. There is no single exact solution satisfying all printed conditions.

The complete worked variant below explicitly changes the invalid parents to their last four bits (values modulo 16), producing [13,6,2,7]. This is one declared repair, not a silent interpretation of the printed question. If the instructor clarifies different corrected data, follow those data.

#### Given

Printed parents: [13, 22, 18, 23]. Worked variant: [13, 6, 2, 7] with 4 bits. For the unspecified selection step, select the two highest-fitness candidates. For the unspecified mutation location, flip the last bit of each child. Crossover is after bit 2.

#### To find

Two valid children under the declared assumptions and their fitness.

#### Formula and why it applies

Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.



$$
f(x)=2x^3-5x^2+7x
$$



#### Solution

##### Step 1. Encode and evaluate the declared parent population

| x | Binary | Fitness substitution |
| --- | --- | --- |
| 13 | 1101 | 2(13³) − 5(13²) + 7(13) = 3640 |
| 6 | 0110 | 2(6³) − 5(6²) + 7(6) = 294 |
| 2 | 0010 | 2(2³) − 5(2²) + 7(2) = 10 |
| 7 | 0111 | 2(7³) − 5(7²) + 7(7) = 490 |

##### Step 2. Select the two fittest under the stated assumption

[13, 7] with fitness [3640, 490].

##### Step 3. Cut after bit 2 and exchange tails

| Parent 1 | Parent 2 | Child 1 | Child 2 |
| --- | --- | --- | --- |
| 11 | 01 | 01 | 11 | 1111 | 0101 |

##### Step 4. Flip the last bit of each child

| Before | After | Decoded x |
| --- | --- | --- |
| 1111 | 1110 | 14 |
| 0101 | 0100 | 4 |

##### Step 5. Evaluate both children

| x | Fitness calculation |
| --- | --- |
| 14 | 2(2744) − 5(196) + 7(14) = 4606 |
| 4 | 2(64) − 5(16) + 7(4) = 76 |

##### Step 6. Compare with the selected parents

Best parent score = 3640; best child score = 4606. Parent average = 2065; child average = 2341. Both the best score and the average score increased in this worked variant. An individual child can still be worse than a parent; GA does not guarantee improvement after every random operator.

**Final answer.** Under these declared repairs and operator choices, children are [14, 4] with fitness [4606, 76]. These are not unique answers to the inconsistent and under-specified original question.

The printed wording about “two offspring” is not an explicit requirement for two complete generations. The M2 examples separately work two full generations because your class update asks for iteration 2.

## Evaluate the polynomial without skipping the powers

Calculate x²=x×x, then x³=x²×x. Multiply each by its coefficient and combine with the written signs. A bit-string repair in the worked answer is an explicitly stated response to inconsistent printed givens; it is not a new instruction in the original paper.

### x=13



$$
x^2=13\times13=169\qquad x^3=169\times13=2197
$$





$$
2x^3=4394\quad 5x^2=845\quad 7x=91
$$





$$
f(13)=4394-845+91=3640
$$



### x=6



$$
x^2=6\times6=36\qquad x^3=36\times6=216
$$





$$
2x^3=432\quad 5x^2=180\quad 7x=42
$$





$$
f(6)=432-180+42=294
$$



### x=2



$$
x^2=2\times2=4\qquad x^3=4\times2=8
$$





$$
2x^3=16\quad 5x^2=20\quad 7x=14
$$





$$
f(2)=16-20+14=10
$$



### x=7



$$
x^2=7\times7=49\qquad x^3=49\times7=343
$$





$$
2x^3=686\quad 5x^2=245\quad 7x=49
$$





$$
f(7)=686-245+49=490
$$



### x=15



$$
x^2=15\times15=225\qquad x^3=225\times15=3375
$$





$$
2x^3=6750\quad 5x^2=1125\quad 7x=105
$$





$$
f(15)=6750-1125+105=5730
$$



### x=5



$$
x^2=5\times5=25\qquad x^3=25\times5=125
$$





$$
2x^3=250\quad 5x^2=125\quad 7x=35
$$





$$
f(5)=250-125+35=160
$$



### x=14



$$
x^2=14\times14=196\qquad x^3=196\times14=2744
$$





$$
2x^3=5488\quad 5x^2=980\quad 7x=98
$$





$$
f(14)=5488-980+98=4606
$$



### x=4



$$
x^2=4\times4=16\qquad x^3=16\times4=64
$$





$$
2x^3=128\quad 5x^2=80\quad 7x=28
$$





$$
f(4)=128-80+28=76
$$



“Modulo 16” means keep the remainder after dividing by 16: 22=1×16+6, so its remainder is 6; 18=1×16+2; 23=1×16+7. This is only the declared repair used here, not an unspoken general encoding rule.

---

## TEE · Q6(a) Applications of fuzzy logic [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q6a

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**List the applications of fuzzy logic. Explain any one application in detail.** [10 marks]

### Answer

### Definition

Fuzzy logic is a multi-valued logic, introduced by Lotfi Zadeh (1965), in which truth values range over [0, 1]; it lets machines reason with vague, human-like terms such as “slightly dirty” or “very hot”.

### Applications

| Area | Examples |
| --- | --- |
| Home appliances | Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners |
| Automotive | Automatic transmission, anti-lock braking (ABS), cruise control, engine control |
| Transportation | Traffic-signal control, Sendai subway train control (smooth braking and acceleration) |
| Consumer electronics | Camera autofocus and auto-exposure, image stabilisation |
| Industrial control | Cement kilns, pH, temperature and distillation control in chemical plants |
| Aerospace | Satellite and spacecraft attitude control |
| Medicine | Diagnosis support, anaesthesia dosage control |
| Finance and decisions | Loan approval, credit and fire-risk scoring, stock trading rules |
| AI and robotics | Robot navigation, natural-language interfaces, expert systems |

### One application in detail: fuzzy washing machine

1. **Problem.** Wash time depends on how dirty and how greasy the clothes are. These are vague (“a bit dirty”), and a fixed timer wastes water and power.
2. **Inputs and outputs.** Sensors measure dirt (turbidity of water) and grease; the output is wash time. Each is described by fuzzy sets: dirt Small/Medium/High, grease Small/Medium/High, time Very Short … Very Long.
3. **Fuzzification.** Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.
4. **Rule base.** 9 expert rules, e.g. IF dirt is High AND grease is High THEN time is Very Long; IF dirt is Small AND grease is Small THEN time is Very Short.
5. **Inference.** Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.
6. **Defuzzification.** Use the specified defuzzifier. For a separate representative-weighted illustration, strengths [.6,.4,.2] at times [25,40,60] give (.6×25+.4×40+.2×60)/(.6+.4+.2)=(15+16+12)/1.2≈35.833 minutes. These illustrative strengths are supplied here, not derived from unspecified input graphs. A Mamdani area centroid requires the full aggregate shape.
7. **Benefits.** Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.

### Advantages and disadvantages (bonus)

**Advantages:** handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. **Disadvantages:** rules and membership functions depend on expert judgement; results are hard to verify formally; tuning can take time; not suited where very high precision is required.

**Yaad rakho:** Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.

---

## TEE · Q6(b) Learner progression (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q6b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q6b

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Students are Beginner (B), Intermediate (I) or Advanced (A). Of Beginners, 60% remain, 30% become Intermediate, 10% go to Advanced. Of Intermediates, 20% fall back, 50% remain, 30% progress. Of Advanced, 10% drop to Intermediate, 80% remain and 10% stop (treated as remaining in A). 1. Construct the matrix. 2. Interpret retention, progression and regression. 3. Draw the diagram. 4. For [50, 30, 20], find the distribution after one day. 5. Which level has the largest steady-state share?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: B, I, A. Initial vector [50, 30, 20].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | B | I | A |
| --- | --- | --- | --- |
| B | 0.6 | 0.3 | 0.1 |
| I | 0.2 | 0.5 | 0.3 |
| A | 0 | 0.1 | 0.9 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_learning.61a789edc7.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Daily learner movement: Beginner, Intermediate, Advanced | 0.3 | 0.1 | 0.2 | 0.3 | 0.1 | 0.6 | 0.5 | 0.9 | B | I | A

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to B

| Origin | Current count/share | Transition to B | Contribution |
| --- | --- | --- | --- |
| B | 50 | 0.6 | 50 × 0.6 = 30 |
| I | 30 | 0.2 | 30 × 0.2 = 6 |
| A | 20 | 0 | 20 × 0 = 0 |



$$
B_{new}=30+6+0=36
$$



##### Step 4. Next step: collect all contributions to I

| Origin | Current count/share | Transition to I | Contribution |
| --- | --- | --- | --- |
| B | 50 | 0.3 | 50 × 0.3 = 15 |
| I | 30 | 0.5 | 30 × 0.5 = 15 |
| A | 20 | 0.1 | 20 × 0.1 = 2 |



$$
I_{new}=15+15+2=32
$$



##### Step 5. Next step: collect all contributions to A

| Origin | Current count/share | Transition to A | Contribution |
| --- | --- | --- | --- |
| B | 50 | 0.1 | 50 × 0.1 = 5 |
| I | 30 | 0.3 | 30 × 0.3 = 9 |
| A | 20 | 0.9 | 20 × 0.9 = 18 |



$$
A_{new}=5+9+18=32
$$



##### Step 6. Stationarity: balance the Beginner column



$$
b=0.6b+0.2i
$$





$$
0.4b=0.2i\quad\Rightarrow\quad i=2b
$$



##### Step 7. Balance the Advanced column



$$
a=0.1b+0.3i+0.9a
$$





$$
0.1a=0.1b+0.3(2b)=0.7b
$$





$$
a=0.7b/0.1=7b
$$



##### Step 8. Use the sum of shares



$$
b+i+a=1\quad b+2b+7b=1
$$





$$
10b=1\quad b=0.1\quad i=0.2\quad a=0.7
$$



Advanced is not an absorbing state: its self-transition is .9, not 1.

##### Step 9. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| B | 0.5 | 0.1 | -0.4 | Loses |
| I | 0.3 | 0.2 | -0.1 | Loses |
| A | 0.2 | 0.7 | 0.5 | Gains |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [36.0, 32.0, 32.0]. Stationary shares ≈ [0.1, 0.2, 0.7]. B loses, I loses, A gains.

---

## TEE · Q7(a) Applications of PSO [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q7a

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**List the applications of Particle Swarm Optimization and explain any one application in detail.** [10 marks]

### Answer

### Definition (1 line)

Particle Swarm Optimization is a population-based metaheuristic, inspired by bird flocking and fish schooling, in which particles move through the search space using their own best position (pbest) and the swarm's best position (gbest) to find optimal or near-optimal solutions.

### Applications

1. **Function optimisation**: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.
2. **Neural-network training**: optimising weights and biases (your Lab 8 uses the pyswarms library for this).
3. **Hyper-parameter tuning** of ML models (learning rate, number of hidden units, SVM C and γ).
4. **Feature selection**: choosing the most useful subset of features (binary PSO).
5. **Image processing**: threshold selection for segmentation, edge detection, image enhancement.
6. **Path planning** for robots and drones: shortest collision-free path.
7. **Power systems**: economic load dispatch, optimal placement of capacitors.
8. **Control engineering**: tuning PID controller gains.
9. **Scheduling and wireless sensor networks**: job scheduling, sensor node placement and clustering.

### One application in detail: training a neural network with PSO

Training data

→

Neural network with weights = particle position

→

Error (fitness)

→

PSO moves the weights

→

Best weights = gbest

1. **Encoding.** Flatten all weights and biases of the network into one vector. Each particle is one complete set of weights; a network with 50 weights gives a 50-dimensional search space.
2. **Fitness.** Run the training data through the network with that particle's weights and compute the error (for example mean squared error or cross-entropy). Lower error = better particle (minimisation).
3. **Search.** Apply the velocity and position updates. Each particle is pulled towards the weight set that gave its own lowest error (pbest) and towards the lowest-error weights found by the swarm (gbest).
4. **Stop** after a fixed number of iterations or when the error stops improving; gbest is the trained network.
5. **Why PSO here:** it needs no gradients, so it works with non-differentiable activations and can explore candidate weights without differentiating the objective. It can still stagnate; comparison with gradient methods depends on the problem. **Limitation:** large networks create a high-dimensional search space, and evaluating many complete candidate networks can be computationally expensive. Gradient-based training is often more efficient when useful gradients are available; there is no universal speed ordering for every problem and implementation.

### Advantages and disadvantages (add for 10 marks)

| Advantages | Disadvantages |
| --- | --- |
| Simple to implement; few parameters (w, c₁, c₂) | Can converge prematurely to a local optimum |
| No derivatives needed | Sensitive to parameter choice |
| Fast convergence in early iterations; memory (pbest, gbest) | No guarantee of the global optimum |
| Objective evaluations can be parallel; particles share information through gbest | Less suited to discrete problems without modification |

Marking pattern used for ACO in the same paper: listing 3 marks + explanation 2 marks (5-mark version); listing 5 + explanation 5 (10-mark version).

**Yaad rakho:** Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.

---

## TEE · Q7(b) ACO for TSP [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-final-2025--q7b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-final-2025/q7b

100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. For the four-city travelling salesman problem, the distance and pheromone matrices (A, B, C, D) are given. Apply Ant Colony Optimization. Calculate the path travelled by 2 ants to cover all cities starting from city A. Random numbers for Ant 1 are 0.3, 0.8 and for Ant 2 are 0.5, 0.7. Also update the pheromone matrix after 1 iteration.** [10 marks]

### Answer

#### Given



$$
D=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&4&2&4\\B&4&0&3&6\\C&2&3&0&2\\D&4&6&2&0\end{array}\qquad \tau=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&1&1&1\\B&1&0&1&1\\C&1&1&0&1\\D&1&1&1&0\end{array}
$$



Assume 

$$
\alpha=\beta=1
$$

, 

$$
\rho=0.5
$$

, 

$$
Q=1
$$

 (class convention; not stated in the question).

#### To find

Tour of each ant, tour lengths, updated pheromone matrix.

Swipe across the diagram to read its labels ↔

![Final 2025 Q7b: distances (all pheromones start at 1)](https://deep-learning-study-room.vercel.app/is2/fig/aco_final_graph.ac3cd4aeac.svg)

Diagram: Final 2025 Q7b: distances (all pheromones start at 1). Labels: Final 2025 Q7b: distances (all pheromones start at 1) | 4 | 2 | 4 | 3 | 6 | 2 | A | B | C | D

#### Formula and why it applies



$$
P_{ij}=\frac{\tau_{ij}\,\eta_{ij}}{\sum_{l\in\text{allowed}}\tau_{il}\,\eta_{il}},\qquad\eta_{ij}=\frac1{d_{ij}}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}+\sum_{k:\,ij\in\mathrm{tour}_k}\frac{Q}{L_k}
$$



The sum includes **only ants whose completed tour contains edge ij**. An unused edge receives no deposit but still evaporates. Here distances are symmetric, so a traversed edge updates both symmetric matrix cells. Both ants construct their tours using the old pheromones; update after both finish, including their return to A.

#### Solution

##### Step 1. Probabilities from A (both ants start at A)



$$
\tau\eta:\;A\to B=1\times\tfrac14=0.25,\quad A\to C=1\times\tfrac12=0.5,\quad A\to D=1\times\tfrac14=0.25;\quad\text{sum}=1
$$



| Move | P | Cumulative | Range |
| --- | --- | --- | --- |
| A→B | 0.25 | 0.25 | 0–0.25 |
| A→C | 0.50 | 0.75 | 0.25–0.75 |
| A→D | 0.25 | 1.00 | 0.75–1 |

Ant 1: r = 0.3 → **C**. Ant 2: r = 0.5 → **C**.

##### Step 2. Probabilities from C (B and D left)



$$
C\to B=\tfrac13=0.3333,\quad C\to D=\tfrac12=0.5;\quad\text{sum}=0.8333\Rightarrow P_{CB}=0.4,\;P_{CD}=0.6
$$



Cumulative in city order: B 0–0.4, D 0.4–1. Ant 1: r = 0.8 → **D**. Ant 2: r = 0.7 → **D**.

##### Step 3. Complete the tours

Only B is left, then return to A.



$$
\text{Ant 1}=\text{Ant 2}:\;A\to C\to D\to B\to A,\qquad L=2+2+6+4=14
$$



Swipe across the diagram to read its labels ↔

![Both ants: A → C → D → B → A, length 14](https://deep-learning-study-room.vercel.app/is2/fig/aco_final_tour.1dbfdb8b98.svg)

Diagram: Both ants: A → C → D → B → A, length 14. Labels: Both ants: A → C → D → B → A, length 14 | 4 | 2 | 4 | 3 | 6 | 2 | A | B | C | D

##### Step 4. Pheromone update

Each ant deposits 

$$
Q/L=1/14=0.0714
$$

 on each edge of its tour; two ants used the same four edges (AC, CD, DB, BA), so each gets 

$$
2/14=0.1429
$$

.



$$
\text{used edge: }(1-0.5)(1)+0.1429=0.6429\qquad\text{unused edge (AD, BC): }(1-0.5)(1)+0=0.5
$$





$$
\tau_{\text{new}}=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&0.6429&0.6429&0.5\\B&0.6429&0&0.5&0.6429\\C&0.6429&0.5&0&0.6429\\D&0.5&0.6429&0.6429&0\end{array}
$$



**Final answer.** Both ants: A → C → D → B → A, length 14. Updated pheromone: 0.6429 on AB, AC, CD, BD; 0.5 on AD and BC. In the next iteration the ants will prefer the edges of this tour.

**Official key note.** The key's matrix shows 0.643 on AC, CD and BD but leaves AB at 0.5, i.e. it forgot to deposit on the return edge B → A even though it counted its length (4) in L = 14. Your slides deposit on the return edge, so AB = 0.6429 is correct. If you wish, write one line: “the return edge B–A is part of the tour, so it also receives Q/L.”

Official marking: path of Ant 1 (3) + path of Ant 2 (3) + pheromone matrix (4).

---

## TEE · Q1(a) Disease, fever and test joint table [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q1a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q1a

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. For a disease Y with fever X as a symptom, a test Z is conducted. Joint probabilities: Disease (Y=1): fever & test+ 0.576, fever & test− 0.144, no fever & test+ 0.072, no fever & test− 0.016; No disease (Y=0): 0.008, 0.064, 0.012, 0.108. (1) If fever occurs and the test is positive, what is the probability of disease? (2) What is the probability that a random person tests positive? (3) Given no fever, what is the probability of still having the disease?** [5 marks]

### Answer

#### Given

The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.

#### To find

All requested marginal and conditional probabilities.

#### Formula and why it applies

Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum.



$$
P(A\mid E)=\frac{P(A\cap E)}{P(E)},\quad P(E)>0
$$



#### Solution

##### Step 1. (1)



$$
P(Y{=}1\mid X{=}1,Z{=}1)=\frac{0.576}{0.576+0.008}=\frac{0.576}{0.584}=0.986
$$



##### Step 2. (2) Add every test-positive cell



$$
P(Z{=}1)=0.576+0.072+0.008+0.012=0.668
$$



##### Step 3. (3)



$$
P(X{=}0)=0.072+0.016+0.012+0.108=0.208,\qquad P(Y{=}1\mid X{=}0)=\frac{0.072+0.016}{0.208}=\frac{0.088}{0.208}=0.423
$$



**Final answer.** (1) 0.986; (2) 0.668; (3) 0.423.

**Key correction.** The key writes 0.088/0.076 = 1.158 for part (3). A probability cannot exceed 1; the denominator must be P(no fever) = 0.208.

---

## TEE · Q1(b) Applications of PSO [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q1b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q1b

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**List the applications of Particle Swarm Optimization and explain any one application in detail.** [5 marks]

### Answer

### Definition (1 line)

Particle Swarm Optimization is a population-based metaheuristic, inspired by bird flocking and fish schooling, in which particles move through the search space using their own best position (pbest) and the swarm's best position (gbest) to find optimal or near-optimal solutions.

### Applications

1. **Function optimisation**: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.
2. **Neural-network training**: optimising weights and biases (your Lab 8 uses the pyswarms library for this).
3. **Hyper-parameter tuning** of ML models (learning rate, number of hidden units, SVM C and γ).
4. **Feature selection**: choosing the most useful subset of features (binary PSO).
5. **Image processing**: threshold selection for segmentation, edge detection, image enhancement.
6. **Path planning** for robots and drones: shortest collision-free path.
7. **Power systems**: economic load dispatch, optimal placement of capacitors.
8. **Control engineering**: tuning PID controller gains.
9. **Scheduling and wireless sensor networks**: job scheduling, sensor node placement and clustering.

### One application in detail: training a neural network with PSO

Training data

→

Neural network with weights = particle position

→

Error (fitness)

→

PSO moves the weights

→

Best weights = gbest

1. **Encoding.** Flatten all weights and biases of the network into one vector. Each particle is one complete set of weights; a network with 50 weights gives a 50-dimensional search space.
2. **Fitness.** Run the training data through the network with that particle's weights and compute the error (for example mean squared error or cross-entropy). Lower error = better particle (minimisation).
3. **Search.** Apply the velocity and position updates. Each particle is pulled towards the weight set that gave its own lowest error (pbest) and towards the lowest-error weights found by the swarm (gbest).
4. **Stop** after a fixed number of iterations or when the error stops improving; gbest is the trained network.
5. **Why PSO here:** it needs no gradients, so it works with non-differentiable activations and can explore candidate weights without differentiating the objective. It can still stagnate; comparison with gradient methods depends on the problem. **Limitation:** large networks create a high-dimensional search space, and evaluating many complete candidate networks can be computationally expensive. Gradient-based training is often more efficient when useful gradients are available; there is no universal speed ordering for every problem and implementation.

### Advantages and disadvantages (add for 10 marks)

| Advantages | Disadvantages |
| --- | --- |
| Simple to implement; few parameters (w, c₁, c₂) | Can converge prematurely to a local optimum |
| No derivatives needed | Sensitive to parameter choice |
| Fast convergence in early iterations; memory (pbest, gbest) | No guarantee of the global optimum |
| Objective evaluations can be parallel; particles share information through gbest | Less suited to discrete problems without modification |

Marking pattern used for ACO in the same paper: listing 3 marks + explanation 2 marks (5-mark version); listing 5 + explanation 5 (10-mark version).

**Yaad rakho:** Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.

---

## TEE · Q1(c) Fuzzy set operations [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q1c/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q1c

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. X = {(c1, 0.7), (c2, 0.9), (c3, 0.2), (c4, 0.4), (c5, 0.9)}, Y = {(c1, 0.6), (c2, 0.3), (c3, 0.8), (c4, 0.7), (c5, 0.1)}. Find X ∪ Y, X ∩ Y, ¬X ∪ ¬Y, ¬X ∩ ¬Y.** [5 marks]

### Answer

#### Given

The aligned X and Y memberships printed in this question.

#### To find

The four requested membership lists in the original element order.

#### Formula and why it applies

Use max for OR, min for AND, and 1−μ for NOT.



$$
\mu_{X\cup Y}=\max(\mu_X,\mu_Y),\quad\mu_{X\cap Y}=\min(\mu_X,\mu_Y)
$$



Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.

#### Solution

|  | c1 | c2 | c3 | c4 | c5 |
| --- | --- | --- | --- | --- | --- |
| ¬X | 0.3 | 0.1 | 0.8 | 0.6 | 0.1 |
| ¬Y | 0.4 | 0.7 | 0.2 | 0.3 | 0.9 |
| **X ∪ Y** | 0.7 | 0.9 | 0.8 | 0.7 | 0.9 |
| **X ∩ Y** | 0.6 | 0.3 | 0.2 | 0.4 | 0.1 |
| **¬X ∪ ¬Y** | 0.4 | 0.7 | 0.8 | 0.6 | 0.9 |
| **¬X ∩ ¬Y** | 0.3 | 0.1 | 0.2 | 0.3 | 0.1 |

**Final answer.** As in the last four rows. De Morgan check: ¬X ∪ ¬Y = 1 − (X ∩ Y) and ¬X ∩ ¬Y = 1 − (X ∪ Y) ✓.

## Calculate every element separately

### Element c1



$$
\neg X:1-0.7=0.3\qquad\neg Y:1-0.6=0.4
$$





$$
X\cup Y:\max(0.7,0.6)=0.7
$$





$$
X\cap Y:\min(0.7,0.6)=0.6
$$





$$
\neg X\cup\neg Y:\max(0.3,0.4)=0.4
$$





$$
\neg X\cap\neg Y:\min(0.3,0.4)=0.3
$$



### Element c2



$$
\neg X:1-0.9=0.1\qquad\neg Y:1-0.3=0.7
$$





$$
X\cup Y:\max(0.9,0.3)=0.9
$$





$$
X\cap Y:\min(0.9,0.3)=0.3
$$





$$
\neg X\cup\neg Y:\max(0.1,0.7)=0.7
$$





$$
\neg X\cap\neg Y:\min(0.1,0.7)=0.1
$$



### Element c3



$$
\neg X:1-0.2=0.8\qquad\neg Y:1-0.8=0.2
$$





$$
X\cup Y:\max(0.2,0.8)=0.8
$$





$$
X\cap Y:\min(0.2,0.8)=0.2
$$





$$
\neg X\cup\neg Y:\max(0.8,0.2)=0.8
$$





$$
\neg X\cap\neg Y:\min(0.8,0.2)=0.2
$$



### Element c4



$$
\neg X:1-0.4=0.6\qquad\neg Y:1-0.7=0.3
$$





$$
X\cup Y:\max(0.4,0.7)=0.7
$$





$$
X\cap Y:\min(0.4,0.7)=0.4
$$





$$
\neg X\cup\neg Y:\max(0.6,0.3)=0.6
$$





$$
\neg X\cap\neg Y:\min(0.6,0.3)=0.3
$$



### Element c5



$$
\neg X:1-0.9=0.1\qquad\neg Y:1-0.1=0.9
$$





$$
X\cup Y:\max(0.9,0.1)=0.9
$$





$$
X\cap Y:\min(0.9,0.1)=0.1
$$





$$
\neg X\cup\neg Y:\max(0.1,0.9)=0.9
$$





$$
\neg X\cap\neg Y:\min(0.1,0.9)=0.1
$$



---

## TEE · Q1(d) Savings and current accounts (Markov chain) [5]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q1d/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q1d

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Each year 20% of Savings holders switch to Current and 80% stay; 10% of Current holders switch to Savings and 90% stay. (a) Construct the transition matrix. (b) Draw the state diagram.** [5 marks]

### Answer

#### Given

All transition values are given in the full question. State order: S, C.

#### To find

The transition matrix and state diagram.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.

#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | S | C |
| --- | --- | --- |
| S | 0.8 | 0.2 |
| C | 0.1 | 0.9 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_bank.879499f6eb.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Savings (S) and Current (C) accounts per year | 0.2 | 0.1 | 0.8 | 0.9 | S | C

Each arrow is labelled with the probability of that transition.

**Final answer.** The transition matrix and state diagram are given above.

---

## TEE · Q2(a) Fuzzy fire-hazard system [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q2a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q2a

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**A building safety department wants a fuzzy logic system to predict fire hazards. Inputs are Temperature (1–100°C) and Smoke Level (1–100). The output Fire Risk (1–100) has labels Low, Moderate and High. Define triangular membership functions, construct at least nine rules, explain Mamdani inference and defuzzify for Temperature=65°C and Smoke=80.** [10 marks]

### Answer

#### Given

| Variable | Crisp value |
| --- | --- |
| Temperature | 65 |
| Smoke Level | 80 |

The question asks us to design the membership functions. This solution chooses Low=Tri(1,25,50), Medium=Tri(25,50,75), High=Tri(50,75,100) for both inputs. Output labels use the same triangles in their respective order. These are explicit design choices, not additional printed givens.

#### To find

A complete stated design and its continuous Mamdani centroid.

#### Formula and why it applies

Use min for AND and implication, max for aggregation and the true area centroid of the resulting shape. A peak-only weighted average is a different defuzzifier.



$$
z^*=\frac{\int z\mu_{out}(z)\,dz}{\int\mu_{out}(z)\,dz}
$$



#### Solution

##### Step 1. Specify the membership functions

| Input / output position | Triangle | Peak |
| --- | --- | --- |
| Low / Low | (1,25,50) | 25 |
| Medium / Moderate | (25,50,75) | 50 |
| High / High | (50,75,100) | 75 |

Use 0 outside each triangle, the rising fraction before the peak and the falling fraction after it. This design is evaluated at the requested input; a deployed controller would also need coverage/fallback at all boundary values.

##### Step 2. Write all nine rules

| Temperature / Smoke Level | Low | Medium | High |
| --- | --- | --- | --- |
| Low | Low | Low | Moderate |
| Medium | Low | Moderate | High |
| High | Moderate | High | High |

Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.

##### Step 3. Fuzzify Temperature = 65



$$
\mu_{Low}(65)=0
$$





$$
\mu_{Medium}(65)=\frac{75-65}{75-50}=0.4
$$





$$
\mu_{High}(65)=\frac{65-50}{75-50}=0.6
$$



##### Step 4. Fuzzify Smoke Level = 80



$$
\mu_{Low}(80)=0
$$





$$
\mu_{Medium}(80)=0
$$





$$
\mu_{High}(80)=\frac{100-80}{100-75}=0.8
$$



##### Step 5. Evaluate all rules and aggregate matching consequents

| Temperature | Smoke Level | Firing strength | Consequent |
| --- | --- | --- | --- |
| Low | Low | min(0,0) = 0 | Low |
| Low | Medium | min(0,0) = 0 | Low |
| Low | High | min(0,0.8) = 0 | Moderate |
| Medium | Low | min(0.4,0) = 0 | Low |
| Medium | Medium | min(0.4,0) = 0 | Moderate |
| Medium | High | min(0.4,0.8) = 0.4 | High |
| High | Low | min(0.6,0) = 0 | Moderate |
| High | Medium | min(0.6,0) = 0 | High |
| High | High | min(0.6,0.8) = 0.6 | High |

Aggregated label strengths: Low = 0, Moderate = 0, High = 0.6.



$$
\mu_{out}(z)=\max_r\min(\alpha_r,\mu_{C_r}(z))
$$



##### Step 6. Draw the aggregated output

Swipe across the diagram to read its labels ↔

![The shaded upper envelope counts any overlap only once.](https://deep-learning-study-room.vercel.app/is2/fig/v2_fire_aggregate.e0cab4ad42.svg)

Diagram: The shaded upper envelope counts any overlap only once.. Labels: Chosen triangular output sets and their max-aggregate | 0 | 0.5 | 1 | 1 | 25 | 50 | 75 | 100 | μ | Output score | Low | Moderate | High | centroid ≈ 75

The shaded upper envelope counts any overlap only once.

##### Step 7. Calculate area and moment of each straight-line strip

For a strip from a to b with endpoint heights u and v, its trapezoid area is A. Its first moment M is the integral of z times the line height.



$$
A=(b-a)(u+v)/2
$$





$$
M=\frac{b-a}{6}\big[(2a+b)u+(a+2b)v\big]
$$



| a | b | u | v | Area A | Moment M |
| --- | --- | --- | --- | --- | --- |
| 50 | 65 | 0 | 0.6 | 4.5 | 270 |
| 65 | 85 | 0.6 | 0.6 | 12 | 900 |
| 85 | 100 | 0.6 | 0 | 4.5 | 405 |

##### Step 8. Divide total moment by total area



$$
\sum A=21
$$





$$
\sum M=1575
$$





$$
z^*=\frac{1575}{21}\approx75
$$



**Final answer.** For these stated triangles and rules, the centroid is 75. This is in the high-risk region of this illustrative fuzzy design.

Because the paper asks for a design, a different explicitly specified membership/rule system can yield a different numerical output. Explain the choices and use the chosen defuzzification method consistently; no particular examiner mark outcome is promised.

## Why the clipped High shape is symmetric about 75

Only the High output survives, at height .6. Its triangle is (50,75,100). Solve its rising edge: (z−50)/25=.6, so z=50+15=65. Solve its falling edge: (100−z)/25=.6, so z=100−15=85.

| Piece | Area calculation | Centre | Moment |
| --- | --- | --- | --- |
| Left triangle [50,65] | ½×15×.6=4.5 | (50+65+65)/3=60 | 4.5×60=270 |
| Rectangle [65,85] | 20×.6=12 | (65+85)/2=75 | 12×75=900 |
| Right triangle [85,100] | ½×15×.6=4.5 | (85+85+100)/3=90 | 4.5×90=405 |

The horizontal centroid of a triangle is the average of the three vertex x-coordinates. Add areas: 4.5+12+4.5=21. Add moments:270+900+405=1575. Divide 1575/21=75, agreeing with symmetry.

---

## TEE · Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q2b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q2b

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**With reference to the Gaussian Mixture Model (GMM): compare GMM with the k-means algorithm; derive the equation for the log-likelihood function; state the number of parameters to be computed if K = 5.** [10 marks]

### Answer

## Read the derivation’s symbols first

“i.i.d.” means the observations are modelled as independent draws from the same distribution. The product Π runs over observations; the inner sum Σ runs over components. λki in some notes is the same responsibility that other sections call γik. A superscript i here labels the observation, not an exponent.

Jensen’s inequality gives a lower bound on the log of the component sum. EM chooses responsibilities making that bound touch the current likelihood, then updates the parameters to maximise the bound with those responsibilities fixed. This explains the two alternating steps; λ values are not arbitrary new model parameters.

| Parameter | Number in a 1D K-component GMM | Why |
| --- | --- | --- |
| Means | K | One centre for each component |
| Variances | K | One spread for each component |
| Independent mixing weights | K−1 | The last weight is 1 minus the others |
| Total | 3K−1 | K+K+(K−1) |

For K=2, choose μ₁,μ₂,σ₁²,σ₂² and π₁: five free numbers. Then π₂=1−π₁. For K=5, 5+5+4=14. In 2D with a full covariance matrix, each component instead has two means and three independent covariance entries (two variances and one shared off-diagonal covariance). Five such components have 5×(2+3)+4=29 free parameters.

### 1. GMM versus k-means

| Aspect | k-means | GMM |
| --- | --- | --- |
| Assignment | Hard: each point in exactly one cluster | Soft: probability 

$$
\lambda_k^i
$$

 of belonging to each cluster |
| Model | Geometric: nearest centroid | Probabilistic generative model 

$$
\sum_k\pi_k\mathcal N(\mu_k,\Sigma_k)
$$

 |
| Cluster shape | Spherical, similar size | Elliptical, any size/orientation; overlapping clusters |
| Parameters | K centroids | Weights, means, covariances (1-D: 3K − 1) |
| Algorithm / objective | Assign–update; minimise squared distances | EM; maximise log-likelihood |
| Output | Hard labels and fitted centroids | Labels, membership probabilities and a density (useful for anomaly detection) |
| Relation | The hard-assignment, equal spherical variance, small-variance limit of a Gaussian-mixture objective leads to the k-means objective. Ordinary finite-variance EM is not the same algorithm as k-means. Both need K in advance and depend on initialisation. | |

### 2. Derivation of the log-likelihood

**Step 1. Model.** Each point is generated by choosing component k with probability 

$$
\pi_k
$$

 and drawing 

$$
x_i\sim\mathcal N(\mu_k,\sigma_k^2)
$$

, so its density is 

$$
f_{mix}(x_i)=\sum_k\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)
$$

.

**Step 2. Likelihood.** Points are i.i.d., so the likelihood is a product (θ = all parameters):



$$
L(\theta)=\prod_{i=1}^{n}\Big[\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big]
$$



**Step 3. Log-likelihood.** Logs turn the product into a sum:



$$
\log L(\theta)=\sum_{i=1}^{n}\log\Big(\sum_{k=1}^{K}\pi_k\frac{1}{\sqrt{2\pi}\,\sigma_k}e^{-\frac{(x_i-\mu_k)^2}{2\sigma_k^2}}\Big)
$$



**Step 4. Why it cannot be solved directly.** The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.

**Step 5. Jensen's inequality.** log is concave, so for weights 

$$
\lambda_k\ge0,\;\sum\lambda_k=1
$$

: 

$$
\log\big(\sum_k\lambda_ka_k\big)\ge\sum_k\lambda_k\log a_k
$$

. Introduce 

$$
\lambda_k^i
$$

 for every point (

$$
\sum_k\lambda_k^i=1
$$

), multiply and divide inside the log:



$$
\log L(\theta)=\sum_i\log\Big(\sum_k\lambda_k^i\,\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}\Big)\;\ge\;\sum_i\sum_k\lambda_k^i\log\frac{\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\lambda_k^i}
$$



**Step 6. Estimation (EM).** Maximise the lower bound alternately. Fixing θ gives the E-step 

$$
\lambda_k^i=\pi_k\mathcal N(x_i\mid\mu_k,\sigma_k^2)/\sum_l\pi_l\mathcal N(x_i\mid\mu_l,\sigma_l^2)
$$

. Fixing λ and differentiating (with a Lagrange multiplier for 

$$
\sum\pi_k=1
$$

) gives the M-step:



$$
\hat\mu_k=\frac{\sum_i\lambda_k^ix_i}{\sum_i\lambda_k^i},\qquad\hat\sigma_k^2=\frac{\sum_i\lambda_k^i(x_i-\hat\mu_k)^2}{\sum_i\lambda_k^i},\qquad\hat\pi_k=\frac{\sum_i\lambda_k^i}{n}
$$



### 3. Number of parameters for K = 5

The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:



$$
2K+(K-1)=3K-1=3(5)-1=\mathbf{14}
$$



(5 means + 5 variances + 4 free weights, since the 5 weights must add to 1.) In two dimensions with full covariance it would be 29.

**Slide note.** One slide puts the convex inequality under the “concave” heading. Correct: log is *concave*, so 

$$
f(\sum\lambda a)\ge\sum\lambda f(a)
$$

 (≥, not >).

---

## TEE · Q3(a) Bayesian network: fever given no flu [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q3a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q3a

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Weather → Flu, Weather → Cough, Flu and Cough → Fever. P(Weather) = 0.75; P(Flu | W) = 0.2, P(Flu | ¬W) = 0.5; P(Cough | W) = 0.70, P(Cough | ¬W) = 0.25; P(Fever | Flu, Cough) = 0.60, P(Fever | Flu, ¬Cough) = 0.02, P(Fever | ¬Flu, Cough) = 0.60, P(Fever | ¬Flu, ¬Cough) = 0.01. Calculate the probability of a person having fever given he doesn't have flu.** [10 marks]

### Answer

The following table enumerates the values of Weather and Cough that were not fixed by the question. Two Boolean choices give four rows: true/true, true/false, false/true, false/false. Each row is one mutually exclusive complete case. Read the CPT entry using that row’s parent values, multiply its factors, and add the resulting row weights. The denominator must include all cases matching the evidence, including both possible values of the queried outcome.

#### Given

W→F, W→C, (F,C)→V. The complete probabilities are in the question. Evidence F=false.

#### To find

P(V=true | F=false), summing hidden W and C.

#### Formula and why it applies

Use the network joint and normalise by the no-Flu evidence.



$$
P(V\mid\neg F)=\frac{\sum_{w,c}P(w)P(\neg F\mid w)P(c\mid w)P(V\mid\neg F,c)}{\sum_wP(w)P(\neg F\mid w)}
$$



#### Solution

Swipe across the diagram to read its labels ↔

![Re-exam 2026 Q3a: weather–flu–cough–fever network](https://deep-learning-study-room.vercel.app/is2/fig/bn_flu.1d732f0fb6.svg)

Diagram: Re-exam 2026 Q3a: weather–flu–cough–fever network. Labels: Re-exam 2026 Q3a: weather–flu–cough–fever network | Weather | P(W) = 0.75 | Flu | P(F|W) = 0.2, P(F|¬W) = 0.5 | Cough | P(C|W) = 0.7, P(C|¬W) = 0.25 | Fever | P(V|F,C): .60 · .02 · .60 · .01 | (TT · TF · FT · FF)

##### Step 1. Chain rule



$$
P(W,F,C,V)=P(W)\,P(F\mid W)\,P(C\mid W)\,P(V\mid F,C)
$$



##### Step 2. Sum over W and C with F = false, V = true

| W | C | P(W) | P(¬F|W) | P(C|W) | P(V|¬F,C) | Product |
| --- | --- | --- | --- | --- | --- | --- |
| T | T | 0.75 | 0.8 | 0.70 | 0.60 | 0.252 |
| T | F | 0.75 | 0.8 | 0.30 | 0.01 | 0.0018 |
| F | T | 0.25 | 0.5 | 0.25 | 0.60 | 0.01875 |
| F | F | 0.25 | 0.5 | 0.75 | 0.01 | 0.0009375 |
| **P(V, ¬F)** | | | | | | **0.2734875** |

##### Step 3. Evidence



$$
P(\lnot F)=0.75(0.8)+0.25(0.5)=0.6+0.125=0.725
$$



##### Step 4. Divide



$$
P(V\mid\lnot F)=\frac{0.2734875}{0.725}=0.3772
$$



**Final answer.** P(fever | no flu) ≈ **0.377** (fever without flu comes mostly from cough).

**Key correction.** The key uses P(Flu) = 0.05 and P(Fever | ¬Flu) = 0.2, which are not in this network, and answers 0.2. Marking scheme (still applies): write the equation with hidden variables (2), take true/false cases (3), substitute (2), answer (3).

---

## TEE · Q3(b) Fuzzy relations and composition [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q3b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q3b

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. A = {0.6/small + 0.4/medium + 0.1/large}, B = {0.4/slow + 0.8/moderate + 0.3/fast}, C = {0.5/small + 0.2/medium + 0.4/large}. Find R = A × B, S = C × B and the max–min composition S ∘ R.** [10 marks]

### Answer

#### Given

The fuzzy sets or relation matrices and their listed row/column order.

#### To find

The relation matrix/matrices and the composition specified in the question.

#### Formula and why it applies

For Cartesian products take min of row and column membership. For the ordered matrix composition shown here:



$$
T_{ik}=\max_j\min(S_{ij},R_{jk})
$$



If max–product is asked instead, replace the inner min by multiplication.

#### Solution

##### Step 1. R and S



$$
R=\begin{bmatrix}0.4&0.6&0.3\\0.4&0.4&0.3\\0.1&0.1&0.1\end{bmatrix},\qquad S=\begin{bmatrix}0.4&0.5&0.3\\0.2&0.2&0.2\\0.4&0.4&0.3\end{bmatrix}
$$



##### Step 2. S ∘ R



$$
(1,1)=\max[\min(.4,.4),\min(.5,.4),\min(.3,.1)]=\max(.4,.4,.1)=0.4
$$





$$
(1,2)=\max[\min(.4,.6),\min(.5,.4),\min(.3,.1)]=\max(.4,.4,.1)=0.4
$$





$$
(1,3)=\max[\min(.4,.3),\min(.5,.3),\min(.3,.1)]=0.3
$$





$$
\text{row 2 (all 0.2)}=(0.2,0.2,0.2);\quad(3,1)=\max(.4,.4,.1)=0.4,\;(3,2)=\max(.4,.4,.1)=0.4,\;(3,3)=0.3
$$



**Final answer.** 

$$
R=\begin{bmatrix}.4&.6&.3\\.4&.4&.3\\.1&.1&.1\end{bmatrix}
$$

, 

$$
S=\begin{bmatrix}.4&.5&.3\\.2&.2&.2\\.4&.4&.3\end{bmatrix}
$$

, 

$$
S\circ R=\begin{bmatrix}0.4&0.4&0.3\\0.2&0.2&0.2\\0.4&0.4&0.3\end{bmatrix}
$$

. (The key gives R and S only.)

## Every cell without the row shortcuts

Both printed relations run from size to speed; their middle labels do not match for genuine relation composition. The numerical working below follows the question’s intended row-of-S with column-of-R operation using explicitly assumed positional alignment of the three middle entries.

### R: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| R11 | 0.6 | 0.4 | 0.4 |
| R12 | 0.6 | 0.8 | 0.6 |
| R13 | 0.6 | 0.3 | 0.3 |
| R21 | 0.4 | 0.4 | 0.4 |
| R22 | 0.4 | 0.8 | 0.4 |
| R23 | 0.4 | 0.3 | 0.3 |
| R31 | 0.1 | 0.4 | 0.1 |
| R32 | 0.1 | 0.8 | 0.1 |
| R33 | 0.1 | 0.3 | 0.1 |

### S: Cartesian-product cells

| Cell | Row degree | Column degree | min result |
| --- | --- | --- | --- |
| S11 | 0.5 | 0.4 | 0.4 |
| S12 | 0.5 | 0.8 | 0.5 |
| S13 | 0.5 | 0.3 | 0.3 |
| S21 | 0.2 | 0.4 | 0.2 |
| S22 | 0.2 | 0.8 | 0.2 |
| S23 | 0.2 | 0.3 | 0.2 |
| S31 | 0.4 | 0.4 | 0.4 |
| S32 | 0.4 | 0.8 | 0.4 |
| S33 | 0.4 | 0.3 | 0.3 |

**Result cell (1,1)**



$$
\max\{\min(0.4,0.4),\min(0.5,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (1,2)**



$$
\max\{\min(0.4,0.6),\min(0.5,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (1,3)**



$$
\max\{\min(0.4,0.3),\min(0.5,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.3,0.3,0.1\}=0.3
$$



**Result cell (2,1)**



$$
\max\{\min(0.2,0.4),\min(0.2,0.4),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (2,2)**



$$
\max\{\min(0.2,0.6),\min(0.2,0.4),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (2,3)**



$$
\max\{\min(0.2,0.3),\min(0.2,0.3),\min(0.2,0.1)\}
$$





$$
=\max\{0.2,0.2,0.1\}=0.2
$$



**Result cell (3,1)**



$$
\max\{\min(0.4,0.4),\min(0.4,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (3,2)**



$$
\max\{\min(0.4,0.6),\min(0.4,0.4),\min(0.3,0.1)\}
$$





$$
=\max\{0.4,0.4,0.1\}=0.4
$$



**Result cell (3,3)**



$$
\max\{\min(0.4,0.3),\min(0.4,0.3),\min(0.3,0.1)\}
$$





$$
=\max\{0.3,0.3,0.1\}=0.3
$$



---

## TEE · Q4(a) PSO, one iteration [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q4a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q4a

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Maximize 

$$
F(x)=x_1^2-x_1x_2+x_2^2+3x_1+4x_2+5
$$

 using Particle Swarm Optimization. 

$$
X=\begin{bmatrix}3.1472&-4.0246\\4.0579&-2.2150\end{bmatrix},\;V=\begin{bmatrix}0.2194&0.2449\\0.1908&0.2228\end{bmatrix}
$$

. Take 

$$
W=0.9,\;c_1=c_2=1.5,\;r_1=0.5949,\;r_2=0.0855
$$

. Optimize and give the solution after 1 iteration showing the step-by-step process.** [10 marks]

### Answer

#### Given

P1: 

$$
x=(3.1472,\,-4.0246)
$$

, 

$$
v=(0.2194,\,0.2449)
$$

. P2: 

$$
x=(4.0579,\,-2.2150)
$$

, 

$$
v=(0.1908,\,0.2228)
$$

. 

$$
c_1r_1=0.89235
$$

, 

$$
c_2r_2=0.12825
$$

.

#### To find

Updated velocities, positions, pbest and gbest after one iteration.

#### Formula and why it applies



$$
v^{new}=wv+c_1r_1(pbest-x)+c_2r_2(gbest-x),\quad x^{new}=x+v^{new}
$$



Initial personal bests equal the starting positions. Use one frozen global best for all particles. This question maximises fitness, so keep a memory only when its score is larger.

#### Solution

##### Step 1. Fitness of P1 (term by term)



$$
x_1^2=9.904868,\;-x_1x_2=+12.666221,\;x_2^2=16.197405,\;3x_1=9.4416,\;4x_2=-16.0984
$$





$$
F_1=9.904868+12.666221+16.197405+9.4416-16.0984+5=37.1117
$$



##### Step 2. Fitness of P2



$$
F_2=16.466552+8.988249+4.906225+12.1737-8.86+5=38.6747
$$



##### Step 3. pbest and gbest

pbest = current positions. 

$$
38.6747>37.1117
$$

, so **gbest = P2 = (4.0579, −2.2150)**.

##### Step 4. Particle 1 updates



$$
v_{11}=0.9(0.2194)+0+0.12825(4.0579-3.1472)=0.19746+0.116797=0.314257
$$





$$
x_{11}=3.1472+0.314257=3.461457
$$





$$
v_{12}=0.9(0.2449)+0+0.12825(-2.2150+4.0246)=0.22041+0.232081=0.452491
$$





$$
x_{12}=-4.0246+0.452491=-3.572109
$$



##### Step 5. Particle 2 updates (gbest particle: only inertia acts)



$$
v_{21}=0.9(0.1908)=0.17172,\quad x_{21}=4.22962;\qquad v_{22}=0.9(0.2228)=0.20052,\quad x_{22}=-2.01448
$$



##### Step 6. New fitness and bests

Use the same objective at each new position. Keep full precision internally; displayed coordinates are rounded.



$$
F(3.461457275,-3.5721088)=(3.461457275)^2-(3.461457275)(-3.5721088)+(-3.5721088)^2+3(3.461457275)+4(-3.5721088)+5
$$





$$
=11.981686467+12.364701993+12.759961279+10.384371825+(-14.2884352)+5\approx38.202286364
$$





$$
F(4.22962,-2.01448)=(4.22962)^2-(4.22962)(-2.01448)+(-2.01448)^2+3(4.22962)+4(-2.01448)+5
$$





$$
=17.889685344+8.520484898+4.05812967+12.68886+(-8.05792)+5\approx40.099239912
$$



| Particle | New position | New F | Old F | pbest |
| --- | --- | --- | --- | --- |
| 1 | (3.461457, −3.572109) | 38.2023 | 37.1117 | updated |
| 2 | (4.22962, −2.01448) | 40.0992 | 38.6747 | updated |

The best pbest is now P2's with F = 40.0992, so gbest moves to (4.22962, −2.01448).

**Final answer.** 

$$
V=\begin{bmatrix}0.314257&0.452491\\0.17172&0.20052\end{bmatrix}
$$

, 

$$
X=\begin{bmatrix}3.461457&-3.572109\\4.22962&-2.01448\end{bmatrix}
$$

. Both particles improved; new gbest = (4.22962, −2.01448) with F = 40.0992.

**Official key warning.** The re-exam answer key solves a *different* problem: particles (0.4, 0.3) and (0.3, 0.4) with velocities (0.1, −0.2) and (−0.2, 0.1), giving fitness 7.53 and 7.86. Do not copy it. The numbers above solve the question as printed.

This X and V are particles 1 and 2 of your lecture's five-particle example; only the function differs (+3x₁ and +5 here instead of +2x₁ and +3).

---

## TEE · Q4(b) Naive Bayes: job offer [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q4b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q4b

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Predict whether a candidate accepts a job offer from Experience (Fresher/Mid/Senior), Expected Salary (Low/Medium/High) and Company Reputation (Good/Average). Data: (Fresher, Low, Good, Yes), (Mid, High, Good, Yes), (Senior, High, Average, No), (Fresher, Medium, Average, Yes), (Senior, Low, Good, No), (Mid, Medium, Good, Yes), (Fresher, High, Average, No), (Senior, Medium, Average, No). New candidate: Mid, Low, Good.** [10 marks]

### Answer

#### Given

The full training data are in Step 1. Query: Experience=Mid, Salary=Low, Reputation=Good. The main calculation uses unsmoothed counts.

#### To find

Both class scores and the predicted class.

#### Formula and why it applies



$$
score(C)=P(C)\prod_jP(a_j\mid C)
$$



C is a class label. Each aⱼ is one query feature value. First count inside a class, then multiply the prior and all three likelihoods.

#### Solution

##### Step 1. Write the training rows as a table

| Row | Experience | Salary | Reputation | Class |
| --- | --- | --- | --- | --- |
| 1 | Fresher | Low | Good | Yes |
| 2 | Mid | High | Good | Yes |
| 3 | Senior | High | Average | No |
| 4 | Fresher | Medium | Average | Yes |
| 5 | Senior | Low | Good | No |
| 6 | Mid | Medium | Good | Yes |
| 7 | Fresher | High | Average | No |
| 8 | Senior | Medium | Average | No |

##### Step 2. Separate the two class groups

| Class | Rows in this group | Class count | Prior |
| --- | --- | --- | --- |
| Yes | 1, 2, 4, 6 | 4 | 4/8 = 0.5 |
| No | 3, 5, 7, 8 | 4 | 4/8 = 0.5 |

##### Step 3. For class Yes, count Experience=Mid

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 2, 6.



$$
P(\text{Experience}=\text{Mid}\mid C=\text{Yes})=\frac{2}{4}=0.5
$$



##### Step 4. For class Yes, count Salary=Low

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1.



$$
P(\text{Salary}=\text{Low}\mid C=\text{Yes})=\frac{1}{4}=0.25
$$



##### Step 5. For class Yes, count Reputation=Good

Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1, 2, 6.



$$
P(\text{Reputation}=\text{Good}\mid C=\text{Yes})=\frac{3}{4}=0.75
$$



##### Step 6. Multiply the Yes score one factor at a time



$$
P(Yes)=4/8=0.5
$$





$$
0.5\times0.5=0.25
$$





$$
0.25\times0.25=0.0625
$$





$$
0.0625\times0.75=0.046875
$$



##### Step 7. For class No, count Experience=Mid

Look only at class No rows 3, 5, 7, 8. No row in this class has that feature value.



$$
P(\text{Experience}=\text{Mid}\mid C=\text{No})=\frac{0}{4}=0
$$



##### Step 8. For class No, count Salary=Low

Look only at class No rows 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Salary}=\text{Low}\mid C=\text{No})=\frac{1}{4}=0.25
$$



##### Step 9. For class No, count Reputation=Good

Look only at class No rows 3, 5, 7, 8. The matching rows are 5.



$$
P(\text{Reputation}=\text{Good}\mid C=\text{No})=\frac{1}{4}=0.25
$$



##### Step 10. Multiply the No score one factor at a time



$$
P(No)=4/8=0.5
$$





$$
0.5\times0=0
$$





$$
0\times0.25=0
$$





$$
0\times0.25=0
$$



##### Step 11. Compare the scores



$$
score(Yes)=0.046875\qquad score(No)=0
$$



The larger score belongs to Yes. Normalise only if a posterior probability is requested: divide each score by their total 0.046875.

**Final answer.** Predict Yes. Yes score=0.046875; No score=0.

**Official key note.** The key gives No = 0.0068 and P(Yes) = 0.873. That No value comes from Laplace smoothing (1/7 × 2/7 × 2/6 × 0.5), but the key did not smooth the Yes side. If you smooth, smooth both: Yes = 0.5 × 3/7 × 2/7 × 4/6 = 0.0408, No = 0.0068, P(Yes) = 0.857. The prediction is Yes either way.

**Yaad rakho:** Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.

---

## TEE · Q5(a) Genetic algorithm [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q5a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q5a

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Implement a GA to maximise 

$$
f(x)=2x^3-3x^2+8x
$$

 for x in [0,50]. Take 4-bit representations of 12, 20, 17, 13. Crossover after the second bit and mutate by flipping any one bit. Produce two offspring and comment on fitness.** [10 marks]

### Answer

**The printed data are inconsistent.** 20 and 17 do not fit into four bits, and covering 0–50 needs six bits. We use six-bit encoding to preserve the supplied parent values and the stated range.

#### Given

Printed parents: [12, 20, 17, 13]. Worked variant: [12, 20, 17, 13] with 6 bits. For the unspecified selection step, select the two highest-fitness candidates. For the unspecified mutation location, flip the last bit of each child. Crossover is after bit 2.

#### To find

Two valid children under the declared assumptions and their fitness.

#### Formula and why it applies

Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.



$$
f(x)=2x^3-3x^2+8x
$$



#### Solution

##### Step 1. Encode and evaluate the declared parent population

| x | Binary | Fitness substitution |
| --- | --- | --- |
| 12 | 001100 | 2(12³) − 3(12²) + 8(12) = 3120 |
| 20 | 010100 | 2(20³) − 3(20²) + 8(20) = 14960 |
| 17 | 010001 | 2(17³) − 3(17²) + 8(17) = 9095 |
| 13 | 001101 | 2(13³) − 3(13²) + 8(13) = 3991 |

##### Step 2. Select the two fittest under the stated assumption

[20, 17] with fitness [14960, 9095].

##### Step 3. Cut after bit 2 and exchange tails

| Parent 1 | Parent 2 | Child 1 | Child 2 |
| --- | --- | --- | --- |
| 01 | 0100 | 01 | 0001 | 010001 | 010100 |

##### Step 4. Flip the last bit of each child

| Before | After | Decoded x |
| --- | --- | --- |
| 010001 | 010000 | 16 |
| 010100 | 010101 | 21 |

##### Step 5. Evaluate both children

| x | Fitness calculation |
| --- | --- |
| 16 | 2(4096) − 3(256) + 8(16) = 7552 |
| 21 | 2(9261) − 3(441) + 8(21) = 17367 |

##### Step 6. Compare with the selected parents

Best parent score = 14960; best child score = 17367. Parent average = 12027.5; child average = 12459.5. Both the best score and the average score increased in this worked variant. An individual child can still be worse than a parent; GA does not guarantee improvement after every random operator.

**Final answer.** Under these declared repairs and operator choices, children are [16, 21] with fitness [7552, 17367]. These are not unique answers to the inconsistent and under-specified original question.

The printed wording about “two offspring” is not an explicit requirement for two complete generations. The M2 examples separately work two full generations because your class update asks for iteration 2.

## Evaluate the polynomial without skipping the powers

Calculate x²=x×x, then x³=x²×x. Multiply each by its coefficient and combine with the written signs. A bit-string repair in the worked answer is an explicitly stated response to inconsistent printed givens; it is not a new instruction in the original paper.

### x=12



$$
x^2=12\times12=144\qquad x^3=144\times12=1728
$$





$$
2x^3=3456\quad 3x^2=432\quad 8x=96
$$





$$
f(12)=3456-432+96=3120
$$



### x=20



$$
x^2=20\times20=400\qquad x^3=400\times20=8000
$$





$$
2x^3=16000\quad 3x^2=1200\quad 8x=160
$$





$$
f(20)=16000-1200+160=14960
$$



### x=17



$$
x^2=17\times17=289\qquad x^3=289\times17=4913
$$





$$
2x^3=9826\quad 3x^2=867\quad 8x=136
$$





$$
f(17)=9826-867+136=9095
$$



### x=13



$$
x^2=13\times13=169\qquad x^3=169\times13=2197
$$





$$
2x^3=4394\quad 3x^2=507\quad 8x=104
$$





$$
f(13)=4394-507+104=3991
$$



### x=16



$$
x^2=16\times16=256\qquad x^3=256\times16=4096
$$





$$
2x^3=8192\quad 3x^2=768\quad 8x=128
$$





$$
f(16)=8192-768+128=7552
$$



### x=21



$$
x^2=21\times21=441\qquad x^3=441\times21=9261
$$





$$
2x^3=18522\quad 3x^2=1323\quad 8x=168
$$





$$
f(21)=18522-1323+168=17367
$$



---

## TEE · Q5(b) Hotel booking channels (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q5b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q5b

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Bookings come via Website (W), App (A) or Counter (C). From W: 50% W, 30% A, 20% C. From A: 40% A, 40% W, 20% C. From C: 20% W, 30% A, 50% C. 1. Develop the transition matrix. 2. Interpret retention and gain/loss. 3. Draw the diagram. 4. If now 40% W, 35% A, 25% C, estimate next week. 5. Which channel grows or shrinks in the long term?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: W, A, C. Initial vector [0.4, 0.35, 0.25].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | W | A | C |
| --- | --- | --- | --- |
| W | 0.5 | 0.3 | 0.2 |
| A | 0.4 | 0.4 | 0.2 |
| C | 0.2 | 0.3 | 0.5 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_booking.a7176dff51.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Weekly booking channel: Website, App, Counter | 0.3 | 0.2 | 0.4 | 0.2 | 0.2 | 0.3 | 0.5 | 0.4 | 0.5 | W | A | C

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to W

| Origin | Current count/share | Transition to W | Contribution |
| --- | --- | --- | --- |
| W | 0.4 | 0.5 | 0.4 × 0.5 = 0.2 |
| A | 0.35 | 0.4 | 0.35 × 0.4 = 0.14 |
| C | 0.25 | 0.2 | 0.25 × 0.2 = 0.05 |



$$
W_{new}=0.2+0.14+0.05=0.39
$$



##### Step 4. Next step: collect all contributions to A

| Origin | Current count/share | Transition to A | Contribution |
| --- | --- | --- | --- |
| W | 0.4 | 0.3 | 0.4 × 0.3 = 0.12 |
| A | 0.35 | 0.4 | 0.35 × 0.4 = 0.14 |
| C | 0.25 | 0.3 | 0.25 × 0.3 = 0.075 |



$$
A_{new}=0.12+0.14+0.075=0.335
$$



##### Step 5. Next step: collect all contributions to C

| Origin | Current count/share | Transition to C | Contribution |
| --- | --- | --- | --- |
| W | 0.4 | 0.2 | 0.4 × 0.2 = 0.08 |
| A | 0.35 | 0.2 | 0.35 × 0.2 = 0.07 |
| C | 0.25 | 0.5 | 0.25 × 0.5 = 0.125 |



$$
C_{new}=0.08+0.07+0.125=0.275
$$



##### Step 6. Stationarity: find Counter first



$$
c=0.2w+0.2a+0.5c
$$



Since w+a+c=1, replace w+a with 1−c.



$$
c=0.2(1-c)+0.5c=0.2+0.3c
$$





$$
0.7c=0.2\quad c=2/7
$$



##### Step 7. Find App in terms of Website



$$
a=0.3w+0.4a+0.3c
$$





$$
0.6a=0.3w+0.3c\quad a=0.5w+0.5c
$$



##### Step 8. Use the sum to isolate Website



$$
w+(0.5w+0.5c)+c=1
$$





$$
1.5w=1-1.5c=1-3/7=4/7
$$





$$
w=(4/7)/1.5=8/21
$$





$$
a=1-w-c=1-8/21-6/21=7/21=1/3
$$



##### Step 9. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| W | 0.4 | 0.380952381 | -0.019047619 | Loses |
| A | 0.35 | 0.333333333 | -0.016666667 | Loses |
| C | 0.25 | 0.285714286 | 0.035714286 | Gains |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [0.39, 0.335, 0.275]. Stationary shares ≈ [0.380952381, 0.333333333, 0.285714286]. W loses, A loses, C gains.

---

## TEE · Q6(a) ACO for TSP [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q6a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q6a

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. For the four-city travelling salesman problem the distance matrix and pheromone matrix are given (all pheromones 1). Apply Ant Colony Optimization. Calculate the path travelled by 2 ants starting from city A; random numbers for Ant 1 are 0.3, 0.8 and for Ant 2 are 0.5, 0.7. Also update the pheromone matrix after 1 iteration.** [10 marks]

### Answer

#### Given



$$
D=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&1&2&3\\B&1&0&4&5\\C&2&4&0&6\\D&3&5&6&0\end{array},\qquad\tau_{ij}=1\;(i\ne j)
$$



Assume 

$$
\alpha=\beta=1,\;\rho=0.5,\;Q=1
$$

.

#### To find

Both tours, their lengths and the pheromone matrix after one iteration.

#### Formula and why it applies



$$
P_{ij}=\frac{\tau_{ij}^{\alpha}(1/d_{ij})^\beta}{\sum_{k\in allowed}\tau_{ik}^{\alpha}(1/d_{ik})^\beta}
$$





$$
\tau_{ij}^{new}=(1-\rho)\tau_{ij}+\sum_{k:\,ij\in tour_k}\frac{Q}{L_k}
$$



Use unvisited cities in alphabetical order for cumulative selection. Every ant completes its tour using old pheromones; then evaporate and deposit on each undirected edge, including the return edge.

#### Solution

##### Step 1. From A



$$
\eta:\;B=1,\;C=0.5,\;D=0.3333;\;\text{sum}=1.8333\Rightarrow P=0.5455,\;0.2727,\;0.1818
$$



Cumulative: B 0–0.5455, C 0.5455–0.8182, D 0.8182–1. Ant 1 (0.3) → **B**; Ant 2 (0.5) → **B**.

##### Step 2. From B (C and D left)



$$
\eta:\;C=0.25,\;D=0.2;\;\text{sum}=0.45\Rightarrow P_{BC}=0.5556,\;P_{BD}=0.4444
$$



Cumulative: C 0–0.5556, D 0.5556–1. Ant 1 (0.8) → **D**; Ant 2 (0.7) → **D**.

##### Step 3. Complete the tours



$$
A\to B\to D\to C\to A,\qquad L=1+5+6+2=14\;\text{(both ants)}
$$



Swipe across the diagram to read its labels ↔

![Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14](https://deep-learning-study-room.vercel.app/is2/fig/aco_reexam_graph.02195c6ee9.svg)

Diagram: Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14. Labels: Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14 | 1 | 2 | 3 | 4 | 5 | 6 | A | B | C | D

##### Step 4. Pheromone update

Used edges AB, BD, DC, CA get 

$$
0.5(1)+2\times\frac1{14}=0.6429
$$

; unused edges AD and BC become 

$$
0.5
$$

.



$$
\tau_{\text{new}}=\begin{array}{c|cccc}&A&B&C&D\\\hline A&0&0.6429&0.6429&0.5\\B&0.6429&0&0.5&0.6429\\C&0.6429&0.5&0&0.6429\\D&0.5&0.6429&0.6429&0\end{array}
$$



**Final answer.** Both ants: A → B → D → C → A, length 14. Pheromone 0.6429 on AB, BD, CD, AC; 0.5 on AD, BC.

**Official key note.** This key applies *no evaporation* (

$$
1+0.1428=1.1428
$$

) and its matrix is inconsistent: it increases the unused edge A–D, leaves the used return edge C–A at 1, and gives B–D and D–B different values. If your examiner follows the no-evaporation idea, the consistent version is 1.1429 on AB, BD, CD, AC and 1 on AD, BC. The paper does not specify ρ. State the convention you use; the resulting matrix depends on it. Grading depends on the examiner’s intended convention.

---

## TEE · Q6(b) Aircraft movement between hubs (Markov chain) [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q6b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q6b

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Question. Planes at A: 50% stay, 30% to B, 20% to C. At B: 40% to A, 40% stay, 20% to C. At C: 25% to A, 25% to B, 50% stay. 1. Construct the matrix. 2. Interpret retention and movement. 3. Draw the diagram. 4. For [30, 40, 30] find the next night's distribution. 5. Which airport is a long-term net gainer or loser?** [10 marks]

### Answer

#### Given

All transition values are given in the full question. State order: A, B, C. Initial vector [30, 40, 30].

#### To find

The matrix, diagram, next-step vector and long-run comparison.

#### Formula and why it applies

Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.



$$
x_{next}=x_{now}P\qquad\pi=\pi P,\quad\sum_i\pi_i=1
$$



#### Solution

##### Step 1. Convert every origin row to probabilities

| From / To | A | B | C |
| --- | --- | --- | --- |
| A | 0.5 | 0.3 | 0.2 |
| B | 0.4 | 0.4 | 0.2 |
| C | 0.25 | 0.25 | 0.5 |

Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.

##### Step 2. Interpret entries and draw the transitions

Diagonal entries are the fractions staying at their current state; off-diagonal entries are fractions moving to a different state. Each arrow uses its origin row and destination column. These fractions have different origin populations, so adding raw column probabilities does not give the number arriving.

Swipe across the diagram to read its labels ↔

![Each arrow is labelled with the probability of that transition.](https://deep-learning-study-room.vercel.app/is2/fig/mk_airline.779a8c5fd6.svg)

Diagram: Each arrow is labelled with the probability of that transition.. Labels: Nightly aircraft movement between hubs | 0.3 | 0.2 | 0.4 | 0.2 | 0.25 | 0.25 | 0.5 | 0.4 | 0.5 | A | B | C

Each arrow is labelled with the probability of that transition.

##### Step 3. Next step: collect all contributions to A

| Origin | Current count/share | Transition to A | Contribution |
| --- | --- | --- | --- |
| A | 30 | 0.5 | 30 × 0.5 = 15 |
| B | 40 | 0.4 | 40 × 0.4 = 16 |
| C | 30 | 0.25 | 30 × 0.25 = 7.5 |



$$
A_{new}=15+16+7.5=38.5
$$



##### Step 4. Next step: collect all contributions to B

| Origin | Current count/share | Transition to B | Contribution |
| --- | --- | --- | --- |
| A | 30 | 0.3 | 30 × 0.3 = 9 |
| B | 40 | 0.4 | 40 × 0.4 = 16 |
| C | 30 | 0.25 | 30 × 0.25 = 7.5 |



$$
B_{new}=9+16+7.5=32.5
$$



##### Step 5. Next step: collect all contributions to C

| Origin | Current count/share | Transition to C | Contribution |
| --- | --- | --- | --- |
| A | 30 | 0.2 | 30 × 0.2 = 6 |
| B | 40 | 0.2 | 40 × 0.2 = 8 |
| C | 30 | 0.5 | 30 × 0.5 = 15 |



$$
C_{new}=6+8+15=29
$$



##### Step 6. Stationarity: find C first



$$
c=0.2(a+b)+0.5c
$$





$$
c=0.2(1-c)+0.5c=0.2+0.3c
$$





$$
0.7c=0.2\quad c=2/7
$$



##### Step 7. Find B in terms of A



$$
b=0.3a+0.4b+0.25c
$$





$$
0.6b=0.3a+0.25c
$$





$$
b=0.5a+\frac5{12}c
$$



##### Step 8. Use a+b=1−c



$$
a+0.5a+\frac5{12}\frac27=1-\frac27=\frac57
$$





$$
1.5a=\frac57-\frac5{42}=\frac{25}{42}
$$





$$
a=\frac{25}{42}\div\frac32=\frac{25}{63}
$$





$$
b=1-\frac{25}{63}-\frac{18}{63}=\frac{20}{63}
$$



##### Step 9. Compare the stationary shares with the initial shares

| State | Initial share | Stationary share | Change in share | Conclusion |
| --- | --- | --- | --- | --- |
| A | 0.3 | 0.396825397 | 0.096825397 | Gains |
| B | 0.4 | 0.317460317 | -0.082539683 | Loses |
| C | 0.3 | 0.285714286 | -0.014285714 | Loses |

Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.

**Final answer.** Next-step vector [38.5, 32.5, 29.0]. Stationary shares ≈ [0.396825397, 0.317460317, 0.285714286]. A gains, B loses, C loses.

---

## TEE · Q7(a) Applications of fuzzy logic [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q7a/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q7a

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**List the applications of fuzzy logic. Explain any one application in detail.** [10 marks]

### Answer

### Definition

Fuzzy logic is a multi-valued logic, introduced by Lotfi Zadeh (1965), in which truth values range over [0, 1]; it lets machines reason with vague, human-like terms such as “slightly dirty” or “very hot”.

### Applications

| Area | Examples |
| --- | --- |
| Home appliances | Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners |
| Automotive | Automatic transmission, anti-lock braking (ABS), cruise control, engine control |
| Transportation | Traffic-signal control, Sendai subway train control (smooth braking and acceleration) |
| Consumer electronics | Camera autofocus and auto-exposure, image stabilisation |
| Industrial control | Cement kilns, pH, temperature and distillation control in chemical plants |
| Aerospace | Satellite and spacecraft attitude control |
| Medicine | Diagnosis support, anaesthesia dosage control |
| Finance and decisions | Loan approval, credit and fire-risk scoring, stock trading rules |
| AI and robotics | Robot navigation, natural-language interfaces, expert systems |

### One application in detail: fuzzy washing machine

1. **Problem.** Wash time depends on how dirty and how greasy the clothes are. These are vague (“a bit dirty”), and a fixed timer wastes water and power.
2. **Inputs and outputs.** Sensors measure dirt (turbidity of water) and grease; the output is wash time. Each is described by fuzzy sets: dirt Small/Medium/High, grease Small/Medium/High, time Very Short … Very Long.
3. **Fuzzification.** Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.
4. **Rule base.** 9 expert rules, e.g. IF dirt is High AND grease is High THEN time is Very Long; IF dirt is Small AND grease is Small THEN time is Very Short.
5. **Inference.** Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.
6. **Defuzzification.** Use the specified defuzzifier. For a separate representative-weighted illustration, strengths [.6,.4,.2] at times [25,40,60] give (.6×25+.4×40+.2×60)/(.6+.4+.2)=(15+16+12)/1.2≈35.833 minutes. These illustrative strengths are supplied here, not derived from unspecified input graphs. A Mamdani area centroid requires the full aggregate shape.
7. **Benefits.** Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.

### Advantages and disadvantages (bonus)

**Advantages:** handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. **Disadvantages:** rules and membership functions depend on expert judgement; results are hard to verify formally; tuning can take time; not suited where very high precision is required.

**Yaad rakho:** Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.

---

## TEE · Q7(b) Bellman equation and applications of RL [10]

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/mocks/paper-reexam-2026--q7b/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/mocks/paper-reexam-2026/q7b

100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.

**Explain the Bellman equation in reinforcement learning. Also give applications of reinforcement learning.** [10 marks]

### Answer

Write the answer below in this order. It fits in about two pages.

### Part A · Bellman equation (5 marks)

**1. Setting.** Reinforcement learning problems are modelled as a Markov decision process 

$$
\langle\mathcal S,\mathcal A,P,R,\gamma\rangle
$$

. The agent follows a policy 

$$
\pi(a\mid s)
$$

 and wants to maximise the return 

$$
G_t=\sum_{k\ge0}\gamma^kR_{t+k+1}
$$

.

**2. Value functions.** 

$$
v_\pi(s)=\mathbb E_\pi[G_t\mid S_t=s]
$$

 and 

$$
q_\pi(s,a)=\mathbb E_\pi[G_t\mid S_t=s,A_t=a]
$$

.

**3. Key idea.** The return is recursive: 

$$
G_t=R_{t+1}+\gamma G_{t+1}
$$

. Taking expectations gives the **Bellman expectation equation**:



$$
v_\pi(s)=\sum_a\pi(a\mid s)\sum_{s'}P(s'\mid s,a)\,[R(s,a,s')+\gamma v_\pi(s')]
$$





$$
q_\pi(s,a)=\sum_{s'}P(s'\mid s,a)\,\Big[R(s,a,s')+\gamma\sum_{a'}\pi(a'\mid s')q_\pi(s',a')\Big]
$$



**4. Optimality.** For the optimal policy the average over actions becomes a maximum (**Bellman optimality equation**):



$$
v_*(s)=\max_a\sum_{s'}P(s'\mid s,a)\,[R+\gamma v_*(s')],\qquad q_*(s,a)=\sum_{s'}P(s'\mid s,a)\,[R+\gamma\max_{a'}q_*(s',a')]
$$



**5. Meaning and use.** The value of a state equals the immediate reward plus the discounted value of the successor state. This breaks a long-horizon problem into one-step sub-problems (dynamic programming). It is the basis of policy evaluation, policy iteration, value iteration and Q-learning; the optimal policy is 

$$
\pi_*(s)=\arg\max_a q_*(s,a)
$$

.

**6. Small illustration** (adds clarity): if staying in a state gives +1 each step with 

$$
\gamma=0.9
$$

, then 

$$
v=1+0.9v\Rightarrow v=10
$$

.

### Part B · Applications of reinforcement learning (5 marks)

1. **Game playing**: AlphaGo (defeated Lee Sedol, 2016), Atari agents (DQN), and the Mario agent built in this course's lab.
2. **Robotics**: walking, grasping and balancing learned by trial and error in simulation.
3. **Autonomous driving**: lane changing, merging and parking decisions.
4. **Recommendation systems**: choosing content to maximise long-term engagement rather than single clicks.
5. **Finance**: trading and portfolio rebalancing as sequential decisions.
6. **Healthcare**: dynamic treatment regimes (dose adjustment over time).
7. **Resource and energy management**: data-centre cooling control, traffic-signal timing, inventory control.
8. **Language models**: reinforcement learning from human feedback (RLHF) for chatbots.

#### One application in detail: traffic-signal control

|  |  |
| --- | --- |
| Agent | Controller at an intersection. |
| State | Queue length and waiting time on each approach, current signal phase. |
| Actions | Keep the current phase or switch to the next green phase. |
| Reward | Negative of total waiting time (or vehicles cleared per cycle). |
| Learning | Q-learning updates 

$$
Q(s,a)
$$

 from observed traffic; ε-greedy exploration tries alternative timings. |
| Benefit | Adapts to rush hours and incidents; fixed timers cannot. |
| Challenge | Safety during exploration, so agents are trained in simulation first. |

**Yaad rakho:** Bellman ka sar: “value = reward abhi + γ × value aage”. Application likho to S, A, R batao: examiner ko yahi chahiye.

---

## TEE · The final revision: methods, theory and common mistakes

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/revision/m2-revision-v2--final-read/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/revision/m2-revision-v2/final-read

A compact read after the worked lessons.

## Q1: short calculations and definitions

| Asked for | Write |
| --- | --- |
| Union / intersection | Same element, max / min respectively. |
| Complement / difference | 1−μA / min(μA,1−μB). |
| Triangle membership | Locate x; rising (x−a)/(b−a), falling (c−x)/(c−b), 0 outside, 1 at peak. |
| Swarm intelligence | Collective problem-solving emerging from interacting simple agents; explain PSO through position, velocity, pbest and gbest. |

## GA: the table to make in the exam

Individual → current x → bit string → fitness → selected parent → crossover child → mutated child → decoded x → new fitness. Use this resulting population as the input to the second generation. The cut position and flipped bit are counted from the stated end; this guide counts from the left.

Do not change the mutation instruction midway because an answer looks worse. Without elitism, fitness can worsen. Do not confuse a mating-pool index with the decimal x value.

## PSO: the table to make in the exam

Particle → old position → old velocity → pbest → gbest → inertia/personal/social terms → new velocity → new position → new objective → retained pbest. After all particles, update gbest. For synchronous updates, freeze the old gbest throughout one iteration.

At initialisation pbest=x, hence personal pull=0. In iteration 2 it need not be zero. For minimisation, smaller objective wins; a worse move must not overwrite a better memory.

## Fuzzy controller: five operations

1. Calculate input memberships using the specified graphs.
2. Apply AND=min or the supplied connective to obtain rule strengths.
3. Clip consequents using min-implication.
4. Combine output sets by max-aggregation.
5. Use the named defuzzification method. MoM, full area centroid and peak-weighted average are different operations.

## Three short theory answers to revise

**Mamdani:** crisp inputs → fuzzifier → knowledge base and inference engine → aggregation → defuzzifier → crisp output. Rules are interpretable, but require careful membership/rule design and can grow in number.

**GA:** population search inspired by evolution, using evaluation, selection, crossover, mutation and replacement. Flexible and derivative-free, but may be expensive or converge prematurely.

**PSO:** particles move using inertia, personal best and swarm best. Simple and derivative-free, but parameter-dependent and not guaranteed to find a global optimum.

## Calculator and rounding

Enter a fraction as (whole numerator) ÷ (whole denominator). For a negative square use parentheses: (−2)²=4. Retain full calculator precision through iterations and round only the displayed result. Binary place values 8,4,2,1 can be checked manually without a special calculator mode.

**Yaad rakho:** Question ki instruction follow karo; answer ko sundar banane ke liye data ya operator mat badlo.

---

## TEE · Units 1 and 4 in one page

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/revision/tee-revision--units-1-and-4/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/revision/tee-revision/units-1-and-4

Read the night before the TEE

## Unit 1

- Logic fails under uncertainty (laziness, theoretical and practical ignorance) → degrees of belief. Decision theory = probability + utility; maximise expected utility.
- Full joint: add the cells where the statement is true; for “given”, divide by the evidence cells. Check the table sums to 1.
- Bayes: posterior = likelihood × prior ÷ evidence. A low prior can make the posterior surprisingly small even after positive evidence; calculate using the stated sensitivity and false-positive rate.
- Naive Bayes: prior × product of class-conditional likelihoods. Without smoothing, one zero likelihood makes the class score zero. Apply Laplace smoothing only when required or when you explicitly state that modelling choice.
- Bayesian network: DAG + CPTs; joint = Π P(node | parents); a node is independent of non-descendants given its parents; 

$$
2^k
$$

 numbers per Boolean node.
- Query with evidence: sum over hidden variables, both query values, normalise (α). Sprinkler PYQ: P(W | ¬R) = 0.1919 / 0.5 = 0.3838. Flu PYQ: P(Fever | ¬Flu) = 0.2735 / 0.725 = 0.3772.
- Univariate GMM: 

$$
p(x)=\sum_k\pi_k\mathcal N(x\mid\mu_k,\sigma_k^2)
$$

. With K separate means, K variances and K weights summing to 1, there are 3K − 1 free parameters (K=5 → 14). Higher-dimensional covariance models have different counts. EM alternates responsibilities and weighted parameter updates.
- EM: E-step calculates responsibilities. M-step calculates weighted means and variances, with πₖ=Nₖ/n. GMM uses soft assignments and likelihood; k-means uses hard nearest-centroid assignments and squared distance. Elliptical covariance applies to a multivariate GMM with full covariance matrices.

## Unit 4

- Agent, environment, state, action, reward, policy, value, model; exploration vs exploitation (ε-greedy).
- Markov chain: rows = from, columns = to; row sums 1; next = row vector × P; diagram with self-loops.
- Steady state: π = πP, Σπ = 1; compare with today's shares for gain/loss; diagonal = retention.
- MP ⟨S, P⟩ → MRP ⟨S, P, R, γ⟩ → MDP ⟨S, A, P, R, γ⟩.
- Bellman: value = immediate reward + γ × expected next value; optimality replaces Σπ by max.
- Applications: games, robotics, self-driving, recommendation, finance, healthcare, traffic signals, data-centre cooling, RLHF.

**Unit 1 and 4 traps:** (1) dividing by the wrong evidence in conditional questions; (2) forgetting hidden variables in Bayes nets; (3) writing 15 instead of 14 GMM parameters; (4) multiplying the transition matrix the wrong way; (5) calling a state absorbing when it is not (Pii must be 1).

---

## TEE · Portion, source priority and what was checked

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/about/about--portion-sources/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/about/about/portion-sources

What this guide covers, where it came from, and every error found in the slides and answer keys

## M2

The 8 October class update identifies Fuzzy Logic, GA and PSO, including rules, architecture, advantages/disadvantages, fuzzy operations and numerical work through iteration 2. The confirmed pattern is Q1(a) 2 marks and Q1(b) 2 marks compulsory, plus any two of three 3-mark questions. ACO and GA-for-TSP remain in TEE, not the M2 core.

## TEE official syllabus

1. Uncertain knowledge and reasoning: uncertainty, full joint distributions, Bayes, naive Bayes, Bayesian networks, mixture models, GMM, EM and clustering.
2. Fuzzy systems: rules, properties/operations, membership functions, intuition-based fuzzification, mean of maxima, centroid, Mamdani and applications.
3. Evolutionary intelligence: biological basis, GA terms/search space, simple/general GA, encoding/selection/crossover/mutation, stopping, constraints, GA-for-TSP, ACO and swarm optimisation.
4. Reinforcement learning: Markov processes, MRP, MDP, policies, value functions, Bellman equations and applications.

The course policy specifies a 100-mark, three-hour TEE scaled to 50, and 10-mark class tests. The available Final 24 November 2025 and Re-exam 31 January 2026 papers have Q1 compulsory plus any four of Q2–Q7. The next paper’s instructions take precedence.

## Source priority

Primary course sources are the AY 2026–27 syllabus and course-policy files, faculty slides and solved-problem material in the 8 October OneDrive archive, the two actual question papers, and the class data supplied in the conversation. The old generated IS2 draft and the separate generated midterm PDF are not authorities for the new teaching sequence.

Handwritten photos can contain inconsistent arithmetic or incomplete conventions. The fan example states its chosen membership functions; the PSO example states minimisation and synchronous updates. Missing selection choices, mutation bits or inconsistent encodings in older papers are labelled explicitly rather than presented as unique answers.

## Technical references used for checking conventions

- [MathWorks: fuzzy inference process](https://www.mathworks.com/help/fuzzy/fuzzy-inference-process.html) — separation of antecedent operations, implication, aggregation and defuzzification.
- [MathWorks: defuzzification definitions](https://www.mathworks.com/help/fuzzy/defuzz.html) — centroid uses the area; MoM uses locations at the maximum.
- [MathWorks: particle swarm update](https://www.mathworks.com/help/gads/particle-swarm-optimization-algorithm.html) — velocity components and best-position memory. Its adaptive neighbourhood implementation is not substituted for the fixed classroom global-best examples.

New worked numerical examples are calculated by reproducible scripts and checked separately. Build checks validate formula rendering and internal routes. This does not justify a promise that no typo can remain, that every future numerical is predictable, or that reading alone guarantees a score.

---

## TEE · How inconsistent source questions are handled

Canonical: https://deep-learning-study-room.vercel.app/read/is2/tee/about/about--corrections/

Reader: https://deep-learning-study-room.vercel.app/is2/#tee/about/about/corrections

What this guide covers, where it came from, and every error found in the slides and answer keys

## State the issue before solving a changed question

The final GA paper requests four-bit parents larger than 15 while also restricting x to 0–15. Those conditions cannot all hold. Its worked example declares a repaired parent set. The re-exam GA paper needs six bits to cover the stated 0–50 range. An encoding change must not silently change the legal range.

The final joint table sums to 1.002 rather than 1. Its lesson distinguishes ratios from the printed weights, normalisation, and an assumed typo correction. None is presented as a guaranteed marking-scheme interpretation.

Some fuzzy classroom solutions calculate a peak-weighted output and call it a centroid. The new lessons name that operation and separately teach the true area centroid. The class fan photographs do not supply one consistent complete set of membership functions, so its worked design makes every breakpoint explicit.

For relation composition, check the intermediate labels and the author’s convention for S∘R. A numerical matrix product alone does not resolve a mismatched relation domain.
