{"edition":"is2-2026-10-10-deep-review","routes":{"m2":{"read":[{"id":"m2-start","title":"Start here","unit":"M2","scope":"M2 scope and pattern confirmed in your 8 October class update.","sections":[{"id":"how-to-use","title":"Start here: your IS2 M2 study order","html":"<p class=\"lead\">Learn <strong>Fuzzy Logic → Genetic Algorithms → Particle Swarm Optimization</strong>, with the required maths explained just before it is used. The answers stay below the questions.</p>\r\n<h2>The confirmed 10-mark pattern</h2>\r\n<table><thead><tr><th>Question</th><th>Marks</th><th>Attempt rule</th><th>Prepare for</th></tr></thead><tbody>\r\n<tr><td>Q1(a)</td><td>2</td><td>Compulsory</td><td>A short numerical or theory question</td></tr>\r\n<tr><td>Q1(b)</td><td>2</td><td>Compulsory</td><td>A short numerical or theory question, including swarm intelligence</td></tr>\r\n<tr><td>Q2, Q3, Q4</td><td>3 each</td><td>Attempt any two</td><td>GA, PSO and fuzzy logic; the mix can include theory and numericals</td></tr>\r\n</tbody></table>\r\n<p>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 <strong>iteration 2</strong>. The mock question numbering is a practice arrangement; the actual exam can rearrange the topics.</p>\r\n<h2>Read in this order</h2>\r\n<ol><li><a href=\"#m2/read/core-maths/reading-formulas\">Essential maths</a>: candidate versus score, fractions, min/max, binary and two-coordinate movement.</li>\r\n<li><a href=\"#m2/read/fuzzy-core/membership-meaning\">Fuzzy logic</a>: membership meaning → graphs → set operations → rule base → Mamdani → defuzzification. Then the complete 32°C / 7-person fan example.</li>\r\n<li><a href=\"#m2/read/ga-core/meaning\">Genetic algorithms</a>: terms → encoding → selection → crossover/mutation → complete two-generation solutions.</li>\r\n<li><a href=\"#m2/read/pso-core/meaning\">PSO</a>: position, velocity and memory → single updates → two particles → two dimensions → class photograph example.</li>\r\n<li><a href=\"#m2/mocks\">Three 10-mark mocks</a>, followed by <a href=\"#m2/revision\">last-day revision</a>.</li></ol>\r\n<p>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.</p>\r\n<h2>How to write a numerical</h2><p><strong>Full question → Given → To find → Formula and why → numbered calculation steps → final answer.</strong> 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.</p>\r\n<h2>If the exam is tomorrow</h2><p>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.</p>\r\n<p class=\"memory\"><strong>Yaad rakho:</strong> Fuzzy = degree aur rules. GA = select, cross, mutate. PSO = velocity, position, best memories.</p>"}]},{"id":"core-maths","title":"1. The maths these three topics use","unit":"Start here","scope":"Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.","sections":[{"id":"reading-formulas","title":"Symbols, brackets and iteration labels: how to read a formula","html":"<h2>Read a formula as a calculation instruction</h2><p>A <strong>variable</strong> is a name for a number that can change. In <strong>f(x)=x²+1</strong>, x is the input, f is the name of the scoring rule, and f(x) is its result. An <strong>equation</strong> says that the expressions on both sides have the same value. A formula tells you how to calculate a quantity.</p><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>x²</td><td>x multiplied by itself</td><td>3² = 3 × 3 = 9</td></tr><tr><td>2x or 2(x)</td><td>2 multiplied by x</td><td>For x=3: 2x=6, while x²=9</td></tr><tr><td>f(3)</td><td>Apply the rule named f to input 3</td><td>If f(x)=x²+1, then f(3)=10</td></tr><tr><td>x₁ and x₂</td><td>First and second named entries; the small lower number is a label</td><td>If a position is (3,7), x₁=3 and x₂=7</td></tr><tr><td>x at time t</td><td>A version of x at a particular iteration</td><td>Old x=3; after a move x=2. The time label is not squaring.</td></tr><tr><td>= and ≈</td><td>Exactly equal; approximately equal after rounding</td><td>1/3 ≈ 0.333333</td></tr><tr><td>∈ and { }</td><td>Belongs to; a collection of values</td><td>x ∈ {2,5} means x may be 2 or 5</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>Evaluate f(x)=2x²+1 at x=−3.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>The rule is f(x)=2x²+1. The supplied input is x=−3.</p><h4>To find</h4><p>f(−3): the output of this rule for input −3.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/4ee7030c8a3d9d3a.svg\" alt=\"f(x)=2x^2+1\" style=\"width:14.626ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute with parentheses</h5><div class=\"math-display\"><img src=\"math/c18467bab709f205.svg\" alt=\"f(-3)=2(-3)^2+1\" style=\"width:19.58ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Do the square first</h5><div class=\"math-display\"><img src=\"math/ac40c2845414cf0d.svg\" alt=\"(-3)^2=(-3)\\times(-3)=9\" style=\"width:24.874ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Multiply by 2</h5><div class=\"math-display\"><img src=\"math/c271680245ea1d71.svg\" alt=\"2\\times9=18\" style=\"width:10.308ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add 1</h5><div class=\"math-display\"><img src=\"math/27fc155eedcc5888.svg\" alt=\"f(-3)=18+1=19\" style=\"width:20.352ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> f(−3)=19.</div></section><section class=\"example\"><p class=\"question\"><strong>Evaluate g(x)=(x−2)/4 at x=10.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>The rule is g(x)=(x−2)/4. The supplied input is x=10.</p><h4>To find</h4><p>g(10): the output of this rule for input 10.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/ef554c6170bf393e.svg\" alt=\"g(x)=\\frac{x-2}{4}\" style=\"width:13.337ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><p>The fraction bar groups the numerator x−2. Subtract 2 from the input first, then divide the entire difference by 4.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Replace the input</h5><div class=\"math-display\"><img src=\"math/e276417a70627f82.svg\" alt=\"g(10)=\\frac{10-2}{4}\" style=\"width:15.274ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Finish the numerator</h5><div class=\"math-display\"><img src=\"math/bdb801d401c03c68.svg\" alt=\"10-2=8\" style=\"width:10.308ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/40041b1514c36954.svg\" alt=\"g(10)=8/4=2\" style=\"width:15.661ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> g(10)=2.</div></section><section class=\"example\"><p class=\"question\"><strong>At iteration 0, x=4. The rule is new x = old x − 1. Find x after two iterations.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Initial value x=4 at iteration 0. Every update subtracts 1 from the current value. Perform two updates.</p><h4>To find</h4><p>The value after update 1 and after update 2.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/14d3646dbde001b1.svg\" alt=\"x^{(t+1)}=x^{(t)}-1\" style=\"width:15.567ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Iteration 1 uses the initial value</h5><div class=\"math-display\"><img src=\"math/6df71b72d0a31e70.svg\" alt=\"x^{(1)}=4-1=3\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Iteration 2 uses the updated value</h5><div class=\"math-display\"><img src=\"math/40962d708fa42c89.svg\" alt=\"x^{(2)}=3-1=2\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Distinguish a label from a power</h5><p>x at iteration 2 is 2. Squaring the initial value would give 4²=16; that is a different operation.</p></div><div class=\"answer\"><strong>Final answer.</strong> After update 1: x=3. After update 2: x=2. The sequence is 4 → 3 → 2.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Symbol sirf naam hai. Pehle bolo kaunsa number chahiye, phir uski jagah value likho.</p>"},{"id":"objective","title":"Position, score, minimisation and maximisation","html":"<h2>What are we trying to do in IS2?</h2>\r\n<p><strong>An intelligent system</strong> uses information and a decision procedure to choose an output or an action. In M2, you study three different procedures.</p><table><thead><tr><th>Topic</th><th>Input</th><th>What the procedure does</th><th>Output</th></tr></thead><tbody><tr><td>Fuzzy logic</td><td>Temperature and occupancy</td><td>Applies rules such as IF hot AND crowded THEN fast</td><td>A fan-speed setting</td></tr><tr><td>Genetic algorithm (GA)</td><td>A population of candidate answers</td><td>Selects, combines and changes candidate answers</td><td>A good solution and its fitness</td></tr><tr><td>Particle swarm optimization (PSO)</td><td>Positions and velocities of particles</td><td>Moves candidate answers using individual and shared experience</td><td>A best position and its objective value</td></tr></tbody></table>\r\n<h2>Candidate answer and score are different</h2>\r\n<p>An <strong>objective function</strong> is the calculation used to score an answer. In <strong>minimisation</strong>, a smaller score is better; in <strong>maximisation</strong>, a larger score is better. The letter <strong>x</strong> names a candidate answer. The notation <strong>f(x)</strong>, read “f of x”, means its score. Parentheses here do not mean f multiplied by x.</p><section class=\"example\"><p class=\"question\"><strong>For the minimisation problem <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span>, find the score at <span class=\"math-inline\"><img src=\"math/feb11b3ddc232396.svg\" alt=\"x=2\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/feb11b3ddc232396.svg\" alt=\"x=2\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span></p><h4>To find</h4><p>The objective value f(x).</p></div><h4>Formula and why it applies</h4><p>Replace x by the supplied number. Square means multiply the result by itself.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract 3</h5><div class=\"math-display\"><img src=\"math/55d4a2b861701691.svg\" alt=\"x-3=2-3=-1\" style=\"width:19.145ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the difference</h5><div class=\"math-display\"><img src=\"math/28ec806f80fe7e4c.svg\" alt=\"f(2)=(-1)^2=(-1)\\times(-1)=1\" style=\"width:32.026ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The position is x = 2; its score is 1. These are two different numbers.</div></section><section class=\"example\"><p class=\"question\"><strong>For the minimisation problem <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span>, find the score at <span class=\"math-inline\"><img src=\"math/7a95cf78643aae43.svg\" alt=\"x=5\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/7a95cf78643aae43.svg\" alt=\"x=5\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span></p><h4>To find</h4><p>The objective value f(x).</p></div><h4>Formula and why it applies</h4><p>Replace x by the supplied number. Square means multiply the result by itself.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract 3</h5><div class=\"math-display\"><img src=\"math/c893e43cc49d3cae.svg\" alt=\"x-3=5-3=2\" style=\"width:17.385ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the difference</h5><div class=\"math-display\"><img src=\"math/4ad5b97ffc47b26c.svg\" alt=\"f(5)=(2)^2=(2)\\times(2)=4\" style=\"width:26.746ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The position is x = 5; its score is 4. These are two different numbers.</div></section><section class=\"example\"><p class=\"question\"><strong>For the minimisation problem <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span>, find the score at <span class=\"math-inline\"><img src=\"math/2854d883b15c7a60.svg\" alt=\"x=-1\" style=\"width:7.203ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/2854d883b15c7a60.svg\" alt=\"x=-1\" style=\"width:7.203ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span></p><h4>To find</h4><p>The objective value f(x).</p></div><h4>Formula and why it applies</h4><p>Replace x by the supplied number. Square means multiply the result by itself.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract 3</h5><div class=\"math-display\"><img src=\"math/cca2cd1e0a06e8d4.svg\" alt=\"x-3=(-1)-3=-4\" style=\"width:22.665ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the difference</h5><div class=\"math-display\"><img src=\"math/dce608d3d6bd8495.svg\" alt=\"f(-1)=(-4)^2=(-4)\\times(-4)=16\" style=\"width:34.918ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The position is x = -1; its score is 16. These are two different numbers.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> x = answer ki jagah; f(x) = us answer ka score. Min mein chhota score jeetega.</p>"},{"id":"arithmetic","title":"Fractions, brackets, minimum and maximum","html":"<h2>Fractions, min and max</h2><p>A fraction means division: the top number is the <strong>numerator</strong>, and the bottom is the <strong>denominator</strong>. Calculate each bracket first. <strong>min</strong> selects the smallest listed number; <strong>max</strong> selects the largest. Neither word means addition.</p><section class=\"example\"><p class=\"question\"><strong>Evaluate <span class=\"math-inline\"><img src=\"math/df0b8ec6b8392714.svg\" alt=\"\\frac{32-25}{35-25}\" style=\"width:5.44ex;height:2.878ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Top: 32 − 25; bottom: 35 − 25.</p><h4>To find</h4><p>The quotient.</p></div><h4>Formula and why it applies</h4><p>Subtract separately in the numerator and denominator, then divide.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Calculate the numerator</h5><div class=\"math-display\"><img src=\"math/c65340df2ae7cb64.svg\" alt=\"32-25=7\" style=\"width:11.439ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate the denominator</h5><div class=\"math-display\"><img src=\"math/9a5b4bf9b146b2b2.svg\" alt=\"35-25=10\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/6b3a1b0f1231fc45.svg\" alt=\"\\frac{7}{10}=0.7\" style=\"width:9.166ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.7</div></section><section class=\"example\"><p class=\"question\"><strong>Evaluate <span class=\"math-inline\"><img src=\"math/55a4e1a39f439f8c.svg\" alt=\"\\frac{35-32}{35-25}\" style=\"width:5.44ex;height:2.878ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Top: 35 − 32; bottom: 35 − 25.</p><h4>To find</h4><p>The quotient.</p></div><h4>Formula and why it applies</h4><p>Subtract separately in the numerator and denominator, then divide.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Calculate the numerator</h5><div class=\"math-display\"><img src=\"math/b8b4baa992603f77.svg\" alt=\"35-32=3\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate the denominator</h5><div class=\"math-display\"><img src=\"math/9a5b4bf9b146b2b2.svg\" alt=\"35-25=10\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/df25a279590f4f48.svg\" alt=\"\\frac{3}{10}=0.3\" style=\"width:9.166ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.3</div></section><section class=\"example\"><p class=\"question\"><strong>Evaluate <span class=\"math-inline\"><img src=\"math/5627768e8762bda4.svg\" alt=\"\\frac{7-6}{8-6}\" style=\"width:3.84ex;height:2.894ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Top: 7 − 6; bottom: 8 − 6.</p><h4>To find</h4><p>The quotient.</p></div><h4>Formula and why it applies</h4><p>Subtract separately in the numerator and denominator, then divide.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Calculate the numerator</h5><div class=\"math-display\"><img src=\"math/e03d8b2e4fa9e9e0.svg\" alt=\"7-6=1\" style=\"width:9.176ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate the denominator</h5><div class=\"math-display\"><img src=\"math/2511936ca0026cfc.svg\" alt=\"8-6=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/0ef4a9ef78e1b7d5.svg\" alt=\"\\frac{1}{2}=0.5\" style=\"width:8.035ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.5</div></section><section class=\"example\"><p class=\"question\"><strong>Find <span class=\"math-inline\"><img src=\"math/f5116e7e9b08a405.svg\" alt=\"\\max\\{\\min(0.7,0.2),\\min(0.4,0.8)\\}\" style=\"width:32.12ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Two inner min operations followed by one outer max.</p><h4>To find</h4><p>One number.</p></div><h4>Formula and why it applies</h4><p>Work from the innermost brackets outward. This exact pattern occurs in fuzzy relation composition.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First pair</h5><div class=\"math-display\"><img src=\"math/0f24b8a13d9d75d1.svg\" alt=\"\\min(0.7,0.2)=0.2\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second pair</h5><div class=\"math-display\"><img src=\"math/8fd31f9127b73dc1.svg\" alt=\"\\min(0.4,0.8)=0.4\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Choose the larger result</h5><div class=\"math-display\"><img src=\"math/06c831ab89f196ab.svg\" alt=\"\\max(0.2,0.4)=0.4\" style=\"width:18.668ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.4.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Pehle bracket, phir divide. AND ka min; OR ka max.</p>"},{"id":"probability","title":"Percentages, probabilities and cumulative intervals","html":"<h2>Probability is a share of a specified total</h2><p>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><div class=\"math-display\"><img src=\"math/8e42f83b578b6254.svg\" alt=\"P(\\text{event})=\\frac{\\text{favourable count}}{\\text{total count}}\" style=\"width:29.228ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Red=3; blue=7. Each ball is equally likely.</p><h4>To find</h4><p>Both probabilities and their percentages.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/6e0b3ead99011455.svg\" alt=\"P(\\text{colour})=\\frac{\\text{balls of that colour}}{\\text{all balls}}\" style=\"width:31.761ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><p>All balls are equally likely, so counting them gives probability. The denominator counts all balls; the numerator counts the requested colour.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the total</h5><div class=\"math-display\"><img src=\"math/90e46c6fe6c61dca.svg\" alt=\"3+7=10\" style=\"width:10.308ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Red probability</h5><div class=\"math-display\"><img src=\"math/ac0dd61435e485bc.svg\" alt=\"P(R)=3/10=0.3=30\\%\" style=\"width:25.791ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Blue probability</h5><div class=\"math-display\"><img src=\"math/927c15e53970ce9d.svg\" alt=\"P(B)=7/10=0.7=70\\%\" style=\"width:25.791ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Red 0.3; blue 0.7. Their sum is 1.</div></section><h2>From weights to probabilities to cumulative probabilities</h2><p>A <strong>weight</strong> 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 <strong>normalisation</strong>. <strong>Cumulative</strong> means “total accumulated so far”. It turns separate shares into boundaries along a line from 0 to 1.</p><section class=\"example\"><p class=\"question\"><strong>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?</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Weights [1,2,3,4], draw 0.55. Use intervals including their lower endpoint and excluding their upper endpoint.</p><h4>To find</h4><p>Four probabilities, their running totals and the selected candidate.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/791fc41b905c43f5.svg\" alt=\"P_i=F_i/(F_A+F_B+F_C+F_D)\" style=\"width:30.117ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>F is weight. P is its share. Add P values in row order for the cumulative boundary.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Add all weights</h5><div class=\"math-display\"><img src=\"math/45a76e7db8947072.svg\" alt=\"1+2+3+4=10\" style=\"width:18.102ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Divide each weight by that same total</h5><table><thead><tr><th>Candidate</th><th>Division</th><th>Probability</th></tr></thead><tbody><tr><td>A</td><td>1÷10</td><td>0.1</td></tr><tr><td>B</td><td>2÷10</td><td>0.2</td></tr><tr><td>C</td><td>3÷10</td><td>0.3</td></tr><tr><td>D</td><td>4÷10</td><td>0.4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Build the running totals</h5><table><thead><tr><th>Candidate</th><th>Running addition</th><th>Interval</th></tr></thead><tbody><tr><td>A</td><td>0+0.1=0.1</td><td>0 ≤ r < 0.1</td></tr><tr><td>B</td><td>0.1+0.2=0.3</td><td>0.1 ≤ r < 0.3</td></tr><tr><td>C</td><td>0.3+0.3=0.6</td><td>0.3 ≤ r < 0.6</td></tr><tr><td>D</td><td>0.6+0.4=1</td><td>0.6 ≤ r ≤ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Locate the draw</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> Candidate C is selected.</div></section><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_roulette.12804497d2.svg\" width=\"720\" height=\"220\" alt=\"Each interval width equals its probability. Running totals mark the ends.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each interval width equals its probability. Running totals mark the ends.</figcaption></figure><section class=\"example\"><p class=\"question\"><strong>Two unnormalised class scores are 0.12 and 0.08. Convert them to probabilities.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Scores A=0.12 and B=0.08; they describe the only two alternatives.</p><h4>To find</h4><p>Normalised probabilities.</p></div><h4>Formula and why it applies</h4><p>Divide each score by the sum, preserving their ratio.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum the scores</h5><div class=\"math-display\"><img src=\"math/f3e0db112ddd0eb5.svg\" alt=\"0.12+0.08=0.20\" style=\"width:17.851ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Normalise A</h5><div class=\"math-display\"><img src=\"math/fd57d6dd0af66643.svg\" alt=\"P(A)=0.12/0.20=0.6\" style=\"width:23.258ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Normalise B</h5><div class=\"math-display\"><img src=\"math/a6f1afe6f9d94092.svg\" alt=\"P(B)=0.08/0.20=0.4\" style=\"width:23.279ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> A=0.6 and B=0.4. The original score 0.12 was not the final probability.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Probability = apna hissa ÷ sabka total. Cumulative = ab tak ke saare hisse jodna.</p>"},{"id":"binary","title":"Binary from the beginning: positions, place values and bits","html":"<h2>1. Position means the digit's place</h2>\r\n<p><strong>A position is simply a place occupied by one digit in a number.</strong> A digit is the symbol written there. The <strong>place value</strong> tells us how much one unit in that position is worth.</p>\r\n<p>Start with an ordinary number you already know: <strong>23</strong>. Its two digits are 2 and 3. They do not contribute the same kind of unit.</p><table><thead><tr><th></th><th>LEFT: tens place</th><th>RIGHT: ones place</th></tr></thead><tbody><tr><td>Value of this place</td><td>10</td><td>1</td></tr><tr><td>Digit written here</td><td>2</td><td>3</td></tr><tr><td>Contribution</td><td>2 × 10 = 20</td><td>3 × 1 = 3</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/46c502cb15486e6a.svg\" alt=\"23=(2\\times 10)+(3\\times 1)=20+3\" style=\"width:31.93ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The <strong>2</strong> means two tens because of where it sits. In <strong>32</strong>, the same digit 2 sits on the right and means only two ones. Changing a digit’s position can change its contribution.</p><p class=\"memory\"><strong>Yaad rakho:</strong> 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.</p><h2>2. Binary changes the size of the groups</h2>\r\n<p>Our ordinary number system is <strong>decimal</strong>: 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.</p>\r\n<p><strong>Binary</strong> has only two possible digits: <strong>0 and 1</strong>. One binary digit is called a <strong>bit</strong>. Therefore, a <strong>4-bit number means four digit boxes</strong>, each holding either 0 or 1.</p>\r\n<p>In binary, grouping happens in <strong>twos</strong>. 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 <strong>one group of two</strong> in the next box on the left.</p>\r\n<div class=\"note\"><p><strong>Binary 10 means one group of two and zero single units.</strong></p><p>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.</p></div>\r\n<p>Two groups of two make <strong>4</strong>, so the next box to the left is the fours place. Two groups of four make <strong>8</strong>, so the next box is the eights place. This is why the values double.</p><table><thead><tr><th>Ordinary number</th><th>Binary digits</th><th>Meaning</th></tr></thead><tbody><tr><td>0</td><td><span class=\"bits\">0</span></td><td>No single units</td></tr><tr><td>1</td><td><span class=\"bits\">1</span></td><td>One single unit</td></tr><tr><td>2</td><td><span class=\"bits\">10</span></td><td>One two + zero ones = 2</td></tr><tr><td>3</td><td><span class=\"bits\">11</span></td><td>One two + one one = 3</td></tr><tr><td>4</td><td><span class=\"bits\">100</span></td><td>One four + zero twos + zero ones = 4</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Decimal mein 10 ka group; binary mein 2 ka group. Do singles = ek pair; do pairs = ek group of four.</p><h2>3. Build the places from the RIGHT</h2>\r\n<p>First draw four empty boxes. <strong>Start with the box furthest to the right.</strong> Give that place the value 1. Move left one box at a time, doubling the previous value.</p>\r\n<ol><li><strong>1st box from the right:</strong> value 1.</li><li><strong>2nd box from the right:</strong> 1 × 2 = 2.</li><li><strong>3rd box from the right:</strong> 2 × 2 = 4.</li><li><strong>4th box from the right:</strong> 4 × 2 = 8.</li></ol><figure class=\"place-board\" style=\"--places:4\"><p class=\"place-label\">Place value: what ONE in this box is worth</p><div class=\"place-row\"><div class=\"place-cell\"><small>4th from right</small><strong>8</strong></div><div class=\"place-cell\"><small>3rd from right</small><strong>4</strong></div><div class=\"place-cell\"><small>2nd from right</small><strong>2</strong></div><div class=\"place-cell\"><small>1st from right</small><strong>1</strong></div></div><p class=\"place-direction\">← Double each time you move one box LEFT</p><figcaption>Start at the RIGHT with 1. Then 1 × 2 = 2, 2 × 2 = 4, and 4 × 2 = 8.</figcaption></figure><p>We built the values by moving right to left: <strong>1 → 2 → 4 → 8</strong>. Once the boxes are on paper, reading them in the usual left-to-right direction shows <strong>8, 4, 2, 1</strong>. These are the same four places, viewed in the opposite direction.</p><p><strong>Position number is not place value.</strong> 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.</p><p>If you add a fifth box on the left, its value is 8 × 2 = <strong>16</strong>. The rightmost place stays 1; adding a box on the left does not change the existing places.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Sabse RIGHT se 1 likho. LEFT jaate jaate double karo: 1, 2, 4, 8, 16. Question ke digits baad mein in boxes mein rakho.</p><h2>4. The place value stays fixed; the digit chooses it</h2>\r\n<p>Keep the digit <strong>1</strong> the same and move it into a different place. Put 0 in every other box. Watch how its position changes the number it represents:</p><table><thead><tr><th>Binary digits</th><th>Where the 1 sits</th><th>Decimal value</th></tr></thead><tbody><tr><td><span class=\"bits\">0001</span></td><td>1st place from the right: ones</td><td>1 × 1 = 1</td></tr><tr><td><span class=\"bits\">0010</span></td><td>2nd place from the right: twos</td><td>1 × 2 = 2</td></tr><tr><td><span class=\"bits\">0100</span></td><td>3rd place from the right: fours</td><td>1 × 4 = 4</td></tr><tr><td><span class=\"bits\">1000</span></td><td>4th place from the right: eights</td><td>1 × 8 = 8</td></tr></tbody></table><p>In all four rows, the written digit is still 1. Its <strong>position</strong> decides whether that 1 contributes one, two, four or eight.</p>\r\n<p>Now put <strong class=\"bits\">1 0 1 1</strong> 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:</p>\r\n<ul><li><strong>Digit 1:</strong> take one of this place value.</li><li><strong>Digit 0:</strong> take zero of this place value.</li></ul><figure class=\"place-board\" style=\"--places:4\"><p class=\"place-label\">Place value: what ONE in this box is worth</p><div class=\"place-row\"><div class=\"place-cell\"><small>4th from right</small><strong>8</strong></div><div class=\"place-cell\"><small>3rd from right</small><strong>4</strong></div><div class=\"place-cell\"><small>2nd from right</small><strong>2</strong></div><div class=\"place-cell\"><small>1st from right</small><strong>1</strong></div></div><p class=\"place-label\">Digits written in those boxes</p><div class=\"place-row\"><div class=\"place-cell included\"><strong>1</strong><small>include</small></div><div class=\"place-cell skipped\"><strong>0</strong><small>skip</small></div><div class=\"place-cell included\"><strong>1</strong><small>include</small></div><div class=\"place-cell included\"><strong>1</strong><small>include</small></div></div><p class=\"place-label\">Each box contributes</p><div class=\"place-row\"><div class=\"place-cell\"><span>1 × 8</span><strong>8</strong></div><div class=\"place-cell\"><span>0 × 4</span><strong>0</strong></div><div class=\"place-cell\"><span>1 × 2</span><strong>2</strong></div><div class=\"place-cell\"><span>1 × 1</span><strong>1</strong></div></div><figcaption>Add the contributions: 8 + 0 + 2 + 1 = 11 in ordinary decimal notation.</figcaption></figure><p>The 0 above does <strong>not</strong> 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.</p><p>The three 1s are the same digit, but they sit in different places. They contribute <strong>8, 2 and 1</strong>. Therefore, binary 1011 represents decimal 11.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Box ki value fixed. Andar 1 hai toh value lo; 0 hai toh skip karo. Phir li hui values jodo.</p><h2>5. Binary to decimal: four complete examples</h2>\r\n<p><strong>Decode</strong> 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.</p><div class=\"math-display\"><img src=\"math/2c7d9feaea569d4c.svg\" alt=\"(1011)_2=(11)_{10}\" style=\"width:16.1ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>This line says: “one-zero-one-one in binary and eleven in decimal represent the same quantity.”</p><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/2f07200d2566e6c6.svg\" alt=\"(1011)_2\" style=\"width:7.273ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">1011</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>1</td><td>0</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 8-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/c26b14275b7516e9.svg\" alt=\"1\\times 8=8\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 4-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/ff395ff0ae2a5dd3.svg\" alt=\"0\\times 4=0\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 2-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/46c6b9d4e71ea84d.svg\" alt=\"1\\times 2=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 1-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/37d06720ad44993d.svg\" alt=\"1\\times 1=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Add the contributions</h5><div class=\"math-display\"><img src=\"math/1006619e9b2d19e6.svg\" alt=\"8+0+2+1=11\" style=\"width:18.102ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/9299eb74dd4bc751.svg\" alt=\"(1011)_2=(11)_{10}\" style=\"width:16.1ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/e242d7ba8a184724.svg\" alt=\"(0110)_2\" style=\"width:7.273ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">0110</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>0</td><td>1</td><td>1</td><td>0</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 8-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/c667fae833dbf441.svg\" alt=\"0\\times 8=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 4-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/60e4619429362147.svg\" alt=\"1\\times 4=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 2-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/46c6b9d4e71ea84d.svg\" alt=\"1\\times 2=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 1-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/cbd4799920019db6.svg\" alt=\"0\\times 1=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Add the contributions</h5><div class=\"math-display\"><img src=\"math/972060f72bffad8b.svg\" alt=\"0+4+2+0=6\" style=\"width:16.97ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/c6cd8f6b20d7ec32.svg\" alt=\"(0110)_2=(6)_{10}\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/92700f027de744f9.svg\" alt=\"(1001)_2\" style=\"width:7.273ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">1001</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>1</td><td>0</td><td>0</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 8-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/c26b14275b7516e9.svg\" alt=\"1\\times 8=8\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 4-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/ff395ff0ae2a5dd3.svg\" alt=\"0\\times 4=0\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 2-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/b584619dcb7531a8.svg\" alt=\"0\\times 2=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 1-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/37d06720ad44993d.svg\" alt=\"1\\times 1=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Add the contributions</h5><div class=\"math-display\"><img src=\"math/64fd3b60b066ebf6.svg\" alt=\"8+0+0+1=9\" style=\"width:16.97ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/d83c62995f78037e.svg\" alt=\"(1001)_2=(9)_{10}\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/4d6378ea1db035a2.svg\" alt=\"(10011)_2\" style=\"width:8.404ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">10011</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>16</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 16-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/2d5a7498be08cfdd.svg\" alt=\"1\\times 16=16\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 8-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/c667fae833dbf441.svg\" alt=\"0\\times 8=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 4-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/ff395ff0ae2a5dd3.svg\" alt=\"0\\times 4=0\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 2-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/46c6b9d4e71ea84d.svg\" alt=\"1\\times 2=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Calculate the contribution of the 1-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/37d06720ad44993d.svg\" alt=\"1\\times 1=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Add the contributions</h5><div class=\"math-display\"><img src=\"math/4c61d1192553e0c2.svg\" alt=\"16+0+0+2+1=19\" style=\"width:23.13ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/9557b36b09cf5595.svg\" alt=\"(10011)_2=(19)_{10}\" style=\"width:17.231ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><h2>6. Decimal to binary: choose each digit</h2>\r\n<p><strong>Encode</strong> 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.</p>\r\n<p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Number banana hai. Badi value se start: jitna bacha hai usmein value fit ho toh 1 aur subtract; fit nahi ho toh 0.</p><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 6 as an unsigned 4-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 6. Required length: 4 bits, meaning exactly 4 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 4 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 6 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 8-place</h5><p>We still need 6. Taking 8 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>6</strong>.</p></div><div class=\"step\"><h5>Step 3. Choose the digit in the 4-place</h5><p>We still need 6. This is at least 4, so take one 4. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/2a4c16cf6f52dfc6.svg\" alt=\"\\text{Remaining}=6-4=2\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Choose the digit in the 2-place</h5><p>We still need 2. This is at least 2, so take one 2. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/8d90e4663ec0a413.svg\" alt=\"\\text{Remaining}=2-2=0\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Choose the digit in the 1-place</h5><p>We still need 0. Taking 1 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 6. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">0 1 1 0</strong>. Join them in the same order: <strong class=\"bits\">0110</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 7. Check by converting back</h5><div class=\"math-display\"><img src=\"math/c3e3fe9d6dd4079b.svg\" alt=\"0\\times 8+1\\times 4+1\\times 2+0\\times 1=6\" style=\"width:32.558ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/17dc4cb6ab18cf42.svg\" alt=\"(6)_{10}=(0110)_2\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 4 bits.</div></section><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 11 as an unsigned 4-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 11. Required length: 4 bits, meaning exactly 4 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 4 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 11 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 8-place</h5><p>We still need 11. This is at least 8, so take one 8. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/a475ecc5627f41d9.svg\" alt=\"\\text{Remaining}=11-8=3\" style=\"width:23.915ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Choose the digit in the 4-place</h5><p>We still need 3. Taking 4 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>3</strong>.</p></div><div class=\"step\"><h5>Step 4. Choose the digit in the 2-place</h5><p>We still need 3. This is at least 2, so take one 2. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/21e8a95558e5db30.svg\" alt=\"\\text{Remaining}=3-2=1\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Choose the digit in the 1-place</h5><p>We still need 1. This is at least 1, so take one 1. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/9f9f05b8fd1b9885.svg\" alt=\"\\text{Remaining}=1-1=0\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">1 0 1 1</strong>. Join them in the same order: <strong class=\"bits\">1011</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 7. Check by converting back</h5><div class=\"math-display\"><img src=\"math/f63d65f39c03b2d0.svg\" alt=\"1\\times 8+0\\times 4+1\\times 2+1\\times 1=11\" style=\"width:33.689ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/1b92e7546fc83d0f.svg\" alt=\"(11)_{10}=(1011)_2\" style=\"width:16.1ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 4 bits.</div></section><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 19 as an unsigned 5-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 19. Required length: 5 bits, meaning exactly 5 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 5 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>16</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 19 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 16-place</h5><p>We still need 19. This is at least 16, so take one 16. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/401912fa7840eae2.svg\" alt=\"\\text{Remaining}=19-16=3\" style=\"width:25.047ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Choose the digit in the 8-place</h5><p>We still need 3. Taking 8 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>3</strong>.</p></div><div class=\"step\"><h5>Step 4. Choose the digit in the 4-place</h5><p>We still need 3. Taking 4 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>3</strong>.</p></div><div class=\"step\"><h5>Step 5. Choose the digit in the 2-place</h5><p>We still need 3. This is at least 2, so take one 2. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/21e8a95558e5db30.svg\" alt=\"\\text{Remaining}=3-2=1\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Choose the digit in the 1-place</h5><p>We still need 1. This is at least 1, so take one 1. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/9f9f05b8fd1b9885.svg\" alt=\"\\text{Remaining}=1-1=0\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">1 0 0 1 1</strong>. Join them in the same order: <strong class=\"bits\">10011</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 8. Check by converting back</h5><div class=\"math-display\"><img src=\"math/684f11c4b4f0e966.svg\" alt=\"1\\times 16+0\\times 8+0\\times 4+1\\times 2+1\\times 1=19\" style=\"width:42.614ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/a03240c4b6abd4c3.svg\" alt=\"(19)_{10}=(10011)_2\" style=\"width:17.231ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 5 bits.</div></section><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 0 as an unsigned 4-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 0. Required length: 4 bits, meaning exactly 4 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 4 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 0 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 8-place</h5><p>We still need 0. Taking 8 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 3. Choose the digit in the 4-place</h5><p>We still need 0. Taking 4 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 4. Choose the digit in the 2-place</h5><p>We still need 0. Taking 2 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 5. Choose the digit in the 1-place</h5><p>We still need 0. Taking 1 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 6. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">0 0 0 0</strong>. Join them in the same order: <strong class=\"bits\">0000</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 7. Check by converting back</h5><div class=\"math-display\"><img src=\"math/edfc0319e8a1b583.svg\" alt=\"0\\times 8+0\\times 4+0\\times 2+0\\times 1=0\" style=\"width:32.558ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/a5e664b79f15e056.svg\" alt=\"(0)_{10}=(0000)_2\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 4 bits.</div></section><h2>7. A zero at the start can keep the required length</h2>\r\n<p><strong>Leading zeros</strong> are zeros at the beginning, on the left. Binary 110 and 0110 both represent decimal 6:</p><div class=\"math-display\"><img src=\"math/d9a164fc63da4660.svg\" alt=\"(110)_2=(1\\times4)+(1\\times2)+(0\\times1)=6\" style=\"width:39.203ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c20ea277129e9ff7.svg\" alt=\"(0110)_2=(0\\times8)+(1\\times4)+(1\\times2)+(0\\times1)=6\" style=\"width:49.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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 <strong class=\"bits\">0110</strong>.</p><p>This rule is specifically about zeros on the <strong>left</strong>. 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.</p><h2>8. How many bits are enough?</h2>\r\n<p>For these GA conversions, <strong>unsigned</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Find the largest unsigned integer that can be represented using 4 bits. Can decimal 19 fit in 4 bits?</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Four places with values 8, 4, 2 and 1. Each digit is either 0 or 1.</p><h4>To find</h4><p>The largest possible value and whether 19 can be represented.</p></div><h4>Formula and why it applies</h4><p>A digit contributes the most when it is 1. Set every digit to 1 and add all the place values.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Use all four places</h5><p>The largest 4-bit string is <strong class=\"bits\">1111</strong>.</p></div><div class=\"step\"><h5>Step 2. Add their values</h5><div class=\"math-display\"><img src=\"math/f3965404fe997578.svg\" alt=\"8+4+2+1=15\" style=\"width:18.102ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Compare with 19</h5><p>19 is greater than 15, so four bits are insufficient. Add the 16-place on the left. Then 19 = 16 + 2 + 1, giving <strong class=\"bits\">10011</strong> in five bits.</p></div><div class=\"answer\"><strong>Final answer.</strong> The maximum is 15. Decimal 19 needs at least 5 bits.</div></section><p>The general rule is <span class=\"math-inline\"><img src=\"math/b2b8f1010a02780c.svg\" alt=\"\\text{largest unsigned value}=2^n-1\" style=\"width:30.783ex;height:2.036ex\" loading=\"lazy\" decoding=\"async\"></span>. Here n means the number of bits. The power <span class=\"math-inline\"><img src=\"math/c0a4368527e8571c.svg\" alt=\"2^n\" style=\"width:2.279ex;height:1.528ex\" loading=\"lazy\" decoding=\"async\"></span> means multiplying n copies of 2; for four bits, <span class=\"math-inline\"><img src=\"math/750f21b62900f171.svg\" alt=\"2^4=2\\times2\\times2\\times2=16\" style=\"width:23.238ex;height:2.09ex\" loading=\"lazy\" decoding=\"async\"></span>, so the maximum is 16 − 1 = 15. There are 16 different values, from 0 through 15, because zero is also one value.</p><table><thead><tr><th>Bits</th><th>Place values from left to right</th><th>Unsigned values</th></tr></thead><tbody><tr><td>3</td><td>4, 2, 1</td><td>0 to 7</td></tr><tr><td>4</td><td>8, 4, 2, 1</td><td>0 to 15</td></tr><tr><td>5</td><td>16, 8, 4, 2, 1</td><td>0 to 31</td></tr></tbody></table><p>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.</p><h2>9. Where this fits in a genetic algorithm</h2>\r\n<p>A <strong>chromosome</strong> 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 <strong class=\"bits\">0110</strong>.</p>\r\n<p>During crossover or mutation, the algorithm changes these bits. Afterwards, <strong>decode the resulting chromosome</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Encode: number se bits. Decode: bits se number. GA mein bits badle toh x dobara decode karo, phir uska score nikalo.</p>"},{"id":"coordinates","title":"Vectors, coordinates, matrices and transpose from the first entry","html":"<h2>A vector is an ordered list of numbers</h2><p>A <strong>scalar</strong> is one number, such as 5. A <strong>vector</strong> is an ordered list, such as (3,7). Order matters: the first number may be horizontal position and the second vertical position. A <strong>matrix</strong> is a rectangular table of numbers. These words describe how numbers are arranged, not a new kind of arithmetic.</p><table><thead><tr><th>Arrangement</th><th>Example</th><th>How to read it</th></tr></thead><tbody><tr><td>Scalar</td><td>5</td><td>One value</td></tr><tr><td>Row vector</td><td>[3,7]</td><td>One row, two entries</td></tr><tr><td>Column vector</td><td><span class=\"math-inline\"><img src=\"math/a263cada62354d7d.svg\" alt=\"\\begin{bmatrix}3\\\\7\\end{bmatrix}\" style=\"width:3.52ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span></td><td>Two rows, one entry</td></tr><tr><td>Matrix</td><td><span class=\"math-inline\"><img src=\"math/a9c176e9eb771437.svg\" alt=\"\\begin{bmatrix}3&amp;7\\\\4&amp;2\\end{bmatrix}\" style=\"width:6.914ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span></td><td>Two rows, two columns</td></tr></tbody></table><h2>Rows go across; columns go down</h2><p>For a matrix A, <strong>A₂₁</strong> means the entry in <strong>row 2, column 1</strong>. The first lower label is the row; the second is the column. Matrix size is written <strong>number of rows × number of columns</strong>. A 2×3 matrix has two rows containing three entries each.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_matrix.a8870f4ab6.svg\" width=\"660\" height=\"250\" alt=\"Read an entry by finding its row first and its column second.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Read an entry by finding its row first and its column second.</figcaption></figure><section class=\"example\"><p class=\"question\"><strong>Let A have first row [2,5,8] and second row [1,4,7]. State its size and find A₂₃ and A₁₂.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/01196c6c529af391.svg\" alt=\"A=\\begin{bmatrix}2&amp;5&amp;8\\\\1&amp;4&amp;7\\end{bmatrix}\" style=\"width:15.022ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Matrix dimensions and two entries.</p></div><h4>Formula and why it applies</h4><p>Read the lower labels in row–column order.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Count the arrangement</h5><p>There are 2 horizontal rows and 3 vertical columns. Size=2×3.</p></div><div class=\"step\"><h5>Step 2. Find A₂₃</h5><p>Row 2 is [1,4,7]. Its third entry is 7.</p></div><div class=\"step\"><h5>Step 3. Find A₁₂</h5><p>Row 1 is [2,5,8]. Its second entry is 5.</p></div><div class=\"answer\"><strong>Final answer.</strong> Size 2×3; A₂₃=7; A₁₂=5.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Position x=(3,7); velocity v=(−1,2); personal-best position p=(1,8). First and second coordinates stay in the same order.</p><h4>To find</h4><p>The difference p−x, the scaled difference 0.5(p−x), and the updated position x+v.</p></div><h4>Formula and why it applies</h4><p>Match first with first and second with second. A scalar multiplies every coordinate.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract corresponding coordinates</h5><div class=\"math-display\"><img src=\"math/162ee1a9497444ec.svg\" alt=\"p-x=(1-3,\\;8-7)=(-2,1)\" style=\"width:31.472ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply both coordinates by 0.5</h5><div class=\"math-display\"><img src=\"math/2b6de1af24a02bfa.svg\" alt=\"0.5(p-x)=(0.5(-2),\\;0.5(1))=(-1,0.5)\" style=\"width:41.154ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the velocity to the position</h5><div class=\"math-display\"><img src=\"math/1d4e7e4fb543eeb3.svg\" alt=\"x+v=(3+(-1),\\;7+2)=(2,9)\" style=\"width:33.192ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Difference (−2,1); scaled difference (−1,0.5); new position (2,9).</div></section><h2>Transpose exchanges rows and columns</h2><p>The superscript <strong>T</strong> in Aᵀ means <strong>transpose</strong>. 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.</p><section class=\"example\"><p class=\"question\"><strong>Find the transpose of A = [[2,5,8],[1,4,7]].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/01196c6c529af391.svg\" alt=\"A=\\begin{bmatrix}2&amp;5&amp;8\\\\1&amp;4&amp;7\\end{bmatrix}\" style=\"width:15.022ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Aᵀ.</p></div><h4>Formula and why it applies</h4><p>Turn each old row into a new column, keeping its order.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Move the first row</h5><p>[2,5,8] becomes the first column from top to bottom.</p></div><div class=\"step\"><h5>Step 2. Move the second row</h5><p>[1,4,7] becomes the second column from top to bottom.</p></div><div class=\"step\"><h5>Step 3. Write the new arrangement</h5><div class=\"math-display\"><img src=\"math/1317eeff1ada1bd8.svg\" alt=\"A^T=\\begin{bmatrix}2&amp;1\\\\5&amp;4\\\\8&amp;7\\end{bmatrix}\" style=\"width:13.571ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Aᵀ has 3 rows and 2 columns. No number changed.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the dot product of [2,3] and [4,5].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>First vector a=[2,3]; second vector b=[4,5]. Each has two entries.</p><h4>To find</h4><p>The dot product a·b, a single number obtained by adding the two matching products.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b383a742b04996eb.svg\" alt=\"a\\cdot b=a_1b_1+a_2b_2\" style=\"width:17.87ex;height:1.91ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply corresponding entries, then add the products. Markov matrix multiplication later repeats this for each destination column.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First product</h5><div class=\"math-display\"><img src=\"math/104d4bd59aaafd44.svg\" alt=\"2\\times4=8\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second product</h5><div class=\"math-display\"><img src=\"math/9c14aa0e11753341.svg\" alt=\"3\\times5=15\" style=\"width:10.308ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add</h5><div class=\"math-display\"><img src=\"math/bb009310f34186b1.svg\" alt=\"8+15=23\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The dot product is 23. It is not the vector [8,15].</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Vector = order wali list. Matrix = rows-columns ka table. Entry padhte waqt pehle row, phir column.</p>"},{"id":"graphs","title":"Graph axes, intervals and the fractions inside membership functions","html":"<h2>Read a graph one input at a time</h2><p>The <strong>horizontal axis</strong> runs left to right and shows input x. The <strong>vertical axis</strong> 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.</p><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_slope.c91a1030aa.svg\" width=\"720\" height=\"310\" alt=\"Halfway along a straight rise from height 0 to height 1 gives height 0.5.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Halfway along a straight rise from height 0 to height 1 gives height 0.5.</figcaption></figure><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>x < 5</td><td>Strictly less than 5</td><td>4.9 qualifies; 5 does not</td></tr><tr><td>x ≤ 5</td><td>Less than or equal to 5</td><td>Both 4.9 and 5 qualify</td></tr><tr><td>2 ≤ x ≤ 8</td><td>x is between 2 and 8 including both ends</td><td>The interval is [2,8]</td></tr><tr><td>[2,8)</td><td>Include 2; exclude 8</td><td>Useful for roulette interval boundaries</td></tr><tr><td>Piecewise formula</td><td>Choose one calculation according to where x lies</td><td>Rising branch, falling branch or outside</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>A straight membership line rises from (2,0) to (6,1). Find its height at x=3.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Left input=2; peak input=6; required input=3.</p><h4>To find</h4><p>Membership height.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b04bfa99f868280c.svg\" alt=\"\\text{height}=\\frac{\\text{distance from left}}{\\text{total rising width}}\" style=\"width:27.162ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><p>A straight line changes by the same proportion of its height as the proportion travelled along its width.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find distance travelled</h5><div class=\"math-display\"><img src=\"math/c1d7fd7ffca66c17.svg\" alt=\"3-2=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find total width</h5><div class=\"math-display\"><img src=\"math/0e4232a9d761c2cf.svg\" alt=\"6-2=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide distance by width</h5><div class=\"math-display\"><img src=\"math/07bbe7a121e1fdbb.svg\" alt=\"\\mu(3)=\\frac{1}{4}=0.25\" style=\"width:16.439ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership=0.25.</div></section><section class=\"example\"><p class=\"question\"><strong>A straight membership line rises from (2,0) to (6,1). Find its height at x=4.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Left input=2; peak input=6; required input=4.</p><h4>To find</h4><p>Membership height.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b04bfa99f868280c.svg\" alt=\"\\text{height}=\\frac{\\text{distance from left}}{\\text{total rising width}}\" style=\"width:27.162ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><p>A straight line changes by the same proportion of its height as the proportion travelled along its width.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find distance travelled</h5><div class=\"math-display\"><img src=\"math/bae97278ddb3a17b.svg\" alt=\"4-2=2\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find total width</h5><div class=\"math-display\"><img src=\"math/0e4232a9d761c2cf.svg\" alt=\"6-2=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide distance by width</h5><div class=\"math-display\"><img src=\"math/d97d0314d106677e.svg\" alt=\"\\mu(4)=\\frac{2}{4}=0.5\" style=\"width:15.308ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership=0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>A straight membership line rises from (10,0) to (30,1). Find its height at x=25.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Left input=10; peak input=30; required input=25.</p><h4>To find</h4><p>Membership height.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b04bfa99f868280c.svg\" alt=\"\\text{height}=\\frac{\\text{distance from left}}{\\text{total rising width}}\" style=\"width:27.162ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><p>A straight line changes by the same proportion of its height as the proportion travelled along its width.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find distance travelled</h5><div class=\"math-display\"><img src=\"math/14c6ec773492ed50.svg\" alt=\"25-10=15\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find total width</h5><div class=\"math-display\"><img src=\"math/04505a3de0e682e9.svg\" alt=\"30-10=20\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide distance by width</h5><div class=\"math-display\"><img src=\"math/5aad4f1600b806e2.svg\" alt=\"\\mu(25)=\\frac{15}{20}=0.75\" style=\"width:18.702ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership=0.75.</div></section><section class=\"example\"><p class=\"question\"><strong>A membership line falls from (5,1) to (8,0). Find its height at x=7.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Peak=5; right zero=8; x=7.</p><h4>To find</h4><p>Membership.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/a265ac2e0c52f5aa.svg\" alt=\"\\mu(x)=\\frac{\\text{distance still remaining to right zero}}{\\text{total falling width}}\" style=\"width:43.61ex;height:5.118ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Remaining distance</h5><div class=\"math-display\"><img src=\"math/8f69aa364500c9a0.svg\" alt=\"8-7=1\" style=\"width:9.176ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Total falling width</h5><div class=\"math-display\"><img src=\"math/11fb664a99823789.svg\" alt=\"8-5=3\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/245668271fba02af.svg\" alt=\"\\mu(7)=1/3\\approx0.333333\" style=\"width:22.231ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership≈0.333333. Using distance already travelled would reverse the falling line.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Chadhti line: left se kitna aage? Utarti line: right tak kitna baaki? Dono mein poori width se divide.</p>"},{"id":"sums-averages","title":"Sum notation, ordinary averages and weighted averages","html":"<h2>Σ means add a list of terms</h2><p>The capital Greek letter <strong>Σ</strong> 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.</p><div class=\"math-display\"><img src=\"math/187790b2a1d823b4.svg\" alt=\"\\sum_{i=1}^{3}a_i=a_1+a_2+a_3\" style=\"width:20.683ex;height:6.711ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>For a₁=2, a₂=5 and a₃=8, calculate Σaᵢ and their mean.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Three numbers: 2,5,8.</p><h4>To find</h4><p>Sum and ordinary average.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/5c0dc23066626f45.svg\" alt=\"\\bar a=\\frac{a_1+a_2+a_3}{3}\" style=\"width:17.294ex;height:4.45ex\" loading=\"lazy\" decoding=\"async\"></div><p>The bar means average. Each number has equal weight.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Expand the sum symbol</h5><div class=\"math-display\"><img src=\"math/73da4a922a419fa3.svg\" alt=\"\\sum_{i=1}^3 a_i=2+5+8\" style=\"width:17.523ex;height:6.711ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/a4c248316325eed6.svg\" alt=\"2+5=7\\quad7+8=15\" style=\"width:21.747ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide by the count of numbers</h5><div class=\"math-display\"><img src=\"math/30b09f1f2d830b9a.svg\" alt=\"\\bar a=15/3=5\" style=\"width:12.887ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Sum=15; mean=5.</div></section><h2>A weighted average gives unequal influence</h2><p>If values 20 and 80 have weights 3 and 1, this is equivalent to averaging [20,20,20,80]. Therefore you divide by the <strong>sum of weights</strong>, not by the number of distinct values. Weights may also be decimals. Their total need not initially be 1.</p><div class=\"math-display\"><img src=\"math/b4ce56a94f70502d.svg\" alt=\"\\bar z=\\frac{w_1z_1+w_2z_2+\\cdots}{w_1+w_2+\\cdots}\" style=\"width:22.542ex;height:4.74ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>Find the weighted average of [20, 80] with corresponding weights [3, 1].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Value</th><th>Its weight</th></tr></thead><tbody><tr><td>20</td><td>3</td></tr><tr><td>80</td><td>1</td></tr></tbody></table><h4>To find</h4><p>The weighted average of the listed values.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/91cd48ba0a9e464c.svg\" alt=\"\\bar z=\\frac{\\sum_i w_i z_i}{\\sum_i w_i}\" style=\"width:12.722ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply value 1 by its weight</h5><div class=\"math-display\"><img src=\"math/6b7da7f3a0b59a78.svg\" alt=\"20\\times3=60\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply value 2 by its weight</h5><div class=\"math-display\"><img src=\"math/5b5619f67f240a03.svg\" alt=\"80\\times1=80\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the weighted products</h5><div class=\"math-display\"><img src=\"math/4012d4bc25614db2.svg\" alt=\"60+80=140\" style=\"width:13.701ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add the weights</h5><div class=\"math-display\"><img src=\"math/c37463b701447787.svg\" alt=\"3+1=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Divide the two totals</h5><div class=\"math-display\"><img src=\"math/dbdc025973fedfed.svg\" alt=\"\\bar z=\\frac{140}{4}=35\" style=\"width:13.738ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 35.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the weighted average of [20, 50, 80] with corresponding weights [0.2, 0.6, 0.2].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Value</th><th>Its weight</th></tr></thead><tbody><tr><td>20</td><td>0.2</td></tr><tr><td>50</td><td>0.6</td></tr><tr><td>80</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>The weighted average of the listed values.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/91cd48ba0a9e464c.svg\" alt=\"\\bar z=\\frac{\\sum_i w_i z_i}{\\sum_i w_i}\" style=\"width:12.722ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply value 1 by its weight</h5><div class=\"math-display\"><img src=\"math/396c5c156cb14965.svg\" alt=\"20\\times0.2=4\" style=\"width:12.068ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply value 2 by its weight</h5><div class=\"math-display\"><img src=\"math/f5c2b1ec334e1160.svg\" alt=\"50\\times0.6=30\" style=\"width:13.199ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Multiply value 3 by its weight</h5><div class=\"math-display\"><img src=\"math/9cd289b939140103.svg\" alt=\"80\\times0.2=16\" style=\"width:13.199ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add the weighted products</h5><div class=\"math-display\"><img src=\"math/cd5630515c6da6da.svg\" alt=\"4+30+16=50\" style=\"width:16.467ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Add the weights</h5><div class=\"math-display\"><img src=\"math/62f59e75ba76247e.svg\" alt=\"0.2+0.6+0.2=1\" style=\"width:18.354ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Divide the two totals</h5><div class=\"math-display\"><img src=\"math/21b878898a4a0815.svg\" alt=\"\\bar z=\\frac{50}{1}=50\" style=\"width:12.607ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 50.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the weighted average of [65, 85] with corresponding weights [0.3, 0.5].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Value</th><th>Its weight</th></tr></thead><tbody><tr><td>65</td><td>0.3</td></tr><tr><td>85</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>The weighted average of the listed values.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/91cd48ba0a9e464c.svg\" alt=\"\\bar z=\\frac{\\sum_i w_i z_i}{\\sum_i w_i}\" style=\"width:12.722ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply value 1 by its weight</h5><div class=\"math-display\"><img src=\"math/3285138cffe8477f.svg\" alt=\"65\\times0.3=19.5\" style=\"width:14.959ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply value 2 by its weight</h5><div class=\"math-display\"><img src=\"math/bf9c01dfa8fdf718.svg\" alt=\"85\\times0.5=42.5\" style=\"width:14.959ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the weighted products</h5><div class=\"math-display\"><img src=\"math/6cfaa5029f5a6cb9.svg\" alt=\"19.5+42.5=62\" style=\"width:16.09ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add the weights</h5><div class=\"math-display\"><img src=\"math/8108e5ca96fd589b.svg\" alt=\"0.3+0.5=0.8\" style=\"width:14.457ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Divide the two totals</h5><div class=\"math-display\"><img src=\"math/a313fb00fc0904f5.svg\" alt=\"\\bar z=\\frac{62}{0.8}=77.5\" style=\"width:14.996ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 77.5.</div></section><h2>Π means multiply a list of terms</h2><div class=\"math-display\"><img src=\"math/40f044c5860eb614.svg\" alt=\"\\prod_{i=1}^{3}a_i=a_1a_2a_3\" style=\"width:14.776ex;height:6.711ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Sigma = sab jodo. Product Pi = sab multiply. Weighted mean = value×weight ke total ko weights ke total se divide.</p>"},{"id":"powers-exponentials","title":"Powers, roots, absolute values and exp on the calculator","html":"<h2>Powers, roots and exponentials used later</h2><p>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.</p><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>2⁰, 2¹, 2², 2³</td><td>Binary place values</td><td>1,2,4,8</td></tr><tr><td>|x|</td><td>Absolute value: distance from zero</td><td>|−3|=3 and |3|=3</td></tr><tr><td>e ≈ 2.71828</td><td>A fixed mathematical constant</td><td>e⁰=1</td></tr><tr><td>exp(u)</td><td>Another way of writing eᵘ</td><td>exp(−2)=e⁻²≈0.135335</td></tr><tr><td>ln(x)</td><td>The natural logarithm; the exponent giving x from e</td><td>ln(e²)=2; ln(1)=0</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>Calculate exp(−x²/2) at x=-2.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>x=-2; exp means e raised to the bracketed exponent.</p><h4>To find</h4><p>The exponential value.</p></div><h4>Formula and why it applies</h4><p>Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Square x</h5><div class=\"math-display\"><img src=\"math/4193a49c3f887499.svg\" alt=\"(-2)^2=4\" style=\"width:9.788ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Negate and divide by 2</h5><div class=\"math-display\"><img src=\"math/3d2cdafe17449912.svg\" alt=\"u=-\\frac{4}{2}=-2\" style=\"width:14.107ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate the exponential</h5><div class=\"math-display\"><img src=\"math/93bf357c53e138fe.svg\" alt=\"e^u=e^{-2}\\approx 0.135335283\" style=\"width:23.419ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.135335283.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate exp(−x²/2) at x=0.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>x=0; exp means e raised to the bracketed exponent.</p><h4>To find</h4><p>The exponential value.</p></div><h4>Formula and why it applies</h4><p>Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Square x</h5><div class=\"math-display\"><img src=\"math/cd561d277fcba773.svg\" alt=\"(0)^2=0\" style=\"width:8.027ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Negate and divide by 2</h5><div class=\"math-display\"><img src=\"math/4e1e416350f910b4.svg\" alt=\"u=-\\frac{0}{2}=0\" style=\"width:12.346ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate the exponential</h5><div class=\"math-display\"><img src=\"math/4263edec66681677.svg\" alt=\"e^u=e^{0}\\approx 1\" style=\"width:11.365ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 1.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate exp(−x²/2) at x=2.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>x=2; exp means e raised to the bracketed exponent.</p><h4>To find</h4><p>The exponential value.</p></div><h4>Formula and why it applies</h4><p>Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Square x</h5><div class=\"math-display\"><img src=\"math/730976d327ad7f5e.svg\" alt=\"(2)^2=4\" style=\"width:8.027ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Negate and divide by 2</h5><div class=\"math-display\"><img src=\"math/3d2cdafe17449912.svg\" alt=\"u=-\\frac{4}{2}=-2\" style=\"width:14.107ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate the exponential</h5><div class=\"math-display\"><img src=\"math/93bf357c53e138fe.svg\" alt=\"e^u=e^{-2}\\approx 0.135335283\" style=\"width:23.419ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.135335283.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> exp ka matlab e ki power. Pehle exponent ka poora hisaab, phir eˣ.</p>"}]},{"id":"fuzzy-core","title":"2. Fuzzy logic, from meaning to full solutions","unit":"Unit 2","scope":"Definitions → membership graphs → operations → rules → defuzzification → complete controller.","sections":[{"id":"membership-meaning","title":"Fuzzy sets: what membership actually means","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Start with an input and a label</h2><p>Suppose the input is <strong>temperature 32°C</strong> and the fuzzy label is <strong>Hot</strong>. A membership function is the rule that converts that temperature into a degree of matching the label. If μ<sub>Hot</sub>(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.</p><p>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.</p><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Universe U</td><td>All input values being considered</td><td>Temperatures from 0 to 40°C</td></tr><tr><td>Crisp value</td><td>One definite measured number</td><td>32°C</td></tr><tr><td>Linguistic term</td><td>A word naming a fuzzy category</td><td>Low, Medium, High</td></tr><tr><td>μA(x)</td><td>Degree to which input x fits category A</td><td>μHot(32)=0.7</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> 32 temperature hai; 0.7 us temperature ka Hot label mein degree hai. Dono ko mix mat karo.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Why “true or false” is sometimes too rigid</h2>\r\n<p>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 <strong>crisp</strong> rule. Fuzzy logic allows a gradual degree of belonging to the category “Hot”.</p>\r\n<p><strong>Definition.</strong> 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”.</p><div class=\"math-display\"><img src=\"math/d2598c83177cc2bf.svg\" alt=\"\\mu_A:U\\rightarrow[0,1]\" style=\"width:14.419ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Term</th><th>Meaning</th><th>Temperature example</th></tr></thead><tbody><tr><td>Universe U</td><td>All allowed input values</td><td>Temperatures from 0°C to 40°C</td></tr><tr><td>Element x</td><td>The particular input being considered</td><td>32°C</td></tr><tr><td>Fuzzy set A</td><td>A category described by a membership function</td><td>Hot</td></tr><tr><td>Membership μA(x)</td><td>How strongly x fits that category</td><td>μHot(32) = 0.7</td></tr></tbody></table>\r\n<h2>Read membership correctly</h2><p>Membership 0 means no belonging; 1 means full belonging; 0.7 means partial belonging under the chosen definition. <strong>It does not mean a 70% chance that the measured temperature is 32°C.</strong> 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.</p><table><thead><tr><th>Input</th><th>Warm membership</th><th>Hot membership</th><th>Interpretation</th></tr></thead><tbody><tr><td>28</td><td>0.8</td><td>0.1</td><td>Fits Warm strongly and Hot weakly</td></tr><tr><td>32</td><td>0.3</td><td>0.7</td><td>Fits Hot more than Warm</td></tr><tr><td>35</td><td>0</td><td>1</td><td>Fully Hot in this chosen model</td></tr></tbody></table><p>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”.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered inputs [20, 25, 30, 35]; memberships [0, 0.2, 0.6, 1].</p><h4>To find</h4><p>The set notation and interpretation.</p></div><h4>Formula and why it applies</h4><p>In the common fuzzy-set notation μ/x, the slash separates membership from element; it is not division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Pair each input with its membership</h5><table><thead><tr><th>x</th><th>μHot(x)</th></tr></thead><tbody><tr><td>20</td><td>0</td></tr><tr><td>25</td><td>0.2</td></tr><tr><td>30</td><td>0.6</td></tr><tr><td>35</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Write the set</h5><div class=\"math-display\"><img src=\"math/5a7f23351df5307b.svg\" alt=\"Hot=\\{0/20,\\;0.2/25,\\;0.6/30,\\;1/35\\}\" style=\"width:35.728ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret</h5><p>35 fully belongs; 25 and 30 partly belong; 20 does not belong.</p></div><div class=\"answer\"><strong>Final answer.</strong> Hot = {0/20, 0.2/25, 0.6/30, 1/35}.</div></section><section class=\"example\"><p class=\"question\"><strong>Distinguish crisp and fuzzy sets.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><table><thead><tr><th>Crisp set</th><th>Fuzzy set</th></tr></thead><tbody><tr><td>Membership is 0 or 1</td><td>Membership is any value in [0,1]</td></tr><tr><td>A sharp boundary separates members</td><td>A membership function permits gradual boundaries</td></tr><tr><td>Example: temperature ≥ 30°C</td><td>Example: degree of being Hot increases gradually</td></tr></tbody></table></section><p class=\"memory\"><strong>Yaad rakho:</strong> μ ka matlab: is category mein kitna fit hota hai. Chance nahi.</p>"},{"id":"triangle","title":"Triangular membership: choose the side, then calculate","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Why the triangle has two different fractions</h2><p>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 <strong>input positions</strong>, not three membership degrees.</p><table><thead><tr><th>Where is x?</th><th>Meaning</th><th>Calculation</th></tr></thead><tbody><tr><td>x≤2 or x≥8</td><td>Outside, or at a zero-height endpoint</td><td>0</td></tr><tr><td>2&lt;x&lt;5</td><td>Part-way up the rising edge</td><td>(x−2)/(5−2)</td></tr><tr><td>x=5</td><td>At the peak</td><td>1</td></tr><tr><td>5&lt;x&lt;8</td><td>Part-way down the falling edge</td><td>(8−x)/(8−5)</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> a = start, b = peak, c = end. x kahan pada hai, wahi fraction decide karega.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>A graph is a rule for assigning membership</h2><p>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.</p><p>A triangle has three parameters: <strong>a</strong> is the left zero, <strong>b</strong> is the peak with membership 1, and <strong>c</strong> is the right zero. We assume a &lt; b &lt; c.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_triangle.4eb0b27c9d.svg\" width=\"680\" height=\"300\" alt=\"Rising side: use distance from the left end. Falling side: use distance from the right end.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Rising side: use distance from the left end. Falling side: use distance from the right end.</figcaption></figure><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<h2>Why the two fractions have these forms</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 3.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 3.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>2 < 3 ≤ 5, so membership increases as x moves toward the peak.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Rising side</p><div class=\"math-display\"><img src=\"math/feefc8b7a33635af.svg\" alt=\"\\mu_A(3)=\\frac{3-2}{5-2}=\\frac{1}{3}=0.333333333\" style=\"width:34.786ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(3) = 0.333333333.</div></section><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 7.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 7.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>5 < 7 < 8, so membership decreases as x moves away from the peak.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Falling side</p><div class=\"math-display\"><img src=\"math/379229dc05ca4e37.svg\" alt=\"\\mu_A(7)=\\frac{8-7}{8-5}=\\frac{1}{3}=0.333333333\" style=\"width:34.786ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(7) = 0.333333333.</div></section><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 5.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 5.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>2 < 5 ≤ 5, so membership increases as x moves toward the peak.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Rising side</p><div class=\"math-display\"><img src=\"math/650bc1ad2a8788e3.svg\" alt=\"\\mu_A(5)=\\frac{5-2}{5-2}=\\frac{3}{3}=1\" style=\"width:23.976ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 1. This is full membership at the peak.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(5) = 1.</div></section><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 9.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 9.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>9 is outside the open support (2, 8) or at an endpoint.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Outside the triangle</p><div class=\"math-display\"><img src=\"math/857573d5b79c2b73.svg\" alt=\"\\mu_A(9)=0\" style=\"width:9.792ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 0. It is a membership degree, not a probability.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(9) = 0.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Peak se left: x − a. Peak se right: c − x. Neeche usi side ki poori width.</p>"},{"id":"trapezoid-intuition","title":"Trapezoids, shoulders and intuition-based fuzzification","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>The middle is a flat top, not another slope</h2><p>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.</p><table><thead><tr><th>Input</th><th>Locate it</th><th>Numerator</th><th>Denominator</th><th>Membership</th></tr></thead><tbody><tr><td>1</td><td>Rising: 0<1<2</td><td>1−0=1</td><td>2−0=2</td><td>1/2=0.5</td></tr><tr><td>4</td><td>Flat top: 2≤4≤6</td><td>No division</td><td>No division</td><td>1</td></tr><tr><td>7</td><td>Falling: 6<7<8</td><td>8−7=1</td><td>8−6=2</td><td>1/2=0.5</td></tr><tr><td>9</td><td>Beyond right endpoint</td><td>No division</td><td>No division</td><td>0</td></tr></tbody></table><p>A <strong>left shoulder</strong> 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Trapezoidal membership</h2><p>A trapezoid has four parameters a &lt; b ≤ c &lt; 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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_trapezoid.dbfff598ea.svg\" width=\"680\" height=\"300\" alt=\"From 20 to 30, the membership is exactly 1.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>From 20 to 30, the membership is exactly 1.</figcaption></figure><div class=\"math-display\"><img src=\"math/8db3f8710aa967fd.svg\" alt=\"\\mu(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge d\\\\(x-a)/(b-a),&amp;a&lt;x&lt;b\\\\1,&amp;b\\le x\\le c\\\\(d-x)/(d-c),&amp;c&lt;x&lt;d\\end{cases}\" style=\"width:41.325ex;height:10.407ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(15).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=15.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 15 lies on the rising side.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/dcb555d1584d4cd8.svg\" alt=\"\\mu(15)=(15-10)/(20-10)=5/10=0.5\" style=\"width:41.087ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(15) = 0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(25).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=25.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 25 lies on the flat top.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/3a0f8e229e9dd73e.svg\" alt=\"\\mu(25)=1\" style=\"width:9.535ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(25) = 1.</div></section><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(35).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=35.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 35 lies on the falling side.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/b4c061d09e040d15.svg\" alt=\"\\mu(35)=(40-35)/(40-30)=5/10=0.5\" style=\"width:41.087ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(35) = 0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(45).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=45.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 45 lies on the outside support.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/e052435017d8c2af.svg\" alt=\"\\mu(45)=0\" style=\"width:9.535ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(45) = 0.</div></section><h2>Other membership shapes</h2><p>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”.</p>\r\n<h2>Fuzzification by the intuition method</h2><p><strong>Fuzzification</strong> converts a measured crisp input into its membership degrees. In the <strong>intuition method</strong>, 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.</p>\r\n<ol><li>Specify the variable and its allowed range.</li><li>Choose linguistic labels such as Low, Medium and High.</li><li>Specify each shape and every breakpoint.</li><li>Evaluate the functions at the actual input.</li><li>Validate the controller on representative inputs and adjust the design if needed.</li></ol><p class=\"memory\"><strong>Yaad rakho:</strong> Shape banana design choice; shape milne ke baad membership calculate karni hai.</p>"},{"id":"set-operations","title":"Union, intersection, complement and difference","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Work on one element before working on a whole set</h2><p>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”).</p><section class=\"example\"><p class=\"question\"><strong>At one element u, μA(u)=0.7 and μB(u)=0.4. Find union, intersection, complement of B and A\\B.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>At the same element u, A assigns membership 0.7 and B assigns membership 0.4.</p><h4>To find</h4><p>The membership at u in A∪B, A∩B, Bᶜ and A minus B.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1 minus membership for NOT. Difference is A AND NOT B.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Union: choose the larger</h5><div class=\"math-display\"><img src=\"math/709d5f49fad6a33b.svg\" alt=\"\\max(0.7,0.4)=0.7\" style=\"width:18.668ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Intersection: choose the smaller</h5><div class=\"math-display\"><img src=\"math/f5bde40636dee1a9.svg\" alt=\"\\min(0.7,0.4)=0.4\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Complement B first</h5><div class=\"math-display\"><img src=\"math/553cb087421dc8d7.svg\" alt=\"1-0.4=0.6\" style=\"width:12.697ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Intersect A with complement B</h5><div class=\"math-display\"><img src=\"math/d73caed266f7eed3.svg\" alt=\"\\min(0.7,0.6)=0.6\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section></div>\r\n<!-- depth:bridge:end -->\r\n<h2>The four operations used in Q1</h2><p>Use the <strong>standard max–min convention</strong> 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.</p><table><thead><tr><th>Operation</th><th>Meaning</th><th>Rule</th></tr></thead><tbody><tr><td>Union A ∪ B</td><td>A OR B</td><td>Take the larger membership</td></tr><tr><td>Intersection A ∩ B</td><td>A AND B</td><td>Take the smaller membership</td></tr><tr><td>Complement Aᶜ</td><td>NOT A</td><td>1 − membership of A</td></tr><tr><td>Difference A ∖ B</td><td>A AND NOT B</td><td>min(μA, 1 − μB)</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th></tr></thead><tbody><tr><td>A</td><td>0.2</td><td>0.8</td><td>0.6</td></tr><tr><td>B</td><td>0.7</td><td>0.3</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/ad1dcd17cbaf20b9.svg\" alt=\"\\mu_{B^c}(u_1)=1-0.7=0.3\" style=\"width:23.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3b878090c37dc92f.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0.2,0.3)=0.2\" style=\"width:30.054ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0.2</td><td>0.7</td><td>max(0.2, 0.7) = 0.7</td><td>min(0.2, 0.7) = 0.2</td><td>1 − 0.7 = 0.3</td><td>min(0.2, 0.3) = 0.2</td></tr><tr><td>u2</td><td>0.8</td><td>0.3</td><td>max(0.8, 0.3) = 0.8</td><td>min(0.8, 0.3) = 0.3</td><td>1 − 0.3 = 0.7</td><td>min(0.8, 0.7) = 0.7</td></tr><tr><td>u3</td><td>0.6</td><td>0.5</td><td>max(0.6, 0.5) = 0.6</td><td>min(0.6, 0.5) = 0.5</td><td>1 − 0.5 = 0.5</td><td>min(0.6, 0.5) = 0.5</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th></tr></thead><tbody><tr><td>A</td><td>0</td><td>1</td><td>0.4</td></tr><tr><td>B</td><td>1</td><td>0</td><td>0.4</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/2890d976bd930ef0.svg\" alt=\"\\mu_{B^c}(u_1)=1-1=0\" style=\"width:19.624ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/478aba1f930ec419.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0,0)=0\" style=\"width:24.774ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0</td><td>1</td><td>max(0, 1) = 1</td><td>min(0, 1) = 0</td><td>1 − 1 = 0</td><td>min(0, 0) = 0</td></tr><tr><td>u2</td><td>1</td><td>0</td><td>max(1, 0) = 1</td><td>min(1, 0) = 0</td><td>1 − 0 = 1</td><td>min(1, 1) = 1</td></tr><tr><td>u3</td><td>0.4</td><td>0.4</td><td>max(0.4, 0.4) = 0.4</td><td>min(0.4, 0.4) = 0.4</td><td>1 − 0.4 = 0.6</td><td>min(0.4, 0.6) = 0.4</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th><th>u4</th></tr></thead><tbody><tr><td>A</td><td>0.9</td><td>0.2</td><td>0.5</td><td>0.7</td></tr><tr><td>B</td><td>0.6</td><td>0.8</td><td>0.1</td><td>0.7</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/c9c6864aea087c58.svg\" alt=\"\\mu_{B^c}(u_1)=1-0.6=0.4\" style=\"width:23.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b891d5b3e6b00766.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0.9,0.4)=0.4\" style=\"width:30.054ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0.9</td><td>0.6</td><td>max(0.9, 0.6) = 0.9</td><td>min(0.9, 0.6) = 0.6</td><td>1 − 0.6 = 0.4</td><td>min(0.9, 0.4) = 0.4</td></tr><tr><td>u2</td><td>0.2</td><td>0.8</td><td>max(0.2, 0.8) = 0.8</td><td>min(0.2, 0.8) = 0.2</td><td>1 − 0.8 = 0.2</td><td>min(0.2, 0.2) = 0.2</td></tr><tr><td>u3</td><td>0.5</td><td>0.1</td><td>max(0.5, 0.1) = 0.5</td><td>min(0.5, 0.1) = 0.1</td><td>1 − 0.1 = 0.9</td><td>min(0.5, 0.9) = 0.5</td></tr><tr><td>u4</td><td>0.7</td><td>0.7</td><td>max(0.7, 0.7) = 0.7</td><td>min(0.7, 0.7) = 0.7</td><td>1 − 0.7 = 0.3</td><td>min(0.7, 0.3) = 0.3</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section><p><strong>Why not subtract A − B?</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Union bada; intersection chhota; complement 1 se ghata; difference = pehle B ka complement, phir min.</p>"},{"id":"properties","title":"Fuzzy properties, De Morgan laws and α-cuts","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Translate the property names</h2><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Commutative</td><td>Changing order changes nothing</td><td>max(0.3,0.8)=max(0.8,0.3)=0.8</td></tr><tr><td>Associative</td><td>Regroup the same operation</td><td>max(max(0.2,0.7),0.4)=max(0.2,max(0.7,0.4))=0.7</td></tr><tr><td>Idempotent</td><td>Combining a membership with itself keeps it</td><td>min(0.6,0.6)=0.6</td></tr><tr><td>Involution</td><td>Complement twice returns the original</td><td>1−(1−0.4)=1−0.6=0.4</td></tr><tr><td>De Morgan</td><td>NOT swaps AND and OR while complementing each operand</td><td>1−max(a,b)=min(1−a,1−b)</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Properties that remain valid</h2><table><thead><tr><th>Property</th><th>Statement for max–min operations</th></tr></thead><tbody><tr><td>Commutative</td><td>A ∪ B = B ∪ A; A ∩ B = B ∩ A</td></tr><tr><td>Associative</td><td>(A ∪ B) ∪ C = A ∪ (B ∪ C); likewise for intersection</td></tr><tr><td>Idempotent</td><td>A ∪ A = A; A ∩ A = A</td></tr><tr><td>Distributive</td><td>A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C); and its dual</td></tr><tr><td>Involution</td><td>(Aᶜ)ᶜ = A</td></tr><tr><td>De Morgan</td><td>(A ∪ B)ᶜ = Aᶜ ∩ Bᶜ; (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ</td></tr></tbody></table><h2>Two crisp identities do not generally hold</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>At an element x, μA(x)=0.4. Calculate μ(A ∪ Aᶜ) and μ(A ∩ Aᶜ).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>μA(x)=0.4; standard complement/max/min.</p><h4>To find</h4><p>Whether excluded middle and non-contradiction hold at this element.</p></div><h4>Formula and why it applies</h4><p>Complement first, then use max or min.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Complement</h5><div class=\"math-display\"><img src=\"math/54b240c60f89d754.svg\" alt=\"\\mu_{A^c}(x)=1-0.4=0.6\" style=\"width:22.143ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Union</h5><div class=\"math-display\"><img src=\"math/fbe8846f3efa93f5.svg\" alt=\"\\max(0.4,0.6)=0.6\\ne1\" style=\"width:22.816ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Intersection</h5><div class=\"math-display\"><img src=\"math/4fcb041eeb76aeb4.svg\" alt=\"\\min(0.4,0.6)=0.4\\ne0\" style=\"width:22.377ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The union is 0.6 and the intersection is 0.4; the crisp identities fail here.</div></section><section class=\"example\"><p class=\"question\"><strong>Verify the first De Morgan law for μA=0.3 and μB=0.8.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>A=0.3, B=0.8 at the same element.</p><h4>To find</h4><p>Both sides of (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ.</p></div><h4>Formula and why it applies</h4><p>Evaluate the operations independently on each side.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Left side</h5><div class=\"math-display\"><img src=\"math/8bcb03e96487eae0.svg\" alt=\"1-\\max(0.3,0.8)=1-0.8=0.2\" style=\"width:32.37ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Right side</h5><div class=\"math-display\"><img src=\"math/902b79a384f1ef2a.svg\" alt=\"\\min(1-0.3,1-0.8)=\\min(0.7,0.2)=0.2\" style=\"width:41.36ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Both sides equal 0.2.</div></section><!-- depth:cuts:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>The support, core, boundary and 0.7-cut as sets of elements, and the height as one membership value.</p></div><h4>Formula and why it applies</h4><p>Support: degree>0; core: degree=1; boundary: 0&lt;degree&lt;1; height: largest degree; α-cut: degree≥α.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inspect each element</h5><table><thead><tr><th>Element</th><th>Degree</th><th>Positive?</th><th>Exactly 1?</th><th>At least 0.7?</th></tr></thead><tbody><tr><td>a</td><td>0</td><td>No</td><td>No</td><td>No</td></tr><tr><td>b</td><td>0.3</td><td>Yes</td><td>No</td><td>No</td></tr><tr><td>c</td><td>1</td><td>Yes</td><td>Yes</td><td>Yes</td></tr><tr><td>d</td><td>0.7</td><td>Yes</td><td>No</td><td>Yes</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Collect the requested elements</h5><p>Support={b,c,d}. Core={c}. Boundary={b,d}. The 0.7-cut={c,d}.</p></div><div class=\"step\"><h5>Step 3. Read the height</h5><p>The maximum degree is 1, so the height is 1 and the set is normal.</p></div><div class=\"answer\"><strong>Final answer.</strong> Support {b,c,d}; core {c}; boundary {b,d}; height 1; 0.7-cut {c,d}.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the 0.5-cut of the triangular fuzzy set Tri(2,5,8).</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Triangle start a=2, peak b=5, end c=8; cut level α=0.5. Retain all inputs whose membership is at least 0.5.</p><h4>To find</h4><p>Left and right endpoints of the retained interval.</p></div><h4>Formula and why it applies</h4><p>The triangle rises past 0.5, remains above it, then falls through 0.5. Solve height=0.5 on both slopes.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Left slope: multiply both sides by 3</h5><div class=\"math-display\"><img src=\"math/60bd77c1b7954114.svg\" alt=\"(x-2)/3=0.5\" style=\"width:15.122ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/58646302eb803fe5.svg\" alt=\"x-2=0.5\\times3=1.5\" style=\"width:20.905ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Isolate the left input</h5><div class=\"math-display\"><img src=\"math/5def47a62d44d4a8.svg\" alt=\"x=1.5+2=3.5\" style=\"width:17.008ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Right slope: multiply both sides by 3</h5><div class=\"math-display\"><img src=\"math/101167a6754cbdc0.svg\" alt=\"(8-x)/3=0.5\" style=\"width:15.122ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/35ee639a9616fa80.svg\" alt=\"8-x=1.5\" style=\"width:11.1ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Isolate the right input</h5><div class=\"math-display\"><img src=\"math/4ae644eed157e001.svg\" alt=\"x=8-1.5=6.5\" style=\"width:17.008ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Include all inputs between them</h5><p>The graph is at or above 0.5 for 3.5≤x≤6.5. Include the endpoints because the condition is ≥.</p></div><div class=\"answer\"><strong>Final answer.</strong> The 0.5-cut is [3.5,6.5].</div></section></div>\r\n<!-- depth:cuts:end -->\r\n<h2>Describing a fuzzy set</h2><p><strong>Support:</strong> inputs with μ &gt; 0. <strong>Core:</strong> inputs with μ = 1. <strong>Boundary:</strong> inputs with 0 &lt; μ &lt; 1. <strong>Height:</strong> 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 μ ≥ α.</p><p>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.</p><p>A one-dimensional fuzzy set is <strong>convex</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Fuzzy A aur NOT A dono partial ho sakte hain. Isliye crisp waali 1 aur 0 identities blindly nahi lagani.</p>"},{"id":"mamdani-architecture","title":"Mamdani architecture: what every block does","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Follow one measurement through the controller</h2><p>A <strong>controller</strong> 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.</p><table><thead><tr><th>Stage</th><th>What goes in</th><th>Operation</th><th>What comes out</th></tr></thead><tbody><tr><td>Fuzzifier</td><td>32°C and 7 people</td><td>Use the supplied membership graphs</td><td>Temperature Medium=.3, High=.7; occupancy High=.5</td></tr><tr><td>Knowledge base</td><td>Chosen labels and their shapes</td><td>Store graphs and IF–THEN rules</td><td>A reusable definition of how the controller works</td></tr><tr><td>Inference</td><td>Medium=.3 AND High=.5</td><td>Rule strength=min(.3,.5)=.3</td><td>“Fan High” fires at .3</td></tr><tr><td>Aggregation</td><td>All clipped output sets</td><td>Take the largest output degree at each speed</td><td>One combined fuzzy output shape</td></tr><tr><td>Defuzzifier</td><td>Combined shape</td><td>Apply the specified MoM, centroid or representative method</td><td>One numerical speed</td></tr></tbody></table><p>The <strong>antecedent</strong> is the IF part (“temperature is Medium AND occupancy is High”). The <strong>consequent</strong> 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%.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Definition: a fuzzy inference system</h2><p>A <strong>fuzzy inference system (FIS)</strong> maps inputs to an output by evaluating fuzzy IF–THEN rules. A <strong>Mamdani FIS</strong> uses fuzzy sets in the rule consequents, combines their inferred output sets, and defuzzifies the result.</p>\r\n<div class=\"flow\"><div class=\"node\">Crisp inputs<small>32°C; 7 people</small></div><span class=\"arrow\">→</span><div class=\"node\">Fuzzification<small>degrees of Warm/Hot etc.</small></div><span class=\"arrow\">→</span><div class=\"node\">Rules + inference<small>rule strengths and clipped outputs</small></div><span class=\"arrow\">→</span><div class=\"node\">Aggregation<small>one combined output shape</small></div><span class=\"arrow\">→</span><div class=\"node\">Defuzzification<small>one fan-speed number</small></div></div>\r\n<h2>Architecture: what each block contributes</h2><table><thead><tr><th>Block</th><th>What it stores or calculates</th><th>Concrete meaning</th></tr></thead><tbody><tr><td>Fuzzifier</td><td>Membership values of the measured inputs</td><td>32°C may be Medium to degree 0.3 and High to degree 0.7</td></tr><tr><td>Knowledge base: database</td><td>Ranges and membership functions</td><td>Medium = Tri(15,25,35)</td></tr><tr><td>Knowledge base: rule base</td><td>IF–THEN rules</td><td>IF temperature High AND occupancy High THEN fan Very High</td></tr><tr><td>Inference engine</td><td>Combines conditions and applies consequents</td><td>min for AND; clips the output triangle at the rule strength</td></tr><tr><td>Aggregator</td><td>Combines all rule outputs</td><td>At every output location, take the maximum clipped membership</td></tr><tr><td>Defuzzifier</td><td>Converts the aggregate to one crisp value</td><td>Use centroid or mean of maxima, as requested</td></tr></tbody></table>\r\n<h2>Parts of an IF–THEN rule</h2><p>In “IF temperature is High AND occupancy is High THEN fan speed is Very High”, the IF part is the <strong>antecedent</strong> (condition), and the THEN part is the <strong>consequent</strong> (output category). The input variable temperature, the label High, and the numerical membership μHigh(32) are different things.</p>\r\n<h2>Why a rule strength is not yet the fan speed</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Explain the architecture of a Mamdani fuzzy inference system.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><p class=\"memory\"><strong>Yaad rakho:</strong> Input ka degree → rule ka strength → output ka shape → final number.</p>"},{"id":"rules-clipping","title":"Rule firing, clipping and aggregation: four solved cases","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Clipping means limiting a height</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Speed</th><th>Original A membership</th><th>Original B membership</th></tr></thead><tbody><tr><td>40</td><td>0.1</td><td>0</td></tr><tr><td>60</td><td>0.8</td><td>0.4</td></tr><tr><td>80</td><td>0.2</td><td>1</td></tr></tbody></table><p>Rule A strength=0.3; rule B strength=0.5. Compare memberships at the same speed.</p><h4>To find</h4><p>The combined membership at each speed.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/89f0491f916a2f27.svg\" alt=\"\\mu_{out}(z)=\\max(\\min(0.3,\\mu_A(z)),\\min(0.5,\\mu_B(z)))\" style=\"width:46.627ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Inner min limits a rule’s height; outer max keeps the stronger support at that speed.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Clip A</h5><p>At 40: min(.3,.1)=.1. At 60: min(.3,.8)=.3. At 80: min(.3,.2)=.2.</p></div><div class=\"step\"><h5>Step 2. Clip B</h5><p>At 40: min(.5,0)=0. At 60: min(.5,.4)=.4. At 80: min(.5,1)=.5.</p></div><div class=\"step\"><h5>Step 3. Aggregate at each speed</h5><table><thead><tr><th>Speed</th><th>Clipped A</th><th>Clipped B</th><th>max(A,B)</th></tr></thead><tbody><tr><td>40</td><td>0.1</td><td>0</td><td>0.1</td></tr><tr><td>60</td><td>0.3</td><td>0.4</td><td>0.4</td></tr><tr><td>80</td><td>0.2</td><td>0.5</td><td>0.5</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Combined degrees [0.1,0.4,0.5] at speeds [40,60,80]. A separate defuzzification step is still required.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Clip = height ki ceiling. Aggregate = har same x par sabse upar wala height.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Four different calculations happen in inference</h2><p><strong>AND/OR</strong> combine conditions within a rule. <strong>Implication</strong> uses the resulting strength to modify that rule’s output membership function. <strong>Aggregation</strong> merges different rule outputs. Here we use min-AND, max-OR, min-implication and max-aggregation.</p><div class=\"math-display\"><img src=\"math/e446839a4e5e2d93.svg\" alt=\"\\alpha_{AND}=\\min(a,b)\\qquad\\alpha_{OR}=\\max(a,b)\" style=\"width:38.06ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/32c896372ab93b2e.svg\" alt=\"\\mu_{\\mathrm{rule}}(z)=\\min(\\alpha,\\mu_{\\mathrm{consequent}}(z))\" style=\"width:30.1ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd5c7064495bb995.svg\" alt=\"\\mu_{\\mathrm{aggregate}}(z)=\\max_r\\mu_{\\mathrm{rule}\\ r}(z)\" style=\"width:26.796ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><p>α (“alpha”) is the rule firing strength. z names a possible output value. The subscript r labels a rule, not a multiplication.</p><section class=\"example\"><p class=\"question\"><strong>A rule has two condition degrees 0.7 and 0.5, joined by AND. Find its firing strength.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=0.7; b=0.5; connective=AND.</p><h4>To find</h4><p>The strength α.</p></div><h4>Formula and why it applies</h4><p>Use the smaller degree because both conditions must hold.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Select the operator</h5><div class=\"math-display\"><img src=\"math/c7cb0e48bf98cd0f.svg\" alt=\"\\alpha=\\min(0.7,0.5)\" style=\"width:16.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evaluate</h5><div class=\"math-display\"><img src=\"math/45f07f09a68169c8.svg\" alt=\"\\alpha=0.5\" style=\"width:7.356ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>A rule has two condition degrees 0.3 and 0, joined by AND. Find its firing strength.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=0.3; b=0; connective=AND.</p><h4>To find</h4><p>The strength α.</p></div><h4>Formula and why it applies</h4><p>Use the smaller degree because both conditions must hold.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Select the operator</h5><div class=\"math-display\"><img src=\"math/7194f00ae81bc1b1.svg\" alt=\"\\alpha=\\min(0.3,0)\" style=\"width:15.025ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evaluate</h5><div class=\"math-display\"><img src=\"math/7b95185b7bc8e8a2.svg\" alt=\"\\alpha=0\" style=\"width:5.596ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.</div></section><section class=\"example\"><p class=\"question\"><strong>A rule has two condition degrees 0.2 and 0.8, joined by OR. Find its firing strength.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=0.2; b=0.8; connective=OR.</p><h4>To find</h4><p>The strength α.</p></div><h4>Formula and why it applies</h4><p>Use the larger degree because either condition is sufficient.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Select the operator</h5><div class=\"math-display\"><img src=\"math/a8a03390bc687846.svg\" alt=\"\\alpha=\\max(0.2,0.8)\" style=\"width:17.224ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evaluate</h5><div class=\"math-display\"><img src=\"math/2a9a9be0e9cd69dc.svg\" alt=\"\\alpha=0.8\" style=\"width:7.356ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.8.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Rule 1: α₁=0.3, μ₁(60)=0.8. Rule 2: α₂=0.6, μ₂(60)=0.2.</p><h4>To find</h4><p>Membership at the single output location z=60 after implication and aggregation.</p></div><h4>Formula and why it applies</h4><p>Clip each original degree at its rule strength; then take the larger clipped degree.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Clip rule 1</h5><div class=\"math-display\"><img src=\"math/e2cf40ea63fed461.svg\" alt=\"\\mu_{R1}(60)=\\min(0.3,0.8)=0.3\" style=\"width:28.835ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Clip rule 2</h5><div class=\"math-display\"><img src=\"math/a21d3bc0188016ea.svg\" alt=\"\\mu_{R2}(60)=\\min(0.6,0.2)=0.2\" style=\"width:28.835ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Aggregate at this output location</h5><div class=\"math-display\"><img src=\"math/84156b76989dd58e.svg\" alt=\"\\mu_{out}(60)=\\max(0.3,0.2)=0.3\" style=\"width:29.528ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The aggregate membership at z=60 is 0.3. This is not a crisp fan-speed answer.</div></section><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_clip.f101b5cfa9.svg\" width=\"680\" height=\"300\" alt=\"Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.</figcaption></figure><p class=\"memory\"><strong>Yaad rakho:</strong> AND ke liye min; output clip karne ke liye bhi min; rules ko jodne ke liye max. Har min ka role alag hai.</p>"},{"id":"mom","title":"Mean of maxima: discrete peaks and clipped plateaus","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p><strong>Maximum membership</strong> is a height. <strong>Mean of maxima</strong> 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Mean of maxima (MoM)</h2><p><strong>Defuzzification</strong> 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.</p><div class=\"math-display\"><img src=\"math/bfe66044c82b5d4a.svg\" alt=\"z^*_{MoM}=\\frac{z_1+\\cdots+z_m}{m}\" style=\"width:22.258ex;height:4.425ex\" loading=\"lazy\" decoding=\"async\"></div><p>For a continuous flat maximum from a to b, the mean is its midpoint:</p><div class=\"math-display\"><img src=\"math/5be124f1bdbedfca.svg\" alt=\"z^*_{MoM}=\\frac{a+b}{2}\" style=\"width:14.324ex;height:4.652ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>For the following discrete aggregate, find the mean-of-maxima output.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output z</th><th>Membership μ</th></tr></thead><tbody><tr><td>10</td><td>0.2</td></tr><tr><td>20</td><td>0.8</td></tr><tr><td>30</td><td>0.8</td></tr><tr><td>40</td><td>0.3</td></tr></tbody></table><h4>To find</h4><p>MoM crisp output.</p></div><h4>Formula and why it applies</h4><p>Find all locations at the largest height, then average only those locations.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the maximum height</h5><div class=\"math-display\"><img src=\"math/55721303722e693a.svg\" alt=\"\\mu_{max}=0.8\" style=\"width:10.627ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. List the locations attaining it</h5><p>20, 30</p></div><div class=\"step\"><h5>Step 3. Average these locations</h5><div class=\"math-display\"><img src=\"math/caf06fb51932ddd6.svg\" alt=\"z^*=\\frac{20+30}{2}=25\" style=\"width:18.622ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 25.</div></section><section class=\"example\"><p class=\"question\"><strong>For the following discrete aggregate, find the mean-of-maxima output.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output z</th><th>Membership μ</th></tr></thead><tbody><tr><td>1</td><td>0.1</td></tr><tr><td>2</td><td>0.4</td></tr><tr><td>3</td><td>0.9</td></tr><tr><td>4</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>MoM crisp output.</p></div><h4>Formula and why it applies</h4><p>Find all locations at the largest height, then average only those locations.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the maximum height</h5><div class=\"math-display\"><img src=\"math/c286f3dd87b25655.svg\" alt=\"\\mu_{max}=0.9\" style=\"width:10.627ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. List the locations attaining it</h5><p>3</p></div><div class=\"step\"><h5>Step 3. Average these locations</h5><div class=\"math-display\"><img src=\"math/fc739e8ece1c9e47.svg\" alt=\"z^*=\\frac{3}{1}=3\" style=\"width:11.332ex;height:4.586ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 3.</div></section><section class=\"example\"><p class=\"question\"><strong>A single triangular output Tri(50,65,80) is clipped at α=0.3. Find its crisp value by mean of maxima.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=50, b=65, c=80; clip height α=0.3.</p><h4>To find</h4><p>Both plateau endpoints and their mean.</p></div><h4>Formula and why it applies</h4><p>Set the rising and falling membership fractions equal to 0.3. Every point between those intersections has the maximum height.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the left endpoint</h5><div class=\"math-display\"><img src=\"math/145de080f101d4ed.svg\" alt=\"\\frac{z_L-50}{65-50}=0.3\" style=\"width:14.261ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/39a20fc95a439ada.svg\" alt=\"z_L-50=0.3\\times15=4.5\" style=\"width:24.203ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5ce2529d6b5b0ef5.svg\" alt=\"z_L=54.5\" style=\"width:9.369ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find the right endpoint</h5><div class=\"math-display\"><img src=\"math/cbfa4bdb9123ba28.svg\" alt=\"\\frac{80-z_R}{80-65}=0.3\" style=\"width:14.386ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9c5f88f119fb8224.svg\" alt=\"80-z_R=4.5\" style=\"width:13.391ex;height:1.905ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d02ea96dcfb95060.svg\" alt=\"z_R=75.5\" style=\"width:9.494ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Average endpoints</h5><div class=\"math-display\"><img src=\"math/fd9133cfe48a7467.svg\" alt=\"z^*=(54.5+75.5)/2=65\" style=\"width:25.17ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> MoM = 65.</div></section><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_clip.f101b5cfa9.svg\" width=\"680\" height=\"300\" alt=\"The maximum extends over [54.5,75.5], whose midpoint is 65.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The maximum extends over [54.5,75.5], whose midpoint is 65.</figcaption></figure><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Sabse upar ka level dekho; us level par x-values ka mean lo.</p>"},{"id":"centroid","title":"Centroid: three table sums and one area calculation","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Centroid means the balance point of the whole shape</h2><p>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.</p><p>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 <strong>first moment</strong>: position multiplied by area, accumulated across the shape. Their ratio has units of the output, such as fan-speed percent.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Rectangle: width 4, height 0.5, horizontal centre 2. Triangle: base 4, height 0.5, horizontal centroid 6. Their areas do not overlap.</p><h4>To find</h4><p>The combined horizontal centroid.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/97228eac9007fb53.svg\" alt=\"z^*=\\frac{A_1c_1+A_2c_2}{A_1+A_2}\" style=\"width:18.122ex;height:5.041ex\" loading=\"lazy\" decoding=\"async\"></div><p>Each piece contributes area times its own centre. Use this only for a valid decomposition of the aggregate.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Rectangle area</h5><div class=\"math-display\"><img src=\"math/925738e6d7bc9738.svg\" alt=\"A_1=4\\times0.5=2\" style=\"width:16.638ex;height:1.959ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Triangle area</h5><div class=\"math-display\"><img src=\"math/39c5ce3ae9dbf13b.svg\" alt=\"A_2=\\tfrac12\\times4\\times0.5=1\" style=\"width:21.199ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. First moments</h5><div class=\"math-display\"><img src=\"math/3e993e836c87a393.svg\" alt=\"A_1c_1=2\\times2=4\" style=\"width:16.845ex;height:1.959ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c3ef1e042430e3fc.svg\" alt=\"A_2c_2=1\\times6=6\" style=\"width:16.845ex;height:1.959ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Totals</h5><div class=\"math-display\"><img src=\"math/0582db5cb8a7455e.svg\" alt=\"A=2+1=3\\qquad M=4+6=10\" style=\"width:34.118ex;height:1.805ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Divide</h5><div class=\"math-display\"><img src=\"math/772602a59fae475c.svg\" alt=\"z^*=10/3\\approx3.333333\" style=\"width:21.146ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Centroid≈3.333333, closer to the larger-area piece.</div></section><p>For overlapping clipped sets, first form their max-aggregate. Adding the areas of the original overlapping sets would count the overlap twice.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Centroid: the balance point of the output</h2><p>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.</p><div class=\"math-display\"><img src=\"math/4ca780545740bc9c.svg\" alt=\"z^*=\\frac{\\sum_i z_i\\mu(z_i)}{\\sum_i\\mu(z_i)}\" style=\"width:16.266ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>The index i simply numbers table entries. Σ (“sigma”) means add all listed terms. The denominator must be nonzero.</p><section class=\"example\"><p class=\"question\"><strong>Find the discrete centroid of the aggregate membership table.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>z</th><th>μ(z)</th></tr></thead><tbody><tr><td>10</td><td>0.2</td></tr><tr><td>20</td><td>0.6</td></tr><tr><td>30</td><td>0.4</td></tr></tbody></table><h4>To find</h4><p>One centroid value on the output scale.</p></div><h4>Formula and why it applies</h4><p>This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.</p><div class=\"math-display\"><img src=\"math/0daa1f2e296038c3.svg\" alt=\"z^*=\\frac{\\sum z_i\\mu_i}{\\sum\\mu_i}\" style=\"width:12.714ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply every location by its membership</h5><table><thead><tr><th>z</th><th>μ</th><th>z × μ</th></tr></thead><tbody><tr><td>10</td><td>0.2</td><td>2</td></tr><tr><td>20</td><td>0.6</td><td>12</td></tr><tr><td>30</td><td>0.4</td><td>12</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the numerator</h5><div class=\"math-display\"><img src=\"math/1b63f80f68e4f903.svg\" alt=\"2+12+12=26\" style=\"width:16.467ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the denominator</h5><div class=\"math-display\"><img src=\"math/762eaecf8eca8b36.svg\" alt=\"0.2+0.6+0.4=1.2\" style=\"width:20.114ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/f7410bf10136fdc7.svg\" alt=\"z^*=\\frac{26}{1.2}=21.666666667\" style=\"width:25.033ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 21.666666667.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the discrete centroid of the aggregate membership table.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>z</th><th>μ(z)</th></tr></thead><tbody><tr><td>0</td><td>0.5</td></tr><tr><td>5</td><td>1</td></tr><tr><td>10</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>One centroid value on the output scale.</p></div><h4>Formula and why it applies</h4><p>This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.</p><div class=\"math-display\"><img src=\"math/0daa1f2e296038c3.svg\" alt=\"z^*=\\frac{\\sum z_i\\mu_i}{\\sum\\mu_i}\" style=\"width:12.714ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply every location by its membership</h5><table><thead><tr><th>z</th><th>μ</th><th>z × μ</th></tr></thead><tbody><tr><td>0</td><td>0.5</td><td>0</td></tr><tr><td>5</td><td>1</td><td>5</td></tr><tr><td>10</td><td>0.5</td><td>5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the numerator</h5><div class=\"math-display\"><img src=\"math/31c26d8043dbf781.svg\" alt=\"0+5+5=10\" style=\"width:14.205ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the denominator</h5><div class=\"math-display\"><img src=\"math/723c388b267a6d46.svg\" alt=\"0.5+1+0.5=2\" style=\"width:16.594ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/6b4a65f7e66f3cfb.svg\" alt=\"z^*=\\frac{10}{2}=5\" style=\"width:12.463ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 5.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the discrete centroid of the aggregate membership table.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>z</th><th>μ(z)</th></tr></thead><tbody><tr><td>20</td><td>0</td></tr><tr><td>40</td><td>0.3</td></tr><tr><td>60</td><td>0.6</td></tr><tr><td>80</td><td>0.1</td></tr></tbody></table><h4>To find</h4><p>One centroid value on the output scale.</p></div><h4>Formula and why it applies</h4><p>This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.</p><div class=\"math-display\"><img src=\"math/0daa1f2e296038c3.svg\" alt=\"z^*=\\frac{\\sum z_i\\mu_i}{\\sum\\mu_i}\" style=\"width:12.714ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply every location by its membership</h5><table><thead><tr><th>z</th><th>μ</th><th>z × μ</th></tr></thead><tbody><tr><td>20</td><td>0</td><td>0</td></tr><tr><td>40</td><td>0.3</td><td>12</td></tr><tr><td>60</td><td>0.6</td><td>36</td></tr><tr><td>80</td><td>0.1</td><td>8</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the numerator</h5><div class=\"math-display\"><img src=\"math/eacf08e4fd9566bf.svg\" alt=\"0+12+36+8=56\" style=\"width:20.364ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the denominator</h5><div class=\"math-display\"><img src=\"math/0cd832e4cf2e8857.svg\" alt=\"0+0.3+0.6+0.1=1\" style=\"width:22.251ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/8184446a5afe0a48.svg\" alt=\"z^*=\\frac{56}{1}=56\" style=\"width:13.594ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 56.</div></section><h2>For a continuous shape, integrate the area</h2><div class=\"math-display\"><img src=\"math/a3227ed1a9289bb5.svg\" alt=\"z^*=\\frac{\\int z\\mu(z)\\,dz}{\\int\\mu(z)\\,dz}\" style=\"width:15.644ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><p>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 <span class=\"math-inline\"><img src=\"math/033d1d87c88bf6a8.svg\" alt=\"z^*=(\\sum A_jc_j)/(\\sum A_j)\" style=\"width:22.155ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>. Overlapping regions of a max-aggregate must not be counted twice.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Rectangle [0,4], height 0.5; triangle with vertices (4,0),(4,0.5),(6,0).</p><h4>To find</h4><p>Centroid of the combined area.</p></div><h4>Formula and why it applies</h4><p>The parts do not overlap except at their boundary. Weight each part’s horizontal centroid by its area.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Rectangle area and centre</h5><div class=\"math-display\"><img src=\"math/478220c1039e3c18.svg\" alt=\"A_1=4\\times0.5=2\\qquad c_1=(0+4)/2=2\" style=\"width:39.347ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Triangle area and centre</h5><div class=\"math-display\"><img src=\"math/931f8a69a034cfb8.svg\" alt=\"A_2=\\tfrac12\\times2\\times0.5=0.5\" style=\"width:22.96ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9b85cc1cdfb06f4d.svg\" alt=\"c_2=(4+4+6)/3=14/3\" style=\"width:25.474ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add first moments</h5><div class=\"math-display\"><img src=\"math/f37e6894a3c89e61.svg\" alt=\"A_1c_1+A_2c_2=2(2)+0.5(14/3)=19/3\" style=\"width:38.593ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide by total area</h5><div class=\"math-display\"><img src=\"math/c0212421c50f4e75.svg\" alt=\"z^*=(19/3)/(2+0.5)=38/15\\approx2.533333\" style=\"width:41.259ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Centroid ≈ 2.533333. The plateau MoM would be 2, so different methods can legitimately give different results.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Centroid = har location × uska weight, total karke total weight se divide.</p>"},{"id":"weighted-average","title":"Weighted average and centroid are not automatically the same","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Weighted average of output representatives</h2><p>Some classroom solutions use one representative (often the peak) per output label and weight it by the firing strength. That is a <strong>weighted-average or height-based calculation</strong>. It is exact for a specified weighted combination of singleton outputs, but is not generally the centroid of a max-aggregated, clipped Mamdani shape.</p><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [25, 75] mph with respective strengths [0.1, 0.7].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>25</td><td>0.1</td></tr><tr><td>75</td><td>0.7</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0.1 × 25</td><td>2.5</td></tr><tr><td>0.7 × 75</td><td>52.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/648cd602080c422e.svg\" alt=\"2.5+52.5=55\" style=\"width:14.959ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/e794808140502a26.svg\" alt=\"0.1+0.7=0.8\" style=\"width:14.457ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/5b92e77608da1213.svg\" alt=\"z^*=\\frac{55}{0.8}=68.75\" style=\"width:17.115ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 68.75 mph.</div></section><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [40, 65, 85] % fan speed with respective strengths [0, 0.3, 0.5].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>40</td><td>0</td></tr><tr><td>65</td><td>0.3</td></tr><tr><td>85</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0 × 40</td><td>0</td></tr><tr><td>0.3 × 65</td><td>19.5</td></tr><tr><td>0.5 × 85</td><td>42.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/0bdf70679aafe819.svg\" alt=\"0+19.5+42.5=62\" style=\"width:19.987ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/76b7c63a5ed0de17.svg\" alt=\"0+0.3+0.5=0.8\" style=\"width:18.354ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/31b2865a5ddd122a.svg\" alt=\"z^*=\\frac{62}{0.8}=77.5\" style=\"width:15.983ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 77.5 % fan speed.</div></section><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [25, 40, 60] minutes with respective strengths [0.6, 0.4, 0.2].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>25</td><td>0.6</td></tr><tr><td>40</td><td>0.4</td></tr><tr><td>60</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0.6 × 25</td><td>15</td></tr><tr><td>0.4 × 40</td><td>16</td></tr><tr><td>0.2 × 60</td><td>12</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/368823bf9efe0162.svg\" alt=\"15+16+12=43\" style=\"width:17.598ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/9f1b10f7784e3b8c.svg\" alt=\"0.6+0.4+0.2=1.2\" style=\"width:20.114ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/603521823aee6db6.svg\" alt=\"z^*=\\frac{43}{1.2}=35.833333333\" style=\"width:25.033ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 35.833333333 minutes.</div></section><table><thead><tr><th>Method</th><th>What it uses</th><th>Limitation</th></tr></thead><tbody><tr><td>MoM</td><td>Locations at maximum membership</td><td>Ignores lower portions of the shape; can change abruptly</td></tr><tr><td>Area centroid</td><td>Entire aggregated output area</td><td>Needs an area/moment calculation or numerical integration</td></tr><tr><td>Representative weighted average</td><td>Supplied representative values and strengths</td><td>Not interchangeable with a clipped Mamdani area centroid</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Formula similar dikhega, par weight kya hai? Membership, area, ya rule strength—pehle woh identify karo.</p>\r\n<h2>Faculty slide example: one temperature input</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [50, 80] % fan speed with respective strengths [0.8, 0.2].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>50</td><td>0.8</td></tr><tr><td>80</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0.8 × 50</td><td>40</td></tr><tr><td>0.2 × 80</td><td>16</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/dc4a907872eaaa0b.svg\" alt=\"40+16=56\" style=\"width:12.57ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/ffd94fb58f716964.svg\" alt=\"0.8+0.2=1\" style=\"width:12.697ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/8184446a5afe0a48.svg\" alt=\"z^*=\\frac{56}{1}=56\" style=\"width:13.594ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 56 % fan speed.</div></section>"},{"id":"class-fan","title":"Class fan question: 32°C, 7 people, every rule and step","html":"<!-- depth:rules-grid:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:rules-grid:end -->\r\n<p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Class-question adaptation; full design]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Low / Very Low</th><th>Medium / Low</th><th>High / Medium</th><th>High output</th><th>Very High output</th></tr></thead><tbody><tr><td>Temperature</td><td>Tri(0,10,20)</td><td>Tri(15,25,35)</td><td>Tri(25,35,40)</td><td>—</td><td>—</td></tr><tr><td>Occupancy</td><td>Tri(0,2,4)</td><td>Tri(3,5,7)</td><td>Tri(6,8,10)</td><td>—</td><td>—</td></tr><tr><td>Fan speed</td><td>Tri(0,10,20)</td><td>Tri(10,25,40)</td><td>Tri(20,40,60)</td><td>Tri(50,65,80)</td><td>Tri(70,85,100)</td></tr></tbody></table><p>Input T=32°C; occupancy=7. Use min-AND, min-clipping and max-aggregation.</p><table><thead><tr><th>Temperature</th><th>Occupancy</th><th>Fan output</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>Very Low</td></tr><tr><td>Low</td><td>Medium</td><td>Low</td></tr><tr><td>Low</td><td>High</td><td>Medium</td></tr><tr><td>Medium</td><td>Low</td><td>Low</td></tr><tr><td>Medium</td><td>Medium</td><td>Medium</td></tr><tr><td>Medium</td><td>High</td><td>High</td></tr><tr><td>High</td><td>Low</td><td>Medium</td></tr><tr><td>High</td><td>Medium</td><td>High</td></tr><tr><td>High</td><td>High</td><td>Very High</td></tr></tbody></table><h4>To find</h4><p>Input memberships → nine rule strengths → clipped output → two named crisp outputs.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/2e1abd53c3392e1f.svg\" alt=\"\\alpha_r=\\min(\\mu_{T,r},\\mu_{O,r})\\quad\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:51.241ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Read the temperature graph</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fan_temp.434c9b6635.svg\" width=\"680\" height=\"300\" alt=\"At 32, Medium is on its falling side; High is on its rising side.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>At 32, Medium is on its falling side; High is on its rising side.</figcaption></figure><div class=\"math-display\"><img src=\"math/90541f01c8f3e577.svg\" alt=\"\\mu_L(32)=0\" style=\"width:10.812ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8b417cc7c6fd3b3f.svg\" alt=\"\\mu_M(32)=\\frac{35-32}{35-25}=\\frac3{10}=0.3\" style=\"width:30.743ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1456bdcfcdae3dcf.svg\" alt=\"\\mu_H(32)=\\frac{32-25}{35-25}=\\frac7{10}=0.7\" style=\"width:30.482ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Read the occupancy graph</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fan_people.1861531dd1.svg\" width=\"680\" height=\"300\" alt=\"At 7, Medium reaches its right zero and High is halfway up its rising edge.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>At 7, Medium reaches its right zero and High is halfway up its rising edge.</figcaption></figure><div class=\"math-display\"><img src=\"math/0dc9da58647d7498.svg\" alt=\"\\mu_L(7)=0\\qquad\\mu_M(7)=0\" style=\"width:24.479ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/527793f08bd07193.svg\" alt=\"\\mu_H(7)=\\frac{7-6}{8-6}=\\frac12=0.5\" style=\"width:25.957ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate all nine rules</h5><table><thead><tr><th>T label / degree</th><th>O label / degree</th><th>min = strength</th><th>Output</th></tr></thead><tbody><tr><td>Low / 0</td><td>Low / 0</td><td>0</td><td>Very Low</td></tr><tr><td>Low / 0</td><td>Medium / 0</td><td>0</td><td>Low</td></tr><tr><td>Low / 0</td><td>High / 0.5</td><td>0</td><td>Medium</td></tr><tr><td>Medium / 0.3</td><td>Low / 0</td><td>0</td><td>Low</td></tr><tr><td>Medium / 0.3</td><td>Medium / 0</td><td>0</td><td>Medium</td></tr><tr><td>Medium / 0.3</td><td>High / 0.5</td><td>0.3</td><td>High</td></tr><tr><td>High / 0.7</td><td>Low / 0</td><td>0</td><td>Medium</td></tr><tr><td>High / 0.7</td><td>Medium / 0</td><td>0</td><td>High</td></tr><tr><td>High / 0.7</td><td>High / 0.5</td><td>0.5</td><td>Very High</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Clip and aggregate</h5><div class=\"math-display\"><img src=\"math/2ead49cb7f0674dc.svg\" alt=\"\\mu_{out}(z)=\\max\\{\\min(0.3,\\mu_H(z)),\\min(0.5,\\mu_{VH}(z))\\}\" style=\"width:48.787ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fan_output.8708d0ea77.svg\" width=\"680\" height=\"300\" alt=\"High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.</figcaption></figure></div><div class=\"step\"><h5>Step 5. Find the highest plateau for MoM</h5><p>The maximum is 0.5, belonging to Very High. Its triangle is (70,85,100).</p><div class=\"math-display\"><img src=\"math/a4fdc221a6cfa166.svg\" alt=\"\\frac{z_L-70}{15}=0.5\\Rightarrow z_L=77.5\" style=\"width:27.15ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fba2b937f7b534a8.svg\" alt=\"\\frac{100-z_R}{15}=0.5\\Rightarrow z_R=92.5\" style=\"width:28.531ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a4e234f2232ff44d.svg\" alt=\"z^*_{MoM}=\\frac{77.5+92.5}{2}=85\" style=\"width:25.482ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the representatives by strengths</h5><div class=\"math-display\"><img src=\"math/e44a237331cdc730.svg\" alt=\"0.3\\times65=19.5\" style=\"width:14.959ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dfe0b2ebeb9b2e0c.svg\" alt=\"0.5\\times85=42.5\" style=\"width:14.959ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Add, then divide for the weighted average</h5><div class=\"math-display\"><img src=\"math/1cf8861b16222d21.svg\" alt=\"z^*_{WA}=\\frac{19.5+42.5}{0.3+0.5}=\\frac{62}{0.8}=77.5\" style=\"width:32.883ex;height:4.799ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p><strong>How to adapt it in the exam:</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Temperature aur people ka degree nikalo → 9 min → active outputs clip → jo method poocha hai woh lagao.</p>\r\n\r\n<!-- depth:plateau:start -->\r\n<div class=\"concept-bridge\"><h2>Why the Very High plateau has midpoint 85</h2><p>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.</p></div>\r\n<!-- depth:plateau:end -->\r\n<p>Continue with the <a href=\"#tee/read/fuzzy-core/centroid-comparison\">complete area-centroid calculation for this same fan design</a>: 77.086956522%, with all overlap breakpoints and area/moment arithmetic shown.</p>"},{"id":"centroid-comparison","title":"The same fan controller: true area centroid versus MoM and weighted average","html":"<p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[6 marks]</span></p><p>Worked teaching continuation of the class-design adaptation; the mark allocation here is for practice.</p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Every visible segment of the aggregate, its area and first moment, the centroid, and the differences between the three crisp answers.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/2ead49cb7f0674dc.svg\" alt=\"\\mu_{out}(z)=\\max\\{\\min(0.3,\\mu_H(z)),\\min(0.5,\\mu_{VH}(z))\\}\" style=\"width:48.787ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/175fa0720f954403.svg\" alt=\"z^*_{COA}=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:20.937ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><div class=\"math-display\"><img src=\"math/10dac72a97306eb6.svg\" alt=\"A=\\frac{(b-a)(u+v)}2,\\qquad M=\\frac{b-a}{6}[(2a+b)u+(a+2b)v]\" style=\"width:58.239ex;height:4.905ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the two clipped plateaus</h5><div class=\"math-display\"><img src=\"math/6757779ccc7556ad.svg\" alt=\"H:\\quad z_L=50+0.3(65-50)=54.5,\\quad z_R=80-0.3(80-65)=75.5\" style=\"width:68.263ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/19f28361b506bad3.svg\" alt=\"VH:\\quad z_L=70+0.5(85-70)=77.5,\\quad z_R=100-0.5(100-85)=92.5\" style=\"width:72.266ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 2. Find where the upper envelope changes owner</h5><p>Very High rises through the High plateau at height 0.3. Solve its rising equation:</p><div class=\"math-display\"><img src=\"math/d00383e24c2ca74a.svg\" alt=\"(z-70)/15=0.3\\quad\\Rightarrow\\quad z=74.5\" style=\"width:33.279ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 3. Trace the aggregate graph</h5><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/deep_fan_centroid.98bf1c217d.svg\" width=\"980\" height=\"500\" alt=\"Fan output: trace the upper envelope before finding its centroid\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 4. Work the rising first strip explicitly</h5><div class=\"math-display\"><img src=\"math/5c3f2b7a4bd76f0b.svg\" alt=\"A_1=(54.5-50)(0+0.3)/2=0.675\" style=\"width:35.494ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5570b4038f564dfd.svg\" alt=\"M_1=\\frac{4.5}{6}[(100+54.5)0+(50+109)0.3]=35.775\" style=\"width:49.559ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div><p>The first moment has units of speed multiplied by area. Dividing total moment by total area returns speed.</p></div><div class=\"step\"><h5>Step 5. Calculate all disjoint strips</h5><div class=\"table-scroll\"><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>First moment M</th></tr></thead><tbody><tr><td>50</td><td>54.5</td><td>0</td><td>0.3</td><td>0.675</td><td>35.775</td></tr><tr><td>54.5</td><td>74.5</td><td>0.3</td><td>0.3</td><td>6</td><td>387</td></tr><tr><td>74.5</td><td>77.5</td><td>0.3</td><td>0.5</td><td>1.2</td><td>91.35</td></tr><tr><td>77.5</td><td>92.5</td><td>0.5</td><td>0.5</td><td>7.5</td><td>637.5</td></tr><tr><td>92.5</td><td>100</td><td>0.5</td><td>0</td><td>1.875</td><td>178.125</td></tr></tbody></table></div><div class=\"math-display\"><img src=\"math/1a4fac5b0fc5e065.svg\" alt=\"\\sum A=0.675+6+1.2+7.5+1.875=17.25\" style=\"width:44.813ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3f79a707c0d7b969.svg\" alt=\"\\sum M=35.775+387+91.35+637.5+178.125=1329.75\" style=\"width:57.938ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Divide for the actual centroid</h5><div class=\"math-display\"><img src=\"math/cf56069827f681bb.svg\" alt=\"z^*_{COA}=1329.75/17.25=1773/23\\approx77.086956522\\%\" style=\"width:50.504ex;height:2.294ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Compare methods on the same aggregate</h5><div class=\"table-scroll\"><table><thead><tr><th>Method</th><th>Calculation</th><th>Answer</th></tr></thead><tbody><tr><td>Area centroid</td><td>1329.75 ÷ 17.25</td><td>77.086956522%</td></tr><tr><td>Mean of maxima</td><td>(77.5+92.5) ÷ 2</td><td>85%</td></tr><tr><td>Specified representative weighted average</td><td>(0.3×65+0.5×85) ÷ (0.3+0.5)</td><td>77.5%</td></tr></tbody></table></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p><strong>Boundary coverage of this teaching design.</strong> 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.</p><p><strong>Yaad rakho:</strong> Centroid mein poore shaded area ka balance chahiye. Peak × strength wala shortcut same calculation nahi hai.</p>"},{"id":"exam-theory","title":"Fuzzy theory: definitions, architecture, advantages and applications","html":"<section class=\"example\"><p class=\"question\"><strong>Explain fuzzy logic with one application.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><section class=\"example\"><p class=\"question\"><strong>Give the advantages and limitations of a Mamdani fuzzy controller.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td>Human-readable rules express expert knowledge</td><td>Membership functions and rules require careful design</td></tr><tr><td>Can model gradual boundaries without an exact analytic plant model</td><td>Rule count can grow rapidly with more inputs and categories</td></tr><tr><td>Handles overlapping linguistic descriptions</td><td>A poorly chosen rule base can produce poor or uncovered outputs</td></tr><tr><td>Suitable for many control applications</td><td>Does not automatically learn or guarantee optimal control</td></tr></tbody></table></section><section class=\"example\"><p class=\"question\"><strong>Describe the design of a fuzzy fan controller.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><h2>Other applications you can explain</h2><table><thead><tr><th>Application</th><th>Inputs</th><th>Example rule</th><th>Output</th></tr></thead><tbody><tr><td>Washing machine</td><td>Dirtiness, load</td><td>IF dirt High AND load High THEN wash time Long</td><td>Wash duration</td></tr><tr><td>Loan decision support</td><td>Income, credit score</td><td>IF income High AND credit Good THEN approval suitability High</td><td>Suitability score (not an automatic legal lending decision)</td></tr><tr><td>Fire warning</td><td>Temperature, smoke</td><td>IF temperature High OR smoke High THEN risk High</td><td>Alarm-risk score</td></tr><tr><td>Vehicle control</td><td>Distance, relative speed</td><td>IF distance Small AND closing speed High THEN braking Strong</td><td>Braking command</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Theory answer mein definition → blocks/steps → ek concrete example. Sirf headings se marks nahi milte.</p>"},{"id":"smooth-memberships","title":"Gaussian, singleton and bell memberships","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>A smooth membership function</h2><p>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.</p><div class=\"math-display\"><img src=\"math/518c1dcbf29cffeb.svg\" alt=\"\\mu(x)=\\exp\\left(-\\frac{(x-c)^2}{2\\sigma^2}\\right)\" style=\"width:25.143ex;height:5.641ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>For Gaussian membership with c=10 and σ=2, find μ(10).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=10; centre c=10; width σ=2.</p><h4>To find</h4><p>Membership degree.</p></div><h4>Formula and why it applies</h4><p>Use squared distance from the centre in the Gaussian membership formula.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Distance from the centre</h5><div class=\"math-display\"><img src=\"math/321dce230aba9ce3.svg\" alt=\"10-10=0\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the distance and width</h5><div class=\"math-display\"><img src=\"math/2fa85e59ecadded4.svg\" alt=\"(0)^2=0\\qquad2\\sigma^2=2(2^2)=8\" style=\"width:28.139ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponent</h5><div class=\"math-display\"><img src=\"math/7875a0b4018e0854.svg\" alt=\"-0/8=0\" style=\"width:9.302ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Evaluate e to this power</h5><div class=\"math-display\"><img src=\"math/db4e90ad0923df06.svg\" alt=\"\\mu(10)=e^{0}\\approx1\" style=\"width:14.594ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 1.</div></section><section class=\"example\"><p class=\"question\"><strong>For Gaussian membership with c=10 and σ=2, find μ(12).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=12; centre c=10; width σ=2.</p><h4>To find</h4><p>Membership degree.</p></div><h4>Formula and why it applies</h4><p>Use squared distance from the centre in the Gaussian membership formula.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Distance from the centre</h5><div class=\"math-display\"><img src=\"math/97fe26072a5dade9.svg\" alt=\"12-10=2\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the distance and width</h5><div class=\"math-display\"><img src=\"math/0776e93b48581bdc.svg\" alt=\"(2)^2=4\\qquad2\\sigma^2=2(2^2)=8\" style=\"width:28.139ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponent</h5><div class=\"math-display\"><img src=\"math/31d0827fcff0f487.svg\" alt=\"-4/8=-0.5\" style=\"width:12.823ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Evaluate e to this power</h5><div class=\"math-display\"><img src=\"math/3045651368f264c4.svg\" alt=\"\\mu(12)=e^{-0.5}\\approx0.60653066\" style=\"width:26.762ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.60653066.</div></section><section class=\"example\"><p class=\"question\"><strong>For Gaussian membership with c=10 and σ=2, find μ(14).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=14; centre c=10; width σ=2.</p><h4>To find</h4><p>Membership degree.</p></div><h4>Formula and why it applies</h4><p>Use squared distance from the centre in the Gaussian membership formula.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Distance from the centre</h5><div class=\"math-display\"><img src=\"math/83b853a2ad6339ff.svg\" alt=\"14-10=4\" style=\"width:11.439ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the distance and width</h5><div class=\"math-display\"><img src=\"math/8237f522c90ae910.svg\" alt=\"(4)^2=16\\qquad2\\sigma^2=2(2^2)=8\" style=\"width:29.27ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponent</h5><div class=\"math-display\"><img src=\"math/6189f75f7af84207.svg\" alt=\"-16/8=-2\" style=\"width:12.194ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Evaluate e to this power</h5><div class=\"math-display\"><img src=\"math/a282bbe0d0c6f2b0.svg\" alt=\"\\mu(14)=e^{-2}\\approx0.135335283\" style=\"width:26.649ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.135335283.</div></section><h2>Singleton</h2><p>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.</p>\r\n<h2>Generalised bell (when its formula is supplied)</h2><div class=\"math-display\"><img src=\"math/5710690d4b19691e.svg\" alt=\"\\mu(x)=\\frac1{1+\\left|\\frac{x-c}{a}\\right|^{2b}}\" style=\"width:19.357ex;height:6.163ex\" loading=\"lazy\" decoding=\"async\"></div><p>c is the centre, a&gt;0 controls width and b&gt;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.</p><section class=\"example\"><p class=\"question\"><strong>For a=2, b=1 and c=10, find generalised-bell membership at x=14.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=2, b=1, c=10; x=14.</p><h4>To find</h4><p>μ(14).</p></div><h4>Formula and why it applies</h4><p>Subtract the centre, divide by a, take the absolute value, raise to 2b, then use the reciprocal.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Scaled distance</h5><div class=\"math-display\"><img src=\"math/76742f554dcbda62.svg\" alt=\"|(14-10)/2|=|2|=2\" style=\"width:22.126ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Power</h5><div class=\"math-display\"><img src=\"math/de2c89102c7ce99d.svg\" alt=\"2^{2(1)}=4\" style=\"width:8.312ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Final reciprocal</h5><div class=\"math-display\"><img src=\"math/d1a7dee6fdbdc5f8.svg\" alt=\"\\mu(14)=1/(1+4)=0.2\" style=\"width:23.363ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.2.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Gaussian MF ka centre 1 hota hai. GMM density ke normalising factor ko yahan mat lagao.</p>"}]},{"id":"ga-core","title":"3. Genetic algorithms","unit":"Unit 3 · GA","scope":"Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.","sections":[{"id":"meaning","title":"GA meaning, biological idea and every basic term","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><table><thead><tr><th>Object</th><th>Concrete value</th><th>Do not confuse it with</th></tr></thead><tbody><tr><td>Individual number</td><td>Row 2</td><td>The candidate’s value x</td></tr><tr><td>Candidate value x</td><td>11</td><td>Its chromosome 1011</td></tr><tr><td>Chromosome</td><td>1011</td><td>Its fitness</td></tr><tr><td>Fitness when maximising x²</td><td>11×11=121</td><td>Its row number or bit string</td></tr></tbody></table><p>In this guide, “gene 3” counts the third bit from the <strong>left</strong> starting at 1. Binary place values were built from the <strong>right</strong> starting with weight 1. These are two labelling conventions, not contradictory place-value rules. Read the end specified in an exam.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>What a genetic algorithm does</h2><p>A <strong>genetic algorithm (GA)</strong> 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.</p><p>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.</p><table><thead><tr><th>Term</th><th>Meaning</th><th>Four-bit example</th></tr></thead><tbody><tr><td>Individual</td><td>One candidate solution</td><td>x=11</td></tr><tr><td>Chromosome</td><td>The complete encoded candidate</td><td>1011</td></tr><tr><td>Gene</td><td>One component of an encoding</td><td>The third bit</td></tr><tr><td>Allele</td><td>The value at a gene</td><td>0 or 1 for binary encoding</td></tr><tr><td>Population</td><td>The collection of current individuals</td><td>[3,5,10,12]</td></tr><tr><td>Fitness</td><td>A score used to favour useful candidates</td><td>For max x², fitness of 11 is 121</td></tr><tr><td>Generation</td><td>One cycle producing a new population</td><td>Select → cross → mutate → replace</td></tr><tr><td>Search space</td><td>All candidate solutions permitted</td><td>4-bit integers: 0–15</td></tr><tr><td>Elitism</td><td>Preserving best individuals unchanged</td><td>Copy the best into the next population</td></tr></tbody></table><p>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.</p><section class=\"example\"><p class=\"question\"><strong>For a maximisation GA with objective f(x)=x², find the fitness of x=3.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=3; fitness equals the nonnegative objective x².</p><h4>To find</h4><p>Fitness, not the encoded chromosome.</p></div><h4>Formula and why it applies</h4><p>Square x to evaluate its objective; binary encoding is a separate representation step.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute x</h5><div class=\"math-display\"><img src=\"math/7cb566d00780f2b1.svg\" alt=\"f(3)=3^2\" style=\"width:9.272ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply</h5><div class=\"math-display\"><img src=\"math/40a9936a2387e5b6.svg\" alt=\"3\\times3=9\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Fitness = 9.</div></section><section class=\"example\"><p class=\"question\"><strong>For a maximisation GA with objective f(x)=x², find the fitness of x=7.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=7; fitness equals the nonnegative objective x².</p><h4>To find</h4><p>Fitness, not the encoded chromosome.</p></div><h4>Formula and why it applies</h4><p>Square x to evaluate its objective; binary encoding is a separate representation step.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute x</h5><div class=\"math-display\"><img src=\"math/a39be859ebcf3420.svg\" alt=\"f(7)=7^2\" style=\"width:9.272ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply</h5><div class=\"math-display\"><img src=\"math/67b20e8d00098635.svg\" alt=\"7\\times7=49\" style=\"width:10.308ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Fitness = 49.</div></section><section class=\"example\"><p class=\"question\"><strong>For a maximisation GA with objective f(x)=x², find the fitness of x=12.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=12; fitness equals the nonnegative objective x².</p><h4>To find</h4><p>Fitness, not the encoded chromosome.</p></div><h4>Formula and why it applies</h4><p>Square x to evaluate its objective; binary encoding is a separate representation step.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute x</h5><div class=\"math-display\"><img src=\"math/40c9415d3dcdd694.svg\" alt=\"f(12)=12^2\" style=\"width:11.534ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply</h5><div class=\"math-display\"><img src=\"math/ea37e28a2a0fc9ec.svg\" alt=\"12\\times12=144\" style=\"width:13.701ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Fitness = 144.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Chromosome answer ka code; fitness us code wale answer ka score.</p>"},{"id":"encoding","title":"Encoding: binary, real values and permutations","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Expand the compact decoding formula before using it</h2><div class=\"math-display\"><img src=\"math/7a27d9903aa92206.svg\" alt=\"x=b_1 2^3+b_2 2^2+b_3 2^1+b_4 2^0\" style=\"width:28.917ex;height:2.374ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><p>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.</p><table><thead><tr><th>3-bit code</th><th>Decoded d</th><th>Fraction d/7</th><th>Mapped to [−2,5]</th></tr></thead><tbody><tr><td>000</td><td>0</td><td>0/7=0</td><td>−2+0×7=−2</td></tr><tr><td>011</td><td>3</td><td>3/7</td><td>−2+(3/7)×7=1</td></tr><tr><td>111</td><td>7</td><td>7/7=1</td><td>−2+1×7=5</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Choose an encoding that can express legal solutions</h2><p><strong>Binary encoding</strong> uses bit strings; <strong>real-valued encoding</strong> stores real numbers directly; <strong>permutation encoding</strong> 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.</p><table><thead><tr><th>Representation</th><th>Candidate</th><th>Appropriate use</th></tr></thead><tbody><tr><td>Binary</td><td>1011</td><td>An unsigned integer or a coded real value</td></tr><tr><td>Real-valued</td><td>[0.2, 1.7]</td><td>Continuous parameters</td></tr><tr><td>Permutation</td><td>[A,C,B,D]</td><td>Visit order in TSP</td></tr></tbody></table><h2>Decode an n-bit integer</h2><div class=\"math-display\"><img src=\"math/f86e986776de93a7.svg\" alt=\"x=b_1 2^{n-1}+b_2 2^{n-2}+\\cdots+b_n2^0\" style=\"width:32.06ex;height:2.357ex\" loading=\"lazy\" decoding=\"async\"></div><p>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 <span class=\"math-inline\"><img src=\"math/9dc91f3c375d809f.svg\" alt=\"2^n-1\" style=\"width:6.176ex;height:1.714ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><section class=\"example\"><p class=\"question\"><strong>Decode the 4-bit chromosome 0011.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Bits 0011; place values 8,4,2,1.</p><h4>To find</h4><p>Integer x.</p></div><h4>Formula and why it applies</h4><p>Multiply each bit by its matching place value, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. List contributions</h5><table><thead><tr><th>Bit</th><th>Place value</th><th>Contribution</th></tr></thead><tbody><tr><td>0</td><td>8</td><td>0</td></tr><tr><td>0</td><td>4</td><td>0</td></tr><tr><td>1</td><td>2</td><td>2</td></tr><tr><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/76153632459f881f.svg\" alt=\"0+0+2+1=3\" style=\"width:16.97ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=3.</div></section><section class=\"example\"><p class=\"question\"><strong>Decode the 4-bit chromosome 1010.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Bits 1010; place values 8,4,2,1.</p><h4>To find</h4><p>Integer x.</p></div><h4>Formula and why it applies</h4><p>Multiply each bit by its matching place value, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. List contributions</h5><table><thead><tr><th>Bit</th><th>Place value</th><th>Contribution</th></tr></thead><tbody><tr><td>1</td><td>8</td><td>8</td></tr><tr><td>0</td><td>4</td><td>0</td></tr><tr><td>1</td><td>2</td><td>2</td></tr><tr><td>0</td><td>1</td><td>0</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/d1e04d751dc741ed.svg\" alt=\"8+0+2+0=10\" style=\"width:18.102ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=10.</div></section><section class=\"example\"><p class=\"question\"><strong>Decode the 4-bit chromosome 1111.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Bits 1111; place values 8,4,2,1.</p><h4>To find</h4><p>Integer x.</p></div><h4>Formula and why it applies</h4><p>Multiply each bit by its matching place value, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. List contributions</h5><table><thead><tr><th>Bit</th><th>Place value</th><th>Contribution</th></tr></thead><tbody><tr><td>1</td><td>8</td><td>8</td></tr><tr><td>1</td><td>4</td><td>4</td></tr><tr><td>1</td><td>2</td><td>2</td></tr><tr><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/f3965404fe997578.svg\" alt=\"8+4+2+1=15\" style=\"width:18.102ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=15.</div></section><h2>Encoding a real interval</h2><p>If the question maps an n-bit integer d to a real interval [L,U], first decode d, then use:</p><div class=\"math-display\"><img src=\"math/3013a3fc845c64e5.svg\" alt=\"x=L+\\frac{d}{2^n-1}(U-L)\" style=\"width:23.591ex;height:4.837ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>Map the 3-bit string 101 to the real interval [−2,5] using linear binary decoding.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>n=3, L=−2, U=5; string 101.</p><h4>To find</h4><p>Real x.</p></div><h4>Formula and why it applies</h4><p>The smallest bit code maps to L and the largest to U; the remaining codes are equally spaced.</p><div class=\"math-display\"><img src=\"math/d5a028f7f6ff09e2.svg\" alt=\"x=L+\\frac d{2^n-1}(U-L)\" style=\"width:23.591ex;height:4.837ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Decode integer d</h5><div class=\"math-display\"><img src=\"math/5d98008e8ca61fcc.svg\" alt=\"d=1(4)+0(2)+1(1)=5\" style=\"width:25.941ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate interval width and maximum code</h5><div class=\"math-display\"><img src=\"math/a70472c6ec58ad8d.svg\" alt=\"U-L=5-(-2)=7\\qquad2^3-1=7\" style=\"width:36.445ex;height:2.564ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Map to the interval</h5><div class=\"math-display\"><img src=\"math/2d086e3a5cf5f29f.svg\" alt=\"x=-2+(5/7)(7)=3\" style=\"width:22.162ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=3.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Pehle bits se integer. Real range mapping explicitly diya ho tabhi next formula lagao.</p>"},{"id":"selection","title":"Roulette selection, cumulative intervals and alternatives","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>Before the three complete sums below, read the running-total example in <a href=\"#m2/read/core-maths/probability\">Percentages, probabilities and cumulative intervals</a>. 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Selection chooses parents, usually with replacement</h2><p><strong>Roulette-wheel selection</strong> 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><div class=\"math-display\"><img src=\"math/2cf98c22ed8b8331.svg\" alt=\"P_i=F_i/\\sum_jF_j\" style=\"width:14.858ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Fitness weights of successive individuals are [1, 2, 3, 4]. Select parents using random numbers [0.05, 0.25, 0.55, 0.9].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Fitness weights [1, 2, 3, 4]; draws [0.05, 0.25, 0.55, 0.9].</p><h4>To find</h4><p>Parent row number for each draw.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum fitness</h5><div class=\"math-display\"><img src=\"math/601b2d3d469972c2.svg\" alt=\"\\sum F=1+2+3+4=10\" style=\"width:26.457ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find probabilities and cumulative bounds</h5><table><thead><tr><th>Individual</th><th>Fitness</th><th>Probability</th><th>Cumulative</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>0.1</td><td>0.1</td></tr><tr><td>2</td><td>2</td><td>0.2</td><td>0.3</td></tr><tr><td>3</td><td>3</td><td>0.3</td><td>0.6</td></tr><tr><td>4</td><td>4</td><td>0.4</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Locate each draw</h5><table><thead><tr><th>Draw</th><th>Selected individual</th></tr></thead><tbody><tr><td>0.05</td><td>1</td></tr><tr><td>0.25</td><td>2</td></tr><tr><td>0.55</td><td>3</td></tr><tr><td>0.9</td><td>4</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Selected row numbers: [1, 2, 3, 4]. Repeated selection is permitted.</div></section><section class=\"example\"><p class=\"question\"><strong>Fitness weights of successive individuals are [4, 4, 2]. Select parents using random numbers [0.2, 0.6, 0.85].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Fitness weights [4, 4, 2]; draws [0.2, 0.6, 0.85].</p><h4>To find</h4><p>Parent row number for each draw.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum fitness</h5><div class=\"math-display\"><img src=\"math/a1ef5b129218331e.svg\" alt=\"\\sum F=4+4+2=10\" style=\"width:22.56ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find probabilities and cumulative bounds</h5><table><thead><tr><th>Individual</th><th>Fitness</th><th>Probability</th><th>Cumulative</th></tr></thead><tbody><tr><td>1</td><td>4</td><td>0.4</td><td>0.4</td></tr><tr><td>2</td><td>4</td><td>0.4</td><td>0.8</td></tr><tr><td>3</td><td>2</td><td>0.2</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Locate each draw</h5><table><thead><tr><th>Draw</th><th>Selected individual</th></tr></thead><tbody><tr><td>0.2</td><td>1</td></tr><tr><td>0.6</td><td>2</td></tr><tr><td>0.85</td><td>3</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Selected row numbers: [1, 2, 3]. Repeated selection is permitted.</div></section><section class=\"example\"><p class=\"question\"><strong>Fitness weights of successive individuals are [0, 3, 1]. Select parents using random numbers [0.2, 0.8].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Fitness weights [0, 3, 1]; draws [0.2, 0.8].</p><h4>To find</h4><p>Parent row number for each draw.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum fitness</h5><div class=\"math-display\"><img src=\"math/7f52b89af830db1b.svg\" alt=\"\\sum F=0+3+1=4\" style=\"width:21.429ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find probabilities and cumulative bounds</h5><table><thead><tr><th>Individual</th><th>Fitness</th><th>Probability</th><th>Cumulative</th></tr></thead><tbody><tr><td>1</td><td>0</td><td>0</td><td>0</td></tr><tr><td>2</td><td>3</td><td>0.75</td><td>0.75</td></tr><tr><td>3</td><td>1</td><td>0.25</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Locate each draw</h5><table><thead><tr><th>Draw</th><th>Selected individual</th></tr></thead><tbody><tr><td>0.2</td><td>2</td></tr><tr><td>0.8</td><td>3</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Selected row numbers: [2, 3]. Repeated selection is permitted.</div></section><h2>Other selection methods</h2><table><thead><tr><th>Method</th><th>Procedure</th><th>Why it is used</th></tr></thead><tbody><tr><td>Tournament</td><td>Sample a group and take its best candidate</td><td>Only objective comparisons are needed</td></tr><tr><td>Rank</td><td>Sort candidates; assign weights based on rank</td><td>Reduces sensitivity to a single huge raw fitness</td></tr><tr><td>Elitist survival</td><td>Preserve top individuals unchanged into the next population</td><td>Protects good solutions from destructive variation</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Probability nikalo → cumulative banao → random number ka interval dekho.</p>"},{"id":"operators","title":"Crossover and mutation: four complete worked variants","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Cutting means splitting the written string</h2><p>The <strong>prefix</strong> is the part before the cut; the <strong>suffix</strong> 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.</p><table><thead><tr><th>Operation</th><th>Parents / instruction</th><th>Construction</th><th>Children</th></tr></thead><tbody><tr><td>One-point crossover</td><td>10|11 and 01|00</td><td>First prefix + second tail; second prefix + first tail</td><td>1000 and 0111</td></tr><tr><td>Two-point crossover</td><td>1|01|10 and 0|10|01</td><td>Exchange only the middle blocks</td><td>11010 and 00101</td></tr><tr><td>Uniform crossover</td><td>A=1010, B=0101, mask=1100</td><td>Child 1 takes A where mask=1 and B where mask=0; child 2 reverses this</td><td>1001 and 0110</td></tr><tr><td>Mutation</td><td>1000; flip position 3 from left</td><td>The third bit is 0; replace it by 1; keep every other bit</td><td>1010</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Crossover combines; mutation changes</h2><p>In <strong>single-point crossover</strong>, 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.</p><section class=\"example\"><p class=\"question\"><strong>Cross parents 1011 and 0100 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 1011, 0100; cut after bit 2; mutation bit 4.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">10 | 11</span> and <span class=\"bits\">01 | 00</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">10 + 00 → 1000</span><br><span class=\"bits\">01 + 11 → 0111</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>1000</td><td>0</td><td>1</td><td>1001</td></tr><tr><td>0111</td><td>1</td><td>0</td><td>0110</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>1001</td><td>8 + 0 + 0 + 1</td><td>9</td></tr><tr><td>0110</td><td>0 + 4 + 2 + 0</td><td>6</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 1001 (9) and 0110 (6).</div></section><section class=\"example\"><p class=\"question\"><strong>Cross parents 0011 and 1100 after bit 1. Then flip bit 2 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 0011, 1100; cut after bit 1; mutation bit 2.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">0 | 011</span> and <span class=\"bits\">1 | 100</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">0 + 100 → 0100</span><br><span class=\"bits\">1 + 011 → 1011</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>0100</td><td>1</td><td>0</td><td>0000</td></tr><tr><td>1011</td><td>0</td><td>1</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>0000</td><td>0 + 0 + 0 + 0</td><td>0</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1</td><td>15</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 0000 (0) and 1111 (15).</div></section><section class=\"example\"><p class=\"question\"><strong>Cross parents 1110 and 0001 after bit 3. Then flip bit 1 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 1110, 0001; cut after bit 3; mutation bit 1.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">111 | 0</span> and <span class=\"bits\">000 | 1</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">111 + 1 → 1111</span><br><span class=\"bits\">000 + 0 → 0000</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>1111</td><td>1</td><td>0</td><td>0111</td></tr><tr><td>0000</td><td>0</td><td>1</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>0111</td><td>0 + 4 + 2 + 1</td><td>7</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0</td><td>8</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 0111 (7) and 1000 (8).</div></section><section class=\"example\"><p class=\"question\"><strong>Cross parents 1010 and 1010 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 1010, 1010; cut after bit 2; mutation bit 4.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">10 | 10</span> and <span class=\"bits\">10 | 10</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">10 + 10 → 1010</span><br><span class=\"bits\">10 + 10 → 1010</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>1010</td><td>0</td><td>1</td><td>1011</td></tr><tr><td>1010</td><td>0</td><td>1</td><td>1011</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>1011</td><td>8 + 0 + 2 + 1</td><td>11</td></tr><tr><td>1011</td><td>8 + 0 + 2 + 1</td><td>11</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 1011 (11) and 1011 (11).</div></section><p><strong>Two-point crossover</strong> exchanges the segment between two cuts. <strong>Uniform crossover</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Crossover = tail exchange. Mutation = specified bit flip. Flip ka matlab 1 bhi 0 banega.</p>"},{"id":"algorithm","title":"GA architecture, two-generation flow, constraints and theory","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Feasible</td><td>Obeys every stated constraint</td><td>x≤10: x=9 qualifies; x=12 does not</td></tr><tr><td>Penalty</td><td>A deduction for violating a constraint</td><td>For maximisation, subtract 100×excess</td></tr><tr><td>Elitism</td><td>Explicitly preserve a best old individual</td><td>Only apply if the question specifies it</td></tr><tr><td>Replacement</td><td>Choose what population the next generation uses</td><td>Our full-replacement examples use the new children</td></tr><tr><td>Stopping condition</td><td>A rule ending the repeated process</td><td>Stop after two complete generations</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<h2>A complete GA generation</h2><div class=\"flow\"><div class=\"node\">Encode + evaluate</div><span class=\"arrow\">→</span><div class=\"node\">Select parents</div><span class=\"arrow\">→</span><div class=\"node\">Crossover</div><span class=\"arrow\">→</span><div class=\"node\">Mutation</div><span class=\"arrow\">→</span><div class=\"node\">Evaluate children<small>replace and repeat</small></div></div>\r\n<p>A <strong>simple generational GA</strong> 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.</p>\r\n<h2>What “iteration 2” means here</h2><p>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.</p>\r\n<h2>Stopping conditions</h2><p>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.</p>\r\n<h2>Constraints</h2><p>A <strong>constraint</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Penalty coefficient 100; bound 10; candidates 9 and 12.</p><h4>To find</h4><p>Penalised fitness of both candidates.</p></div><h4>Formula and why it applies</h4><p>Only excess above the bound receives a penalty.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Feasible candidate 9</h5><div class=\"math-display\"><img src=\"math/a12fb07643a5aaa1.svg\" alt=\"\\max(0,9-10)=0\" style=\"width:18.416ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/deb272d3158b70b9.svg\" alt=\"F(9)=81-100(0)=81\" style=\"width:24.196ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Infeasible candidate 12</h5><div class=\"math-display\"><img src=\"math/c2860199dab61091.svg\" alt=\"\\max(0,12-10)=2\" style=\"width:19.547ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/decf48b28bc4a229.svg\" alt=\"F(12)=144-100(2)=-56\" style=\"width:28.218ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Compare</h5><p>For this maximisation fitness, 81 > −56, so x=9 is preferred. Raw objective alone would misleadingly favour 12.</p></div><div class=\"answer\"><strong>Final answer.</strong> F(9)=81; F(12)=−56.</div></section><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td>Derivative-free; supports many encodings</td><td>Many objective evaluations may be costly</td></tr><tr><td>Population explores several candidates</td><td>Premature convergence is possible</td></tr><tr><td>Crossover and mutation can create new candidates</td><td>Parameter and encoding choices affect results</td></tr><tr><td>Applicable to discontinuous or combinatorial searches</td><td>No guaranteed global optimum; variation can worsen fitness</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Do generation = do baar poora cycle. Sirf children banana aur decode karna do alag iterations nahi.</p>"},{"id":"two-generations","title":"Two generations with given selection, cut and mutation","html":"<!-- depth:retained-diagram:start -->\r\n<div class=\"concept-bridge\"><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_ga_generation.fa7bf86c05.svg\" width=\"700\" height=\"490\" alt=\"This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.</figcaption></figure></div>\r\n<!-- depth:retained-diagram:end -->\r\n<section class=\"example\"><p class=\"question\"><strong>Maximise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Current individual row numbers [3, 4, 4, 3]</td></tr><tr><td>2</td><td>Current individual row numbers [2, 3, 2, 3]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>0011</td><td>3 × 3 = 9</td></tr><tr><td>2</td><td>5</td><td>0101</td><td>5 × 5 = 25</td></tr><tr><td>3</td><td>10</td><td>1010</td><td>10 × 10 = 100</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>12 × 12 = 144</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: apply the supplied selection order</h5><p>The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>10</td><td>1010</td></tr><tr><td>2</td><td>4</td><td>12</td><td>1100</td></tr><tr><td>3</td><td>4</td><td>12</td><td>1100</td></tr><tr><td>4</td><td>3</td><td>10</td><td>1010</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>10 | 10</td><td>11 | 00</td><td>1000</td><td>1110</td></tr><tr><td>3 & 4</td><td>11 | 00</td><td>10 | 10</td><td>1110</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr><tr><td>2</td><td>1110</td><td>Flip bit 4</td><td>1111</td></tr><tr><td>3</td><td>1110</td><td>Flip bit 4</td><td>1111</td></tr><tr><td>4</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>9² = 81</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>9² = 81</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/ac14e9c27d115d0e.svg\" alt=\"\\overline f_{old}=\\frac{9+25+100+144}{4}=\\frac{278}{4}=69.5\" style=\"width:40.453ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b4cd0bde2e1de484.svg\" alt=\"\\overline f_{new}=\\frac{81+225+225+81}{4}=\\frac{612}{4}=153\" style=\"width:41.722ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 7. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>9</td><td>1001</td><td>9 × 9 = 81</td></tr><tr><td>2</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>3</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>4</td><td>9</td><td>1001</td><td>9 × 9 = 81</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Generation 2: apply the supplied selection order</h5><p>The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>2</td><td>3</td><td>15</td><td>1111</td></tr><tr><td>3</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>4</td><td>3</td><td>15</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr><tr><td>3 & 4</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>2</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>3</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>4</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr></tbody></table></div><div class=\"step\"><h5>Step 11. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/1526400ff09c5372.svg\" alt=\"\\overline f_{old}=\\frac{81+225+225+81}{4}=\\frac{612}{4}=153\" style=\"width:40.956ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/83698ff516912ccd.svg\" alt=\"\\overline f_{new}=\\frac{196+196+196+196}{4}=\\frac{784}{4}=196\" style=\"width:43.984ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [14, 14, 14, 14]. Best final objective = 196 at x = [14].</div></section>"},{"id":"roulette-generations","title":"Two generations including roulette selection","html":"<section class=\"example\"><p class=\"question\"><strong>Maximise <span class=\"math-inline\"><img src=\"math/163a21622d906b2b.svg\" alt=\"f(x)=x(15-x)+1\" style=\"width:20.589ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Random draws [0.1, 0.4, 0.65, 0.9]</td></tr><tr><td>2</td><td>Random draws [0.2, 0.4, 0.6, 0.95]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>0010</td><td>2 × (15 − 2) + 1 = 27</td></tr><tr><td>2</td><td>5</td><td>0101</td><td>5 × (15 − 5) + 1 = 51</td></tr><tr><td>3</td><td>9</td><td>1001</td><td>9 × (15 − 9) + 1 = 55</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>12 × (15 − 12) + 1 = 37</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: calculate roulette intervals</h5><p>Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.</p><div class=\"math-display\"><img src=\"math/3c9eb5a0f63c3e40.svg\" alt=\"\\sum F=27+51+55+37\\approx170\" style=\"width:32.113ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>27 ÷ 170 ≈ 0.158823529</td><td>0 + 0.158823529 ≈ 0.158823529</td></tr><tr><td>2</td><td>51 ÷ 170 ≈ 0.3</td><td>0.158823529 + 0.3 ≈ 0.458823529</td></tr><tr><td>3</td><td>55 ÷ 170 ≈ 0.323529412</td><td>0.458823529 + 0.323529412 ≈ 0.782352941</td></tr><tr><td>4</td><td>37 ÷ 170 ≈ 0.217647059</td><td>0.782352941 + 0.217647059 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.1</td><td>0 ≤ 0.1 < 0.158823529</td><td>1</td><td>2</td></tr><tr><td>0.4</td><td>0.158823529 ≤ 0.4 < 0.458823529</td><td>2</td><td>5</td></tr><tr><td>0.65</td><td>0.458823529 ≤ 0.65 < 0.782352941</td><td>3</td><td>9</td></tr><tr><td>0.9</td><td>0.782352941 ≤ 0.9 < 1</td><td>4</td><td>12</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 4. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>00 | 10</td><td>01 | 01</td><td>0001</td><td>0110</td></tr><tr><td>3 & 4</td><td>10 | 01</td><td>11 | 00</td><td>1000</td><td>1101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>0001</td><td>No mutation</td><td>0001</td></tr><tr><td>2</td><td>0110</td><td>Flip bit 4</td><td>0111</td></tr><tr><td>3</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>4</td><td>1101</td><td>Flip bit 4</td><td>1100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>0001</td><td>0 + 0 + 0 + 1 = 1</td><td>1(15−1)+1 = 15</td></tr><tr><td>0111</td><td>0 + 4 + 2 + 1 = 7</td><td>7(15−7)+1 = 57</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8(15−8)+1 = 57</td></tr><tr><td>1100</td><td>8 + 4 + 0 + 0 = 12</td><td>12(15−12)+1 = 37</td></tr></tbody></table></div><div class=\"step\"><h5>Step 7. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/22945ccb0391cac7.svg\" alt=\"\\overline f_{old}=\\frac{27+51+55+37}{4}=\\frac{170}{4}=42.5\" style=\"width:39.322ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4832c61f6dee4ab2.svg\" alt=\"\\overline f_{new}=\\frac{15+57+57+37}{4}=\\frac{166}{4}=41.5\" style=\"width:40.088ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 8. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>0001</td><td>1 × (15 − 1) + 1 = 15</td></tr><tr><td>2</td><td>7</td><td>0111</td><td>7 × (15 − 7) + 1 = 57</td></tr><tr><td>3</td><td>8</td><td>1000</td><td>8 × (15 − 8) + 1 = 57</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>12 × (15 − 12) + 1 = 37</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: calculate roulette intervals</h5><p>Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.</p><div class=\"math-display\"><img src=\"math/74f6736e95b5ff63.svg\" alt=\"\\sum F=15+57+57+37\\approx166\" style=\"width:32.113ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>15 ÷ 166 ≈ 0.090361446</td><td>0 + 0.090361446 ≈ 0.090361446</td></tr><tr><td>2</td><td>57 ÷ 166 ≈ 0.343373494</td><td>0.090361446 + 0.343373494 ≈ 0.43373494</td></tr><tr><td>3</td><td>57 ÷ 166 ≈ 0.343373494</td><td>0.43373494 + 0.343373494 ≈ 0.777108434</td></tr><tr><td>4</td><td>37 ÷ 166 ≈ 0.222891566</td><td>0.777108434 + 0.222891566 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.2</td><td>0.090361446 ≤ 0.2 < 0.43373494</td><td>2</td><td>7</td></tr><tr><td>0.4</td><td>0.090361446 ≤ 0.4 < 0.43373494</td><td>2</td><td>7</td></tr><tr><td>0.6</td><td>0.43373494 ≤ 0.6 < 0.777108434</td><td>3</td><td>8</td></tr><tr><td>0.95</td><td>0.777108434 ≤ 0.95 < 1</td><td>4</td><td>12</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 11. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>01 | 11</td><td>01 | 11</td><td>0111</td><td>0111</td></tr><tr><td>3 & 4</td><td>10 | 00</td><td>11 | 00</td><td>1000</td><td>1100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>0111</td><td>No mutation</td><td>0111</td></tr><tr><td>2</td><td>0111</td><td>Flip bit 4</td><td>0110</td></tr><tr><td>3</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>4</td><td>1100</td><td>Flip bit 4</td><td>1101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 13. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>0111</td><td>0 + 4 + 2 + 1 = 7</td><td>7(15−7)+1 = 57</td></tr><tr><td>0110</td><td>0 + 4 + 2 + 0 = 6</td><td>6(15−6)+1 = 55</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8(15−8)+1 = 57</td></tr><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13(15−13)+1 = 27</td></tr></tbody></table></div><div class=\"step\"><h5>Step 14. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/9b9333d937330aaa.svg\" alt=\"\\overline f_{old}=\\frac{15+57+57+37}{4}=\\frac{166}{4}=41.5\" style=\"width:39.322ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5b337e1a852cf7fa.svg\" alt=\"\\overline f_{new}=\\frac{57+55+57+27}{4}=\\frac{196}{4}=49\" style=\"width:38.328ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [7, 6, 8, 13]. Best final objective = 57 at x = [7, 8].</div></section>"},{"id":"minimisation","title":"GA minimisation: transform cost before roulette selection","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/caf5baf4d59a93e5.svg\" alt=\"f(x)=(x-7)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Random draws [0.1, 0.4, 0.65, 0.9]</td></tr><tr><td>2</td><td>Random draws [0.2, 0.4, 0.6, 0.95]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>0010</td><td>(2 − 7)² = 25</td></tr><tr><td>2</td><td>4</td><td>0100</td><td>(4 − 7)² = 9</td></tr><tr><td>3</td><td>8</td><td>1000</td><td>(8 − 7)² = 1</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>(12 − 7)² = 25</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: calculate roulette intervals</h5><p>Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.</p><table><thead><tr><th>Individual</th><th>Cost</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>1</td><td>25</td><td>1 / (1 + 25) = 1 / 26 ≈ 0.038461538</td></tr><tr><td>2</td><td>9</td><td>1 / (1 + 9) = 1 / 10 ≈ 0.1</td></tr><tr><td>3</td><td>1</td><td>1 / (1 + 1) = 1 / 2 ≈ 0.5</td></tr><tr><td>4</td><td>25</td><td>1 / (1 + 25) = 1 / 26 ≈ 0.038461538</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/3a777f87cb72ab3e.svg\" alt=\"\\sum F=0.038461538+0.1+0.5+0.038461538\\approx0.676923077\" style=\"width:61.276ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>0.038461538 ÷ 0.676923077 ≈ 0.056818182</td><td>0 + 0.056818182 ≈ 0.056818182</td></tr><tr><td>2</td><td>0.1 ÷ 0.676923077 ≈ 0.147727273</td><td>0.056818182 + 0.147727273 ≈ 0.204545455</td></tr><tr><td>3</td><td>0.5 ÷ 0.676923077 ≈ 0.738636364</td><td>0.204545455 + 0.738636364 ≈ 0.943181818</td></tr><tr><td>4</td><td>0.038461538 ÷ 0.676923077 ≈ 0.056818182</td><td>0.943181818 + 0.056818182 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.1</td><td>0.056818182 ≤ 0.1 < 0.204545455</td><td>2</td><td>4</td></tr><tr><td>0.4</td><td>0.204545455 ≤ 0.4 < 0.943181818</td><td>3</td><td>8</td></tr><tr><td>0.65</td><td>0.204545455 ≤ 0.65 < 0.943181818</td><td>3</td><td>8</td></tr><tr><td>0.9</td><td>0.204545455 ≤ 0.9 < 0.943181818</td><td>3</td><td>8</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 4. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>01 | 00</td><td>10 | 00</td><td>0100</td><td>1000</td></tr><tr><td>3 & 4</td><td>10 | 00</td><td>10 | 00</td><td>1000</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>0100</td><td>No mutation</td><td>0100</td></tr><tr><td>2</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr><tr><td>3</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>4</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>0100</td><td>0 + 4 + 0 + 0 = 4</td><td>(4−7)² = 9</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>(8−7)² = 1</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 7. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/a688edfd604798b3.svg\" alt=\"\\overline f_{old}=\\frac{25+9+1+25}{4}=\\frac{60}{4}=15\" style=\"width:34.168ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f966da034fd08628.svg\" alt=\"\\overline f_{new}=\\frac{9+4+1+4}{4}=\\frac{18}{4}=4.5\" style=\"width:33.301ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 8. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>4</td><td>0100</td><td>(4 − 7)² = 9</td></tr><tr><td>2</td><td>9</td><td>1001</td><td>(9 − 7)² = 4</td></tr><tr><td>3</td><td>8</td><td>1000</td><td>(8 − 7)² = 1</td></tr><tr><td>4</td><td>9</td><td>1001</td><td>(9 − 7)² = 4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: calculate roulette intervals</h5><p>Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.</p><table><thead><tr><th>Individual</th><th>Cost</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>1</td><td>9</td><td>1 / (1 + 9) = 1 / 10 ≈ 0.1</td></tr><tr><td>2</td><td>4</td><td>1 / (1 + 4) = 1 / 5 ≈ 0.2</td></tr><tr><td>3</td><td>1</td><td>1 / (1 + 1) = 1 / 2 ≈ 0.5</td></tr><tr><td>4</td><td>4</td><td>1 / (1 + 4) = 1 / 5 ≈ 0.2</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/8709c94ae272ba4a.svg\" alt=\"\\sum F=0.1+0.2+0.5+0.2\\approx1\" style=\"width:32.367ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>0.1 ÷ 1 ≈ 0.1</td><td>0 + 0.1 ≈ 0.1</td></tr><tr><td>2</td><td>0.2 ÷ 1 ≈ 0.2</td><td>0.1 + 0.2 ≈ 0.3</td></tr><tr><td>3</td><td>0.5 ÷ 1 ≈ 0.5</td><td>0.3 + 0.5 ≈ 0.8</td></tr><tr><td>4</td><td>0.2 ÷ 1 ≈ 0.2</td><td>0.8 + 0.2 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.2</td><td>0.1 ≤ 0.2 < 0.3</td><td>2</td><td>9</td></tr><tr><td>0.4</td><td>0.3 ≤ 0.4 < 0.8</td><td>3</td><td>8</td></tr><tr><td>0.6</td><td>0.3 ≤ 0.6 < 0.8</td><td>3</td><td>8</td></tr><tr><td>0.95</td><td>0.8 ≤ 0.95 < 1</td><td>4</td><td>9</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 11. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>10 | 01</td><td>10 | 00</td><td>1000</td><td>1001</td></tr><tr><td>3 & 4</td><td>10 | 00</td><td>10 | 01</td><td>1001</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>2</td><td>1001</td><td>Flip bit 4</td><td>1000</td></tr><tr><td>3</td><td>1001</td><td>No mutation</td><td>1001</td></tr><tr><td>4</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 13. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>(8−7)² = 1</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>(8−7)² = 1</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 14. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/b6ef25b43ff486a0.svg\" alt=\"\\overline f_{old}=\\frac{9+4+1+4}{4}=\\frac{18}{4}=4.5\" style=\"width:32.535ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/818ac9c6d2d2746f.svg\" alt=\"\\overline f_{new}=\\frac{1+1+4+4}{4}=\\frac{10}{4}=2.5\" style=\"width:33.301ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [8, 8, 9, 9]. Best final objective = 1 at x = [8].</div></section>"}]},{"id":"pso-core","title":"4. Particle swarm optimization","unit":"Unit 3 · PSO","scope":"First understand position, velocity and memory; then solve complete two-iteration minimisation examples.","sections":[{"id":"meaning","title":"Swarm intelligence, particles, velocity, pbest and gbest","html":"<h2>Swarm intelligence</h2><p><strong>Swarm intelligence</strong> 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.</p>\r\n<p><strong>Particle swarm optimization (PSO)</strong> 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.</p>\r\n<h2>Translate every PSO word into a concrete object</h2><table><thead><tr><th>Term</th><th>Meaning</th><th>Example</th></tr></thead><tbody><tr><td>Particle</td><td>One candidate solution</td><td>Particle A</td></tr><tr><td>Position x</td><td>The candidate’s coordinates</td><td>xA = 3</td></tr><tr><td>Objective f(x)</td><td>The problem’s score for that candidate</td><td>f(3) = 3² = 9</td></tr><tr><td>Velocity v</td><td>Proposed change of position</td><td>vA = −1 means move left by 1</td></tr><tr><td>pbest</td><td>Best position that this particle has visited</td><td>A once visited x=1 with score 1</td></tr><tr><td>gbest</td><td>Best position found by any particle</td><td>Among all personal bests, x=0.5 scores 0.25</td></tr></tbody></table>\r\n<!-- depth:retained-diagram:start -->\r\n<div class=\"concept-bridge\"><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_pso_memory.fcc9783a95.svg\" width=\"700\" height=\"335\" alt=\"A best memory changes only when the new score improves.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>A best memory changes only when the new score improves.</figcaption></figure></div>\r\n<!-- depth:retained-diagram:end -->\r\n<h2>Current position is not necessarily personal best</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>A particle visits x=3, x=1, x=2 in that order while minimising f(x)=x². Find pbest after each visit.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Positions in chronological order: 3 → 1 → 2.</p><h4>To find</h4><p>The best-so-far position and score.</p></div><h4>Formula and why it applies</h4><p>Keep the location with the lowest objective encountered so far.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First visit</h5><div class=\"math-display\"><img src=\"math/7f1b6387a96fa5e5.svg\" alt=\"f(3)=9\" style=\"width:8.284ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>No history: pbest=3, best score=9.</p></div><div class=\"step\"><h5>Step 2. Second visit</h5><div class=\"math-display\"><img src=\"math/c0e5424c98d7c06b.svg\" alt=\"f(1)=1&lt;9\" style=\"width:12.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Replace pbest by 1.</p></div><div class=\"step\"><h5>Step 3. Third visit</h5><div class=\"math-display\"><img src=\"math/e8b8ef3456701e2b.svg\" alt=\"f(2)=4&gt;1\" style=\"width:12.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Keep pbest=1 even though the current position is 2.</p></div><div class=\"answer\"><strong>Final answer.</strong> Final current position=2; pbest=1; personal-best score=1.</div></section><section class=\"example\"><p class=\"question\"><strong>Define swarm intelligence and briefly explain one nature-inspired algorithm.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><p class=\"memory\"><strong>Yaad rakho:</strong> Position abhi kahan ho; pbest apna best past; gbest sabka best past.</p>"},{"id":"equation","title":"Read the PSO equation and work three individual updates","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>First read the update in words</h2><p><strong>New velocity = retained old velocity + pull toward personal best + pull toward the group best.</strong> After finding that velocity, add it to the old position. You are calculating a movement, then applying it.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_pso.88e9c2a672.svg\" width=\"720\" height=\"230\" alt=\"A negative difference pulls toward a best position on the left.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>A negative difference pulls toward a best position on the left.</figcaption></figure><p>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.</p><p>In v<sub>i,j</sub><sup>t</sup>, 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>The velocity equation is three contributions added together</h2><div class=\"math-display\"><img src=\"math/dac83013fb52dd1c.svg\" alt=\"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})\" style=\"width:53.007ex;height:2.988ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/60fe3c0d98c51b4c.svg\" alt=\"x_{i,j}^{t+1}=x_{i,j}^{t}+v_{i,j}^{t+1}\" style=\"width:16.932ex;height:2.988ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>i</td><td>Which particle</td></tr><tr><td>j</td><td>Which coordinate of that particle</td></tr><tr><td>t / t+1</td><td>Before / after this iteration; these are labels, not powers</td></tr><tr><td>w</td><td>Inertia weight: how much old velocity is kept</td></tr><tr><td>c₁r₁</td><td>Combined strength of the pull to personal best</td></tr><tr><td>c₂r₂</td><td>Combined strength of the pull to global best</td></tr><tr><td>r₁,r₂</td><td>Random factors, normally in [0,1]; use the values supplied in an exam</td></tr></tbody></table><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=4, v=0, pbest=4, gbest=2; w=.5; c₁r₁=.5; c₂r₂=.5.</p><h4>To find</h4><p>New velocity followed by new position.</p></div><h4>Formula and why it applies</h4><p>Use the three-term velocity equation, then add the new velocity to x.</p><div class=\"math-display\"><img src=\"math/a86502ce620dafcc.svg\" alt=\"v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)\" style=\"width:44.119ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inertia</h5><div class=\"math-display\"><img src=\"math/e71e2d0a61e9d301.svg\" alt=\"0.5\\times0=0\" style=\"width:10.937ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Personal pull</h5><div class=\"math-display\"><img src=\"math/a6908257a641f5f9.svg\" alt=\"0.5(4-(4))=0\" style=\"width:15.588ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Social pull</h5><div class=\"math-display\"><img src=\"math/572c7c6589c1b745.svg\" alt=\"0.5(2-(4))=-1\" style=\"width:17.348ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. New velocity</h5><div class=\"math-display\"><img src=\"math/96abcf8e044d8408.svg\" alt=\"v_{new}=0+0+(-1)=-1\" style=\"width:25.507ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. New position</h5><div class=\"math-display\"><img src=\"math/7ce7c2323916220b.svg\" alt=\"x_{new}=4+(-1)=3\" style=\"width:20.047ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> vnew=-1; xnew=3.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=4, v=-2, pbest=3, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.</p><h4>To find</h4><p>New velocity followed by new position.</p></div><h4>Formula and why it applies</h4><p>Use the three-term velocity equation, then add the new velocity to x.</p><div class=\"math-display\"><img src=\"math/a86502ce620dafcc.svg\" alt=\"v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)\" style=\"width:44.119ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inertia</h5><div class=\"math-display\"><img src=\"math/493f21e1dcf9ae65.svg\" alt=\"0.5\\times(-2)=-1\" style=\"width:16.217ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Personal pull</h5><div class=\"math-display\"><img src=\"math/4914c1155f2d3a69.svg\" alt=\"0.5(3-(4))=-0.5\" style=\"width:19.109ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Social pull</h5><div class=\"math-display\"><img src=\"math/b774cba7be997b80.svg\" alt=\"0.5(1-(4))=-1.5\" style=\"width:19.109ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. New velocity</h5><div class=\"math-display\"><img src=\"math/fb1a87666bd393ac.svg\" alt=\"v_{new}=(-1)+(-0.5)+(-1.5)=-3\" style=\"width:36.068ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. New position</h5><div class=\"math-display\"><img src=\"math/87db5516b0eef4a5.svg\" alt=\"x_{new}=4+(-3)=1\" style=\"width:20.047ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> vnew=-3; xnew=1.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=-2, v=1, pbest=-1, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.</p><h4>To find</h4><p>New velocity followed by new position.</p></div><h4>Formula and why it applies</h4><p>Use the three-term velocity equation, then add the new velocity to x.</p><div class=\"math-display\"><img src=\"math/a86502ce620dafcc.svg\" alt=\"v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)\" style=\"width:44.119ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inertia</h5><div class=\"math-display\"><img src=\"math/12ea92d29476784c.svg\" alt=\"0.5\\times1=0.5\" style=\"width:12.697ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Personal pull</h5><div class=\"math-display\"><img src=\"math/61d7bcc89fa9fd8a.svg\" alt=\"0.5(-1-(-2))=0.5\" style=\"width:20.869ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Social pull</h5><div class=\"math-display\"><img src=\"math/85cc697d8abbcf2c.svg\" alt=\"0.5(1-(-2))=1.5\" style=\"width:19.109ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. New velocity</h5><div class=\"math-display\"><img src=\"math/bc8dd34ee10c4d4d.svg\" alt=\"v_{new}=0.5+0.5+1.5=2.5\" style=\"width:27.267ex;height:1.864ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. New position</h5><div class=\"math-display\"><img src=\"math/264c82a55bf4620a.svg\" alt=\"x_{new}=(-2)+2.5=0.5\" style=\"width:23.567ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> vnew=2.5; xnew=0.5.</div></section><p><strong>First-iteration shortcut:</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Old speed ka hissa + apne best ki pull + group best ki pull; phir new speed ko position mein add.</p>"},{"id":"two-particles","title":"Two particles, two iterations: start with the simplest minimisation","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(-2)</td><td>(0)</td></tr><tr><td>B</td><td>(4)</td><td>(0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/73d4f3be5484ad52.svg\" alt=\"f(-2)=(-2)^2=4=4\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/312433d364d9cfab.svg\" alt=\"f(4)=4^2=16=16\" style=\"width:19.831ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/130e21267aeccc61.svg\" alt=\"gbest^0=(-2)\" style=\"width:13.638ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 4. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (-2). pbest values are A: (-2), B: (4).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/1d782a69e1d0fcb8.svg\" alt=\"d_p=-2-(-2)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6f82367c11e33631.svg\" alt=\"d_g=-2-(-2)=0\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/4e58cfc2f623e47e.svg\" alt=\"x^{(1)}=(-2)+0=-2\" style=\"width:21.001ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/ad073051db57b851.svg\" alt=\"d_p=4-(4)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/eb7d3c2c066600f2.svg\" alt=\"d_g=-2-(4)=-6\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4dd7f304ffa4f233.svg\" alt=\"S=0.5\\times(-6)=-3\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/c239eeeeeca7f890.svg\" alt=\"v^{(1)}=0+0+(-3)=-3\" style=\"width:24.701ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/d71458dcf56b7a77.svg\" alt=\"x^{(1)}=4+(-3)=1\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/73d4f3be5484ad52.svg\" alt=\"f(-2)=(-2)^2=4=4\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/872b6624767f4385.svg\" alt=\"f(1)=1^2=1=1\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>4</td><td>4</td><td>Keep old: tie</td><td>(-2)</td></tr><tr><td>B</td><td>16</td><td>1</td><td>Replace: new score is lower</td><td>(1)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1)</strong>, with objective <strong>1</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(-2)</td><td>(0)</td><td>(-2)</td></tr><tr><td>B</td><td>(1)</td><td>(-3)</td><td>(1)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (-2), B: (1).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/1d782a69e1d0fcb8.svg\" alt=\"d_p=-2-(-2)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/9102a4aae4f9ab55.svg\" alt=\"d_g=1-(-2)=3\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9efd684a8627ac87.svg\" alt=\"S=0.5\\times(3)=1.5\" style=\"width:18.933ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/25e29c2b2380aded.svg\" alt=\"v^{(2)}=0+0+1.5=1.5\" style=\"width:22.94ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/0af67fb865c5f5c7.svg\" alt=\"x^{(2)}=(-2)+1.5=-0.5\" style=\"width:24.521ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/02f316319733ea90.svg\" alt=\"I=0.5\\times(-3)=-1.5\" style=\"width:22.135ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/4e2008e440fe556c.svg\" alt=\"v^{(2)}=(-1.5)+0+0=-1.5\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/700c5bb73aa33b26.svg\" alt=\"x^{(2)}=1+(-1.5)=-0.5\" style=\"width:24.521ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/6c453bb065df6e4a.svg\" alt=\"f(-0.5)=(-0.5)^2=0.25=0.25\" style=\"width:32.152ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/6c453bb065df6e4a.svg\" alt=\"f(-0.5)=(-0.5)^2=0.25=0.25\" style=\"width:32.152ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>4</td><td>0.25</td><td>Replace: new score is lower</td><td>(-0.5)</td></tr><tr><td>B</td><td>1</td><td>0.25</td><td>Replace: new score is lower</td><td>(-0.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(-0.5)</strong>, with objective <strong>0.25</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(-0.5)</td><td>(1.5)</td><td>(-0.5)</td></tr><tr><td>B</td><td>(-0.5)</td><td>(-1.5)</td><td>(-0.5)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"memory-matters","title":"A worse move: pbest stays in the past","html":"<p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(1)</td><td>(4)</td></tr><tr><td>B</td><td>(3)</td><td>(-1)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/872b6624767f4385.svg\" alt=\"f(1)=1^2=1=1\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/519522f49346438a.svg\" alt=\"f(3)=3^2=9=9\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/d6d8eee6e10c4922.svg\" alt=\"gbest^0=(1)\" style=\"width:11.878ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 1. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (1), B: (3).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/e009c778bab94586.svg\" alt=\"I=0.5\\times4=2\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/25c7782eb44a678a.svg\" alt=\"v^{(1)}=2+0+0=2\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/8e886f0f9174fead.svg\" alt=\"x^{(1)}=1+2=3\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/dc7ed342b0db88bc.svg\" alt=\"I=0.5\\times(-1)=-0.5\" style=\"width:22.135ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/114e8d23bb26d062.svg\" alt=\"d_p=3-(3)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/57f4bea8a1c6b79f.svg\" alt=\"d_g=1-(3)=-2\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/96dd8f64f9d9a341.svg\" alt=\"S=0.5\\times(-2)=-1\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/e15db2dfd9b255cf.svg\" alt=\"v^{(1)}=(-0.5)+0+(-1)=-1.5\" style=\"width:31.741ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/76c197431121b5e1.svg\" alt=\"x^{(1)}=3+(-1.5)=1.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/519522f49346438a.svg\" alt=\"f(3)=3^2=9=9\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/b61e97d213b18164.svg\" alt=\"f(1.5)=1.5^2=2.25=2.25\" style=\"width:26.872ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>9</td><td>Keep old: new score is worse</td><td>(1)</td></tr><tr><td>B</td><td>9</td><td>2.25</td><td>Replace: new score is lower</td><td>(1.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1)</strong>, with objective <strong>1</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(3)</td><td>(2)</td><td>(1)</td></tr><tr><td>B</td><td>(1.5)</td><td>(-1.5)</td><td>(1.5)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (1), B: (1.5).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/4d6486404a7509ba.svg\" alt=\"I=0.5\\times2=1\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e56ef95c25fb8bde.svg\" alt=\"d_p=1-(3)=-2\" style=\"width:17.883ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a08a6d09414479ce.svg\" alt=\"C=0.5\\times(-2)=-1\" style=\"width:20.954ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/57f4bea8a1c6b79f.svg\" alt=\"d_g=1-(3)=-2\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/96dd8f64f9d9a341.svg\" alt=\"S=0.5\\times(-2)=-1\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/a51eec1438d949c1.svg\" alt=\"v^{(2)}=1+(-1)+(-1)=-1\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/60104aa04f06aad8.svg\" alt=\"x^{(2)}=3+(-1)=2\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/16e3f0369a50c03f.svg\" alt=\"I=0.5\\times(-1.5)=-0.75\" style=\"width:25.026ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/dcb7c97c6295715d.svg\" alt=\"d_p=1.5-(1.5)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2e6ff91ff778f21f.svg\" alt=\"d_g=1-(1.5)=-0.5\" style=\"width:21.362ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/418a15cd3fa3bbcc.svg\" alt=\"S=0.5\\times(-0.5)=-0.25\" style=\"width:25.345ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/c528696fa4ba4081.svg\" alt=\"v^{(2)}=(-0.75)+0+(-0.25)=-1\" style=\"width:34.004ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/905c77866baf10ae.svg\" alt=\"x^{(2)}=1.5+(-1)=0.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/4c640081b99e1be6.svg\" alt=\"f(0.5)=0.5^2=0.25=0.25\" style=\"width:26.872ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>4</td><td>Keep old: new score is worse</td><td>(1)</td></tr><tr><td>B</td><td>2.25</td><td>0.25</td><td>Replace: new score is lower</td><td>(0.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(0.5)</strong>, with objective <strong>0.25</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(2)</td><td>(-1)</td><td>(1)</td></tr><tr><td>B</td><td>(0.5)</td><td>(-1)</td><td>(0.5)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Naya result kharab ho toh position toh badlegi, pbest nahi.</p>"},{"id":"two-coordinates","title":"Two-dimensional PSO: keep the coordinates separate","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/a02144dad2ff9c8a.svg\" alt=\"f(x)=x_1^2+x_2^2\" style=\"width:14.645ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(1, 1)</td><td>(0, 0)</td></tr><tr><td>B</td><td>(3, 2)</td><td>(0, 0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/952bb71a534d7b48.svg\" alt=\"f(3, 2)=3^2+2^2=9+4=13\" style=\"width:29.618ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/bae2559b2265b2a0.svg\" alt=\"gbest^0=(1, 1)\" style=\"width:14.015ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 2. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (3, 2).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/bc4c5112ff057d33.svg\" alt=\"x^{(1)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/bc4c5112ff057d33.svg\" alt=\"x^{(1)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/114e8d23bb26d062.svg\" alt=\"d_p=3-(3)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/57f4bea8a1c6b79f.svg\" alt=\"d_g=1-(3)=-2\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/96dd8f64f9d9a341.svg\" alt=\"S=0.5\\times(-2)=-1\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/000e26bf52e8a50e.svg\" alt=\"v^{(1)}=0+0+(-1)=-1\" style=\"width:24.701ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/a890dd5de2855674.svg\" alt=\"x^{(1)}=3+(-1)=2\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e7f9deeb68816f5a.svg\" alt=\"d_p=2-(2)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fe1a995f4b4afef.svg\" alt=\"d_g=1-(2)=-1\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38f7adbc6f0de36b.svg\" alt=\"S=0.5\\times(-1)=-0.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/a489ee8326d49a33.svg\" alt=\"v^{(1)}=0+0+(-0.5)=-0.5\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/51c2ec0b6a29b186.svg\" alt=\"x^{(1)}=2+(-0.5)=1.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/d342f4df799385a1.svg\" alt=\"f(2, 1.5)=2^2+1.5^2=4+2.25=6.25\" style=\"width:37.79ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>2</td><td>2</td><td>Keep old: tie</td><td>(1, 1)</td></tr><tr><td>B</td><td>13</td><td>6.25</td><td>Replace: new score is lower</td><td>(2, 1.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1, 1)</strong>, with objective <strong>2</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(1, 1)</td><td>(0, 0)</td><td>(1, 1)</td></tr><tr><td>B</td><td>(2, 1.5)</td><td>(-1, -0.5)</td><td>(2, 1.5)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (2, 1.5).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8ba6a1d6c9203afb.svg\" alt=\"v^{(2)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/a7841f9dac4f92c7.svg\" alt=\"x^{(2)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8ba6a1d6c9203afb.svg\" alt=\"v^{(2)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/a7841f9dac4f92c7.svg\" alt=\"x^{(2)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/dc7ed342b0db88bc.svg\" alt=\"I=0.5\\times(-1)=-0.5\" style=\"width:22.135ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e7f9deeb68816f5a.svg\" alt=\"d_p=2-(2)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fe1a995f4b4afef.svg\" alt=\"d_g=1-(2)=-1\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38f7adbc6f0de36b.svg\" alt=\"S=0.5\\times(-1)=-0.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/31b640bb301f8dce.svg\" alt=\"v^{(2)}=(-0.5)+0+(-0.5)=-1\" style=\"width:31.741ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/144d4f69ce96cfe2.svg\" alt=\"x^{(2)}=2+(-1)=1\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/84dfd42953d2811a.svg\" alt=\"I=0.5\\times(-0.5)=-0.25\" style=\"width:25.026ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/dcb7c97c6295715d.svg\" alt=\"d_p=1.5-(1.5)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2e6ff91ff778f21f.svg\" alt=\"d_g=1-(1.5)=-0.5\" style=\"width:21.362ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/418a15cd3fa3bbcc.svg\" alt=\"S=0.5\\times(-0.5)=-0.25\" style=\"width:25.345ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8789b37bca837a83.svg\" alt=\"v^{(2)}=(-0.25)+0+(-0.25)=-0.5\" style=\"width:35.764ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/b71d05464709fcf3.svg\" alt=\"x^{(2)}=1.5+(-0.5)=1\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>2</td><td>2</td><td>Keep old: tie</td><td>(1, 1)</td></tr><tr><td>B</td><td>6.25</td><td>2</td><td>Replace: new score is lower</td><td>(1, 1)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1, 1)</strong>, with objective <strong>2</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(1, 1)</td><td>(0, 0)</td><td>(1, 1)</td></tr><tr><td>B</td><td>(1, 1)</td><td>(-1, -0.5)</td><td>(1, 1)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"class-three-particles","title":"Class PSO photograph: all three particles through iteration 2","html":"<p>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.</p><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/ef9d55cf7c043920.svg\" alt=\"f(x)=x_1^2+x_2^2-x_1x_2\" style=\"width:21.974ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using 3 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[10 marks · Class data; two-iteration minimisation extension]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(3.14, 7.21)</td><td>(0.1, 0.3)</td></tr><tr><td>B</td><td>(4.15, 7.31)</td><td>(0.5, 0.1)</td></tr><tr><td>C</td><td>(6.17, 8.27)</td><td>(0.2, 0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/bf321f61ed66837c.svg\" alt=\"f(3.14, 7.21)=3.14^2+7.21^2-(3.14)(7.21)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d54138730c346bbf.svg\" alt=\"=9.8596+51.9841-22.6394=39.2043\" style=\"width:39.471ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/1980ac03eb9e462c.svg\" alt=\"f(4.15, 7.31)=4.15^2+7.31^2-(4.15)(7.31)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ba408f391fd916c4.svg\" alt=\"=17.2225+53.4361-30.3365=40.3221\" style=\"width:40.602ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle C</strong></p><div class=\"math-display\"><img src=\"math/ac0fc4a2897f8794.svg\" alt=\"f(6.17, 8.27)=6.17^2+8.27^2-(6.17)(8.27)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/558e7a3b9a40d34e.svg\" alt=\"=38.0689+68.3929-51.0259=55.4359\" style=\"width:40.602ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/567a650862d29da5.svg\" alt=\"gbest^0=(3.14, 7.21)\" style=\"width:19.798ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 39.2043. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>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).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/4f87680527f659f2.svg\" alt=\"I=0.5\\times0.1=0.05\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/d3ab4c94a5f284d2.svg\" alt=\"d_p=3.14-(3.14)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6212c336dbecc343.svg\" alt=\"d_g=3.14-(3.14)=0\" style=\"width:21.864ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/16804d70bddc0ccc.svg\" alt=\"S=0.12\\times(0)=0\" style=\"width:18.304ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/6950d20a25859fe4.svg\" alt=\"v^{(1)}=0.05+0+0=0.05\" style=\"width:25.203ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/de8ab0140b454ff9.svg\" alt=\"x^{(1)}=3.14+0.05=3.19\" style=\"width:24.394ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/eb88185c1e62a59c.svg\" alt=\"I=0.5\\times0.3=0.15\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/d7b5c8d3808f4c73.svg\" alt=\"d_p=7.21-(7.21)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/ca02c52199da4f04.svg\" alt=\"d_g=7.21-(7.21)=0\" style=\"width:21.864ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/16804d70bddc0ccc.svg\" alt=\"S=0.12\\times(0)=0\" style=\"width:18.304ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/c7ca03a89be4beea.svg\" alt=\"v^{(1)}=0.15+0+0=0.15\" style=\"width:25.203ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/f693927b5eebad50.svg\" alt=\"x^{(1)}=7.21+0.15=7.36\" style=\"width:24.394ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/db302571bbe707b4.svg\" alt=\"I=0.5\\times0.5=0.25\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/2ddd2b101f36cd26.svg\" alt=\"d_p=4.15-(4.15)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/1978fefc1be6f223.svg\" alt=\"d_g=3.14-(4.15)=-1.01\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/060e9302bdac4457.svg\" alt=\"S=0.12\\times(-1.01)=-0.1212\" style=\"width:29.87ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/08fa8ab93dce4fd3.svg\" alt=\"v^{(1)}=0.25+0+(-0.1212)=0.1288\" style=\"width:36.14ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/bb72c3734ea8a809.svg\" alt=\"x^{(1)}=4.15+0.1288=4.2788\" style=\"width:28.919ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/4f87680527f659f2.svg\" alt=\"I=0.5\\times0.1=0.05\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/bceb9619d4320629.svg\" alt=\"d_p=7.31-(7.31)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fc0a8e88db078cd.svg\" alt=\"d_g=7.21-(7.31)=-0.1\" style=\"width:25.384ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f8e69de5d9161da2.svg\" alt=\"S=0.12\\times(-0.1)=-0.012\" style=\"width:27.608ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/3dca081cd95c2dd0.svg\" alt=\"v^{(1)}=0.05+0+(-0.012)=0.038\" style=\"width:33.877ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/644604a12b5bcc31.svg\" alt=\"x^{(1)}=7.31+0.038=7.348\" style=\"width:26.657ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: update particle C</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/3c5f4d0f2cda8136.svg\" alt=\"I=0.5\\times0.2=0.1\" style=\"width:18.614ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/13f27d08182e6e02.svg\" alt=\"d_p=6.17-(6.17)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/93416da8e366b396.svg\" alt=\"d_g=3.14-(6.17)=-3.03\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a59d670bba6f5dac.svg\" alt=\"S=0.12\\times(-3.03)=-0.3636\" style=\"width:29.87ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/3fdb1b4bffd3874d.svg\" alt=\"v^{(1)}=0.1+0+(-0.3636)=-0.2636\" style=\"width:36.769ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/40f8a4a790d7094f.svg\" alt=\"x^{(1)}=6.17+(-0.2636)=5.9064\" style=\"width:32.439ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/d343c09e8978bf19.svg\" alt=\"d_p=8.27-(8.27)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/ea093f799c7411f8.svg\" alt=\"d_g=7.21-(8.27)=-1.06\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b9fa5298c9c7cb16.svg\" alt=\"S=0.12\\times(-1.06)=-0.1272\" style=\"width:29.87ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/28af9633e743719d.svg\" alt=\"v^{(1)}=0+0+(-0.1272)=-0.1272\" style=\"width:35.008ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/dba6d056546c8535.svg\" alt=\"x^{(1)}=8.27+(-0.1272)=8.1428\" style=\"width:32.439ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/3ae29bc527e20248.svg\" alt=\"f(3.19, 7.36)=3.19^2+7.36^2-(3.19)(7.36)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b9b0c1a8c0f513a8.svg\" alt=\"=10.1761+54.1696-23.4784=40.8673\" style=\"width:40.602ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/c476266715700a96.svg\" alt=\"f(4.2788, 7.348)=4.2788^2+7.348^2-(4.2788)(7.348)\" style=\"width:52.372ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1baa4a09739c8180.svg\" alt=\"=18.30812944+53.993104-31.4406224=40.86061104\" style=\"width:55.308ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle C</strong></p><div class=\"math-display\"><img src=\"math/3a9fac3b191a1ffa.svg\" alt=\"f(5.9064, 8.1428)=5.9064^2+8.1428^2-(5.9064)(8.1428)\" style=\"width:55.765ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/273655b1059b7aef.svg\" alt=\"=34.88556096+66.30519184-48.09463392=53.09611888\" style=\"width:58.702ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>39.2043</td><td>40.8673</td><td>Keep old: new score is worse</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>40.3221</td><td>40.86061104</td><td>Keep old: new score is worse</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>55.4359</td><td>53.09611888</td><td>Replace: new score is lower</td><td>(5.9064, 8.1428)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(3.14, 7.21)</strong>, with objective <strong>39.2043</strong>.</p></div><div class=\"step\"><h5>Step 9. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(3.19, 7.36)</td><td>(0.05, 0.15)</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>(4.2788, 7.348)</td><td>(0.1288, 0.038)</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>(5.9064, 8.1428)</td><td>(-0.2636, -0.1272)</td><td>(5.9064, 8.1428)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Iteration 2: freeze the previous memories</h5><p>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).</p></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/e4bd35a53c831c76.svg\" alt=\"I=0.5\\times0.05=0.025\" style=\"width:22.008ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/cc2af53bc1a4a60e.svg\" alt=\"d_p=3.14-(3.19)=-0.05\" style=\"width:26.557ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/db60d8d854aa5ee6.svg\" alt=\"C=0.6\\times(-0.05)=-0.03\" style=\"width:26.737ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/1dbfd156a9aafbb3.svg\" alt=\"d_g=3.14-(3.19)=-0.05\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e7739769871dabe8.svg\" alt=\"S=0.12\\times(-0.05)=-0.006\" style=\"width:28.739ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/4e6287c93cb39658.svg\" alt=\"v^{(2)}=0.025+(-0.03)+(-0.006)=-0.011\" style=\"width:43.18ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/04d374313aaab72d.svg\" alt=\"x^{(2)}=3.19+(-0.011)=3.179\" style=\"width:30.177ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/e9c97812dc9ecc86.svg\" alt=\"I=0.5\\times0.15=0.075\" style=\"width:22.008ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/08869d3b9cefb65b.svg\" alt=\"d_p=7.21-(7.36)=-0.15\" style=\"width:26.557ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b80cfa7b094e421e.svg\" alt=\"C=0.6\\times(-0.15)=-0.09\" style=\"width:26.737ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/8346d41c793ff815.svg\" alt=\"d_g=7.21-(7.36)=-0.15\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bb6864a422495c83.svg\" alt=\"S=0.12\\times(-0.15)=-0.018\" style=\"width:28.739ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/df1003fde626354c.svg\" alt=\"v^{(2)}=0.075+(-0.09)+(-0.018)=-0.033\" style=\"width:43.18ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/04ced9552ec0a2fc.svg\" alt=\"x^{(2)}=7.36+(-0.033)=7.327\" style=\"width:30.177ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/c7a3d7f19f863ddf.svg\" alt=\"I=0.5\\times0.1288=0.0644\" style=\"width:25.402ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a86b46d750156354.svg\" alt=\"d_p=4.15-(4.2788)=-0.1288\" style=\"width:31.082ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9088271ed20d40af.svg\" alt=\"C=0.6\\times(-0.1288)=-0.07728\" style=\"width:32.393ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/ad7db7d0feab17e6.svg\" alt=\"d_g=3.14-(4.2788)=-1.1388\" style=\"width:31.04ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/115797e01c1867dd.svg\" alt=\"S=0.12\\times(-1.1388)=-0.136656\" style=\"width:34.395ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/ebf74e4d56d1b7b9.svg\" alt=\"v^{(2)}=0.0644+(-0.07728)+(-0.136656)=-0.149536\" style=\"width:54.492ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/eae7d898d5a551e1.svg\" alt=\"x^{(2)}=4.2788+(-0.149536)=4.129264\" style=\"width:39.227ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/45baaa3ae928b8b4.svg\" alt=\"I=0.5\\times0.038=0.019\" style=\"width:23.139ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/c86909b46639b9bb.svg\" alt=\"d_p=7.31-(7.348)=-0.038\" style=\"width:28.82ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/241c822838613f93.svg\" alt=\"C=0.6\\times(-0.038)=-0.0228\" style=\"width:30.13ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/fe0c41420480a542.svg\" alt=\"d_g=7.21-(7.348)=-0.138\" style=\"width:28.778ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e9a578685c025bc9.svg\" alt=\"S=0.12\\times(-0.138)=-0.01656\" style=\"width:32.132ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/9363048bb26f273e.svg\" alt=\"v^{(2)}=0.019+(-0.0228)+(-0.01656)=-0.02036\" style=\"width:49.968ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/d30e07ac98dd2bba.svg\" alt=\"x^{(2)}=7.348+(-0.02036)=7.32764\" style=\"width:35.833ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update particle C</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/cfc400d9e06f7358.svg\" alt=\"I=0.5\\times(-0.2636)=-0.1318\" style=\"width:30.682ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/786ba18b3b62c512.svg\" alt=\"d_p=5.9064-(5.9064)=0\" style=\"width:26.43ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6b3316f35248ffdf.svg\" alt=\"d_g=3.14-(5.9064)=-2.7664\" style=\"width:31.04ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b32a5de2e3b2cefc.svg\" alt=\"S=0.12\\times(-2.7664)=-0.331968\" style=\"width:34.395ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/de7212cc169aa2f9.svg\" alt=\"v^{(2)}=(-0.1318)+0+(-0.331968)=-0.463768\" style=\"width:48.207ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/ab68ef2fa1b527a9.svg\" alt=\"x^{(2)}=5.9064+(-0.463768)=5.442632\" style=\"width:39.227ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/d56f94fb044781a6.svg\" alt=\"I=0.5\\times(-0.1272)=-0.0636\" style=\"width:30.682ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/9923de46bc28d517.svg\" alt=\"d_p=8.1428-(8.1428)=0\" style=\"width:26.43ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/024d71da7fe2cc3c.svg\" alt=\"d_g=7.21-(8.1428)=-0.9328\" style=\"width:31.04ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/71d9611ef2b3e668.svg\" alt=\"S=0.12\\times(-0.9328)=-0.111936\" style=\"width:34.395ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/1a832b53cf0e106d.svg\" alt=\"v^{(2)}=(-0.0636)+0+(-0.111936)=-0.175536\" style=\"width:48.207ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/17e63ccf7082af52.svg\" alt=\"x^{(2)}=8.1428+(-0.175536)=7.967264\" style=\"width:39.227ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 14. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/76bb4ad3f6895999.svg\" alt=\"f(3.179, 7.327)=3.179^2+7.327^2-(3.179)(7.327)\" style=\"width:48.978ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e1463199434aa355.svg\" alt=\"=10.106041+53.684929-23.292533=40.498437\" style=\"width:49.652ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/0ac428234bdb63ad.svg\" alt=\"f(4.129264, 7.32764)=4.129264^2+7.32764^2-(4.129264)(7.32764)\" style=\"width:65.946ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a32da9cd0f25ac36.svg\" alt=\"=17.050821182+53.69430797-30.257760057=40.487369094\" style=\"width:62.096ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle C</strong></p><div class=\"math-display\"><img src=\"math/515e8ddbaa301792.svg\" alt=\"f(5.442632, 7.967264)=5.442632^2+7.967264^2-(5.442632)(7.967264)\" style=\"width:69.34ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a9051d35de42b6a1.svg\" alt=\"=29.622243087+63.477295646-43.362885999=49.736652734\" style=\"width:63.227ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 15. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>39.2043</td><td>40.498437</td><td>Keep old: new score is worse</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>40.3221</td><td>40.487369094</td><td>Keep old: new score is worse</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>53.09611888</td><td>49.736652734</td><td>Replace: new score is lower</td><td>(5.442632, 7.967264)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(3.14, 7.21)</strong>, with objective <strong>39.2043</strong>.</p></div><div class=\"step\"><h5>Step 16. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(3.179, 7.327)</td><td>(-0.011, -0.033)</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>(4.129264, 7.32764)</td><td>(-0.149536, -0.02036)</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>(5.442632, 7.967264)</td><td>(-0.463768, -0.175536)</td><td>(5.442632, 7.967264)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>\r\n\r\n<!-- depth:retained-diagram:start -->\r\n<div class=\"concept-bridge\"><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_pso_class_paths.961831cda1.svg\" width=\"700\" height=\"440\" alt=\"Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.</figcaption></figure></div>\r\n<!-- depth:retained-diagram:end -->"},{"id":"theory","title":"PSO algorithm, architecture, advantages and limitations","html":"<h2>Algorithm you can write in an exam</h2><ol><li>Define the objective and whether to minimise or maximise it. Initialise particle positions and velocities.</li><li>Evaluate every particle. Set each pbest to its initial position and gbest to the best among them.</li><li>Use the previous state to calculate each new velocity.</li><li>Update each position using that new velocity. Apply bounds or a velocity limit only according to the stated policy.</li><li>Evaluate the new positions. Update a pbest only when the new objective is better; choose gbest from the personal bests.</li><li>Repeat until the iteration budget or another stopping criterion is reached.</li></ol>\r\n<div class=\"flow\"><div class=\"node\">Initialise</div><span class=\"arrow\">→</span><div class=\"node\">Evaluate + memories</div><span class=\"arrow\">→</span><div class=\"node\">Velocity</div><span class=\"arrow\">→</span><div class=\"node\">Position</div><span class=\"arrow\">→</span><div class=\"node\">Evaluate + update memories<small>repeat until stopping</small></div></div><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td>Simple position/velocity updates; does not require objective derivatives</td><td>Can converge prematurely to a local region</td></tr><tr><td>Uses both individual and shared experience</td><td>Results depend on coefficients, initialisation and random factors</td></tr><tr><td>Useful for many continuous optimisation problems</td><td>Constraints and discrete encodings need suitable handling</td></tr><tr><td>Keeps best-so-far memories</td><td>Does not guarantee the global optimum in a finite run</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>Explain one application of PSO.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><table><thead><tr><th>Exam situation</th><th>Action</th></tr></thead><tbody><tr><td>Minimisation</td><td>Lower f is better</td></tr><tr><td>Maximisation</td><td>Higher f is better; do not reverse velocity differences</td></tr><tr><td>Tie in best score</td><td>Keep the previous best unless a tie rule is supplied</td></tr><tr><td>Different random factors each iteration</td><td>Read the relevant row; do not reuse old factors</td></tr><tr><td>Synchronous update</td><td>Freeze gbest for all particles within one iteration</td></tr><tr><td>Position/velocity outside a limit</td><td>Use the limit-handling rule explicitly supplied; state an assumption if absent</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Velocity → position → score → pbest → gbest. Ye order har iteration mein same.</p>"}]},{"id":"fuzzy-relations","title":"Fuzzy relations and matrices","unit":"Unit 2","scope":"Longer Unit 2 numerical practice, also useful for TEE.","sections":[{"id":"cartesian","title":"Cartesian product: every cell explained","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>How a row membership and a column membership meet</h2><p>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.</p><div class=\"math-display\"><img src=\"math/59fc3a309a7ab813.svg\" alt=\"R_{23}=\\min(A_2,B_3)=\\min(0.2,0.5)=0.2\" style=\"width:39.695ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>What is a fuzzy relation?</h2><p>A fuzzy set gives a membership to one element. A <strong>fuzzy relation</strong> gives a degree to an ordered pair. A matrix is a convenient table: rows name the first element and columns name the second.</p><p>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.</p><div class=\"math-display\"><img src=\"math/1132359c819cab8a.svg\" alt=\"R_{ij}=\\min(\\mu_A(a_i),\\mu_B(b_j))\" style=\"width:25.463ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>Find the fuzzy Cartesian product A×B for memberships A=[0.6, 0.2] and B=[0.3, 0.8, 0.5].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered A memberships [0.6, 0.2]; B memberships [0.3, 0.8, 0.5].</p><h4>To find</h4><p>A 2×3 relation matrix.</p></div><h4>Formula and why it applies</h4><p>Every row corresponds to an A element and every column to a B element; apply min in every cell.</p><div class=\"math-display\"><img src=\"math/50b8f8fcf2c15000.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\" style=\"width:17.671ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Determine dimensions</h5><p>2 row elements × 3 column elements.</p></div><div class=\"step\"><h5>Step 2. Compute each cell</h5><table><thead><tr><th>A ↓ / B →</th><th>0.3</th><th>0.8</th><th>0.5</th></tr></thead><tbody><tr><td>0.6</td><td>min(0.6,0.3) = 0.3</td><td>min(0.6,0.8) = 0.6</td><td>min(0.6,0.5) = 0.5</td></tr><tr><td>0.2</td><td>min(0.2,0.3) = 0.2</td><td>min(0.2,0.8) = 0.2</td><td>min(0.2,0.5) = 0.2</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Write the matrix</h5><div class=\"math-display\"><img src=\"math/eb5e24dcbf5263d2.svg\" alt=\"R=\\begin{bmatrix}0.3&amp;0.6&amp;0.5\\\\0.2&amp;0.2&amp;0.2\\end{bmatrix}\" style=\"width:20.323ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> R is the matrix in Step 3.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the fuzzy Cartesian product A×B for memberships A=[1, 0.4] and B=[0.7, 0].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered A memberships [1, 0.4]; B memberships [0.7, 0].</p><h4>To find</h4><p>A 2×2 relation matrix.</p></div><h4>Formula and why it applies</h4><p>Every row corresponds to an A element and every column to a B element; apply min in every cell.</p><div class=\"math-display\"><img src=\"math/50b8f8fcf2c15000.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\" style=\"width:17.671ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Determine dimensions</h5><p>2 row elements × 2 column elements.</p></div><div class=\"step\"><h5>Step 2. Compute each cell</h5><table><thead><tr><th>A ↓ / B →</th><th>0.7</th><th>0</th></tr></thead><tbody><tr><td>1</td><td>min(1,0.7) = 0.7</td><td>min(1,0) = 0</td></tr><tr><td>0.4</td><td>min(0.4,0.7) = 0.4</td><td>min(0.4,0) = 0</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Write the matrix</h5><div class=\"math-display\"><img src=\"math/00a9ec4b6529a3a5.svg\" alt=\"R=\\begin{bmatrix}0.7&amp;0\\\\0.4&amp;0\\end{bmatrix}\" style=\"width:13.408ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> R is the matrix in Step 3.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the fuzzy Cartesian product A×B for memberships A=[0.2, 0.9, 0.5] and B=[0.6, 0.1].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered A memberships [0.2, 0.9, 0.5]; B memberships [0.6, 0.1].</p><h4>To find</h4><p>A 3×2 relation matrix.</p></div><h4>Formula and why it applies</h4><p>Every row corresponds to an A element and every column to a B element; apply min in every cell.</p><div class=\"math-display\"><img src=\"math/50b8f8fcf2c15000.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\" style=\"width:17.671ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Determine dimensions</h5><p>3 row elements × 2 column elements.</p></div><div class=\"step\"><h5>Step 2. Compute each cell</h5><table><thead><tr><th>A ↓ / B →</th><th>0.6</th><th>0.1</th></tr></thead><tbody><tr><td>0.2</td><td>min(0.2,0.6) = 0.2</td><td>min(0.2,0.1) = 0.1</td></tr><tr><td>0.9</td><td>min(0.9,0.6) = 0.6</td><td>min(0.9,0.1) = 0.1</td></tr><tr><td>0.5</td><td>min(0.5,0.6) = 0.5</td><td>min(0.5,0.1) = 0.1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Write the matrix</h5><div class=\"math-display\"><img src=\"math/587e0aaf2cb10cc7.svg\" alt=\"R=\\begin{bmatrix}0.2&amp;0.1\\\\0.6&amp;0.1\\\\0.5&amp;0.1\\end{bmatrix}\" style=\"width:15.798ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> R is the matrix in Step 3.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Row ka degree aur column ka degree—dono ka min us cell mein.</p>"},{"id":"composition","title":"Max–min composition: three complete matrix examples","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>One result cell combines alternative two-link paths</h2><p>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.</p><table><thead><tr><th>Path</th><th>First link from R</th><th>Second link from S</th><th>Path strength</th></tr></thead><tbody><tr><td>u₁ → v₁ → w₁</td><td>.2</td><td>.5</td><td>min(.2,.5)=.2</td></tr><tr><td>u₁ → v₂ → w₁</td><td>.8</td><td>.7</td><td>min(.8,.7)=.7</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Ek path mein dono links chahiye, isliye min. Alag paths mein best chalega, isliye max.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Composition connects through a middle element</h2><p>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.</p><div class=\"math-display\"><img src=\"math/56cc213f59fd4c68.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Calculate the max–min composition using <span class=\"math-inline\"><img src=\"math/7ad9b78ea1d9260b.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:24.067ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/6a3980f8eb0faad9.svg\" alt=\"R=\\begin{bmatrix}0.2&amp;0.8\\\\0.6&amp;0.3\\end{bmatrix}\" style=\"width:15.169ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ae4133e873ae6a3f.svg\" alt=\"S=\\begin{bmatrix}0.5&amp;0.9\\\\0.7&amp;0.1\\end{bmatrix}\" style=\"width:14.911ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Every entry of T.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Cell (1,1): row 1 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/ce290d4a2b6414c6.svg\" alt=\"T_{11}=\\max\\{\\min(0.2,0.5),\\min(0.8,0.7)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5d7c26e3f57345f9.svg\" alt=\"=\\max\\{0.2,0.7\\}=0.7\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Cell (1,2): row 1 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/ce2b2b77de4033df.svg\" alt=\"T_{12}=\\max\\{\\min(0.2,0.9),\\min(0.8,0.1)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/197ec23ba477e3ac.svg\" alt=\"=\\max\\{0.2,0.1\\}=0.2\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Cell (2,1): row 2 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/07f583df1f70440b.svg\" alt=\"T_{21}=\\max\\{\\min(0.6,0.5),\\min(0.3,0.7)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5d84612aa0c3dabf.svg\" alt=\"=\\max\\{0.5,0.3\\}=0.5\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Cell (2,2): row 2 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/e2fa4ca72e9eecdf.svg\" alt=\"T_{22}=\\max\\{\\min(0.6,0.9),\\min(0.3,0.1)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b6bb46f767031fd8.svg\" alt=\"=\\max\\{0.6,0.1\\}=0.6\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/c434184a79340d55.svg\" alt=\"T=\\begin{bmatrix}0.7&amp;0.2\\\\0.5&amp;0.6\\end{bmatrix}\" style=\"width:15.044ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the max–min composition using <span class=\"math-inline\"><img src=\"math/7ad9b78ea1d9260b.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:24.067ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/5525680a26d9df18.svg\" alt=\"R=\\begin{bmatrix}1&amp;0\\\\0.4&amp;0.7\\end{bmatrix}\" style=\"width:15.169ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/377016d2bce333c2.svg\" alt=\"S=\\begin{bmatrix}0.2&amp;0.6\\\\0.8&amp;0.3\\end{bmatrix}\" style=\"width:14.911ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Every entry of T.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Cell (1,1): row 1 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/cf3e1892a786961d.svg\" alt=\"T_{11}=\\max\\{\\min(1,0.2),\\min(0,0.8)\\}\" style=\"width:34.725ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9ba8671f889808c7.svg\" alt=\"=\\max\\{0.2,0\\}=0.2\" style=\"width:19.799ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Cell (1,2): row 1 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/d6b9af12c569f647.svg\" alt=\"T_{12}=\\max\\{\\min(1,0.6),\\min(0,0.3)\\}\" style=\"width:34.725ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/234802688b1bc952.svg\" alt=\"=\\max\\{0.6,0\\}=0.6\" style=\"width:19.799ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Cell (2,1): row 2 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/145badb953d03e7a.svg\" alt=\"T_{21}=\\max\\{\\min(0.4,0.2),\\min(0.7,0.8)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5d7c26e3f57345f9.svg\" alt=\"=\\max\\{0.2,0.7\\}=0.7\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Cell (2,2): row 2 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/7580af7f56a5d58b.svg\" alt=\"T_{22}=\\max\\{\\min(0.4,0.6),\\min(0.7,0.3)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fed46295bb39d225.svg\" alt=\"=\\max\\{0.4,0.3\\}=0.4\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/303c2bbbbf128653.svg\" alt=\"T=\\begin{bmatrix}0.2&amp;0.6\\\\0.7&amp;0.4\\end{bmatrix}\" style=\"width:15.044ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the max–min composition using <span class=\"math-inline\"><img src=\"math/7ad9b78ea1d9260b.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:24.067ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/12f5f2edbde65b9d.svg\" alt=\"R=\\begin{bmatrix}0.3&amp;0.6&amp;0.9\\end{bmatrix}\" style=\"width:19.191ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1823a7e672a05e76.svg\" alt=\"S=\\begin{bmatrix}0.8&amp;0.1\\\\0.2&amp;0.7\\\\0.5&amp;0.4\\end{bmatrix}\" style=\"width:15.54ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Every entry of T.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Cell (1,1): row 1 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/559127d73e85d555.svg\" alt=\"T_{11}=\\max\\{\\min(0.3,0.8),\\min(0.6,0.2),\\min(0.9,0.5)\\}\" style=\"width:51.572ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ebeaf1e5ce8f9612.svg\" alt=\"=\\max\\{0.3,0.2,0.5\\}=0.5\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Cell (1,2): row 1 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/843b8913b1abe9b7.svg\" alt=\"T_{12}=\\max\\{\\min(0.3,0.1),\\min(0.6,0.7),\\min(0.9,0.4)\\}\" style=\"width:51.572ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8ce46b5da48e6fa8.svg\" alt=\"=\\max\\{0.1,0.6,0.4\\}=0.6\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/fc69cd14a88a24b1.svg\" alt=\"T=\\begin{bmatrix}0.5&amp;0.6\\end{bmatrix}\" style=\"width:13.913ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Har path mein min, phir saare paths mein max. Multiply-and-add nahi.</p>"}]}],"formulas":[{"id":"m2-formulas-v2","title":"All M2 formulas","unit":"M2 revision","scope":"One place for the formulas, meanings, conditions and links to full worked examples.","sections":[{"id":"fuzzy","title":"Fuzzy formulas, with meanings and worked-example links","html":"<h2>Fuzzy formulas</h2><h3>Triangular membership</h3><div class=\"math-display\"><img src=\"math/f0ca7a326bd064e8.svg\" alt=\"\\mu(x)=\\max\\left(0,\\min\\left(\\frac{x-a}{b-a},\\frac{c-x}{c-b}\\right)\\right)\" style=\"width:38.263ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><p>a=left zero, b=peak, c=right zero, with a&lt;b&lt;c. Locate x before choosing the rising/falling branch.</p><p><a href=\"#m2/read/fuzzy-core/triangle\">Read the explanation and worked sums →</a></p><h3>Union and intersection</h3><div class=\"math-display\"><img src=\"math/eaf940ee2fdf1f17.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\quad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:42.914ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Compare memberships at the same element. These formulas use standard max–min operations.</p><p><a href=\"#m2/read/fuzzy-core/set-operations\">Read the explanation and worked sums →</a></p><h3>Complement and difference</h3><div class=\"math-display\"><img src=\"math/ac545c5022ffd6a1.svg\" alt=\"\\mu_{A^c}=1-\\mu_A\\quad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:39.039ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><p>A difference means A AND NOT B; it is not ordinary subtraction.</p><p><a href=\"#m2/read/fuzzy-core/set-operations\">Read the explanation and worked sums →</a></p><h3>Rule strength, clipping and aggregation</h3><div class=\"math-display\"><img src=\"math/043f511911bca932.svg\" alt=\"\\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)\" style=\"width:62.895ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><p>a,b are input degrees; α is the strength; z is a candidate output value. OR conditions use max instead.</p><p><a href=\"#m2/read/fuzzy-core/rules-clipping\">Read the explanation and worked sums →</a></p><h3>Mean of maxima</h3><div class=\"math-display\"><img src=\"math/9ed17a341041965a.svg\" alt=\"z^*=\\frac{\\sum_{z_i\\in M}z_i}{|M|}\\quad\\text{one plateau }[a,b]:\\ z^*=(a+b)/2\" style=\"width:49.788ex;height:5.805ex\" loading=\"lazy\" decoding=\"async\"></div><p>M is the set of discrete output locations attaining maximum membership. The plateau shortcut is for one continuous maximum interval.</p><p><a href=\"#m2/read/fuzzy-core/mom\">Read the explanation and worked sums →</a></p><h3>Discrete / continuous centroid</h3><div class=\"math-display\"><img src=\"math/79ddc9ad485491a0.svg\" alt=\"z^*=\\frac{\\sum_i z_i\\mu_i}{\\sum_i\\mu_i}\\qquad z^*=\\frac{\\int z\\mu(z)\\,dz}{\\int\\mu(z)\\,dz}\" style=\"width:33.623ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><p>Use actual discrete memberships or the full continuous aggregate. Denominator must be positive.</p><p><a href=\"#m2/read/fuzzy-core/centroid\">Read the explanation and worked sums →</a></p><h3>Specified representative-weighted output</h3><div class=\"math-display\"><img src=\"math/0fb4cda8fcd0e1d8.svg\" alt=\"z^*=\\frac{\\sum_r\\alpha_r c_r}{\\sum_r\\alpha_r}\" style=\"width:13.974ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>c is a supplied representative such as a peak. Do not call this the exact area centroid of a clipped Mamdani aggregate without justification.</p><p><a href=\"#m2/read/fuzzy-core/weighted-average\">Read the explanation and worked sums →</a></p><h3>Cartesian product and max–min composition</h3><div class=\"math-display\"><img src=\"math/dfabdb4f1a2b77c3.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\\quad T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:43.154ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div><p>Relations must have a common middle domain in the same order. Min along a path, max across paths.</p><p><a href=\"#m2/read/fuzzy-relations/composition\">Read the explanation and worked sums →</a></p>\r\n\r\n<!-- depth:remaining-memberships:start -->\r\n<div class=\"concept-bridge\"><h2>Other membership formulas from the reading lessons</h2><h3>Trapezoid with distinct breakpoints</h3><div class=\"math-display\"><img src=\"math/61dfda51f019f3c9.svg\" alt=\"\\mu(x)=\\max\\left(0,\\min\\left(\\frac{x-a}{b-a},1,\\frac{d-x}{d-c}\\right)\\right)\" style=\"width:40.597ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><p>For a&lt;b≤c&lt;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. <a href=\"#m2/read/fuzzy-core/trapezoid-intuition\">Branch examples →</a></p><h3>Gaussian membership</h3><div class=\"math-display\"><img src=\"math/3a8ce5565c9dd1ff.svg\" alt=\"\\mu(x)=e^{-(x-c)^2/(2\\sigma^2)}\" style=\"width:19.174ex;height:2.834ex\" loading=\"lazy\" decoding=\"async\"></div><p>c is the centre and σ&gt;0 sets the width. At x=c the exponent is zero and membership is 1. <a href=\"#m2/read/fuzzy-core/smooth-memberships\">Worked exponential calculations →</a></p><h3>Generalised bell membership</h3><div class=\"math-display\"><img src=\"math/37da3dd6f213b8e7.svg\" alt=\"\\mu(x)=\\frac{1}{1+|(x-c)/a|^{2b}}\" style=\"width:24.388ex;height:5.275ex\" loading=\"lazy\" decoding=\"async\"></div><p>a&gt;0 controls width; b&gt;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.</p><h3>Alpha-cut</h3><div class=\"math-display\"><img src=\"math/34e8388304c6f4b2.svg\" alt=\"A_\\alpha=\\{x:\\mu_A(x)\\ge\\alpha\\}\" style=\"width:21.639ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>α is the chosen membership threshold. For 0&lt;α≤1 keep inputs meeting or exceeding it, including threshold-equality endpoints. <a href=\"#m2/read/fuzzy-core/properties\">Discrete and triangular examples →</a></p></div>\r\n<!-- depth:remaining-memberships:end -->"},{"id":"ga-pso","title":"GA and PSO formulas, symbols and memory rules","html":"<h3>Binary decoding</h3><div class=\"math-display\"><img src=\"math/4fb94e1436769fba.svg\" alt=\"x=\\sum_{i=1}^{n}b_i2^{n-i}\" style=\"width:13.741ex;height:6.354ex\" loading=\"lazy\" decoding=\"async\"></div><p>bᵢ is a bit; the maximum n-bit unsigned integer is 2ⁿ−1.</p><p><a href=\"#m2/read/ga-core/encoding\">Full explanation and worked solutions →</a></p><h3>Roulette selection</h3><div class=\"math-display\"><img src=\"math/a3d3e670e29c240d.svg\" alt=\"P_i=F_i/\\sum_jF_j\\quad C_i=\\sum_{j=1}^iP_j\" style=\"width:28.438ex;height:6.9ex\" loading=\"lazy\" decoding=\"async\"></div><p>Fitness weights must be nonnegative with a positive total. For minimisation use the specified transformation or selection method. C is cumulative probability.</p><p><a href=\"#m2/read/ga-core/selection\">Full explanation and worked solutions →</a></p><h3>Population average</h3><div class=\"math-display\"><img src=\"math/5a16aa84fc40bbd3.svg\" alt=\"\\bar f=\\frac{f_1+\\cdots+f_N}{N}\" style=\"width:18.253ex;height:4.676ex\" loading=\"lazy\" decoding=\"async\"></div><p>N is the number of individuals. Compare both best and average; mutation need not improve either.</p><p><a href=\"#m2/read/ga-core/two-generations\">Full explanation and worked solutions →</a></p><h3>PSO velocity</h3><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>w weights inertia; c₁r₁ weights personal pull; c₂r₂ weights social pull. Apply the same equation separately to each coordinate.</p><p><a href=\"#m2/read/pso-core/equation\">Full explanation and worked solutions →</a></p><h3>PSO position</h3><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><p>Use the new velocity, not the old one. Then reevaluate the objective.</p><p><a href=\"#m2/read/pso-core/two-particles\">Full explanation and worked solutions →</a></p><p><strong>Memory updates:</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Formula ke pehle objective direction aur old state likho. Iteration 2 mein fresh positions aur retained memories use karo.</p>\r\n\r\n<!-- depth:encoding-conventions:start -->\r\n<div class=\"concept-bridge\"><h2>Encoding and minimisation conventions</h2><div class=\"math-display\"><img src=\"math/3013a3fc845c64e5.svg\" alt=\"x=L+\\frac{d}{2^n-1}(U-L)\" style=\"width:23.591ex;height:4.837ex\" loading=\"lazy\" decoding=\"async\"></div><p>For the specified uniform real-range encoding: decode n bits into unsigned integer d first. L and U are the physical limits. <a href=\"#m2/read/ga-core/encoding\">Endpoint examples →</a></p><div class=\"math-display\"><img src=\"math/361a654c14fe241e.svg\" alt=\"F=\\frac{1}{1+f(x)}\" style=\"width:13.903ex;height:5.208ex\" loading=\"lazy\" decoding=\"async\"></div><p>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. <a href=\"#m2/read/ga-core/minimisation\">Complete minimisation example →</a></p></div>\r\n<!-- depth:encoding-conventions:end -->"}]}],"papers":[{"id":"paper-final-2025","title":"Final examination · 24 Nov 2025","unit":"paper","scope":"Longer past-paper questions on Fuzzy, GA and PSO. Original TEE marks retained; not the M2 paper pattern.","sections":[{"id":"q1c","title":"Q1(c) Fuzzy set operations [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The aligned X and Y memberships printed in this question.</p><h4>To find</h4><p>The four requested membership lists in the original element order.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1−μ for NOT. <div class=\"math-display\"><img src=\"math/e32ad02c5ba3dae5.svg\" alt=\"\\mu_{X\\cup Y}=\\max(\\mu_X,\\mu_Y),\\quad\\mu_{X\\cap Y}=\\min(\\mu_X,\\mu_Y)\" style=\"width:44.598ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div> Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Complements</h5><p>¬X = {0.4, 0.2, 0.7, 0.5, 0.3}; ¬Y = {0.6, 0.5, 0.1, 0.4, 0.8}.</p></div>\r\n<div class=\"step\"><h5>Step 2. Table</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th></tr></thead><tbody>\r\n<tr><td>X</td><td>0.6</td><td>0.8</td><td>0.3</td><td>0.5</td><td>0.7</td></tr>\r\n<tr><td>Y</td><td>0.4</td><td>0.5</td><td>0.9</td><td>0.6</td><td>0.2</td></tr>\r\n<tr><td><strong>X ∪ Y = max</strong></td><td>0.6</td><td>0.8</td><td>0.9</td><td>0.6</td><td>0.7</td></tr>\r\n<tr><td><strong>X ∩ Y = min</strong></td><td>0.4</td><td>0.5</td><td>0.3</td><td>0.5</td><td>0.2</td></tr>\r\n<tr><td><strong>¬X ∪ ¬Y</strong></td><td>0.6</td><td>0.5</td><td>0.7</td><td>0.5</td><td>0.8</td></tr>\r\n<tr><td><strong>¬X ∩ ¬Y</strong></td><td>0.4</td><td>0.2</td><td>0.1</td><td>0.4</td><td>0.3</td></tr>\r\n</tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Check with De Morgan's law</h5><p>¬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} ✓.</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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)}.</div>\r\n<p class=\"marks-split\">Official marking: 1 + 1 + 1.5 + 1.5.</p>\r\n</section>\r\n\r\n<!-- depth:element-working:start -->\r\n<div class=\"concept-bridge\"><h2>Calculate every element separately</h2><h3>Element c1</h3><div class=\"math-display\"><img src=\"math/ab521a108b232136.svg\" alt=\"\\neg X:1-0.6=0.4\\qquad\\neg Y:1-0.4=0.6\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9fba815e535802c7.svg\" alt=\"X\\cup Y:\\max(0.6,0.4)=0.6\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/580180c90f774b30.svg\" alt=\"X\\cap Y:\\min(0.6,0.4)=0.4\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ac5d994d1c80e0dd.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.4,0.6)=0.6\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f8ad2bf1c74a8449.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.4,0.6)=0.4\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c2</h3><div class=\"math-display\"><img src=\"math/994b18481ef2566a.svg\" alt=\"\\neg X:1-0.8=0.2\\qquad\\neg Y:1-0.5=0.5\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/34ae0707b407acaa.svg\" alt=\"X\\cup Y:\\max(0.8,0.5)=0.8\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/276fcc7ea7945a48.svg\" alt=\"X\\cap Y:\\min(0.8,0.5)=0.5\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e450f31b46fa1e42.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.2,0.5)=0.5\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/503c7cc18cb10c65.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.2,0.5)=0.2\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c3</h3><div class=\"math-display\"><img src=\"math/abbf5f7c84a2a614.svg\" alt=\"\\neg X:1-0.3=0.7\\qquad\\neg Y:1-0.9=0.1\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b75d7a85a782c820.svg\" alt=\"X\\cup Y:\\max(0.3,0.9)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/33c018c6e76860e7.svg\" alt=\"X\\cap Y:\\min(0.3,0.9)=0.3\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b158ec14569973da.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.7,0.1)=0.7\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7b8935d4bd0523c1.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.7,0.1)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c4</h3><div class=\"math-display\"><img src=\"math/9b11f9a14b9e240f.svg\" alt=\"\\neg X:1-0.5=0.5\\qquad\\neg Y:1-0.6=0.4\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/30d486e82175d463.svg\" alt=\"X\\cup Y:\\max(0.5,0.6)=0.6\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd263e46a0f4e96c.svg\" alt=\"X\\cap Y:\\min(0.5,0.6)=0.5\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bc8abd6badb711b9.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.5,0.4)=0.5\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2acca2b0b18cfada.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.5,0.4)=0.4\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c5</h3><div class=\"math-display\"><img src=\"math/b115216f7121911a.svg\" alt=\"\\neg X:1-0.7=0.3\\qquad\\neg Y:1-0.2=0.8\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ca6e5562fab61517.svg\" alt=\"X\\cup Y:\\max(0.7,0.2)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3de60cd86ef1a257.svg\" alt=\"X\\cap Y:\\min(0.7,0.2)=0.2\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0712a083103a814e.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.3,0.8)=0.8\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6274e157a87eaf7b.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.3,0.8)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:element-working:end -->"},{"id":"q2a","title":"Q2(a) PSO, one iteration [10]","html":"<p class=\"question\"><strong>Question. Maximize <span class=\"math-inline\"><img src=\"math/51d7b4f8ba214898.svg\" alt=\"F(x_1,x_2)=2x_1^2-3x_1x_2+x_2^2+5x_1+2x_2+7\" style=\"width:45.217ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using Particle Swarm Optimization. <span class=\"math-inline\"><img src=\"math/cf25c61c163c59c7.svg\" alt=\"X=\\begin{bmatrix}2.5&amp;-3.0\\\\3.5&amp;-1.5\\end{bmatrix},\\;V=\\begin{bmatrix}0.2&amp;0.3\\\\0.1&amp;0.25\\end{bmatrix}\" style=\"width:35.097ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Take <span class=\"math-inline\"><img src=\"math/d99737a5fc79423b.svg\" alt=\"W=0.9,\\;c_1=c_2=1.5,\\;r_1=0.5949,\\;r_2=0.0855\" style=\"width:48.665ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></span>. Optimize and give the solution after 1 iteration showing the step-by-step process.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4><p>Particle 1: <span class=\"math-inline\"><img src=\"math/85ac77f48027edb2.svg\" alt=\"x=(2.5,\\,-3.0)\" style=\"width:14.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/438166430b0200d4.svg\" alt=\"v=(0.2,\\,0.3)\" style=\"width:13.041ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. Particle 2: <span class=\"math-inline\"><img src=\"math/a92c6e5b7c6f437f.svg\" alt=\"x=(3.5,\\,-1.5)\" style=\"width:14.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/3bf1b4b0830b2535.svg\" alt=\"v=(0.1,\\,0.25)\" style=\"width:14.172ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/24c25a9332d3129e.svg\" alt=\"c_1r_1=1.5\\times0.5949=0.89235,\\qquad c_2r_2=1.5\\times0.0855=0.12825\" style=\"width:64.267ex;height:1.971ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<h4>To find</h4><p>Fitness, pbest, gbest; new velocities and positions; updated pbest and gbest.</p></div>\r\n<h4>Formula and why it applies</h4>\r\n<div class=\"math-display\"><img src=\"math/15c9c9495dc886c9.svg\" alt=\"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}\" style=\"width:62.375ex;height:3.036ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Each particle is pulled by its own memory and by the swarm's best; we maximise, so the larger <span class=\"math-inline\"><img src=\"math/277a47abb82a8255.svg\" alt=\"F\" style=\"width:1.695ex;height:1.538ex\" loading=\"lazy\" decoding=\"async\"></span> is better.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Fitness of particle 1</h5><div class=\"math-display\"><img src=\"math/3938546a658fac5b.svg\" alt=\"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\" style=\"width:97.613ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Fitness of particle 2</h5><div class=\"math-display\"><img src=\"math/4d48c40dfb866c17.svg\" alt=\"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\" style=\"width:101.006ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. pbest and gbest</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>Position</th><th>F</th><th>pbest</th></tr></thead><tbody><tr><td>1</td><td>(2.5, −3.0)</td><td>57.5</td><td>(2.5, −3.0)</td></tr><tr><td>2</td><td>(3.5, −1.5)</td><td>64</td><td>(3.5, −1.5)</td></tr></tbody></table></div>\r\n<p>No previous iteration, so pbest = current position. Largest fitness is 64, so <strong>gbest = (3.5, −1.5)</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 4. Velocity and position of particle 1</h5>\r\n<div class=\"math-display\"><img src=\"math/c5345abf4a118373.svg\" alt=\"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\" style=\"width:85.978ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/aa0bacfeb906b753.svg\" alt=\"x_{11}=2.5+0.30825=2.80825\" style=\"width:29.606ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/a3af7b24f214c46d.svg\" alt=\"v_{12}=0.9(0.3)+0.89235(0)+0.12825(-1.5-(-3.0))=0.27+0.192375=0.462375\" style=\"width:82.207ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c09ac9a314e4985c.svg\" alt=\"x_{12}=-3.0+0.462375=-2.537625\" style=\"width:35.388ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 5. Velocity and position of particle 2 (it is gbest, so both pull terms are 0)</h5>\r\n<div class=\"math-display\"><img src=\"math/d5ef6ea1fa183f88.svg\" alt=\"v_{21}=0.9(0.1)+0+0=0.09,\\qquad x_{21}=3.5+0.09=3.59\" style=\"width:56.628ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/cdc998e6ae01e141.svg\" alt=\"v_{22}=0.9(0.25)+0+0=0.225,\\qquad x_{22}=-1.5+0.225=-1.275\" style=\"width:64.673ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 6. New fitness</h5>\r\n<div class=\"math-display\"><img src=\"math/d85fb6275e35f72d.svg\" alt=\"F(2.80825,-2.537625)=15.772536+21.378856+6.439541+14.04125-5.07525+7=59.5569\" style=\"width:94.464ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/df29fd84a6cdf039.svg\" alt=\"F(3.59,-1.275)=25.7762+13.73175+1.625625+17.95-2.55+7=63.5336\" style=\"width:77.495ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 7. Update pbest and gbest</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>New position</th><th>New F</th><th>Old pbest F</th><th>pbest after iteration</th></tr></thead><tbody>\r\n<tr><td>1</td><td>(2.80825, −2.537625)</td><td>59.5569</td><td>57.5</td><td>(2.80825, −2.537625) — improved</td></tr>\r\n<tr><td>2</td><td>(3.59, −1.275)</td><td>63.5336</td><td>64</td><td>(3.5, −1.5) — kept</td></tr></tbody></table></div>\r\n<p>The best pbest fitness is still 64, so gbest stays (3.5, −1.5).</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/4cf56ad79b60f4ff.svg\" alt=\"V=\\begin{bmatrix}0.30825&amp;0.462375\\\\0.09&amp;0.225\\end{bmatrix}\" style=\"width:25.372ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/befb5808089844a6.svg\" alt=\"X=\\begin{bmatrix}2.80825&amp;-2.537625\\\\3.59&amp;-1.275\\end{bmatrix}\" style=\"width:27.32ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. After one iteration particle 1 improved to F = 59.5569; the best solution so far is gbest = (3.5, −1.5) with F = 64.</div>\r\n<p class=\"marks-split\">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 <span class=\"math-inline\"><img src=\"math/e82facc124656ec6.svg\" alt=\"x_{11}\" style=\"width:3.082ex;height:1.339ex\" loading=\"lazy\" decoding=\"async\"></span>; that is a copying slip.</p>\r\n</section>\r\n"},{"id":"q3b","title":"Q3(b) Fuzzy loan-approval system [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Crisp value</th></tr></thead><tbody><tr><td>Credit Score</td><td>55</td></tr><tr><td>Income Stability</td><td>35</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>A complete stated design and its continuous Mamdani centroid.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/5aa4acd6aab4215a.svg\" alt=\"z^*=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:18.101ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Specify the membership functions</h5><table><thead><tr><th>Input / output position</th><th>Triangle</th><th>Peak</th></tr></thead><tbody><tr><td>Low / Reject</td><td>(1,25,50)</td><td>25</td></tr><tr><td>Medium / Consider</td><td>(25,50,75)</td><td>50</td></tr><tr><td>High / Approve</td><td>(50,75,100)</td><td>75</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 2. Write all nine rules</h5><table><thead><tr><th>Credit Score / Income Stability</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Reject</td><td>Reject</td><td>Consider</td></tr><tr><td>Medium</td><td>Reject</td><td>Consider</td><td>Approve</td></tr><tr><td>High</td><td>Consider</td><td>Approve</td><td>Approve</td></tr></tbody></table><p>Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.</p></div><div class=\"step\"><h5>Step 3. Fuzzify Credit Score = 55</h5><div class=\"math-display\"><img src=\"math/b1adf4cfc2121094.svg\" alt=\"\\mu_{Low}(55)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0625f25570fc580f.svg\" alt=\"\\mu_{Medium}(55)=\\frac{75-55}{75-50}=0.8\" style=\"width:28.917ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6f64cb8c41f3eca0.svg\" alt=\"\\mu_{High}(55)=\\frac{55-50}{75-50}=0.2\" style=\"width:26.443ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Fuzzify Income Stability = 35</h5><div class=\"math-display\"><img src=\"math/c3eeae587085fbae.svg\" alt=\"\\mu_{Low}(35)=\\frac{50-35}{50-25}=0.6\" style=\"width:25.797ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d607a558d66f8791.svg\" alt=\"\\mu_{Medium}(35)=\\frac{35-25}{50-25}=0.4\" style=\"width:28.917ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1509e75effd66d75.svg\" alt=\"\\mu_{High}(35)=0\" style=\"width:13.38ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Evaluate all rules and aggregate matching consequents</h5><table><thead><tr><th>Credit Score</th><th>Income Stability</th><th>Firing strength</th><th>Consequent</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>min(0,0.6) = 0</td><td>Reject</td></tr><tr><td>Low</td><td>Medium</td><td>min(0,0.4) = 0</td><td>Reject</td></tr><tr><td>Low</td><td>High</td><td>min(0,0) = 0</td><td>Consider</td></tr><tr><td>Medium</td><td>Low</td><td>min(0.8,0.6) = 0.6</td><td>Reject</td></tr><tr><td>Medium</td><td>Medium</td><td>min(0.8,0.4) = 0.4</td><td>Consider</td></tr><tr><td>Medium</td><td>High</td><td>min(0.8,0) = 0</td><td>Approve</td></tr><tr><td>High</td><td>Low</td><td>min(0.2,0.6) = 0.2</td><td>Consider</td></tr><tr><td>High</td><td>Medium</td><td>min(0.2,0.4) = 0.2</td><td>Approve</td></tr><tr><td>High</td><td>High</td><td>min(0.2,0) = 0</td><td>Approve</td></tr></tbody></table><p>Aggregated label strengths: Reject = 0.6, Consider = 0.4, Approve = 0.2.</p><div class=\"math-display\"><img src=\"math/d1c2a08444481d0c.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:29.283ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Draw the aggregated output</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_loan_aggregate.2c5ffa32a7.svg\" width=\"680\" height=\"300\" alt=\"The shaded upper envelope counts any overlap only once.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The shaded upper envelope counts any overlap only once.</figcaption></figure></div><div class=\"step\"><h5>Step 7. Calculate area and moment of each straight-line strip</h5><p>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.</p><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d68335c9ce0df62c.svg\" alt=\"M=\\frac{b-a}{6}\\big[(2a+b)u+(a+2b)v\\big]\" style=\"width:34.017ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>1</td><td>15.4</td><td>0</td><td>0.6</td><td>4.32</td><td>45.792</td></tr><tr><td>15.4</td><td>25</td><td>0.6</td><td>0.6</td><td>5.76</td><td>116.352</td></tr><tr><td>25</td><td>35</td><td>0.6</td><td>0.6</td><td>6</td><td>180</td></tr><tr><td>35</td><td>40</td><td>0.6</td><td>0.4</td><td>2.5</td><td>93.333333333</td></tr><tr><td>40</td><td>50</td><td>0.4</td><td>0.4</td><td>4</td><td>180</td></tr><tr><td>50</td><td>55</td><td>0.4</td><td>0.4</td><td>2</td><td>105</td></tr><tr><td>55</td><td>65</td><td>0.4</td><td>0.4</td><td>4</td><td>240</td></tr><tr><td>65</td><td>70</td><td>0.4</td><td>0.2</td><td>1.5</td><td>100.833333333</td></tr><tr><td>70</td><td>75</td><td>0.2</td><td>0.2</td><td>1</td><td>72.5</td></tr><tr><td>75</td><td>95</td><td>0.2</td><td>0.2</td><td>4</td><td>340</td></tr><tr><td>95</td><td>100</td><td>0.2</td><td>0</td><td>0.5</td><td>48.333333333</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Divide total moment by total area</h5><div class=\"math-display\"><img src=\"math/04fe6e4450abbfe1.svg\" alt=\"\\sum A=35.58\" style=\"width:13.512ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/db33614c63a7fe19.svg\" alt=\"\\sum M=1522.144\" style=\"width:17.586ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd239737d0e6ec58.svg\" alt=\"z^*=\\frac{1522.144}{35.58}\\approx42.780888139\" style=\"width:30.689ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:centroid-working:start -->\r\n<div class=\"concept-bridge\"><h2>How the centroid table’s breakpoints are obtained</h2><p>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.</p><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>A and M for one table row.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ee3fb707739e8b69.svg\" alt=\"M=\\frac{b-a}{6}[(2a+b)u+(a+2b)v]\" style=\"width:33.388ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><p>A is trapezoid area. M weights every small area by its horizontal position; this formula integrates a straight line.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Width and height sum</h5><div class=\"math-display\"><img src=\"math/49c4a9b06649aac9.svg\" alt=\"b-a=15.4-1=14.4\\qquad u+v=0.6\" style=\"width:38.5ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Area</h5><div class=\"math-display\"><img src=\"math/344db3e57e5c18d1.svg\" alt=\"A=14.4\\times0.6/2=8.64/2=4.32\" style=\"width:32.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. First bracket term</h5><div class=\"math-display\"><img src=\"math/f077b4473411d432.svg\" alt=\"(2a+b)u=(2+15.4)\\times0=0\" style=\"width:29.861ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Second bracket term</h5><div class=\"math-display\"><img src=\"math/79c1733b7155a919.svg\" alt=\"(a+2b)v=(1+30.8)\\times0.6=31.8\\times0.6=19.08\" style=\"width:48.144ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Moment</h5><div class=\"math-display\"><img src=\"math/26cef63984606712.svg\" alt=\"M=(14.4/6)(0+19.08)=2.4\\times19.08=45.792\" style=\"width:47.381ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Area=4.32; moment=45.792. Repeat the same arithmetic for each row, then sum the areas and moments separately.</div></section></div>\r\n<!-- depth:centroid-working:end --><h3>Interpret the loan result using an explicit decision rule</h3><p>Choose the output label having the greatest membership at the centroid; this is an additional stated interpretation rule. At z=42.780888139:</p><div class=\"math-display\"><img src=\"math/388fb9433b0d08db.svg\" alt=\"\\mu_{Reject}=(50-z)/25\\approx0.288764474,\\quad\\mu_{Consider}=(z-25)/25\\approx0.711235526,\\quad\\mu_{Approve}=0\" style=\"width:90.776ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><p>The resulting recommendation is <strong>Consider / manual review</strong>; 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.</p>"},{"id":"q4a","title":"Q4(a) Cartesian product and max–min composition [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The fuzzy sets or relation matrices and their listed row/column order.</p><h4>To find</h4><p>The relation matrix/matrices and the composition specified in the question.</p></div><h4>Formula and why it applies</h4><p>For Cartesian products take min of row and column membership. For the ordered matrix composition shown here: <div class=\"math-display\"><img src=\"math/1a39e95150df91b7.svg\" alt=\"T_{ik}=\\max_j\\min(S_{ij},R_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div> If max–product is asked instead, replace the inner min by multiplication.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. R = A × B (rows small, medium, large; columns slow, moderate, fast)</h5>\r\n<div class=\"math-display\"><img src=\"math/9db67d15872888f6.svg\" alt=\"R=\\begin{bmatrix}\\min(.4,.2)&amp;\\min(.4,.7)&amp;\\min(.4,.3)\\\\\\min(.3,.2)&amp;\\min(.3,.7)&amp;\\min(.3,.3)\\\\\\min(.1,.2)&amp;\\min(.1,.7)&amp;\\min(.1,.3)\\end{bmatrix}=\\begin{bmatrix}0.2&amp;0.4&amp;0.3\\\\0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\end{bmatrix}\" style=\"width:61.686ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. S = C × B</h5>\r\n<div class=\"math-display\"><img src=\"math/03c1b332a4b4facf.svg\" alt=\"S=\\begin{bmatrix}0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\\\0.2&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:20.694ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. S ∘ R by max–min (row of S with column of R)</h5>\r\n<p>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.</p>\r\n<div class=\"math-display\"><img src=\"math/2134a14de60dd459.svg\" alt=\"(1,1)=\\max[\\min(.2,.2),\\min(.3,.2),\\min(.3,.1)]=\\max(.2,.2,.1)=0.2\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/b81568f26ae092d4.svg\" alt=\"(1,2)=\\max[\\min(.2,.4),\\min(.3,.3),\\min(.3,.1)]=\\max(.2,.3,.1)=0.3\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/0857c1f332a31d0c.svg\" alt=\"(1,3)=\\max[\\min(.2,.3),\\min(.3,.3),\\min(.3,.1)]=0.3\" style=\"width:51.609ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Row 2 of S is all 0.1, so every entry of row 2 is 0.1.</p>\r\n<div class=\"math-display\"><img src=\"math/7cbca4576287a20a.svg\" alt=\"(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\" style=\"width:108.309ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/564480fc64ab9d52.svg\" alt=\"S\\circ R=\\begin{bmatrix}0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\\\0.2&amp;0.3&amp;0.3\\end{bmatrix}\" style=\"width:24.548ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> 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.</div>\r\n<div class=\"note\"><strong>A careful remark you can add.</strong> 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.</div>\r\n</section>\r\n\r\n<!-- depth:all-cells:start -->\r\n<div class=\"concept-bridge\"><h2>Every cell without the row shortcuts</h2><p>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.</p><h3>R: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>R11</td><td>0.4</td><td>0.2</td><td>0.2</td></tr><tr><td>R12</td><td>0.4</td><td>0.7</td><td>0.4</td></tr><tr><td>R13</td><td>0.4</td><td>0.3</td><td>0.3</td></tr><tr><td>R21</td><td>0.3</td><td>0.2</td><td>0.2</td></tr><tr><td>R22</td><td>0.3</td><td>0.7</td><td>0.3</td></tr><tr><td>R23</td><td>0.3</td><td>0.3</td><td>0.3</td></tr><tr><td>R31</td><td>0.1</td><td>0.2</td><td>0.1</td></tr><tr><td>R32</td><td>0.1</td><td>0.7</td><td>0.1</td></tr><tr><td>R33</td><td>0.1</td><td>0.3</td><td>0.1</td></tr></tbody></table><h3>S: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>S11</td><td>0.3</td><td>0.2</td><td>0.2</td></tr><tr><td>S12</td><td>0.3</td><td>0.7</td><td>0.3</td></tr><tr><td>S13</td><td>0.3</td><td>0.3</td><td>0.3</td></tr><tr><td>S21</td><td>0.1</td><td>0.2</td><td>0.1</td></tr><tr><td>S22</td><td>0.1</td><td>0.7</td><td>0.1</td></tr><tr><td>S23</td><td>0.1</td><td>0.3</td><td>0.1</td></tr><tr><td>S31</td><td>0.4</td><td>0.2</td><td>0.2</td></tr><tr><td>S32</td><td>0.4</td><td>0.7</td><td>0.4</td></tr><tr><td>S33</td><td>0.4</td><td>0.3</td><td>0.3</td></tr></tbody></table><p><strong>Result cell (1,1)</strong></p><div class=\"math-display\"><img src=\"math/04a79caa9a98c1c4.svg\" alt=\"\\max\\{\\min(0.2,0.2),\\min(0.3,0.2),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,2)</strong></p><div class=\"math-display\"><img src=\"math/fb42face9e153c77.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.3,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,3)</strong></p><div class=\"math-display\"><img src=\"math/4535d46543709132.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.3,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,1)</strong></p><div class=\"math-display\"><img src=\"math/b8bd41528e9d1a36.svg\" alt=\"\\max\\{\\min(0.1,0.2),\\min(0.1,0.2),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,2)</strong></p><div class=\"math-display\"><img src=\"math/9eda900daa88d0f0.svg\" alt=\"\\max\\{\\min(0.1,0.4),\\min(0.1,0.3),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,3)</strong></p><div class=\"math-display\"><img src=\"math/a0554ac89675d583.svg\" alt=\"\\max\\{\\min(0.1,0.3),\\min(0.1,0.3),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,1)</strong></p><div class=\"math-display\"><img src=\"math/7738d5099a9e3ab1.svg\" alt=\"\\max\\{\\min(0.2,0.2),\\min(0.4,0.2),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,2)</strong></p><div class=\"math-display\"><img src=\"math/952b0167063f5e45.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,3)</strong></p><div class=\"math-display\"><img src=\"math/859d029599adbb59.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:all-cells:end -->"},{"id":"q5b","title":"Q5(b) Genetic algorithm [10]","html":"<p class=\"question\"><strong>Implement a GA to maximise <span class=\"math-inline\"><img src=\"math/aacd674038ffd6be.svg\" alt=\"f(x)=2x^3-5x^2+7x\" style=\"width:22.099ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> 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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><p><strong>The printed data are inconsistent.</strong> 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.</p><p>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.</p><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Two valid children under the declared assumptions and their fitness.</p></div><h4>Formula and why it applies</h4><p>Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.</p><div class=\"math-display\"><img src=\"math/fb065d212fc56261.svg\" alt=\"f(x)=2x^3-5x^2+7x\" style=\"width:22.099ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Encode and evaluate the declared parent population</h5><table><thead><tr><th>x</th><th>Binary</th><th>Fitness substitution</th></tr></thead><tbody><tr><td>13</td><td>1101</td><td>2(13³) − 5(13²) + 7(13) = 3640</td></tr><tr><td>6</td><td>0110</td><td>2(6³) − 5(6²) + 7(6) = 294</td></tr><tr><td>2</td><td>0010</td><td>2(2³) − 5(2²) + 7(2) = 10</td></tr><tr><td>7</td><td>0111</td><td>2(7³) − 5(7²) + 7(7) = 490</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Select the two fittest under the stated assumption</h5><p>[13, 7] with fitness [3640, 490].</p></div><div class=\"step\"><h5>Step 3. Cut after bit 2 and exchange tails</h5><table><thead><tr><th>Parent 1</th><th>Parent 2</th><th>Child 1</th><th>Child 2</th></tr></thead><tbody><tr><td>11 | 01</td><td>01 | 11</td><td>1111</td><td>0101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Flip the last bit of each child</h5><table><thead><tr><th>Before</th><th>After</th><th>Decoded x</th></tr></thead><tbody><tr><td>1111</td><td>1110</td><td>14</td></tr><tr><td>0101</td><td>0100</td><td>4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Evaluate both children</h5><table><thead><tr><th>x</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>14</td><td>2(2744) − 5(196) + 7(14) = 4606</td></tr><tr><td>4</td><td>2(64) − 5(16) + 7(4) = 76</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Compare with the selected parents</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:polynomial-working:start -->\r\n<div class=\"concept-bridge\"><h2>Evaluate the polynomial without skipping the powers</h2><p>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.</p><h3>x=13</h3><div class=\"math-display\"><img src=\"math/3b2d51c91ac2cf33.svg\" alt=\"x^2=13\\times13=169\\qquad x^3=169\\times13=2197\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b223b59b645fb4b2.svg\" alt=\"2x^3=4394\\quad 5x^2=845\\quad 7x=91\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/729d7b573feaaf95.svg\" alt=\"f(13)=4394-845+91=3640\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=6</h3><div class=\"math-display\"><img src=\"math/4a05c63ed6e04319.svg\" alt=\"x^2=6\\times6=36\\qquad x^3=36\\times6=216\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/402fc08edced6189.svg\" alt=\"2x^3=432\\quad 5x^2=180\\quad 7x=42\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a5f219480ddd154a.svg\" alt=\"f(6)=432-180+42=294\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=2</h3><div class=\"math-display\"><img src=\"math/3a35f3beb07d2871.svg\" alt=\"x^2=2\\times2=4\\qquad x^3=4\\times2=8\" style=\"width:33.476ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/42f55d86ed2302e7.svg\" alt=\"2x^3=16\\quad 5x^2=20\\quad 7x=14\" style=\"width:29.615ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/235889b9921ff9b5.svg\" alt=\"f(2)=16-20+14=10\" style=\"width:24.751ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=7</h3><div class=\"math-display\"><img src=\"math/eac1f56ad09d694c.svg\" alt=\"x^2=7\\times7=49\\qquad x^3=49\\times7=343\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e9a8667a88c96f77.svg\" alt=\"2x^3=686\\quad 5x^2=245\\quad 7x=49\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8c54966ea16cb628.svg\" alt=\"f(7)=686-245+49=490\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=15</h3><div class=\"math-display\"><img src=\"math/8c2aaf117e33ac77.svg\" alt=\"x^2=15\\times15=225\\qquad x^3=225\\times15=3375\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9652ff9e90959bb5.svg\" alt=\"2x^3=6750\\quad 5x^2=1125\\quad 7x=105\" style=\"width:35.271ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1609c9dac811fd7a.svg\" alt=\"f(15)=6750-1125+105=5730\" style=\"width:33.801ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=5</h3><div class=\"math-display\"><img src=\"math/63703f64d73bd95d.svg\" alt=\"x^2=5\\times5=25\\qquad x^3=25\\times5=125\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c7ab1b91c2eced73.svg\" alt=\"2x^3=250\\quad 5x^2=125\\quad 7x=35\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b80fc8e2e02f0c86.svg\" alt=\"f(5)=250-125+35=160\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=14</h3><div class=\"math-display\"><img src=\"math/13e67d57f1606f3f.svg\" alt=\"x^2=14\\times14=196\\qquad x^3=196\\times14=2744\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7a11853924c667dd.svg\" alt=\"2x^3=5488\\quad 5x^2=980\\quad 7x=98\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4be8ca3a4ac49622.svg\" alt=\"f(14)=5488-980+98=4606\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=4</h3><div class=\"math-display\"><img src=\"math/9c1546066fc40eda.svg\" alt=\"x^2=4\\times4=16\\qquad x^3=16\\times4=64\" style=\"width:36.869ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a4dd7bf5365d3c7e.svg\" alt=\"2x^3=128\\quad 5x^2=80\\quad 7x=28\" style=\"width:30.746ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/818af979753c0a98.svg\" alt=\"f(4)=128-80+28=76\" style=\"width:25.882ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>“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.</p></div>\r\n<!-- depth:polynomial-working:end -->"},{"id":"q6a","title":"Q6(a) Applications of fuzzy logic [10]","html":"<p class=\"question\"><strong>List the applications of fuzzy logic. Explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition</h3>\r\n<p>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”.</p>\r\n<h3>Applications</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Area</th><th>Examples</th></tr></thead><tbody>\r\n<tr><td>Home appliances</td><td>Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners</td></tr>\r\n<tr><td>Automotive</td><td>Automatic transmission, anti-lock braking (ABS), cruise control, engine control</td></tr>\r\n<tr><td>Transportation</td><td>Traffic-signal control, Sendai subway train control (smooth braking and acceleration)</td></tr>\r\n<tr><td>Consumer electronics</td><td>Camera autofocus and auto-exposure, image stabilisation</td></tr>\r\n<tr><td>Industrial control</td><td>Cement kilns, pH, temperature and distillation control in chemical plants</td></tr>\r\n<tr><td>Aerospace</td><td>Satellite and spacecraft attitude control</td></tr>\r\n<tr><td>Medicine</td><td>Diagnosis support, anaesthesia dosage control</td></tr>\r\n<tr><td>Finance and decisions</td><td>Loan approval, credit and fire-risk scoring, stock trading rules</td></tr>\r\n<tr><td>AI and robotics</td><td>Robot navigation, natural-language interfaces, expert systems</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>One application in detail: fuzzy washing machine</h3>\r\n<ol>\r\n<li><strong>Problem.</strong> 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.</li>\r\n<li><strong>Inputs and outputs.</strong> 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.</li>\r\n<li><strong>Fuzzification.</strong> Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.</li>\r\n<li><strong>Rule base.</strong> 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.</li>\r\n<li><strong>Inference.</strong> Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.</li>\r\n<li><strong>Defuzzification.</strong> 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.</li>\r\n<li><strong>Benefits.</strong> Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.</li>\r\n</ol>\r\n<h3>Advantages and disadvantages (bonus)</h3>\r\n<p><strong>Advantages:</strong> handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. <strong>Disadvantages:</strong> 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.</p>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.</div>\r\n"},{"id":"q7a","title":"Q7(a) Applications of PSO [10]","html":"<p class=\"question\"><strong>List the applications of Particle Swarm Optimization and explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Function optimisation</strong>: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.</li>\r\n<li><strong>Neural-network training</strong>: optimising weights and biases (your Lab 8 uses the pyswarms library for this).</li>\r\n<li><strong>Hyper-parameter tuning</strong> of ML models (learning rate, number of hidden units, SVM C and γ).</li>\r\n<li><strong>Feature selection</strong>: choosing the most useful subset of features (binary PSO).</li>\r\n<li><strong>Image processing</strong>: threshold selection for segmentation, edge detection, image enhancement.</li>\r\n<li><strong>Path planning</strong> for robots and drones: shortest collision-free path.</li>\r\n<li><strong>Power systems</strong>: economic load dispatch, optimal placement of capacitors.</li>\r\n<li><strong>Control engineering</strong>: tuning PID controller gains.</li>\r\n<li><strong>Scheduling and wireless sensor networks</strong>: job scheduling, sensor node placement and clustering.</li>\r\n</ol>\r\n\r\n<h3>One application in detail: training a neural network with PSO</h3>\r\n<div class=\"flow\"><div class=\"node\">Training data</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Neural network with weights = particle position</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Error (fitness)</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">PSO moves the weights</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Best weights = gbest</div></div>\r\n<ol>\r\n<li><strong>Encoding.</strong> 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.</li>\r\n<li><strong>Fitness.</strong> 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).</li>\r\n<li><strong>Search.</strong> 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).</li>\r\n<li><strong>Stop</strong> after a fixed number of iterations or when the error stops improving; gbest is the trained network.</li>\r\n<li><strong>Why PSO here:</strong> 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. <strong>Limitation:</strong> 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.</li>\r\n</ol>\r\n\r\n<h3>Advantages and disadvantages (add for 10 marks)</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Disadvantages</th></tr></thead><tbody>\r\n<tr><td>Simple to implement; few parameters (w, c₁, c₂)</td><td>Can converge prematurely to a local optimum</td></tr>\r\n<tr><td>No derivatives needed</td><td>Sensitive to parameter choice</td></tr>\r\n<tr><td>Fast convergence in early iterations; memory (pbest, gbest)</td><td>No guarantee of the global optimum</td></tr>\r\n<tr><td>Objective evaluations can be parallel; particles share information through gbest</td><td>Less suited to discrete problems without modification</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<p class=\"marks-split\">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).</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.</div>\r\n"}]},{"id":"paper-reexam-2026","title":"Re-examination · 31 Jan 2026","unit":"paper","scope":"Longer past-paper practice restricted to Fuzzy, GA and PSO.","sections":[{"id":"q1b","title":"Q1(b) Applications of PSO [5]","html":"<p class=\"question\"><strong>List the applications of Particle Swarm Optimization and explain any one application in detail.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3>\r\n\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Function optimisation</strong>: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.</li>\r\n<li><strong>Neural-network training</strong>: optimising weights and biases (your Lab 8 uses the pyswarms library for this).</li>\r\n<li><strong>Hyper-parameter tuning</strong> of ML models (learning rate, number of hidden units, SVM C and γ).</li>\r\n<li><strong>Feature selection</strong>: choosing the most useful subset of features (binary PSO).</li>\r\n<li><strong>Image processing</strong>: threshold selection for segmentation, edge detection, image enhancement.</li>\r\n<li><strong>Path planning</strong> for robots and drones: shortest collision-free path.</li>\r\n<li><strong>Power systems</strong>: economic load dispatch, optimal placement of capacitors.</li>\r\n<li><strong>Control engineering</strong>: tuning PID controller gains.</li>\r\n<li><strong>Scheduling and wireless sensor networks</strong>: job scheduling, sensor node placement and clustering.</li>\r\n</ol>\r\n\r\n<h3>One application in detail: training a neural network with PSO</h3>\r\n<div class=\"flow\"><div class=\"node\">Training data</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Neural network with weights = particle position</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Error (fitness)</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">PSO moves the weights</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Best weights = gbest</div></div>\r\n<ol>\r\n<li><strong>Encoding.</strong> 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.</li>\r\n<li><strong>Fitness.</strong> 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).</li>\r\n<li><strong>Search.</strong> 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).</li>\r\n<li><strong>Stop</strong> after a fixed number of iterations or when the error stops improving; gbest is the trained network.</li>\r\n<li><strong>Why PSO here:</strong> 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. <strong>Limitation:</strong> 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.</li>\r\n</ol>\r\n\r\n<h3>Advantages and disadvantages (add for 10 marks)</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Disadvantages</th></tr></thead><tbody>\r\n<tr><td>Simple to implement; few parameters (w, c₁, c₂)</td><td>Can converge prematurely to a local optimum</td></tr>\r\n<tr><td>No derivatives needed</td><td>Sensitive to parameter choice</td></tr>\r\n<tr><td>Fast convergence in early iterations; memory (pbest, gbest)</td><td>No guarantee of the global optimum</td></tr>\r\n<tr><td>Objective evaluations can be parallel; particles share information through gbest</td><td>Less suited to discrete problems without modification</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<p class=\"marks-split\">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).</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.</div>\r\n"},{"id":"q1c","title":"Q1(c) Fuzzy set operations [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The aligned X and Y memberships printed in this question.</p><h4>To find</h4><p>The four requested membership lists in the original element order.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1−μ for NOT. <div class=\"math-display\"><img src=\"math/e32ad02c5ba3dae5.svg\" alt=\"\\mu_{X\\cup Y}=\\max(\\mu_X,\\mu_Y),\\quad\\mu_{X\\cap Y}=\\min(\\mu_X,\\mu_Y)\" style=\"width:44.598ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div> Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.</p><h4>Solution</h4>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th></tr></thead><tbody>\r\n<tr><td>¬X</td><td>0.3</td><td>0.1</td><td>0.8</td><td>0.6</td><td>0.1</td></tr>\r\n<tr><td>¬Y</td><td>0.4</td><td>0.7</td><td>0.2</td><td>0.3</td><td>0.9</td></tr>\r\n<tr><td><strong>X ∪ Y</strong></td><td>0.7</td><td>0.9</td><td>0.8</td><td>0.7</td><td>0.9</td></tr>\r\n<tr><td><strong>X ∩ Y</strong></td><td>0.6</td><td>0.3</td><td>0.2</td><td>0.4</td><td>0.1</td></tr>\r\n<tr><td><strong>¬X ∪ ¬Y</strong></td><td>0.4</td><td>0.7</td><td>0.8</td><td>0.6</td><td>0.9</td></tr>\r\n<tr><td><strong>¬X ∩ ¬Y</strong></td><td>0.3</td><td>0.1</td><td>0.2</td><td>0.3</td><td>0.1</td></tr>\r\n</tbody></table></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> As in the last four rows. De Morgan check: ¬X ∪ ¬Y = 1 − (X ∩ Y) and ¬X ∩ ¬Y = 1 − (X ∪ Y) ✓.</div>\r\n</section>\r\n\r\n<!-- depth:element-working:start -->\r\n<div class=\"concept-bridge\"><h2>Calculate every element separately</h2><h3>Element c1</h3><div class=\"math-display\"><img src=\"math/c590062072bce4a3.svg\" alt=\"\\neg X:1-0.7=0.3\\qquad\\neg Y:1-0.6=0.4\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a2eea0fe6bbb6b87.svg\" alt=\"X\\cup Y:\\max(0.7,0.6)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ecd4a7a60c39fa85.svg\" alt=\"X\\cap Y:\\min(0.7,0.6)=0.6\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1aca856a2f38fa09.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.3,0.4)=0.4\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4ef33b6f553800c5.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.3,0.4)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c2</h3><div class=\"math-display\"><img src=\"math/ce24f9cbda57e56d.svg\" alt=\"\\neg X:1-0.9=0.1\\qquad\\neg Y:1-0.3=0.7\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/05dee517321dfca3.svg\" alt=\"X\\cup Y:\\max(0.9,0.3)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4a2bc31233f313e7.svg\" alt=\"X\\cap Y:\\min(0.9,0.3)=0.3\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b188e2e037566b1e.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.1,0.7)=0.7\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/82b3199ed4befd72.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.1,0.7)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c3</h3><div class=\"math-display\"><img src=\"math/24c8a43adb44c324.svg\" alt=\"\\neg X:1-0.2=0.8\\qquad\\neg Y:1-0.8=0.2\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ddba21d8acd6b044.svg\" alt=\"X\\cup Y:\\max(0.2,0.8)=0.8\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/247907e255730431.svg\" alt=\"X\\cap Y:\\min(0.2,0.8)=0.2\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/41e12e8e143ca16d.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.8,0.2)=0.8\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ea5cfbc43203761d.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.8,0.2)=0.2\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c4</h3><div class=\"math-display\"><img src=\"math/0b5f5f89785edd94.svg\" alt=\"\\neg X:1-0.4=0.6\\qquad\\neg Y:1-0.7=0.3\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/05b7177b2b3fbf81.svg\" alt=\"X\\cup Y:\\max(0.4,0.7)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1cfa1c76382cbe6b.svg\" alt=\"X\\cap Y:\\min(0.4,0.7)=0.4\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1568254a4bf6e796.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.6,0.3)=0.6\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/edebdcb00abb9544.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.6,0.3)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c5</h3><div class=\"math-display\"><img src=\"math/f594ae61dd359b85.svg\" alt=\"\\neg X:1-0.9=0.1\\qquad\\neg Y:1-0.1=0.9\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/da89b631e703aa27.svg\" alt=\"X\\cup Y:\\max(0.9,0.1)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5461384d5ad733c2.svg\" alt=\"X\\cap Y:\\min(0.9,0.1)=0.1\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2a8b87917a1340f9.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.1,0.9)=0.9\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/601ec64fa8926431.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.1,0.9)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:element-working:end -->"},{"id":"q2a","title":"Q2(a) Fuzzy fire-hazard system [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Crisp value</th></tr></thead><tbody><tr><td>Temperature</td><td>65</td></tr><tr><td>Smoke Level</td><td>80</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>A complete stated design and its continuous Mamdani centroid.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/5aa4acd6aab4215a.svg\" alt=\"z^*=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:18.101ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Specify the membership functions</h5><table><thead><tr><th>Input / output position</th><th>Triangle</th><th>Peak</th></tr></thead><tbody><tr><td>Low / Low</td><td>(1,25,50)</td><td>25</td></tr><tr><td>Medium / Moderate</td><td>(25,50,75)</td><td>50</td></tr><tr><td>High / High</td><td>(50,75,100)</td><td>75</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 2. Write all nine rules</h5><table><thead><tr><th>Temperature / Smoke Level</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>Low</td><td>Moderate</td></tr><tr><td>Medium</td><td>Low</td><td>Moderate</td><td>High</td></tr><tr><td>High</td><td>Moderate</td><td>High</td><td>High</td></tr></tbody></table><p>Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.</p></div><div class=\"step\"><h5>Step 3. Fuzzify Temperature = 65</h5><div class=\"math-display\"><img src=\"math/9e3859fafc31a24f.svg\" alt=\"\\mu_{Low}(65)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f35f654b9795c088.svg\" alt=\"\\mu_{Medium}(65)=\\frac{75-65}{75-50}=0.4\" style=\"width:28.917ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/de5666dfbbcb02fc.svg\" alt=\"\\mu_{High}(65)=\\frac{65-50}{75-50}=0.6\" style=\"width:26.443ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Fuzzify Smoke Level = 80</h5><div class=\"math-display\"><img src=\"math/0a1689e705282396.svg\" alt=\"\\mu_{Low}(80)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af4f190a786e2c05.svg\" alt=\"\\mu_{Medium}(80)=0\" style=\"width:15.853ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ec0cdd51e84c6204.svg\" alt=\"\\mu_{High}(80)=\\frac{100-80}{100-75}=0.8\" style=\"width:27.575ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Evaluate all rules and aggregate matching consequents</h5><table><thead><tr><th>Temperature</th><th>Smoke Level</th><th>Firing strength</th><th>Consequent</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>min(0,0) = 0</td><td>Low</td></tr><tr><td>Low</td><td>Medium</td><td>min(0,0) = 0</td><td>Low</td></tr><tr><td>Low</td><td>High</td><td>min(0,0.8) = 0</td><td>Moderate</td></tr><tr><td>Medium</td><td>Low</td><td>min(0.4,0) = 0</td><td>Low</td></tr><tr><td>Medium</td><td>Medium</td><td>min(0.4,0) = 0</td><td>Moderate</td></tr><tr><td>Medium</td><td>High</td><td>min(0.4,0.8) = 0.4</td><td>High</td></tr><tr><td>High</td><td>Low</td><td>min(0.6,0) = 0</td><td>Moderate</td></tr><tr><td>High</td><td>Medium</td><td>min(0.6,0) = 0</td><td>High</td></tr><tr><td>High</td><td>High</td><td>min(0.6,0.8) = 0.6</td><td>High</td></tr></tbody></table><p>Aggregated label strengths: Low = 0, Moderate = 0, High = 0.6.</p><div class=\"math-display\"><img src=\"math/d1c2a08444481d0c.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:29.283ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Draw the aggregated output</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fire_aggregate.e0cab4ad42.svg\" width=\"680\" height=\"300\" alt=\"The shaded upper envelope counts any overlap only once.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The shaded upper envelope counts any overlap only once.</figcaption></figure></div><div class=\"step\"><h5>Step 7. Calculate area and moment of each straight-line strip</h5><p>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.</p><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d68335c9ce0df62c.svg\" alt=\"M=\\frac{b-a}{6}\\big[(2a+b)u+(a+2b)v\\big]\" style=\"width:34.017ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>50</td><td>65</td><td>0</td><td>0.6</td><td>4.5</td><td>270</td></tr><tr><td>65</td><td>85</td><td>0.6</td><td>0.6</td><td>12</td><td>900</td></tr><tr><td>85</td><td>100</td><td>0.6</td><td>0</td><td>4.5</td><td>405</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Divide total moment by total area</h5><div class=\"math-display\"><img src=\"math/2ffb3645f0d4cc76.svg\" alt=\"\\sum A=21\" style=\"width:10.62ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0a14da79e18490bb.svg\" alt=\"\\sum M=1575\" style=\"width:13.564ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/647a203082aabc5c.svg\" alt=\"z^*=\\frac{1575}{21}\\approx75\" style=\"width:15.857ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> For these stated triangles and rules, the centroid is 75. This is in the high-risk region of this illustrative fuzzy design.</div></section><p>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.</p>\r\n\r\n<!-- depth:centroid-working:start -->\r\n<div class=\"concept-bridge\"><h2>Why the clipped High shape is symmetric about 75</h2><p>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.</p><table><thead><tr><th>Piece</th><th>Area calculation</th><th>Centre</th><th>Moment</th></tr></thead><tbody><tr><td>Left triangle [50,65]</td><td>½×15×.6=4.5</td><td>(50+65+65)/3=60</td><td>4.5×60=270</td></tr><tr><td>Rectangle [65,85]</td><td>20×.6=12</td><td>(65+85)/2=75</td><td>12×75=900</td></tr><tr><td>Right triangle [85,100]</td><td>½×15×.6=4.5</td><td>(85+85+100)/3=90</td><td>4.5×90=405</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:centroid-working:end -->"},{"id":"q3b","title":"Q3(b) Fuzzy relations and composition [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The fuzzy sets or relation matrices and their listed row/column order.</p><h4>To find</h4><p>The relation matrix/matrices and the composition specified in the question.</p></div><h4>Formula and why it applies</h4><p>For Cartesian products take min of row and column membership. For the ordered matrix composition shown here: <div class=\"math-display\"><img src=\"math/1a39e95150df91b7.svg\" alt=\"T_{ik}=\\max_j\\min(S_{ij},R_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div> If max–product is asked instead, replace the inner min by multiplication.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. R and S</h5>\r\n<div class=\"math-display\"><img src=\"math/463247054a5e2b55.svg\" alt=\"R=\\begin{bmatrix}0.4&amp;0.6&amp;0.3\\\\0.4&amp;0.4&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\end{bmatrix},\\qquad S=\\begin{bmatrix}0.4&amp;0.5&amp;0.3\\\\0.2&amp;0.2&amp;0.2\\\\0.4&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:47.176ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. S ∘ R</h5>\r\n<div class=\"math-display\"><img src=\"math/07a16abae3efd072.svg\" alt=\"(1,1)=\\max[\\min(.4,.4),\\min(.5,.4),\\min(.3,.1)]=\\max(.4,.4,.1)=0.4\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/8e54167083aa61b1.svg\" alt=\"(1,2)=\\max[\\min(.4,.6),\\min(.5,.4),\\min(.3,.1)]=\\max(.4,.4,.1)=0.4\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/6ce0ff88a64ad0ef.svg\" alt=\"(1,3)=\\max[\\min(.4,.3),\\min(.5,.3),\\min(.3,.1)]=0.3\" style=\"width:51.609ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c87a743bfa211789.svg\" alt=\"\\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\" style=\"width:100.894ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/f54af3b992bbd86c.svg\" alt=\"R=\\begin{bmatrix}.4&amp;.6&amp;.3\\\\.4&amp;.4&amp;.3\\\\.1&amp;.1&amp;.1\\end{bmatrix}\" style=\"width:17.558ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/acc98fbd37745e57.svg\" alt=\"S=\\begin{bmatrix}.4&amp;.5&amp;.3\\\\.2&amp;.2&amp;.2\\\\.4&amp;.4&amp;.3\\end{bmatrix}\" style=\"width:17.3ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/291bb354e326dcfa.svg\" alt=\"S\\circ R=\\begin{bmatrix}0.4&amp;0.4&amp;0.3\\\\0.2&amp;0.2&amp;0.2\\\\0.4&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:24.548ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>. (The key gives R and S only.)</div>\r\n</section>\r\n\r\n<!-- depth:all-cells:start -->\r\n<div class=\"concept-bridge\"><h2>Every cell without the row shortcuts</h2><p>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.</p><h3>R: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>R11</td><td>0.6</td><td>0.4</td><td>0.4</td></tr><tr><td>R12</td><td>0.6</td><td>0.8</td><td>0.6</td></tr><tr><td>R13</td><td>0.6</td><td>0.3</td><td>0.3</td></tr><tr><td>R21</td><td>0.4</td><td>0.4</td><td>0.4</td></tr><tr><td>R22</td><td>0.4</td><td>0.8</td><td>0.4</td></tr><tr><td>R23</td><td>0.4</td><td>0.3</td><td>0.3</td></tr><tr><td>R31</td><td>0.1</td><td>0.4</td><td>0.1</td></tr><tr><td>R32</td><td>0.1</td><td>0.8</td><td>0.1</td></tr><tr><td>R33</td><td>0.1</td><td>0.3</td><td>0.1</td></tr></tbody></table><h3>S: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>S11</td><td>0.5</td><td>0.4</td><td>0.4</td></tr><tr><td>S12</td><td>0.5</td><td>0.8</td><td>0.5</td></tr><tr><td>S13</td><td>0.5</td><td>0.3</td><td>0.3</td></tr><tr><td>S21</td><td>0.2</td><td>0.4</td><td>0.2</td></tr><tr><td>S22</td><td>0.2</td><td>0.8</td><td>0.2</td></tr><tr><td>S23</td><td>0.2</td><td>0.3</td><td>0.2</td></tr><tr><td>S31</td><td>0.4</td><td>0.4</td><td>0.4</td></tr><tr><td>S32</td><td>0.4</td><td>0.8</td><td>0.4</td></tr><tr><td>S33</td><td>0.4</td><td>0.3</td><td>0.3</td></tr></tbody></table><p><strong>Result cell (1,1)</strong></p><div class=\"math-display\"><img src=\"math/21233f6c94b2b173.svg\" alt=\"\\max\\{\\min(0.4,0.4),\\min(0.5,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,2)</strong></p><div class=\"math-display\"><img src=\"math/999b4f88f5256b56.svg\" alt=\"\\max\\{\\min(0.4,0.6),\\min(0.5,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,3)</strong></p><div class=\"math-display\"><img src=\"math/d50a44d1852d902c.svg\" alt=\"\\max\\{\\min(0.4,0.3),\\min(0.5,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f11631b96248ce3d.svg\" alt=\"=\\max\\{0.3,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,1)</strong></p><div class=\"math-display\"><img src=\"math/c683e55ca4bccac0.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.2,0.4),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,2)</strong></p><div class=\"math-display\"><img src=\"math/5eeb6f5598722d4c.svg\" alt=\"\\max\\{\\min(0.2,0.6),\\min(0.2,0.4),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,3)</strong></p><div class=\"math-display\"><img src=\"math/524a01bd31cd2a0e.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.2,0.3),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,1)</strong></p><div class=\"math-display\"><img src=\"math/4c61c54bcac1075e.svg\" alt=\"\\max\\{\\min(0.4,0.4),\\min(0.4,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,2)</strong></p><div class=\"math-display\"><img src=\"math/cedfe000344abbe9.svg\" alt=\"\\max\\{\\min(0.4,0.6),\\min(0.4,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,3)</strong></p><div class=\"math-display\"><img src=\"math/98186c591a86ee1c.svg\" alt=\"\\max\\{\\min(0.4,0.3),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f11631b96248ce3d.svg\" alt=\"=\\max\\{0.3,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:all-cells:end -->"},{"id":"q4a","title":"Q4(a) PSO, one iteration [10]","html":"<p class=\"question\"><strong>Question. Maximize <span class=\"math-inline\"><img src=\"math/523616224185a5ce.svg\" alt=\"F(x)=x_1^2-x_1x_2+x_2^2+3x_1+4x_2+5\" style=\"width:38.679ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using Particle Swarm Optimization. <span class=\"math-inline\"><img src=\"math/0ba0d9983a41cf83.svg\" alt=\"X=\\begin{bmatrix}3.1472&amp;-4.0246\\\\4.0579&amp;-2.2150\\end{bmatrix},\\;V=\\begin{bmatrix}0.2194&amp;0.2449\\\\0.1908&amp;0.2228\\end{bmatrix}\" style=\"width:47.54ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Take <span class=\"math-inline\"><img src=\"math/d99737a5fc79423b.svg\" alt=\"W=0.9,\\;c_1=c_2=1.5,\\;r_1=0.5949,\\;r_2=0.0855\" style=\"width:48.665ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></span>. Optimize and give the solution after 1 iteration showing the step-by-step process.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4><p>P1: <span class=\"math-inline\"><img src=\"math/f58367ac748ee874.svg\" alt=\"x=(3.1472,\\,-4.0246)\" style=\"width:21.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/582ec15d8b22479d.svg\" alt=\"v=(0.2194,\\,0.2449)\" style=\"width:19.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. P2: <span class=\"math-inline\"><img src=\"math/1588eb472c257b22.svg\" alt=\"x=(4.0579,\\,-2.2150)\" style=\"width:21.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/ea7da7e3a3880e01.svg\" alt=\"v=(0.1908,\\,0.2228)\" style=\"width:19.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. <span class=\"math-inline\"><img src=\"math/37a512f090105dd3.svg\" alt=\"c_1r_1=0.89235\" style=\"width:14.409ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/c760fda5e7728aea.svg\" alt=\"c_2r_2=0.12825\" style=\"width:14.409ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p>Updated velocities, positions, pbest and gbest after one iteration.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/d17ec7429fc5876d.svg\" alt=\"v^{new}=wv+c_1r_1(pbest-x)+c_2r_2(gbest-x),\\quad x^{new}=x+v^{new}\" style=\"width:63.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Fitness of P1 (term by term)</h5>\r\n<div class=\"math-display\"><img src=\"math/3c47a0a1f1465e31.svg\" alt=\"x_1^2=9.904868,\\;-x_1x_2=+12.666221,\\;x_2^2=16.197405,\\;3x_1=9.4416,\\;4x_2=-16.0984\" style=\"width:84.466ex;height:2.559ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/10f900e5ecd1d222.svg\" alt=\"F_1=9.904868+12.666221+16.197405+9.4416-16.0984+5=37.1117\" style=\"width:72.459ex;height:1.878ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Fitness of P2</h5>\r\n<div class=\"math-display\"><img src=\"math/323572bf8ccf630b.svg\" alt=\"F_2=16.466552+8.988249+4.906225+12.1737-8.86+5=38.6747\" style=\"width:69.065ex;height:1.878ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. pbest and gbest</h5><p>pbest = current positions. <span class=\"math-inline\"><img src=\"math/0858b2bce4269ef8.svg\" alt=\"38.6747&gt;37.1117\" style=\"width:17.85ex;height:1.622ex\" loading=\"lazy\" decoding=\"async\"></span>, so <strong>gbest = P2 = (4.0579, −2.2150)</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 4. Particle 1 updates</h5>\r\n<div class=\"math-display\"><img src=\"math/0c6669f7602148c0.svg\" alt=\"v_{11}=0.9(0.2194)+0+0.12825(4.0579-3.1472)=0.19746+0.116797=0.314257\" style=\"width:81.325ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c789efe14e1349c9.svg\" alt=\"x_{11}=3.1472+0.314257=3.461457\" style=\"width:35.262ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/82dc2ed77545eeb8.svg\" alt=\"v_{12}=0.9(0.2449)+0+0.12825(-2.2150+4.0246)=0.22041+0.232081=0.452491\" style=\"width:83.085ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/daa1f4fff8808c55.svg\" alt=\"x_{12}=-4.0246+0.452491=-3.572109\" style=\"width:38.782ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 5. Particle 2 updates (gbest particle: only inertia acts)</h5>\r\n<div class=\"math-display\"><img src=\"math/42d42b7358982c8c.svg\" alt=\"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\" style=\"width:95.402ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 6. New fitness and bests</h5><div data-v2-fitness=\"true\"><p>Use the same objective at each new position. Keep full precision internally; displayed coordinates are rounded.</p><div class=\"math-display\"><img src=\"math/b030a3c1723e90f0.svg\" alt=\"F(3.461457275,-3.5721088)=(3.461457275)^2-(3.461457275)(-3.5721088)+(-3.5721088)^2+3(3.461457275)+4(-3.5721088)+5\" style=\"width:130.757ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/246cb1e4add2ab6e.svg\" alt=\"=11.981686467+12.364701993+12.759961279+10.384371825+(-14.2884352)+5\\approx38.202286364\" style=\"width:100.058ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3fe27d20d1a3f2c2.svg\" alt=\"F(4.22962,-2.01448)=(4.22962)^2-(4.22962)(-2.01448)+(-2.01448)^2+3(4.22962)+4(-2.01448)+5\" style=\"width:103.608ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a64c8baf9521e960.svg\" alt=\"=17.889685344+8.520484898+4.05812967+12.68886+(-8.05792)+5\\approx40.099239912\" style=\"width:88.746ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>New position</th><th>New F</th><th>Old F</th><th>pbest</th></tr></thead><tbody>\r\n<tr><td>1</td><td>(3.461457, −3.572109)</td><td>38.2023</td><td>37.1117</td><td>updated</td></tr>\r\n<tr><td>2</td><td>(4.22962, −2.01448)</td><td>40.0992</td><td>38.6747</td><td>updated</td></tr></tbody></table></div>\r\n<p>The best pbest is now P2's with F = 40.0992, so gbest moves to (4.22962, −2.01448).</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/181c38752c9bafe9.svg\" alt=\"V=\\begin{bmatrix}0.314257&amp;0.452491\\\\0.17172&amp;0.20052\\end{bmatrix}\" style=\"width:26.504ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/751b3a44f8f94dbc.svg\" alt=\"X=\\begin{bmatrix}3.461457&amp;-3.572109\\\\4.22962&amp;-2.01448\\end{bmatrix}\" style=\"width:28.451ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Both particles improved; new gbest = (4.22962, −2.01448) with F = 40.0992.</div>\r\n<div class=\"keyfix\"><strong>Official key warning.</strong> The re-exam answer key solves a <em>different</em> 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.</div>\r\n<p class=\"marks-split\">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).</p>\r\n</section>\r\n"},{"id":"q5a","title":"Q5(a) Genetic algorithm [10]","html":"<p class=\"question\"><strong>Implement a GA to maximise <span class=\"math-inline\"><img src=\"math/d678d50d2d5c4ae4.svg\" alt=\"f(x)=2x^3-3x^2+8x\" style=\"width:22.099ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> 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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><p><strong>The printed data are inconsistent.</strong> 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.</p><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Two valid children under the declared assumptions and their fitness.</p></div><h4>Formula and why it applies</h4><p>Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.</p><div class=\"math-display\"><img src=\"math/68385220447af94f.svg\" alt=\"f(x)=2x^3-3x^2+8x\" style=\"width:22.099ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Encode and evaluate the declared parent population</h5><table><thead><tr><th>x</th><th>Binary</th><th>Fitness substitution</th></tr></thead><tbody><tr><td>12</td><td>001100</td><td>2(12³) − 3(12²) + 8(12) = 3120</td></tr><tr><td>20</td><td>010100</td><td>2(20³) − 3(20²) + 8(20) = 14960</td></tr><tr><td>17</td><td>010001</td><td>2(17³) − 3(17²) + 8(17) = 9095</td></tr><tr><td>13</td><td>001101</td><td>2(13³) − 3(13²) + 8(13) = 3991</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Select the two fittest under the stated assumption</h5><p>[20, 17] with fitness [14960, 9095].</p></div><div class=\"step\"><h5>Step 3. Cut after bit 2 and exchange tails</h5><table><thead><tr><th>Parent 1</th><th>Parent 2</th><th>Child 1</th><th>Child 2</th></tr></thead><tbody><tr><td>01 | 0100</td><td>01 | 0001</td><td>010001</td><td>010100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Flip the last bit of each child</h5><table><thead><tr><th>Before</th><th>After</th><th>Decoded x</th></tr></thead><tbody><tr><td>010001</td><td>010000</td><td>16</td></tr><tr><td>010100</td><td>010101</td><td>21</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Evaluate both children</h5><table><thead><tr><th>x</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>16</td><td>2(4096) − 3(256) + 8(16) = 7552</td></tr><tr><td>21</td><td>2(9261) − 3(441) + 8(21) = 17367</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Compare with the selected parents</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:polynomial-working:start -->\r\n<div class=\"concept-bridge\"><h2>Evaluate the polynomial without skipping the powers</h2><p>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.</p><h3>x=12</h3><div class=\"math-display\"><img src=\"math/68dcfd678cb95894.svg\" alt=\"x^2=12\\times12=144\\qquad x^3=144\\times12=1728\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f6a8611548b73ce.svg\" alt=\"2x^3=3456\\quad 3x^2=432\\quad 8x=96\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ece74f225f6dc343.svg\" alt=\"f(12)=3456-432+96=3120\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=20</h3><div class=\"math-display\"><img src=\"math/b143d22c2e5129d2.svg\" alt=\"x^2=20\\times20=400\\qquad x^3=400\\times20=8000\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/581d9ac708a9edf4.svg\" alt=\"2x^3=16000\\quad 3x^2=1200\\quad 8x=160\" style=\"width:36.402ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af62ea37a6cc0979.svg\" alt=\"f(20)=16000-1200+160=14960\" style=\"width:36.063ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=17</h3><div class=\"math-display\"><img src=\"math/8106fc4d3ea404bb.svg\" alt=\"x^2=17\\times17=289\\qquad x^3=289\\times17=4913\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3f446d5c18f6525b.svg\" alt=\"2x^3=9826\\quad 3x^2=867\\quad 8x=136\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/33f7934e87e644ca.svg\" alt=\"f(17)=9826-867+136=9095\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=13</h3><div class=\"math-display\"><img src=\"math/3b2d51c91ac2cf33.svg\" alt=\"x^2=13\\times13=169\\qquad x^3=169\\times13=2197\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/963b6763e9667406.svg\" alt=\"2x^3=4394\\quad 3x^2=507\\quad 8x=104\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fb78bd652840ab88.svg\" alt=\"f(13)=4394-507+104=3991\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=16</h3><div class=\"math-display\"><img src=\"math/1a7d6636e629e211.svg\" alt=\"x^2=16\\times16=256\\qquad x^3=256\\times16=4096\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/116d99ec87e1c7e9.svg\" alt=\"2x^3=8192\\quad 3x^2=768\\quad 8x=128\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f0bfce15122fad53.svg\" alt=\"f(16)=8192-768+128=7552\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=21</h3><div class=\"math-display\"><img src=\"math/db60547636676c53.svg\" alt=\"x^2=21\\times21=441\\qquad x^3=441\\times21=9261\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7a74ad5911e6f0d8.svg\" alt=\"2x^3=18522\\quad 3x^2=1323\\quad 8x=168\" style=\"width:36.402ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/da828d5642e53dc9.svg\" alt=\"f(21)=18522-1323+168=17367\" style=\"width:36.063ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:polynomial-working:end -->"},{"id":"q7a","title":"Q7(a) Applications of fuzzy logic [10]","html":"<p class=\"question\"><strong>List the applications of fuzzy logic. Explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition</h3>\r\n<p>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”.</p>\r\n<h3>Applications</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Area</th><th>Examples</th></tr></thead><tbody>\r\n<tr><td>Home appliances</td><td>Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners</td></tr>\r\n<tr><td>Automotive</td><td>Automatic transmission, anti-lock braking (ABS), cruise control, engine control</td></tr>\r\n<tr><td>Transportation</td><td>Traffic-signal control, Sendai subway train control (smooth braking and acceleration)</td></tr>\r\n<tr><td>Consumer electronics</td><td>Camera autofocus and auto-exposure, image stabilisation</td></tr>\r\n<tr><td>Industrial control</td><td>Cement kilns, pH, temperature and distillation control in chemical plants</td></tr>\r\n<tr><td>Aerospace</td><td>Satellite and spacecraft attitude control</td></tr>\r\n<tr><td>Medicine</td><td>Diagnosis support, anaesthesia dosage control</td></tr>\r\n<tr><td>Finance and decisions</td><td>Loan approval, credit and fire-risk scoring, stock trading rules</td></tr>\r\n<tr><td>AI and robotics</td><td>Robot navigation, natural-language interfaces, expert systems</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>One application in detail: fuzzy washing machine</h3>\r\n<ol>\r\n<li><strong>Problem.</strong> 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.</li>\r\n<li><strong>Inputs and outputs.</strong> 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.</li>\r\n<li><strong>Fuzzification.</strong> Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.</li>\r\n<li><strong>Rule base.</strong> 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.</li>\r\n<li><strong>Inference.</strong> Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.</li>\r\n<li><strong>Defuzzification.</strong> 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.</li>\r\n<li><strong>Benefits.</strong> Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.</li>\r\n</ol>\r\n<h3>Advantages and disadvantages (bonus)</h3>\r\n<p><strong>Advantages:</strong> handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. <strong>Disadvantages:</strong> 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.</p>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.</div>\r\n"}]}],"mocks":[{"id":"m2-paper-v2-1","title":"M2 mock 1 · 10 marks","unit":"M2 practice","scope":"Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.","sections":[{"id":"q1a","title":"Q1(a) · Fuzzy operations [2]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th></tr></thead><tbody><tr><td>A</td><td>0.2</td><td>0.8</td><td>0.6</td></tr><tr><td>B</td><td>0.7</td><td>0.3</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/ad1dcd17cbaf20b9.svg\" alt=\"\\mu_{B^c}(u_1)=1-0.7=0.3\" style=\"width:23.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3b878090c37dc92f.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0.2,0.3)=0.2\" style=\"width:30.054ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0.2</td><td>0.7</td><td>max(0.2, 0.7) = 0.7</td><td>min(0.2, 0.7) = 0.2</td><td>1 − 0.7 = 0.3</td><td>min(0.2, 0.3) = 0.2</td></tr><tr><td>u2</td><td>0.8</td><td>0.3</td><td>max(0.8, 0.3) = 0.8</td><td>min(0.8, 0.3) = 0.3</td><td>1 − 0.3 = 0.7</td><td>min(0.8, 0.7) = 0.7</td></tr><tr><td>u3</td><td>0.6</td><td>0.5</td><td>max(0.6, 0.5) = 0.6</td><td>min(0.6, 0.5) = 0.5</td><td>1 − 0.5 = 0.5</td><td>min(0.6, 0.5) = 0.5</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section>"},{"id":"q1b","title":"Q1(b) · Swarm intelligence [2]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q1(b). Define swarm intelligence. Briefly explain one nature-inspired algorithm.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section>"},{"id":"q2","title":"Q2 · GA through two generations [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q2. Maximise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Current individual row numbers [3, 4, 4, 3]</td></tr><tr><td>2</td><td>Current individual row numbers [2, 3, 2, 3]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>0011</td><td>3 × 3 = 9</td></tr><tr><td>2</td><td>5</td><td>0101</td><td>5 × 5 = 25</td></tr><tr><td>3</td><td>10</td><td>1010</td><td>10 × 10 = 100</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>12 × 12 = 144</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: apply the supplied selection order</h5><p>The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>10</td><td>1010</td></tr><tr><td>2</td><td>4</td><td>12</td><td>1100</td></tr><tr><td>3</td><td>4</td><td>12</td><td>1100</td></tr><tr><td>4</td><td>3</td><td>10</td><td>1010</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>10 | 10</td><td>11 | 00</td><td>1000</td><td>1110</td></tr><tr><td>3 & 4</td><td>11 | 00</td><td>10 | 10</td><td>1110</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr><tr><td>2</td><td>1110</td><td>Flip bit 4</td><td>1111</td></tr><tr><td>3</td><td>1110</td><td>Flip bit 4</td><td>1111</td></tr><tr><td>4</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>9² = 81</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>9² = 81</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/ac14e9c27d115d0e.svg\" alt=\"\\overline f_{old}=\\frac{9+25+100+144}{4}=\\frac{278}{4}=69.5\" style=\"width:40.453ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b4cd0bde2e1de484.svg\" alt=\"\\overline f_{new}=\\frac{81+225+225+81}{4}=\\frac{612}{4}=153\" style=\"width:41.722ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 7. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>9</td><td>1001</td><td>9 × 9 = 81</td></tr><tr><td>2</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>3</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>4</td><td>9</td><td>1001</td><td>9 × 9 = 81</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Generation 2: apply the supplied selection order</h5><p>The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>2</td><td>3</td><td>15</td><td>1111</td></tr><tr><td>3</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>4</td><td>3</td><td>15</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr><tr><td>3 & 4</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>2</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>3</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>4</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr></tbody></table></div><div class=\"step\"><h5>Step 11. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/1526400ff09c5372.svg\" alt=\"\\overline f_{old}=\\frac{81+225+225+81}{4}=\\frac{612}{4}=153\" style=\"width:40.956ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/83698ff516912ccd.svg\" alt=\"\\overline f_{new}=\\frac{196+196+196+196}{4}=\\frac{784}{4}=196\" style=\"width:43.984ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [14, 14, 14, 14]. Best final objective = 196 at x = [14].</div></section>"},{"id":"q3","title":"Q3 · Two-particle PSO through iteration 2 [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q3. Minimise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(-1)</td><td>(0)</td></tr><tr><td>B</td><td>(3)</td><td>(0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/cb918b9a5ef7b82c.svg\" alt=\"f(-1)=(-1)^2=1=1\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/519522f49346438a.svg\" alt=\"f(3)=3^2=9=9\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/4bb3271e5427b8e5.svg\" alt=\"gbest^0=(-1)\" style=\"width:13.638ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 1. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (-1). pbest values are A: (-1), B: (3).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/726263f8c97a9f8e.svg\" alt=\"d_p=-1-(-1)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6223039cb154c72e.svg\" alt=\"d_g=-1-(-1)=0\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/92761bdfeb82fb87.svg\" alt=\"x^{(1)}=(-1)+0=-1\" style=\"width:21.001ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/114e8d23bb26d062.svg\" alt=\"d_p=3-(3)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/4224cdc3d1fd7742.svg\" alt=\"d_g=-1-(3)=-4\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d9a3c8d94a7312e.svg\" alt=\"S=0.5\\times(-4)=-2\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/146db9adf4c34c65.svg\" alt=\"v^{(1)}=0+0+(-2)=-2\" style=\"width:24.701ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/39edc010c99575f0.svg\" alt=\"x^{(1)}=3+(-2)=1\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/cb918b9a5ef7b82c.svg\" alt=\"f(-1)=(-1)^2=1=1\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/872b6624767f4385.svg\" alt=\"f(1)=1^2=1=1\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>1</td><td>Keep old: tie</td><td>(-1)</td></tr><tr><td>B</td><td>9</td><td>1</td><td>Replace: new score is lower</td><td>(1)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(-1)</strong>, with objective <strong>1</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(-1)</td><td>(0)</td><td>(-1)</td></tr><tr><td>B</td><td>(1)</td><td>(-2)</td><td>(1)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (-1). pbest values are A: (-1), B: (1).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/726263f8c97a9f8e.svg\" alt=\"d_p=-1-(-1)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6223039cb154c72e.svg\" alt=\"d_g=-1-(-1)=0\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8ba6a1d6c9203afb.svg\" alt=\"v^{(2)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/a4857620c6480702.svg\" alt=\"x^{(2)}=(-1)+0=-1\" style=\"width:21.001ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/8dba29f0d505433a.svg\" alt=\"I=0.5\\times(-2)=-1\" style=\"width:20.375ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/de044b0c7b70c868.svg\" alt=\"d_g=-1-(1)=-2\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/96dd8f64f9d9a341.svg\" alt=\"S=0.5\\times(-2)=-1\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/b437ff946e9d4080.svg\" alt=\"v^{(2)}=(-1)+0+(-1)=-2\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/6aabd1c885e75a7f.svg\" alt=\"x^{(2)}=1+(-2)=-1\" style=\"width:21.001ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/cb918b9a5ef7b82c.svg\" alt=\"f(-1)=(-1)^2=1=1\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/cb918b9a5ef7b82c.svg\" alt=\"f(-1)=(-1)^2=1=1\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>1</td><td>Keep old: tie</td><td>(-1)</td></tr><tr><td>B</td><td>1</td><td>1</td><td>Keep old: tie</td><td>(1)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(-1)</strong>, with objective <strong>1</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(-1)</td><td>(0)</td><td>(-1)</td></tr><tr><td>B</td><td>(-1)</td><td>(-2)</td><td>(1)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"q4","title":"Q4 · Fuzzy architecture [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q4. Explain the architecture of a Mamdani fuzzy inference system with a fan-controller example.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section>"}]},{"id":"m2-paper-v2-2","title":"M2 mock 2 · 10 marks","unit":"M2 practice","scope":"Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.","sections":[{"id":"q1a","title":"Q1(a) · Fuzzy operations [2]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th></tr></thead><tbody><tr><td>A</td><td>0.1</td><td>0.5</td><td>1</td></tr><tr><td>B</td><td>0.9</td><td>0.4</td><td>0</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/3e895fda5c8f4e29.svg\" alt=\"\\mu_{B^c}(u_1)=1-0.9=0.1\" style=\"width:23.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4ec160ba0bee68fe.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0.1,0.1)=0.1\" style=\"width:30.054ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0.1</td><td>0.9</td><td>max(0.1, 0.9) = 0.9</td><td>min(0.1, 0.9) = 0.1</td><td>1 − 0.9 = 0.1</td><td>min(0.1, 0.1) = 0.1</td></tr><tr><td>u2</td><td>0.5</td><td>0.4</td><td>max(0.5, 0.4) = 0.5</td><td>min(0.5, 0.4) = 0.4</td><td>1 − 0.4 = 0.6</td><td>min(0.5, 0.6) = 0.5</td></tr><tr><td>u3</td><td>1</td><td>0</td><td>max(1, 0) = 1</td><td>min(1, 0) = 0</td><td>1 − 0 = 1</td><td>min(1, 1) = 1</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section>"},{"id":"q1b","title":"Q1(b) · Swarm intelligence [2]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q1(b). Define swarm intelligence. Briefly explain one nature-inspired algorithm.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section>"},{"id":"q2","title":"Q2 · GA through two generations [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q2. Maximise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Current individual row numbers [3, 4, 4, 3]</td></tr><tr><td>2</td><td>Current individual row numbers [2, 3, 2, 3]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>0001</td><td>1 × 1 = 1</td></tr><tr><td>2</td><td>6</td><td>0110</td><td>6 × 6 = 36</td></tr><tr><td>3</td><td>9</td><td>1001</td><td>9 × 9 = 81</td></tr><tr><td>4</td><td>14</td><td>1110</td><td>14 × 14 = 196</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: apply the supplied selection order</h5><p>The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>9</td><td>1001</td></tr><tr><td>2</td><td>4</td><td>14</td><td>1110</td></tr><tr><td>3</td><td>4</td><td>14</td><td>1110</td></tr><tr><td>4</td><td>3</td><td>9</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>10 | 01</td><td>11 | 10</td><td>1010</td><td>1101</td></tr><tr><td>3 & 4</td><td>11 | 10</td><td>10 | 01</td><td>1101</td><td>1010</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1010</td><td>Flip bit 3</td><td>1000</td></tr><tr><td>2</td><td>1101</td><td>Flip bit 3</td><td>1111</td></tr><tr><td>3</td><td>1101</td><td>Flip bit 3</td><td>1111</td></tr><tr><td>4</td><td>1010</td><td>Flip bit 3</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8² = 64</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8² = 64</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/7aeb7f13264a06b2.svg\" alt=\"\\overline f_{old}=\\frac{1+36+81+196}{4}=\\frac{314}{4}=78.5\" style=\"width:39.322ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/534a2fd2aa176655.svg\" alt=\"\\overline f_{new}=\\frac{64+225+225+64}{4}=\\frac{578}{4}=144.5\" style=\"width:43.482ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 7. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>8</td><td>1000</td><td>8 × 8 = 64</td></tr><tr><td>2</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>3</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>4</td><td>8</td><td>1000</td><td>8 × 8 = 64</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Generation 2: apply the supplied selection order</h5><p>The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>2</td><td>3</td><td>15</td><td>1111</td></tr><tr><td>3</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>4</td><td>3</td><td>15</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr><tr><td>3 & 4</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1111</td><td>Flip bit 3</td><td>1101</td></tr><tr><td>2</td><td>1111</td><td>Flip bit 3</td><td>1101</td></tr><tr><td>3</td><td>1111</td><td>Flip bit 3</td><td>1101</td></tr><tr><td>4</td><td>1111</td><td>Flip bit 3</td><td>1101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 11. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13² = 169</td></tr><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13² = 169</td></tr><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13² = 169</td></tr><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13² = 169</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/290d9d3cf2ac1342.svg\" alt=\"\\overline f_{old}=\\frac{64+225+225+64}{4}=\\frac{578}{4}=144.5\" style=\"width:42.716ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d460690a1684b5f8.svg\" alt=\"\\overline f_{new}=\\frac{169+169+169+169}{4}=\\frac{676}{4}=169\" style=\"width:43.984ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [13, 13, 13, 13]. Best final objective = 169 at x = [13].</div></section>"},{"id":"q3","title":"Q3 · Two-particle PSO through iteration 2 [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q3. Minimise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(2)</td><td>(0)</td></tr><tr><td>B</td><td>(5)</td><td>(0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/12fb2bbb149af9d6.svg\" alt=\"f(5)=5^2=25=25\" style=\"width:19.831ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/a00ef2dd53de0008.svg\" alt=\"gbest^0=(2)\" style=\"width:11.878ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 4. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (2). pbest values are A: (2), B: (5).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e7f9deeb68816f5a.svg\" alt=\"d_p=2-(2)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/df4d0e49facbaae8.svg\" alt=\"d_g=2-(2)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/bfaa1b2d391c5f4e.svg\" alt=\"x^{(1)}=2+0=2\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/302db7bc64d6f9e9.svg\" alt=\"d_p=5-(5)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/c53a1760c2aca6d6.svg\" alt=\"d_g=2-(5)=-3\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/13ae8508c1795085.svg\" alt=\"S=0.5\\times(-3)=-1.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/4e26de872fe8bfca.svg\" alt=\"v^{(1)}=0+0+(-1.5)=-1.5\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/83a647473c6fa205.svg\" alt=\"x^{(1)}=5+(-1.5)=3.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/4c8cdadcd9350fe6.svg\" alt=\"f(3.5)=3.5^2=12.25=12.25\" style=\"width:29.134ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>4</td><td>4</td><td>Keep old: tie</td><td>(2)</td></tr><tr><td>B</td><td>25</td><td>12.25</td><td>Replace: new score is lower</td><td>(3.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(2)</strong>, with objective <strong>4</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(2)</td><td>(0)</td><td>(2)</td></tr><tr><td>B</td><td>(3.5)</td><td>(-1.5)</td><td>(3.5)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (2). pbest values are A: (2), B: (3.5).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e7f9deeb68816f5a.svg\" alt=\"d_p=2-(2)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/df4d0e49facbaae8.svg\" alt=\"d_g=2-(2)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8ba6a1d6c9203afb.svg\" alt=\"v^{(2)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/2189c0d7cea22f3c.svg\" alt=\"x^{(2)}=2+0=2\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/16e3f0369a50c03f.svg\" alt=\"I=0.5\\times(-1.5)=-0.75\" style=\"width:25.026ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/dfcb6b54b5bd04e2.svg\" alt=\"d_p=3.5-(3.5)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/01ad6e560abc36e6.svg\" alt=\"d_g=2-(3.5)=-1.5\" style=\"width:21.362ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/59d60f341dbf8e9b.svg\" alt=\"S=0.5\\times(-1.5)=-0.75\" style=\"width:25.345ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/02342391a534b540.svg\" alt=\"v^{(2)}=(-0.75)+0+(-0.75)=-1.5\" style=\"width:35.764ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/24dbc384ce5eb239.svg\" alt=\"x^{(2)}=3.5+(-1.5)=2\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>4</td><td>4</td><td>Keep old: tie</td><td>(2)</td></tr><tr><td>B</td><td>12.25</td><td>4</td><td>Replace: new score is lower</td><td>(2)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(2)</strong>, with objective <strong>4</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(2)</td><td>(0)</td><td>(2)</td></tr><tr><td>B</td><td>(2)</td><td>(-1.5)</td><td>(2)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"q4","title":"Q4 · Fuzzy membership [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q4. A fuzzy set A has triangular membership Tri(15, 25, 35). Find membership at x = 32.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 15; peak b = 25; right endpoint c = 35; input x = 32.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>25 < 32 < 35, so membership decreases as x moves away from the peak.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Falling side</p><div class=\"math-display\"><img src=\"math/3ed9e45724bceb7e.svg\" alt=\"\\mu_A(32)=\\frac{35-32}{35-25}=\\frac{3}{10}=0.3\" style=\"width:30.261ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 0.3. It is a membership degree, not a probability.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(32) = 0.3.</div></section>"}]},{"id":"m2-paper-v2-3","title":"M2 mock 3 · 10 marks","unit":"M2 practice","scope":"Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.","sections":[{"id":"q1a","title":"Q1(a) · Fuzzy operations [2]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th></tr></thead><tbody><tr><td>A</td><td>0.7</td><td>0.2</td><td>0.9</td></tr><tr><td>B</td><td>0.3</td><td>0.8</td><td>0.4</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/0d89f5d2d8ca13ed.svg\" alt=\"\\mu_{B^c}(u_1)=1-0.3=0.7\" style=\"width:23.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c98cc0f742bee1be.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0.7,0.7)=0.7\" style=\"width:30.054ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0.7</td><td>0.3</td><td>max(0.7, 0.3) = 0.7</td><td>min(0.7, 0.3) = 0.3</td><td>1 − 0.3 = 0.7</td><td>min(0.7, 0.7) = 0.7</td></tr><tr><td>u2</td><td>0.2</td><td>0.8</td><td>max(0.2, 0.8) = 0.8</td><td>min(0.2, 0.8) = 0.2</td><td>1 − 0.8 = 0.2</td><td>min(0.2, 0.2) = 0.2</td></tr><tr><td>u3</td><td>0.9</td><td>0.4</td><td>max(0.9, 0.4) = 0.9</td><td>min(0.9, 0.4) = 0.4</td><td>1 − 0.4 = 0.6</td><td>min(0.9, 0.6) = 0.6</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section>"},{"id":"q1b","title":"Q1(b) · Swarm intelligence [2]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q1(b). Define swarm intelligence. Briefly explain one nature-inspired algorithm.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section>"},{"id":"q2","title":"Q2 · GA through two generations [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q2. Maximise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Current individual row numbers [3, 4, 4, 3]</td></tr><tr><td>2</td><td>Current individual row numbers [2, 3, 2, 3]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>0010</td><td>2 × 2 = 4</td></tr><tr><td>2</td><td>7</td><td>0111</td><td>7 × 7 = 49</td></tr><tr><td>3</td><td>8</td><td>1000</td><td>8 × 8 = 64</td></tr><tr><td>4</td><td>13</td><td>1101</td><td>13 × 13 = 169</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: apply the supplied selection order</h5><p>The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>8</td><td>1000</td></tr><tr><td>2</td><td>4</td><td>13</td><td>1101</td></tr><tr><td>3</td><td>4</td><td>13</td><td>1101</td></tr><tr><td>4</td><td>3</td><td>8</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>10 | 00</td><td>11 | 01</td><td>1001</td><td>1100</td></tr><tr><td>3 & 4</td><td>11 | 01</td><td>10 | 00</td><td>1100</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1001</td><td>Flip bit 4</td><td>1000</td></tr><tr><td>2</td><td>1100</td><td>Flip bit 4</td><td>1101</td></tr><tr><td>3</td><td>1100</td><td>Flip bit 4</td><td>1101</td></tr><tr><td>4</td><td>1001</td><td>Flip bit 4</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8² = 64</td></tr><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13² = 169</td></tr><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13² = 169</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8² = 64</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/6171658d65ed4b49.svg\" alt=\"\\overline f_{old}=\\frac{4+49+64+169}{4}=\\frac{286}{4}=71.5\" style=\"width:39.322ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/866b6bb4aa32a9a4.svg\" alt=\"\\overline f_{new}=\\frac{64+169+169+64}{4}=\\frac{466}{4}=116.5\" style=\"width:43.482ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 7. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>8</td><td>1000</td><td>8 × 8 = 64</td></tr><tr><td>2</td><td>13</td><td>1101</td><td>13 × 13 = 169</td></tr><tr><td>3</td><td>13</td><td>1101</td><td>13 × 13 = 169</td></tr><tr><td>4</td><td>8</td><td>1000</td><td>8 × 8 = 64</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Generation 2: apply the supplied selection order</h5><p>The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>13</td><td>1101</td></tr><tr><td>2</td><td>3</td><td>13</td><td>1101</td></tr><tr><td>3</td><td>2</td><td>13</td><td>1101</td></tr><tr><td>4</td><td>3</td><td>13</td><td>1101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>11 | 01</td><td>11 | 01</td><td>1101</td><td>1101</td></tr><tr><td>3 & 4</td><td>11 | 01</td><td>11 | 01</td><td>1101</td><td>1101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1101</td><td>Flip bit 4</td><td>1100</td></tr><tr><td>2</td><td>1101</td><td>Flip bit 4</td><td>1100</td></tr><tr><td>3</td><td>1101</td><td>Flip bit 4</td><td>1100</td></tr><tr><td>4</td><td>1101</td><td>Flip bit 4</td><td>1100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 11. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1100</td><td>8 + 4 + 0 + 0 = 12</td><td>12² = 144</td></tr><tr><td>1100</td><td>8 + 4 + 0 + 0 = 12</td><td>12² = 144</td></tr><tr><td>1100</td><td>8 + 4 + 0 + 0 = 12</td><td>12² = 144</td></tr><tr><td>1100</td><td>8 + 4 + 0 + 0 = 12</td><td>12² = 144</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/fcafd07eb412a037.svg\" alt=\"\\overline f_{old}=\\frac{64+169+169+64}{4}=\\frac{466}{4}=116.5\" style=\"width:42.716ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cd00806a61b8ba0c.svg\" alt=\"\\overline f_{new}=\\frac{144+144+144+144}{4}=\\frac{576}{4}=144\" style=\"width:43.984ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [12, 12, 12, 12]. Best final objective = 144 at x = [12].</div></section>"},{"id":"q3","title":"Q3 · Two-particle PSO through iteration 2 [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q3. Minimise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(1)</td><td>(2)</td></tr><tr><td>B</td><td>(4)</td><td>(-1)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/872b6624767f4385.svg\" alt=\"f(1)=1^2=1=1\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/312433d364d9cfab.svg\" alt=\"f(4)=4^2=16=16\" style=\"width:19.831ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/d6d8eee6e10c4922.svg\" alt=\"gbest^0=(1)\" style=\"width:11.878ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 1. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (1), B: (4).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/4d6486404a7509ba.svg\" alt=\"I=0.5\\times2=1\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/9a2ea8db49561d57.svg\" alt=\"v^{(1)}=1+0+0=1\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/f9d52a6143caaf7b.svg\" alt=\"x^{(1)}=1+1=2\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/dc7ed342b0db88bc.svg\" alt=\"I=0.5\\times(-1)=-0.5\" style=\"width:22.135ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/ad073051db57b851.svg\" alt=\"d_p=4-(4)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/7cc359443926f7d3.svg\" alt=\"d_g=1-(4)=-3\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/13ae8508c1795085.svg\" alt=\"S=0.5\\times(-3)=-1.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/1329839a69ba9e13.svg\" alt=\"v^{(1)}=(-0.5)+0+(-1.5)=-2\" style=\"width:31.741ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/2b24c838f14c9776.svg\" alt=\"x^{(1)}=4+(-2)=2\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>4</td><td>Keep old: new score is worse</td><td>(1)</td></tr><tr><td>B</td><td>16</td><td>4</td><td>Replace: new score is lower</td><td>(2)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1)</strong>, with objective <strong>1</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(2)</td><td>(1)</td><td>(1)</td></tr><tr><td>B</td><td>(2)</td><td>(-2)</td><td>(2)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (1), B: (2).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/15c0369c89ebba10.svg\" alt=\"I=0.5\\times1=0.5\" style=\"width:16.854ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/72aafd3f3c32f9a7.svg\" alt=\"d_p=1-(2)=-1\" style=\"width:17.883ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5fb29aabbbcf9b90.svg\" alt=\"C=0.5\\times(-1)=-0.5\" style=\"width:22.714ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fe1a995f4b4afef.svg\" alt=\"d_g=1-(2)=-1\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38f7adbc6f0de36b.svg\" alt=\"S=0.5\\times(-1)=-0.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/cd06fdfee86fe231.svg\" alt=\"v^{(2)}=0.5+(-0.5)+(-0.5)=-0.5\" style=\"width:35.262ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/7929aa22070f7f4e.svg\" alt=\"x^{(2)}=2+(-0.5)=1.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/8dba29f0d505433a.svg\" alt=\"I=0.5\\times(-2)=-1\" style=\"width:20.375ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e7f9deeb68816f5a.svg\" alt=\"d_p=2-(2)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fe1a995f4b4afef.svg\" alt=\"d_g=1-(2)=-1\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38f7adbc6f0de36b.svg\" alt=\"S=0.5\\times(-1)=-0.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/88e7bce915d4dcc4.svg\" alt=\"v^{(2)}=(-1)+0+(-0.5)=-1.5\" style=\"width:31.741ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/5721079871bdab79.svg\" alt=\"x^{(2)}=2+(-1.5)=0.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/b61e97d213b18164.svg\" alt=\"f(1.5)=1.5^2=2.25=2.25\" style=\"width:26.872ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/4c640081b99e1be6.svg\" alt=\"f(0.5)=0.5^2=0.25=0.25\" style=\"width:26.872ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>2.25</td><td>Keep old: new score is worse</td><td>(1)</td></tr><tr><td>B</td><td>4</td><td>0.25</td><td>Replace: new score is lower</td><td>(0.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(0.5)</strong>, with objective <strong>0.25</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(1.5)</td><td>(-0.5)</td><td>(1)</td></tr><tr><td>B</td><td>(0.5)</td><td>(-1.5)</td><td>(0.5)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"q4","title":"Q4 · Fuzzy defuzzification [3]","html":"<p><strong>Confirmed M2 pattern:</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Q4. Using the weighted-average method, combine output representatives [20, 50, 80] % with respective strengths [0.2, 0.6, 0.2].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>20</td><td>0.2</td></tr><tr><td>50</td><td>0.6</td></tr><tr><td>80</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0.2 × 20</td><td>4</td></tr><tr><td>0.6 × 50</td><td>30</td></tr><tr><td>0.2 × 80</td><td>16</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/cd5630515c6da6da.svg\" alt=\"4+30+16=50\" style=\"width:16.467ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/62f59e75ba76247e.svg\" alt=\"0.2+0.6+0.2=1\" style=\"width:18.354ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/9c1293c80ea00bab.svg\" alt=\"z^*=\\frac{50}{1}=50\" style=\"width:13.594ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 50 %.</div></section>"}]}],"revision":[{"id":"m2-revision-v2","title":"Last-day revision","unit":"M2","scope":"A compact read after the worked lessons.","sections":[{"id":"final-read","title":"The final revision: methods, theory and common mistakes","html":"<h2>Q1: short calculations and definitions</h2><table><thead><tr><th>Asked for</th><th>Write</th></tr></thead><tbody>\r\n<tr><td>Union / intersection</td><td>Same element, max / min respectively.</td></tr><tr><td>Complement / difference</td><td>1−μA / min(μA,1−μB).</td></tr><tr><td>Triangle membership</td><td>Locate x; rising (x−a)/(b−a), falling (c−x)/(c−b), 0 outside, 1 at peak.</td></tr><tr><td>Swarm intelligence</td><td>Collective problem-solving emerging from interacting simple agents; explain PSO through position, velocity, pbest and gbest.</td></tr></tbody></table>\r\n<h2>GA: the table to make in the exam</h2><p>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.</p>\r\n<p>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.</p>\r\n<h2>PSO: the table to make in the exam</h2><p>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.</p>\r\n<p>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.</p>\r\n<h2>Fuzzy controller: five operations</h2><ol><li>Calculate input memberships using the specified graphs.</li><li>Apply AND=min or the supplied connective to obtain rule strengths.</li><li>Clip consequents using min-implication.</li><li>Combine output sets by max-aggregation.</li><li>Use the named defuzzification method. MoM, full area centroid and peak-weighted average are different operations.</li></ol>\r\n<h2>Three short theory answers to revise</h2><p><strong>Mamdani:</strong> 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.</p><p><strong>GA:</strong> population search inspired by evolution, using evaluation, selection, crossover, mutation and replacement. Flexible and derivative-free, but may be expensive or converge prematurely.</p><p><strong>PSO:</strong> particles move using inertia, personal best and swarm best. Simple and derivative-free, but parameter-dependent and not guaranteed to find a global optimum.</p>\r\n<h2>Calculator and rounding</h2><p>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.</p>\r\n<p class=\"memory\"><strong>Yaad rakho:</strong> Question ki instruction follow karo; answer ko sundar banane ke liye data ya operator mat badlo.</p>"}]}],"about":[{"id":"about","title":"Portion, sources and corrections","unit":"0","scope":"What this guide covers, where it came from, and every error found in the slides and answer keys","sections":[{"id":"portion-sources","title":"Portion, source priority and what was checked","html":"<h2>M2</h2><p>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.</p>\r\n<h2>TEE official syllabus</h2><ol><li>Uncertain knowledge and reasoning: uncertainty, full joint distributions, Bayes, naive Bayes, Bayesian networks, mixture models, GMM, EM and clustering.</li><li>Fuzzy systems: rules, properties/operations, membership functions, intuition-based fuzzification, mean of maxima, centroid, Mamdani and applications.</li><li>Evolutionary intelligence: biological basis, GA terms/search space, simple/general GA, encoding/selection/crossover/mutation, stopping, constraints, GA-for-TSP, ACO and swarm optimisation.</li><li>Reinforcement learning: Markov processes, MRP, MDP, policies, value functions, Bellman equations and applications.</li></ol>\r\n<p>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.</p>\r\n<h2>Source priority</h2><p>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.</p>\r\n<p>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.</p>\r\n<h2>Technical references used for checking conventions</h2><ul>\r\n<li><a href=\"https://www.mathworks.com/help/fuzzy/fuzzy-inference-process.html\">MathWorks: fuzzy inference process</a> — separation of antecedent operations, implication, aggregation and defuzzification.</li>\r\n<li><a href=\"https://www.mathworks.com/help/fuzzy/defuzz.html\">MathWorks: defuzzification definitions</a> — centroid uses the area; MoM uses locations at the maximum.</li>\r\n<li><a href=\"https://www.mathworks.com/help/gads/particle-swarm-optimization-algorithm.html\">MathWorks: particle swarm update</a> — velocity components and best-position memory. Its adaptive neighbourhood implementation is not substituted for the fixed classroom global-best examples.</li></ul>\r\n<p>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.</p>"},{"id":"corrections","title":"How inconsistent source questions are handled","html":"<h2>State the issue before solving a changed question</h2><p>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.</p>\r\n<p>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.</p>\r\n<p>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.</p>\r\n<p>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.</p>"}]}]},"tee":{"read":[{"id":"tee-start","title":"Start here · TEE plan","unit":"0","scope":"Term-end examination · 100 marks · 3 hours · all four units","sections":[{"id":"tee-plan","title":"How the TEE is set and how to prepare","html":"<h2>Paper pattern (both 2025–26 papers)</h2>\r\n<ul>\r\n<li>100 marks, 3 hours, scaled to 50.</li>\r\n<li><strong>Q1 compulsory</strong>: 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.</li>\r\n<li><strong>Answer any four of Q2–Q7</strong>, each with two 10-mark parts.</li>\r\n</ul>\r\n\r\n<h2>What came in each paper</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Topic</th><th>Unit</th><th>Nov 2025</th><th>Jan 2026</th></tr></thead><tbody>\r\n<tr><td>Joint table (5)</td><td>1</td><td>Q1a</td><td>Q1a</td></tr>\r\n<tr><td>GMM: k-means, log-likelihood, parameters (10)</td><td>1</td><td>Q2b</td><td>Q2b</td></tr>\r\n<tr><td>Bayesian network query (10)</td><td>1</td><td>Q3a</td><td>Q3a</td></tr>\r\n<tr><td>Naive Bayes (10)</td><td>1</td><td>Q4b</td><td>Q4b</td></tr>\r\n<tr><td>Fuzzy set operations (5)</td><td>2</td><td>Q1c</td><td>Q1c</td></tr>\r\n<tr><td>Mamdani design + defuzzify (10)</td><td>2</td><td>Q3b</td><td>Q2a</td></tr>\r\n<tr><td>Fuzzy relation composition (10)</td><td>2</td><td>Q4a</td><td>Q3b</td></tr>\r\n<tr><td>Fuzzy applications (10)</td><td>2</td><td>Q6a</td><td>Q7a</td></tr>\r\n<tr><td>PSO numerical (10)</td><td>3</td><td>Q2a</td><td>Q4a</td></tr>\r\n<tr><td>GA numerical (10)</td><td>3</td><td>Q5b</td><td>Q5a</td></tr>\r\n<tr><td>ACO numerical (10)</td><td>3</td><td>Q7b</td><td>Q6a</td></tr>\r\n<tr><td>PSO / ACO applications (5–10)</td><td>3</td><td>Q1b, Q7a</td><td>Q1b</td></tr>\r\n<tr><td>Markov 2-state (5)</td><td>4</td><td>Q1d</td><td>Q1d</td></tr>\r\n<tr><td>Markov 3-state, 5 parts (10)</td><td>4</td><td>Q5a, Q6b</td><td>Q5b, Q6b</td></tr>\r\n<tr><td>Bellman + RL applications (10)</td><td>4</td><td>—</td><td>Q7b</td></tr>\r\n</tbody></table></div>\r\n<p>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.</p>\r\n\r\n<h2>Choosing your four questions</h2>\r\n<ol>\r\n<li>Q1 first (20 marks, about 30 minutes).</li>\r\n<li>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.</li>\r\n<li>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).</li>\r\n</ol>\r\n\r\n<h2>Study route</h2>\r\n<p>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.</p><h2>Question evidence versus teaching examples</h2><p>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.</p><p>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.</p>"},{"id":"question-map","title":"Every paper: question, unit, marks and solved answer","html":"<h2>Use this map with the solved papers</h2><p>Each row links directly to the full question and its answer. <strong>Offered marks</strong> count all printed choices; <strong>attempted marks</strong> 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.</p>\r\n<p><strong>Types:</strong> Numerical = calculations; Theory = explain/compare; Mixed = calculations with explanation; Case = apply or design a system. A case can contain substantial calculation.</p>\r\n<h2>2026-01-31 · Re-examination · current 2025–26 paper</h2>\r\n<p><strong>100 marks to attempt; 140 marks offered.</strong> Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.</p>\r\n<p><strong>Offered marks by current unit:</strong> Unit 1: 35, Unit 2: 35, Unit 3: 35, Unit 4: 35. Unspecified internal task marks are not split or guessed.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Question</th><th>Marks</th><th>Current unit and topic</th><th>Type</th><th>Answer</th></tr></thead><tbody>\r\n<tr><td><strong>Q1(a)</strong></td><td>5</td><td>Unit 1 · Joint probability: disease, fever and test</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q1a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(b)</strong></td><td>5</td><td>Unit 3 · PSO applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-reexam-2026/q1b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(c)</strong></td><td>5</td><td>Unit 2 · Fuzzy set operations</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q1c\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(d)</strong></td><td>5</td><td>Unit 4 · Two-state Markov bank model</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q1d\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(a)</strong></td><td>10</td><td>Unit 2 · Mamdani fire-controller design and centroid</td><td>Case</td><td><a href=\"#tee/papers/paper-reexam-2026/q2a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(b)</strong></td><td>10</td><td>Unit 1 · GMM, k-means, likelihood and parameters</td><td>Mixed</td><td><a href=\"#tee/papers/paper-reexam-2026/q2b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(a)</strong></td><td>10</td><td>Unit 1 · Bayesian network: fever given no flu</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q3a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(b)</strong></td><td>10</td><td>Unit 2 · Fuzzy Cartesian product and composition</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q3b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(a)</strong></td><td>10</td><td>Unit 3 · PSO one iteration and best memories</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q4a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(b)</strong></td><td>10</td><td>Unit 1 · Naive Bayes job classification</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q4b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(a)</strong></td><td>10</td><td>Unit 3 · Genetic algorithm offspring and fitness</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q5a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(b)</strong></td><td>10</td><td>Unit 4 · Markov booking channels and stationary distribution</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q5b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(a)</strong></td><td>10</td><td>Unit 3 · ACO travelling salesman tour and pheromones</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q6a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(b)</strong></td><td>10</td><td>Unit 4 · Markov aircraft movement and stationary distribution</td><td>Numerical</td><td><a href=\"#tee/papers/paper-reexam-2026/q6b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(a)</strong></td><td>10</td><td>Unit 2 · Fuzzy logic applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-reexam-2026/q7a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(b)</strong></td><td>10</td><td>Unit 4 · Bellman equation and RL applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-reexam-2026/q7b\">Full solution</a></td></tr>\r\n</tbody></table></div>\r\n<h2>2025-11-24 · Final examination · current 2025–26 paper</h2>\r\n<p><strong>100 marks to attempt; 140 marks offered.</strong> Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.</p>\r\n<p><strong>Offered marks by current unit:</strong> Unit 1: 35, Unit 2: 35, Unit 3: 45, Unit 4: 25. Unspecified internal task marks are not split or guessed.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Question</th><th>Marks</th><th>Current unit and topic</th><th>Type</th><th>Answer</th></tr></thead><tbody>\r\n<tr><td><strong>Q1(a)</strong></td><td>5</td><td>Unit 1 · Joint probability and conditional inference</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q1a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(b)</strong></td><td>5</td><td>Unit 3 · ACO applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-final-2025/q1b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(c)</strong></td><td>5</td><td>Unit 2 · Fuzzy set operations</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q1c\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(d)</strong></td><td>5</td><td>Unit 4 · Two-state Markov transition model</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q1d\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(a)</strong></td><td>10</td><td>Unit 3 · PSO one iteration and best memories</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q2a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(b)</strong></td><td>10</td><td>Unit 1 · GMM, k-means, likelihood and parameters</td><td>Mixed</td><td><a href=\"#tee/papers/paper-final-2025/q2b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(a)</strong></td><td>10</td><td>Unit 1 · Bayesian network: wet grass given no rain</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q3a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(b)</strong></td><td>10</td><td>Unit 2 · Mamdani loan-controller design and centroid</td><td>Case</td><td><a href=\"#tee/papers/paper-final-2025/q3b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(a)</strong></td><td>10</td><td>Unit 2 · Fuzzy Cartesian product and composition</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q4a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(b)</strong></td><td>10</td><td>Unit 1 · Naive Bayes flu classification</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q4b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(a)</strong></td><td>10</td><td>Unit 4 · Markov hotel movement and stationary distribution</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q5a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(b)</strong></td><td>10</td><td>Unit 3 · Genetic algorithm offspring and fitness</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q5b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(a)</strong></td><td>10</td><td>Unit 2 · Fuzzy logic applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-final-2025/q6a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(b)</strong></td><td>10</td><td>Unit 4 · Markov learner progression and stationary state</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q6b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(a)</strong></td><td>10</td><td>Unit 3 · PSO applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-final-2025/q7a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(b)</strong></td><td>10</td><td>Unit 3 · ACO travelling salesman tour and pheromones</td><td>Numerical</td><td><a href=\"#tee/papers/paper-final-2025/q7b\">Full solution</a></td></tr>\r\n</tbody></table></div>\r\n<h2>2025-04-28 · Final / re-examination · Historical Semester VI</h2>\r\n<p><strong>100 marks to attempt; 140 marks offered.</strong> Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.</p>\r\n<p><strong>Offered marks by current unit:</strong> Unit 1: 35, Unit 2: 35, Unit 3: 35, Unit 4: 35. Unspecified internal task marks are not split or guessed.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Question</th><th>Marks</th><th>Current unit and topic</th><th>Type</th><th>Answer</th></tr></thead><tbody>\r\n<tr><td><strong>Q1(a)</strong></td><td>5</td><td>Unit 1 · Joint masses, normalization and conditional probability</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q1a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(b)</strong></td><td>5</td><td>Unit 3 · Genetic algorithm applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-2025-april/q1b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(c)</strong></td><td>5</td><td>Unit 2 · Fuzzy union, intersection and complements</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q1c\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(d)</strong></td><td>5</td><td>Unit 4 · Cable-company Markov matrix and diagram</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q1d\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(a)</strong></td><td>10</td><td>Unit 2 · Fuzzy investment-controller design and centroid</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q2a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(b)</strong></td><td>10</td><td>Unit 1 · GMM versus k-means, log likelihood and parameter count</td><td>Theory</td><td><a href=\"#tee/papers/paper-2025-april/q2b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(a)</strong></td><td>10</td><td>Unit 1 · Bayesian-network conditional cough probability</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q3a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(b)</strong></td><td>10</td><td>Unit 2 · Fuzzy Cartesian relations and composition-domain ambiguity</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q3b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(a)</strong></td><td>10</td><td>Unit 3 · PSO one iteration with missing initialization</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q4a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(b)</strong></td><td>10</td><td>Unit 1 · Naive Bayes product-purchase classification</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q4b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(a)</strong></td><td>10</td><td>Unit 3 · Binary GA crossover, one-bit mutation and fitness</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q5a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(b)</strong></td><td>10</td><td>Unit 4 · Bike-sharing Markov transitions, retention and gains</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q5b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(a)</strong></td><td>10</td><td>Unit 3 · ACO tour lengths, evaporation and pheromone deposition</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q6a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(b)</strong></td><td>10</td><td>Unit 4 · Two-step walking/cycling Markov transition</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2025-april/q6b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(a)</strong></td><td>10</td><td>Unit 2 · Fuzzy logic applications and complete controller example</td><td>Theory</td><td><a href=\"#tee/papers/paper-2025-april/q7a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(b)</strong></td><td>10</td><td>Unit 4 · Bellman equations and reinforcement-learning applications</td><td>Theory</td><td><a href=\"#tee/papers/paper-2025-april/q7b\">Full solution</a></td></tr>\r\n</tbody></table></div>\r\n<p><strong>Source qualification:</strong> 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.</p>\r\n<h2>2024-06-25 · Re-examination · Historical Semester VI</h2>\r\n<p><strong>100 marks to attempt; 140 marks offered.</strong> Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.</p>\r\n<p><strong>Offered marks by current unit:</strong> Unit 1: 30, Unit 2: 40, Unit 3: 40, Unit 4: 30. Unspecified internal task marks are not split or guessed.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Question</th><th>Marks</th><th>Current unit and topic</th><th>Type</th><th>Answer</th></tr></thead><tbody>\r\n<tr><td><strong>Q1(a)</strong></td><td>5</td><td>Unit 3 · Traditional versus evolutionary optimization</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-reexam/q1a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(b)</strong></td><td>5</td><td>Unit 1 · Bayes posterior for red ball</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q1b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(c)</strong></td><td>5</td><td>Unit 2 · Fuzzy union, intersection and complements</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q1c\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(d)</strong></td><td>5</td><td>Unit 4 · Irreducibility and stationary distribution</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q1d\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(a)</strong></td><td>10</td><td>Unit 1 · GMM modified log likelihood and parameters</td><td>Mixed</td><td><a href=\"#tee/papers/paper-2024-reexam/q2a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(b)</strong></td><td>10</td><td>Unit 2 · Fuzzy washing-machine controller</td><td>Design</td><td><a href=\"#tee/papers/paper-2024-reexam/q2b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(a)</strong></td><td>10</td><td>Unit 2 · Fuzzy relation and max-product comparison</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q3a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(b)</strong></td><td>10</td><td>Unit 3 · PSO maximization, supplied parameters</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q3b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(a)</strong></td><td>10</td><td>Unit 1 · Naive Bayes and Laplace smoothing</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q4a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(b)</strong></td><td>10</td><td>Unit 4 · Transition matrix properties and two-step probabilities</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q4b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(a)</strong></td><td>10</td><td>Unit 3 · GA selection, crossover and survivor replacement</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q5a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(b)</strong></td><td>10</td><td>Unit 2 · Mean of maxima and centroid of trapezoids</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q5b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(a)</strong></td><td>10</td><td>Unit 3 · Genetic algorithm for four-city TSP</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-reexam/q6a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(b)</strong></td><td>10</td><td>Unit 4 · Markov process and homework transition paths</td><td>Mixed</td><td><a href=\"#tee/papers/paper-2024-reexam/q6b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(a)</strong></td><td>5</td><td>Unit 1 · Expectation Maximization algorithm</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-reexam/q7a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(b)</strong></td><td>5</td><td>Unit 2 · Lambda-cut of a fuzzy relation</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q7b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(c)</strong></td><td>5</td><td>Unit 3 · ACO path length and pheromone update</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-reexam/q7c\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(d)</strong></td><td>5</td><td>Unit 4 · Bellman equation</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-reexam/q7d\">Full solution</a></td></tr>\r\n</tbody></table></div>\r\n<p><strong>Source qualification:</strong> 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.</p>\r\n<h2>2024-04-17 · Final examination · Historical Semester VI</h2>\r\n<p><strong>100 marks to attempt; 140 marks offered.</strong> Q1 compulsory; choose any four complete questions from Q2–Q7. Each whole question carries 20 marks.</p>\r\n<p><strong>Offered marks by current unit:</strong> Unit 1: 30, Unit 2: 40, Unit 3: 40, Unit 4: 30. Unspecified internal task marks are not split or guessed.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Question</th><th>Marks</th><th>Current unit and topic</th><th>Type</th><th>Answer</th></tr></thead><tbody>\r\n<tr><td><strong>Q1(a)</strong></td><td>5</td><td>Unit 1 · Conditional probability from fruit counts</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q1a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(b)</strong></td><td>5</td><td>Unit 2 · Membership function and age sketch</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-final/q1b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(c)</strong></td><td>5</td><td>Unit 3 · Mutation operators</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-final/q1c\">Full solution</a></td></tr>\r\n<tr><td><strong>Q1(d)</strong></td><td>5</td><td>Unit 4 · Markov chain diagram and path probability</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q1d\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(a)</strong></td><td>10</td><td>Unit 1 · Bayesian network joint probabilities</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q2a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q2(b)</strong></td><td>10</td><td>Unit 2 · Fuzzy Cartesian product and composition</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q2b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(a)</strong></td><td>10</td><td>Unit 1 · GMM versus K-means</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-final/q3a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q3(b)</strong></td><td>10</td><td>Unit 2 · Center of sums defuzzification</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q3b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(a)</strong></td><td>10</td><td>Unit 2 · Fuzzy quality-control design</td><td>Design</td><td><a href=\"#tee/papers/paper-2024-final/q4a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q4(b)</strong></td><td>10</td><td>Unit 3 · ACO components and roles</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-final/q4b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(a)</strong></td><td>10</td><td>Unit 3 · PSO inspiration, parameters and one iteration</td><td>Mixed</td><td><a href=\"#tee/papers/paper-2024-final/q5a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q5(b)</strong></td><td>10</td><td>Unit 4 · Brand-switching transition matrix</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q5b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(a)</strong></td><td>10</td><td>Unit 3 · GA ranking and three crossover methods</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q6a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q6(b)</strong></td><td>10</td><td>Unit 4 · Markov property and weather path</td><td>Mixed</td><td><a href=\"#tee/papers/paper-2024-final/q6b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(a)</strong></td><td>5</td><td>Unit 1 · Bayes bag posterior</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q7a\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(b)</strong></td><td>5</td><td>Unit 2 · Max–min relational composition</td><td>Numerical</td><td><a href=\"#tee/papers/paper-2024-final/q7b\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(c)</strong></td><td>5</td><td>Unit 3 · Point versus uniform crossover</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-final/q7c\">Full solution</a></td></tr>\r\n<tr><td><strong>Q7(d)</strong></td><td>5</td><td>Unit 4 · Applications of reinforcement learning</td><td>Theory</td><td><a href=\"#tee/papers/paper-2024-final/q7d\">Full solution</a></td></tr>\r\n</tbody></table></div>\r\n<p><strong>Source qualification:</strong> 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.</p>\r\n<h2>What this evidence does and does not establish</h2><p>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.</p>\r\n<p>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.</p>"}]},{"id":"core-maths","title":"1. The maths these three topics use","unit":"Start here","scope":"Short prerequisites, with worked examples. Read once before Fuzzy → GA → PSO.","sections":[{"id":"reading-formulas","title":"Symbols, brackets and iteration labels: how to read a formula","html":"<h2>Read a formula as a calculation instruction</h2><p>A <strong>variable</strong> is a name for a number that can change. In <strong>f(x)=x²+1</strong>, x is the input, f is the name of the scoring rule, and f(x) is its result. An <strong>equation</strong> says that the expressions on both sides have the same value. A formula tells you how to calculate a quantity.</p><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>x²</td><td>x multiplied by itself</td><td>3² = 3 × 3 = 9</td></tr><tr><td>2x or 2(x)</td><td>2 multiplied by x</td><td>For x=3: 2x=6, while x²=9</td></tr><tr><td>f(3)</td><td>Apply the rule named f to input 3</td><td>If f(x)=x²+1, then f(3)=10</td></tr><tr><td>x₁ and x₂</td><td>First and second named entries; the small lower number is a label</td><td>If a position is (3,7), x₁=3 and x₂=7</td></tr><tr><td>x at time t</td><td>A version of x at a particular iteration</td><td>Old x=3; after a move x=2. The time label is not squaring.</td></tr><tr><td>= and ≈</td><td>Exactly equal; approximately equal after rounding</td><td>1/3 ≈ 0.333333</td></tr><tr><td>∈ and { }</td><td>Belongs to; a collection of values</td><td>x ∈ {2,5} means x may be 2 or 5</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>Evaluate f(x)=2x²+1 at x=−3.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>The rule is f(x)=2x²+1. The supplied input is x=−3.</p><h4>To find</h4><p>f(−3): the output of this rule for input −3.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/4ee7030c8a3d9d3a.svg\" alt=\"f(x)=2x^2+1\" style=\"width:14.626ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute with parentheses</h5><div class=\"math-display\"><img src=\"math/c18467bab709f205.svg\" alt=\"f(-3)=2(-3)^2+1\" style=\"width:19.58ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Do the square first</h5><div class=\"math-display\"><img src=\"math/ac40c2845414cf0d.svg\" alt=\"(-3)^2=(-3)\\times(-3)=9\" style=\"width:24.874ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Multiply by 2</h5><div class=\"math-display\"><img src=\"math/c271680245ea1d71.svg\" alt=\"2\\times9=18\" style=\"width:10.308ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add 1</h5><div class=\"math-display\"><img src=\"math/27fc155eedcc5888.svg\" alt=\"f(-3)=18+1=19\" style=\"width:20.352ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> f(−3)=19.</div></section><section class=\"example\"><p class=\"question\"><strong>Evaluate g(x)=(x−2)/4 at x=10.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>The rule is g(x)=(x−2)/4. The supplied input is x=10.</p><h4>To find</h4><p>g(10): the output of this rule for input 10.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/ef554c6170bf393e.svg\" alt=\"g(x)=\\frac{x-2}{4}\" style=\"width:13.337ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><p>The fraction bar groups the numerator x−2. Subtract 2 from the input first, then divide the entire difference by 4.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Replace the input</h5><div class=\"math-display\"><img src=\"math/e276417a70627f82.svg\" alt=\"g(10)=\\frac{10-2}{4}\" style=\"width:15.274ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Finish the numerator</h5><div class=\"math-display\"><img src=\"math/bdb801d401c03c68.svg\" alt=\"10-2=8\" style=\"width:10.308ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/40041b1514c36954.svg\" alt=\"g(10)=8/4=2\" style=\"width:15.661ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> g(10)=2.</div></section><section class=\"example\"><p class=\"question\"><strong>At iteration 0, x=4. The rule is new x = old x − 1. Find x after two iterations.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Initial value x=4 at iteration 0. Every update subtracts 1 from the current value. Perform two updates.</p><h4>To find</h4><p>The value after update 1 and after update 2.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/14d3646dbde001b1.svg\" alt=\"x^{(t+1)}=x^{(t)}-1\" style=\"width:15.567ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Iteration 1 uses the initial value</h5><div class=\"math-display\"><img src=\"math/6df71b72d0a31e70.svg\" alt=\"x^{(1)}=4-1=3\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Iteration 2 uses the updated value</h5><div class=\"math-display\"><img src=\"math/40962d708fa42c89.svg\" alt=\"x^{(2)}=3-1=2\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Distinguish a label from a power</h5><p>x at iteration 2 is 2. Squaring the initial value would give 4²=16; that is a different operation.</p></div><div class=\"answer\"><strong>Final answer.</strong> After update 1: x=3. After update 2: x=2. The sequence is 4 → 3 → 2.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Symbol sirf naam hai. Pehle bolo kaunsa number chahiye, phir uski jagah value likho.</p>"},{"id":"objective","title":"Position, score, minimisation and maximisation","html":"<h2>What are we trying to do in IS2?</h2>\r\n<p><strong>An intelligent system</strong> uses information and a decision procedure to choose an output or an action. In M2, you study three different procedures.</p><table><thead><tr><th>Topic</th><th>Input</th><th>What the procedure does</th><th>Output</th></tr></thead><tbody><tr><td>Fuzzy logic</td><td>Temperature and occupancy</td><td>Applies rules such as IF hot AND crowded THEN fast</td><td>A fan-speed setting</td></tr><tr><td>Genetic algorithm (GA)</td><td>A population of candidate answers</td><td>Selects, combines and changes candidate answers</td><td>A good solution and its fitness</td></tr><tr><td>Particle swarm optimization (PSO)</td><td>Positions and velocities of particles</td><td>Moves candidate answers using individual and shared experience</td><td>A best position and its objective value</td></tr></tbody></table>\r\n<h2>Candidate answer and score are different</h2>\r\n<p>An <strong>objective function</strong> is the calculation used to score an answer. In <strong>minimisation</strong>, a smaller score is better; in <strong>maximisation</strong>, a larger score is better. The letter <strong>x</strong> names a candidate answer. The notation <strong>f(x)</strong>, read “f of x”, means its score. Parentheses here do not mean f multiplied by x.</p><section class=\"example\"><p class=\"question\"><strong>For the minimisation problem <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span>, find the score at <span class=\"math-inline\"><img src=\"math/feb11b3ddc232396.svg\" alt=\"x=2\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/feb11b3ddc232396.svg\" alt=\"x=2\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span></p><h4>To find</h4><p>The objective value f(x).</p></div><h4>Formula and why it applies</h4><p>Replace x by the supplied number. Square means multiply the result by itself.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract 3</h5><div class=\"math-display\"><img src=\"math/55d4a2b861701691.svg\" alt=\"x-3=2-3=-1\" style=\"width:19.145ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the difference</h5><div class=\"math-display\"><img src=\"math/28ec806f80fe7e4c.svg\" alt=\"f(2)=(-1)^2=(-1)\\times(-1)=1\" style=\"width:32.026ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The position is x = 2; its score is 1. These are two different numbers.</div></section><section class=\"example\"><p class=\"question\"><strong>For the minimisation problem <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span>, find the score at <span class=\"math-inline\"><img src=\"math/7a95cf78643aae43.svg\" alt=\"x=5\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/7a95cf78643aae43.svg\" alt=\"x=5\" style=\"width:5.442ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span></p><h4>To find</h4><p>The objective value f(x).</p></div><h4>Formula and why it applies</h4><p>Replace x by the supplied number. Square means multiply the result by itself.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract 3</h5><div class=\"math-display\"><img src=\"math/c893e43cc49d3cae.svg\" alt=\"x-3=5-3=2\" style=\"width:17.385ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the difference</h5><div class=\"math-display\"><img src=\"math/4ad5b97ffc47b26c.svg\" alt=\"f(5)=(2)^2=(2)\\times(2)=4\" style=\"width:26.746ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The position is x = 5; its score is 4. These are two different numbers.</div></section><section class=\"example\"><p class=\"question\"><strong>For the minimisation problem <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span>, find the score at <span class=\"math-inline\"><img src=\"math/2854d883b15c7a60.svg\" alt=\"x=-1\" style=\"width:7.203ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/2854d883b15c7a60.svg\" alt=\"x=-1\" style=\"width:7.203ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/17ba9de444962fb9.svg\" alt=\"f(x)=(x-3)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span></p><h4>To find</h4><p>The objective value f(x).</p></div><h4>Formula and why it applies</h4><p>Replace x by the supplied number. Square means multiply the result by itself.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract 3</h5><div class=\"math-display\"><img src=\"math/cca2cd1e0a06e8d4.svg\" alt=\"x-3=(-1)-3=-4\" style=\"width:22.665ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the difference</h5><div class=\"math-display\"><img src=\"math/dce608d3d6bd8495.svg\" alt=\"f(-1)=(-4)^2=(-4)\\times(-4)=16\" style=\"width:34.918ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The position is x = -1; its score is 16. These are two different numbers.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> x = answer ki jagah; f(x) = us answer ka score. Min mein chhota score jeetega.</p>"},{"id":"arithmetic","title":"Fractions, brackets, minimum and maximum","html":"<h2>Fractions, min and max</h2><p>A fraction means division: the top number is the <strong>numerator</strong>, and the bottom is the <strong>denominator</strong>. Calculate each bracket first. <strong>min</strong> selects the smallest listed number; <strong>max</strong> selects the largest. Neither word means addition.</p><section class=\"example\"><p class=\"question\"><strong>Evaluate <span class=\"math-inline\"><img src=\"math/df0b8ec6b8392714.svg\" alt=\"\\frac{32-25}{35-25}\" style=\"width:5.44ex;height:2.878ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Top: 32 − 25; bottom: 35 − 25.</p><h4>To find</h4><p>The quotient.</p></div><h4>Formula and why it applies</h4><p>Subtract separately in the numerator and denominator, then divide.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Calculate the numerator</h5><div class=\"math-display\"><img src=\"math/c65340df2ae7cb64.svg\" alt=\"32-25=7\" style=\"width:11.439ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate the denominator</h5><div class=\"math-display\"><img src=\"math/9a5b4bf9b146b2b2.svg\" alt=\"35-25=10\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/6b3a1b0f1231fc45.svg\" alt=\"\\frac{7}{10}=0.7\" style=\"width:9.166ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.7</div></section><section class=\"example\"><p class=\"question\"><strong>Evaluate <span class=\"math-inline\"><img src=\"math/55a4e1a39f439f8c.svg\" alt=\"\\frac{35-32}{35-25}\" style=\"width:5.44ex;height:2.878ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Top: 35 − 32; bottom: 35 − 25.</p><h4>To find</h4><p>The quotient.</p></div><h4>Formula and why it applies</h4><p>Subtract separately in the numerator and denominator, then divide.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Calculate the numerator</h5><div class=\"math-display\"><img src=\"math/b8b4baa992603f77.svg\" alt=\"35-32=3\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate the denominator</h5><div class=\"math-display\"><img src=\"math/9a5b4bf9b146b2b2.svg\" alt=\"35-25=10\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/df25a279590f4f48.svg\" alt=\"\\frac{3}{10}=0.3\" style=\"width:9.166ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.3</div></section><section class=\"example\"><p class=\"question\"><strong>Evaluate <span class=\"math-inline\"><img src=\"math/5627768e8762bda4.svg\" alt=\"\\frac{7-6}{8-6}\" style=\"width:3.84ex;height:2.894ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Top: 7 − 6; bottom: 8 − 6.</p><h4>To find</h4><p>The quotient.</p></div><h4>Formula and why it applies</h4><p>Subtract separately in the numerator and denominator, then divide.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Calculate the numerator</h5><div class=\"math-display\"><img src=\"math/e03d8b2e4fa9e9e0.svg\" alt=\"7-6=1\" style=\"width:9.176ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate the denominator</h5><div class=\"math-display\"><img src=\"math/2511936ca0026cfc.svg\" alt=\"8-6=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/0ef4a9ef78e1b7d5.svg\" alt=\"\\frac{1}{2}=0.5\" style=\"width:8.035ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.5</div></section><section class=\"example\"><p class=\"question\"><strong>Find <span class=\"math-inline\"><img src=\"math/f5116e7e9b08a405.svg\" alt=\"\\max\\{\\min(0.7,0.2),\\min(0.4,0.8)\\}\" style=\"width:32.12ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Two inner min operations followed by one outer max.</p><h4>To find</h4><p>One number.</p></div><h4>Formula and why it applies</h4><p>Work from the innermost brackets outward. This exact pattern occurs in fuzzy relation composition.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First pair</h5><div class=\"math-display\"><img src=\"math/0f24b8a13d9d75d1.svg\" alt=\"\\min(0.7,0.2)=0.2\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second pair</h5><div class=\"math-display\"><img src=\"math/8fd31f9127b73dc1.svg\" alt=\"\\min(0.4,0.8)=0.4\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Choose the larger result</h5><div class=\"math-display\"><img src=\"math/06c831ab89f196ab.svg\" alt=\"\\max(0.2,0.4)=0.4\" style=\"width:18.668ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.4.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Pehle bracket, phir divide. AND ka min; OR ka max.</p>"},{"id":"probability","title":"Percentages, probabilities and cumulative intervals","html":"<h2>Probability is a share of a specified total</h2><p>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><div class=\"math-display\"><img src=\"math/8e42f83b578b6254.svg\" alt=\"P(\\text{event})=\\frac{\\text{favourable count}}{\\text{total count}}\" style=\"width:29.228ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Red=3; blue=7. Each ball is equally likely.</p><h4>To find</h4><p>Both probabilities and their percentages.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/6e0b3ead99011455.svg\" alt=\"P(\\text{colour})=\\frac{\\text{balls of that colour}}{\\text{all balls}}\" style=\"width:31.761ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><p>All balls are equally likely, so counting them gives probability. The denominator counts all balls; the numerator counts the requested colour.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the total</h5><div class=\"math-display\"><img src=\"math/90e46c6fe6c61dca.svg\" alt=\"3+7=10\" style=\"width:10.308ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Red probability</h5><div class=\"math-display\"><img src=\"math/ac0dd61435e485bc.svg\" alt=\"P(R)=3/10=0.3=30\\%\" style=\"width:25.791ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Blue probability</h5><div class=\"math-display\"><img src=\"math/927c15e53970ce9d.svg\" alt=\"P(B)=7/10=0.7=70\\%\" style=\"width:25.791ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Red 0.3; blue 0.7. Their sum is 1.</div></section><h2>From weights to probabilities to cumulative probabilities</h2><p>A <strong>weight</strong> 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 <strong>normalisation</strong>. <strong>Cumulative</strong> means “total accumulated so far”. It turns separate shares into boundaries along a line from 0 to 1.</p><section class=\"example\"><p class=\"question\"><strong>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?</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Weights [1,2,3,4], draw 0.55. Use intervals including their lower endpoint and excluding their upper endpoint.</p><h4>To find</h4><p>Four probabilities, their running totals and the selected candidate.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/791fc41b905c43f5.svg\" alt=\"P_i=F_i/(F_A+F_B+F_C+F_D)\" style=\"width:30.117ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>F is weight. P is its share. Add P values in row order for the cumulative boundary.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Add all weights</h5><div class=\"math-display\"><img src=\"math/45a76e7db8947072.svg\" alt=\"1+2+3+4=10\" style=\"width:18.102ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Divide each weight by that same total</h5><table><thead><tr><th>Candidate</th><th>Division</th><th>Probability</th></tr></thead><tbody><tr><td>A</td><td>1÷10</td><td>0.1</td></tr><tr><td>B</td><td>2÷10</td><td>0.2</td></tr><tr><td>C</td><td>3÷10</td><td>0.3</td></tr><tr><td>D</td><td>4÷10</td><td>0.4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Build the running totals</h5><table><thead><tr><th>Candidate</th><th>Running addition</th><th>Interval</th></tr></thead><tbody><tr><td>A</td><td>0+0.1=0.1</td><td>0 ≤ r < 0.1</td></tr><tr><td>B</td><td>0.1+0.2=0.3</td><td>0.1 ≤ r < 0.3</td></tr><tr><td>C</td><td>0.3+0.3=0.6</td><td>0.3 ≤ r < 0.6</td></tr><tr><td>D</td><td>0.6+0.4=1</td><td>0.6 ≤ r ≤ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Locate the draw</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> Candidate C is selected.</div></section><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_roulette.12804497d2.svg\" width=\"720\" height=\"220\" alt=\"Each interval width equals its probability. Running totals mark the ends.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each interval width equals its probability. Running totals mark the ends.</figcaption></figure><section class=\"example\"><p class=\"question\"><strong>Two unnormalised class scores are 0.12 and 0.08. Convert them to probabilities.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Scores A=0.12 and B=0.08; they describe the only two alternatives.</p><h4>To find</h4><p>Normalised probabilities.</p></div><h4>Formula and why it applies</h4><p>Divide each score by the sum, preserving their ratio.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum the scores</h5><div class=\"math-display\"><img src=\"math/f3e0db112ddd0eb5.svg\" alt=\"0.12+0.08=0.20\" style=\"width:17.851ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Normalise A</h5><div class=\"math-display\"><img src=\"math/fd57d6dd0af66643.svg\" alt=\"P(A)=0.12/0.20=0.6\" style=\"width:23.258ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Normalise B</h5><div class=\"math-display\"><img src=\"math/a6f1afe6f9d94092.svg\" alt=\"P(B)=0.08/0.20=0.4\" style=\"width:23.279ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> A=0.6 and B=0.4. The original score 0.12 was not the final probability.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Probability = apna hissa ÷ sabka total. Cumulative = ab tak ke saare hisse jodna.</p>"},{"id":"binary","title":"Binary from the beginning: positions, place values and bits","html":"<h2>1. Position means the digit's place</h2>\r\n<p><strong>A position is simply a place occupied by one digit in a number.</strong> A digit is the symbol written there. The <strong>place value</strong> tells us how much one unit in that position is worth.</p>\r\n<p>Start with an ordinary number you already know: <strong>23</strong>. Its two digits are 2 and 3. They do not contribute the same kind of unit.</p><table><thead><tr><th></th><th>LEFT: tens place</th><th>RIGHT: ones place</th></tr></thead><tbody><tr><td>Value of this place</td><td>10</td><td>1</td></tr><tr><td>Digit written here</td><td>2</td><td>3</td></tr><tr><td>Contribution</td><td>2 × 10 = 20</td><td>3 × 1 = 3</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/46c502cb15486e6a.svg\" alt=\"23=(2\\times 10)+(3\\times 1)=20+3\" style=\"width:31.93ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The <strong>2</strong> means two tens because of where it sits. In <strong>32</strong>, the same digit 2 sits on the right and means only two ones. Changing a digit’s position can change its contribution.</p><p class=\"memory\"><strong>Yaad rakho:</strong> 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.</p><h2>2. Binary changes the size of the groups</h2>\r\n<p>Our ordinary number system is <strong>decimal</strong>: 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.</p>\r\n<p><strong>Binary</strong> has only two possible digits: <strong>0 and 1</strong>. One binary digit is called a <strong>bit</strong>. Therefore, a <strong>4-bit number means four digit boxes</strong>, each holding either 0 or 1.</p>\r\n<p>In binary, grouping happens in <strong>twos</strong>. 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 <strong>one group of two</strong> in the next box on the left.</p>\r\n<div class=\"note\"><p><strong>Binary 10 means one group of two and zero single units.</strong></p><p>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.</p></div>\r\n<p>Two groups of two make <strong>4</strong>, so the next box to the left is the fours place. Two groups of four make <strong>8</strong>, so the next box is the eights place. This is why the values double.</p><table><thead><tr><th>Ordinary number</th><th>Binary digits</th><th>Meaning</th></tr></thead><tbody><tr><td>0</td><td><span class=\"bits\">0</span></td><td>No single units</td></tr><tr><td>1</td><td><span class=\"bits\">1</span></td><td>One single unit</td></tr><tr><td>2</td><td><span class=\"bits\">10</span></td><td>One two + zero ones = 2</td></tr><tr><td>3</td><td><span class=\"bits\">11</span></td><td>One two + one one = 3</td></tr><tr><td>4</td><td><span class=\"bits\">100</span></td><td>One four + zero twos + zero ones = 4</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Decimal mein 10 ka group; binary mein 2 ka group. Do singles = ek pair; do pairs = ek group of four.</p><h2>3. Build the places from the RIGHT</h2>\r\n<p>First draw four empty boxes. <strong>Start with the box furthest to the right.</strong> Give that place the value 1. Move left one box at a time, doubling the previous value.</p>\r\n<ol><li><strong>1st box from the right:</strong> value 1.</li><li><strong>2nd box from the right:</strong> 1 × 2 = 2.</li><li><strong>3rd box from the right:</strong> 2 × 2 = 4.</li><li><strong>4th box from the right:</strong> 4 × 2 = 8.</li></ol><figure class=\"place-board\" style=\"--places:4\"><p class=\"place-label\">Place value: what ONE in this box is worth</p><div class=\"place-row\"><div class=\"place-cell\"><small>4th from right</small><strong>8</strong></div><div class=\"place-cell\"><small>3rd from right</small><strong>4</strong></div><div class=\"place-cell\"><small>2nd from right</small><strong>2</strong></div><div class=\"place-cell\"><small>1st from right</small><strong>1</strong></div></div><p class=\"place-direction\">← Double each time you move one box LEFT</p><figcaption>Start at the RIGHT with 1. Then 1 × 2 = 2, 2 × 2 = 4, and 4 × 2 = 8.</figcaption></figure><p>We built the values by moving right to left: <strong>1 → 2 → 4 → 8</strong>. Once the boxes are on paper, reading them in the usual left-to-right direction shows <strong>8, 4, 2, 1</strong>. These are the same four places, viewed in the opposite direction.</p><p><strong>Position number is not place value.</strong> 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.</p><p>If you add a fifth box on the left, its value is 8 × 2 = <strong>16</strong>. The rightmost place stays 1; adding a box on the left does not change the existing places.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Sabse RIGHT se 1 likho. LEFT jaate jaate double karo: 1, 2, 4, 8, 16. Question ke digits baad mein in boxes mein rakho.</p><h2>4. The place value stays fixed; the digit chooses it</h2>\r\n<p>Keep the digit <strong>1</strong> the same and move it into a different place. Put 0 in every other box. Watch how its position changes the number it represents:</p><table><thead><tr><th>Binary digits</th><th>Where the 1 sits</th><th>Decimal value</th></tr></thead><tbody><tr><td><span class=\"bits\">0001</span></td><td>1st place from the right: ones</td><td>1 × 1 = 1</td></tr><tr><td><span class=\"bits\">0010</span></td><td>2nd place from the right: twos</td><td>1 × 2 = 2</td></tr><tr><td><span class=\"bits\">0100</span></td><td>3rd place from the right: fours</td><td>1 × 4 = 4</td></tr><tr><td><span class=\"bits\">1000</span></td><td>4th place from the right: eights</td><td>1 × 8 = 8</td></tr></tbody></table><p>In all four rows, the written digit is still 1. Its <strong>position</strong> decides whether that 1 contributes one, two, four or eight.</p>\r\n<p>Now put <strong class=\"bits\">1 0 1 1</strong> 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:</p>\r\n<ul><li><strong>Digit 1:</strong> take one of this place value.</li><li><strong>Digit 0:</strong> take zero of this place value.</li></ul><figure class=\"place-board\" style=\"--places:4\"><p class=\"place-label\">Place value: what ONE in this box is worth</p><div class=\"place-row\"><div class=\"place-cell\"><small>4th from right</small><strong>8</strong></div><div class=\"place-cell\"><small>3rd from right</small><strong>4</strong></div><div class=\"place-cell\"><small>2nd from right</small><strong>2</strong></div><div class=\"place-cell\"><small>1st from right</small><strong>1</strong></div></div><p class=\"place-label\">Digits written in those boxes</p><div class=\"place-row\"><div class=\"place-cell included\"><strong>1</strong><small>include</small></div><div class=\"place-cell skipped\"><strong>0</strong><small>skip</small></div><div class=\"place-cell included\"><strong>1</strong><small>include</small></div><div class=\"place-cell included\"><strong>1</strong><small>include</small></div></div><p class=\"place-label\">Each box contributes</p><div class=\"place-row\"><div class=\"place-cell\"><span>1 × 8</span><strong>8</strong></div><div class=\"place-cell\"><span>0 × 4</span><strong>0</strong></div><div class=\"place-cell\"><span>1 × 2</span><strong>2</strong></div><div class=\"place-cell\"><span>1 × 1</span><strong>1</strong></div></div><figcaption>Add the contributions: 8 + 0 + 2 + 1 = 11 in ordinary decimal notation.</figcaption></figure><p>The 0 above does <strong>not</strong> 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.</p><p>The three 1s are the same digit, but they sit in different places. They contribute <strong>8, 2 and 1</strong>. Therefore, binary 1011 represents decimal 11.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Box ki value fixed. Andar 1 hai toh value lo; 0 hai toh skip karo. Phir li hui values jodo.</p><h2>5. Binary to decimal: four complete examples</h2>\r\n<p><strong>Decode</strong> 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.</p><div class=\"math-display\"><img src=\"math/2c7d9feaea569d4c.svg\" alt=\"(1011)_2=(11)_{10}\" style=\"width:16.1ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>This line says: “one-zero-one-one in binary and eleven in decimal represent the same quantity.”</p><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/2f07200d2566e6c6.svg\" alt=\"(1011)_2\" style=\"width:7.273ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">1011</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>1</td><td>0</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 8-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/c26b14275b7516e9.svg\" alt=\"1\\times 8=8\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 4-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/ff395ff0ae2a5dd3.svg\" alt=\"0\\times 4=0\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 2-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/46c6b9d4e71ea84d.svg\" alt=\"1\\times 2=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 1-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/37d06720ad44993d.svg\" alt=\"1\\times 1=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Add the contributions</h5><div class=\"math-display\"><img src=\"math/1006619e9b2d19e6.svg\" alt=\"8+0+2+1=11\" style=\"width:18.102ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/9299eb74dd4bc751.svg\" alt=\"(1011)_2=(11)_{10}\" style=\"width:16.1ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/e242d7ba8a184724.svg\" alt=\"(0110)_2\" style=\"width:7.273ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">0110</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>0</td><td>1</td><td>1</td><td>0</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 8-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/c667fae833dbf441.svg\" alt=\"0\\times 8=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 4-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/60e4619429362147.svg\" alt=\"1\\times 4=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 2-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/46c6b9d4e71ea84d.svg\" alt=\"1\\times 2=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 1-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/cbd4799920019db6.svg\" alt=\"0\\times 1=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Add the contributions</h5><div class=\"math-display\"><img src=\"math/972060f72bffad8b.svg\" alt=\"0+4+2+0=6\" style=\"width:16.97ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/c6cd8f6b20d7ec32.svg\" alt=\"(0110)_2=(6)_{10}\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/92700f027de744f9.svg\" alt=\"(1001)_2\" style=\"width:7.273ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">1001</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>1</td><td>0</td><td>0</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 8-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/c26b14275b7516e9.svg\" alt=\"1\\times 8=8\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 4-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/ff395ff0ae2a5dd3.svg\" alt=\"0\\times 4=0\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 2-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/b584619dcb7531a8.svg\" alt=\"0\\times 2=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 1-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/37d06720ad44993d.svg\" alt=\"1\\times 1=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Add the contributions</h5><div class=\"math-display\"><img src=\"math/64fd3b60b066ebf6.svg\" alt=\"8+0+0+1=9\" style=\"width:16.97ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/d83c62995f78037e.svg\" alt=\"(1001)_2=(9)_{10}\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Convert the binary number <span class=\"math-inline\"><img src=\"math/4d6378ea1db035a2.svg\" alt=\"(10011)_2\" style=\"width:8.404ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> to decimal.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Binary digits: <span class=\"bits\">10011</span>, in this exact order.</p><h4>To find</h4><p>The ordinary decimal number represented by these digits.</p></div><h4>Formula and why it applies</h4><p>Each digit tells us how many of that place value to include. Multiply each digit by its place value, then add.</p><div class=\"math-display\"><img src=\"math/8e2952f36a427b0a.svg\" alt=\"\\text{Number}=\\text{sum of (digit}\\times\\text{place value)}\" style=\"width:37.857ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the place values above the digits</h5><table><thead><tr><th>Place value</th><th>16</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Binary digit</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Calculate the contribution of the 16-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/2d5a7498be08cfdd.svg\" alt=\"1\\times 16=16\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate the contribution of the 8-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/c667fae833dbf441.svg\" alt=\"0\\times 8=0\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Calculate the contribution of the 4-place</h5><p>The digit is 0, so this place contributes zero. Its place value still stays the same.</p><div class=\"math-display\"><img src=\"math/ff395ff0ae2a5dd3.svg\" alt=\"0\\times 4=0\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Calculate the contribution of the 2-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/46c6b9d4e71ea84d.svg\" alt=\"1\\times 2=2\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Calculate the contribution of the 1-place</h5><p>The digit is 1, so include the value of this place.</p><div class=\"math-display\"><img src=\"math/37d06720ad44993d.svg\" alt=\"1\\times 1=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Add the contributions</h5><div class=\"math-display\"><img src=\"math/4c61d1192553e0c2.svg\" alt=\"16+0+0+2+1=19\" style=\"width:23.13ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/9557b36b09cf5595.svg\" alt=\"(10011)_2=(19)_{10}\" style=\"width:17.231ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><h2>6. Decimal to binary: choose each digit</h2>\r\n<p><strong>Encode</strong> 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.</p>\r\n<p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Number banana hai. Badi value se start: jitna bacha hai usmein value fit ho toh 1 aur subtract; fit nahi ho toh 0.</p><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 6 as an unsigned 4-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 6. Required length: 4 bits, meaning exactly 4 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 4 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 6 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 8-place</h5><p>We still need 6. Taking 8 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>6</strong>.</p></div><div class=\"step\"><h5>Step 3. Choose the digit in the 4-place</h5><p>We still need 6. This is at least 4, so take one 4. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/2a4c16cf6f52dfc6.svg\" alt=\"\\text{Remaining}=6-4=2\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Choose the digit in the 2-place</h5><p>We still need 2. This is at least 2, so take one 2. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/8d90e4663ec0a413.svg\" alt=\"\\text{Remaining}=2-2=0\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Choose the digit in the 1-place</h5><p>We still need 0. Taking 1 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 6. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">0 1 1 0</strong>. Join them in the same order: <strong class=\"bits\">0110</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 7. Check by converting back</h5><div class=\"math-display\"><img src=\"math/c3e3fe9d6dd4079b.svg\" alt=\"0\\times 8+1\\times 4+1\\times 2+0\\times 1=6\" style=\"width:32.558ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/17dc4cb6ab18cf42.svg\" alt=\"(6)_{10}=(0110)_2\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 4 bits.</div></section><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 11 as an unsigned 4-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 11. Required length: 4 bits, meaning exactly 4 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 4 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 11 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 8-place</h5><p>We still need 11. This is at least 8, so take one 8. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/a475ecc5627f41d9.svg\" alt=\"\\text{Remaining}=11-8=3\" style=\"width:23.915ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Choose the digit in the 4-place</h5><p>We still need 3. Taking 4 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>3</strong>.</p></div><div class=\"step\"><h5>Step 4. Choose the digit in the 2-place</h5><p>We still need 3. This is at least 2, so take one 2. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/21e8a95558e5db30.svg\" alt=\"\\text{Remaining}=3-2=1\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Choose the digit in the 1-place</h5><p>We still need 1. This is at least 1, so take one 1. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/9f9f05b8fd1b9885.svg\" alt=\"\\text{Remaining}=1-1=0\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">1 0 1 1</strong>. Join them in the same order: <strong class=\"bits\">1011</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 7. Check by converting back</h5><div class=\"math-display\"><img src=\"math/f63d65f39c03b2d0.svg\" alt=\"1\\times 8+0\\times 4+1\\times 2+1\\times 1=11\" style=\"width:33.689ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/1b92e7546fc83d0f.svg\" alt=\"(11)_{10}=(1011)_2\" style=\"width:16.1ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 4 bits.</div></section><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 19 as an unsigned 5-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 19. Required length: 5 bits, meaning exactly 5 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 5 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>16</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 19 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 16-place</h5><p>We still need 19. This is at least 16, so take one 16. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/401912fa7840eae2.svg\" alt=\"\\text{Remaining}=19-16=3\" style=\"width:25.047ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Choose the digit in the 8-place</h5><p>We still need 3. Taking 8 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>3</strong>.</p></div><div class=\"step\"><h5>Step 4. Choose the digit in the 4-place</h5><p>We still need 3. Taking 4 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>3</strong>.</p></div><div class=\"step\"><h5>Step 5. Choose the digit in the 2-place</h5><p>We still need 3. This is at least 2, so take one 2. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/21e8a95558e5db30.svg\" alt=\"\\text{Remaining}=3-2=1\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Choose the digit in the 1-place</h5><p>We still need 1. This is at least 1, so take one 1. Write <strong>1</strong> in this box.</p><div class=\"math-display\"><img src=\"math/9f9f05b8fd1b9885.svg\" alt=\"\\text{Remaining}=1-1=0\" style=\"width:22.784ex;height:2.011ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">1 0 0 1 1</strong>. Join them in the same order: <strong class=\"bits\">10011</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 8. Check by converting back</h5><div class=\"math-display\"><img src=\"math/684f11c4b4f0e966.svg\" alt=\"1\\times 16+0\\times 8+0\\times 4+1\\times 2+1\\times 1=19\" style=\"width:42.614ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/a03240c4b6abd4c3.svg\" alt=\"(19)_{10}=(10011)_2\" style=\"width:17.231ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 5 bits.</div></section><section class=\"example\"><p class=\"question\"><strong>Write the decimal number 0 as an unsigned 4-bit binary number.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Decimal number: 0. Required length: 4 bits, meaning exactly 4 digit boxes.</p><h4>To find</h4><p>The binary digits, including any zero at the beginning needed to keep the required length.</p></div><h4>Formula and why it applies</h4><p>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.</p><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Make 4 boxes and label their values</h5><table><thead><tr><th>Place value</th><th>8</th><th>4</th><th>2</th><th>1</th></tr></thead><tbody><tr><td>Digit to choose</td><td>□</td><td>□</td><td>□</td><td>□</td></tr></tbody></table><p>Start with the whole number 0 still to make. Work from the largest place on the LEFT to the smallest on the RIGHT.</p></div><div class=\"step\"><h5>Step 2. Choose the digit in the 8-place</h5><p>We still need 0. Taking 8 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 3. Choose the digit in the 4-place</h5><p>We still need 0. Taking 4 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 4. Choose the digit in the 2-place</h5><p>We still need 0. Taking 2 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 5. Choose the digit in the 1-place</h5><p>We still need 0. Taking 1 would be too much, so skip this place. Write <strong>0</strong> in this box.</p><p>We used nothing from this place. The remaining amount stays <strong>0</strong>.</p></div><div class=\"step\"><h5>Step 6. Read the digits from LEFT to RIGHT</h5><p>The boxes now contain <strong class=\"bits\">0 0 0 0</strong>. Join them in the same order: <strong class=\"bits\">0000</strong>.</p><p>The remaining amount is 0, so we have made the required number exactly.</p></div><div class=\"step\"><h5>Step 7. Check by converting back</h5><div class=\"math-display\"><img src=\"math/edfc0319e8a1b583.svg\" alt=\"0\\times 8+0\\times 4+0\\times 2+0\\times 1=0\" style=\"width:32.558ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/a5e664b79f15e056.svg\" alt=\"(0)_{10}=(0000)_2\" style=\"width:14.969ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The answer has 4 bits.</div></section><h2>7. A zero at the start can keep the required length</h2>\r\n<p><strong>Leading zeros</strong> are zeros at the beginning, on the left. Binary 110 and 0110 both represent decimal 6:</p><div class=\"math-display\"><img src=\"math/d9a164fc63da4660.svg\" alt=\"(110)_2=(1\\times4)+(1\\times2)+(0\\times1)=6\" style=\"width:39.203ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c20ea277129e9ff7.svg\" alt=\"(0110)_2=(0\\times8)+(1\\times4)+(1\\times2)+(0\\times1)=6\" style=\"width:49.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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 <strong class=\"bits\">0110</strong>.</p><p>This rule is specifically about zeros on the <strong>left</strong>. 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.</p><h2>8. How many bits are enough?</h2>\r\n<p>For these GA conversions, <strong>unsigned</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>Find the largest unsigned integer that can be represented using 4 bits. Can decimal 19 fit in 4 bits?</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Four places with values 8, 4, 2 and 1. Each digit is either 0 or 1.</p><h4>To find</h4><p>The largest possible value and whether 19 can be represented.</p></div><h4>Formula and why it applies</h4><p>A digit contributes the most when it is 1. Set every digit to 1 and add all the place values.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Use all four places</h5><p>The largest 4-bit string is <strong class=\"bits\">1111</strong>.</p></div><div class=\"step\"><h5>Step 2. Add their values</h5><div class=\"math-display\"><img src=\"math/f3965404fe997578.svg\" alt=\"8+4+2+1=15\" style=\"width:18.102ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Compare with 19</h5><p>19 is greater than 15, so four bits are insufficient. Add the 16-place on the left. Then 19 = 16 + 2 + 1, giving <strong class=\"bits\">10011</strong> in five bits.</p></div><div class=\"answer\"><strong>Final answer.</strong> The maximum is 15. Decimal 19 needs at least 5 bits.</div></section><p>The general rule is <span class=\"math-inline\"><img src=\"math/b2b8f1010a02780c.svg\" alt=\"\\text{largest unsigned value}=2^n-1\" style=\"width:30.783ex;height:2.036ex\" loading=\"lazy\" decoding=\"async\"></span>. Here n means the number of bits. The power <span class=\"math-inline\"><img src=\"math/c0a4368527e8571c.svg\" alt=\"2^n\" style=\"width:2.279ex;height:1.528ex\" loading=\"lazy\" decoding=\"async\"></span> means multiplying n copies of 2; for four bits, <span class=\"math-inline\"><img src=\"math/750f21b62900f171.svg\" alt=\"2^4=2\\times2\\times2\\times2=16\" style=\"width:23.238ex;height:2.09ex\" loading=\"lazy\" decoding=\"async\"></span>, so the maximum is 16 − 1 = 15. There are 16 different values, from 0 through 15, because zero is also one value.</p><table><thead><tr><th>Bits</th><th>Place values from left to right</th><th>Unsigned values</th></tr></thead><tbody><tr><td>3</td><td>4, 2, 1</td><td>0 to 7</td></tr><tr><td>4</td><td>8, 4, 2, 1</td><td>0 to 15</td></tr><tr><td>5</td><td>16, 8, 4, 2, 1</td><td>0 to 31</td></tr></tbody></table><p>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.</p><h2>9. Where this fits in a genetic algorithm</h2>\r\n<p>A <strong>chromosome</strong> 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 <strong class=\"bits\">0110</strong>.</p>\r\n<p>During crossover or mutation, the algorithm changes these bits. Afterwards, <strong>decode the resulting chromosome</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Encode: number se bits. Decode: bits se number. GA mein bits badle toh x dobara decode karo, phir uska score nikalo.</p>"},{"id":"coordinates","title":"Vectors, coordinates, matrices and transpose from the first entry","html":"<h2>A vector is an ordered list of numbers</h2><p>A <strong>scalar</strong> is one number, such as 5. A <strong>vector</strong> is an ordered list, such as (3,7). Order matters: the first number may be horizontal position and the second vertical position. A <strong>matrix</strong> is a rectangular table of numbers. These words describe how numbers are arranged, not a new kind of arithmetic.</p><table><thead><tr><th>Arrangement</th><th>Example</th><th>How to read it</th></tr></thead><tbody><tr><td>Scalar</td><td>5</td><td>One value</td></tr><tr><td>Row vector</td><td>[3,7]</td><td>One row, two entries</td></tr><tr><td>Column vector</td><td><span class=\"math-inline\"><img src=\"math/a263cada62354d7d.svg\" alt=\"\\begin{bmatrix}3\\\\7\\end{bmatrix}\" style=\"width:3.52ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span></td><td>Two rows, one entry</td></tr><tr><td>Matrix</td><td><span class=\"math-inline\"><img src=\"math/a9c176e9eb771437.svg\" alt=\"\\begin{bmatrix}3&amp;7\\\\4&amp;2\\end{bmatrix}\" style=\"width:6.914ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span></td><td>Two rows, two columns</td></tr></tbody></table><h2>Rows go across; columns go down</h2><p>For a matrix A, <strong>A₂₁</strong> means the entry in <strong>row 2, column 1</strong>. The first lower label is the row; the second is the column. Matrix size is written <strong>number of rows × number of columns</strong>. A 2×3 matrix has two rows containing three entries each.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_matrix.a8870f4ab6.svg\" width=\"660\" height=\"250\" alt=\"Read an entry by finding its row first and its column second.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Read an entry by finding its row first and its column second.</figcaption></figure><section class=\"example\"><p class=\"question\"><strong>Let A have first row [2,5,8] and second row [1,4,7]. State its size and find A₂₃ and A₁₂.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/01196c6c529af391.svg\" alt=\"A=\\begin{bmatrix}2&amp;5&amp;8\\\\1&amp;4&amp;7\\end{bmatrix}\" style=\"width:15.022ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Matrix dimensions and two entries.</p></div><h4>Formula and why it applies</h4><p>Read the lower labels in row–column order.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Count the arrangement</h5><p>There are 2 horizontal rows and 3 vertical columns. Size=2×3.</p></div><div class=\"step\"><h5>Step 2. Find A₂₃</h5><p>Row 2 is [1,4,7]. Its third entry is 7.</p></div><div class=\"step\"><h5>Step 3. Find A₁₂</h5><p>Row 1 is [2,5,8]. Its second entry is 5.</p></div><div class=\"answer\"><strong>Final answer.</strong> Size 2×3; A₂₃=7; A₁₂=5.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Position x=(3,7); velocity v=(−1,2); personal-best position p=(1,8). First and second coordinates stay in the same order.</p><h4>To find</h4><p>The difference p−x, the scaled difference 0.5(p−x), and the updated position x+v.</p></div><h4>Formula and why it applies</h4><p>Match first with first and second with second. A scalar multiplies every coordinate.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Subtract corresponding coordinates</h5><div class=\"math-display\"><img src=\"math/162ee1a9497444ec.svg\" alt=\"p-x=(1-3,\\;8-7)=(-2,1)\" style=\"width:31.472ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply both coordinates by 0.5</h5><div class=\"math-display\"><img src=\"math/2b6de1af24a02bfa.svg\" alt=\"0.5(p-x)=(0.5(-2),\\;0.5(1))=(-1,0.5)\" style=\"width:41.154ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the velocity to the position</h5><div class=\"math-display\"><img src=\"math/1d4e7e4fb543eeb3.svg\" alt=\"x+v=(3+(-1),\\;7+2)=(2,9)\" style=\"width:33.192ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Difference (−2,1); scaled difference (−1,0.5); new position (2,9).</div></section><h2>Transpose exchanges rows and columns</h2><p>The superscript <strong>T</strong> in Aᵀ means <strong>transpose</strong>. 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.</p><section class=\"example\"><p class=\"question\"><strong>Find the transpose of A = [[2,5,8],[1,4,7]].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/01196c6c529af391.svg\" alt=\"A=\\begin{bmatrix}2&amp;5&amp;8\\\\1&amp;4&amp;7\\end{bmatrix}\" style=\"width:15.022ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Aᵀ.</p></div><h4>Formula and why it applies</h4><p>Turn each old row into a new column, keeping its order.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Move the first row</h5><p>[2,5,8] becomes the first column from top to bottom.</p></div><div class=\"step\"><h5>Step 2. Move the second row</h5><p>[1,4,7] becomes the second column from top to bottom.</p></div><div class=\"step\"><h5>Step 3. Write the new arrangement</h5><div class=\"math-display\"><img src=\"math/1317eeff1ada1bd8.svg\" alt=\"A^T=\\begin{bmatrix}2&amp;1\\\\5&amp;4\\\\8&amp;7\\end{bmatrix}\" style=\"width:13.571ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Aᵀ has 3 rows and 2 columns. No number changed.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the dot product of [2,3] and [4,5].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>First vector a=[2,3]; second vector b=[4,5]. Each has two entries.</p><h4>To find</h4><p>The dot product a·b, a single number obtained by adding the two matching products.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b383a742b04996eb.svg\" alt=\"a\\cdot b=a_1b_1+a_2b_2\" style=\"width:17.87ex;height:1.91ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply corresponding entries, then add the products. Markov matrix multiplication later repeats this for each destination column.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First product</h5><div class=\"math-display\"><img src=\"math/104d4bd59aaafd44.svg\" alt=\"2\\times4=8\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second product</h5><div class=\"math-display\"><img src=\"math/9c14aa0e11753341.svg\" alt=\"3\\times5=15\" style=\"width:10.308ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add</h5><div class=\"math-display\"><img src=\"math/bb009310f34186b1.svg\" alt=\"8+15=23\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The dot product is 23. It is not the vector [8,15].</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Vector = order wali list. Matrix = rows-columns ka table. Entry padhte waqt pehle row, phir column.</p>"},{"id":"graphs","title":"Graph axes, intervals and the fractions inside membership functions","html":"<h2>Read a graph one input at a time</h2><p>The <strong>horizontal axis</strong> runs left to right and shows input x. The <strong>vertical axis</strong> 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.</p><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_slope.c91a1030aa.svg\" width=\"720\" height=\"310\" alt=\"Halfway along a straight rise from height 0 to height 1 gives height 0.5.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Halfway along a straight rise from height 0 to height 1 gives height 0.5.</figcaption></figure><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>x < 5</td><td>Strictly less than 5</td><td>4.9 qualifies; 5 does not</td></tr><tr><td>x ≤ 5</td><td>Less than or equal to 5</td><td>Both 4.9 and 5 qualify</td></tr><tr><td>2 ≤ x ≤ 8</td><td>x is between 2 and 8 including both ends</td><td>The interval is [2,8]</td></tr><tr><td>[2,8)</td><td>Include 2; exclude 8</td><td>Useful for roulette interval boundaries</td></tr><tr><td>Piecewise formula</td><td>Choose one calculation according to where x lies</td><td>Rising branch, falling branch or outside</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>A straight membership line rises from (2,0) to (6,1). Find its height at x=3.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Left input=2; peak input=6; required input=3.</p><h4>To find</h4><p>Membership height.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b04bfa99f868280c.svg\" alt=\"\\text{height}=\\frac{\\text{distance from left}}{\\text{total rising width}}\" style=\"width:27.162ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><p>A straight line changes by the same proportion of its height as the proportion travelled along its width.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find distance travelled</h5><div class=\"math-display\"><img src=\"math/c1d7fd7ffca66c17.svg\" alt=\"3-2=1\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find total width</h5><div class=\"math-display\"><img src=\"math/0e4232a9d761c2cf.svg\" alt=\"6-2=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide distance by width</h5><div class=\"math-display\"><img src=\"math/07bbe7a121e1fdbb.svg\" alt=\"\\mu(3)=\\frac{1}{4}=0.25\" style=\"width:16.439ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership=0.25.</div></section><section class=\"example\"><p class=\"question\"><strong>A straight membership line rises from (2,0) to (6,1). Find its height at x=4.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Left input=2; peak input=6; required input=4.</p><h4>To find</h4><p>Membership height.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b04bfa99f868280c.svg\" alt=\"\\text{height}=\\frac{\\text{distance from left}}{\\text{total rising width}}\" style=\"width:27.162ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><p>A straight line changes by the same proportion of its height as the proportion travelled along its width.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find distance travelled</h5><div class=\"math-display\"><img src=\"math/bae97278ddb3a17b.svg\" alt=\"4-2=2\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find total width</h5><div class=\"math-display\"><img src=\"math/0e4232a9d761c2cf.svg\" alt=\"6-2=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide distance by width</h5><div class=\"math-display\"><img src=\"math/d97d0314d106677e.svg\" alt=\"\\mu(4)=\\frac{2}{4}=0.5\" style=\"width:15.308ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership=0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>A straight membership line rises from (10,0) to (30,1). Find its height at x=25.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Left input=10; peak input=30; required input=25.</p><h4>To find</h4><p>Membership height.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/b04bfa99f868280c.svg\" alt=\"\\text{height}=\\frac{\\text{distance from left}}{\\text{total rising width}}\" style=\"width:27.162ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><p>A straight line changes by the same proportion of its height as the proportion travelled along its width.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find distance travelled</h5><div class=\"math-display\"><img src=\"math/14c6ec773492ed50.svg\" alt=\"25-10=15\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find total width</h5><div class=\"math-display\"><img src=\"math/04505a3de0e682e9.svg\" alt=\"30-10=20\" style=\"width:12.57ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide distance by width</h5><div class=\"math-display\"><img src=\"math/5aad4f1600b806e2.svg\" alt=\"\\mu(25)=\\frac{15}{20}=0.75\" style=\"width:18.702ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership=0.75.</div></section><section class=\"example\"><p class=\"question\"><strong>A membership line falls from (5,1) to (8,0). Find its height at x=7.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Peak=5; right zero=8; x=7.</p><h4>To find</h4><p>Membership.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/a265ac2e0c52f5aa.svg\" alt=\"\\mu(x)=\\frac{\\text{distance still remaining to right zero}}{\\text{total falling width}}\" style=\"width:43.61ex;height:5.118ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Remaining distance</h5><div class=\"math-display\"><img src=\"math/8f69aa364500c9a0.svg\" alt=\"8-7=1\" style=\"width:9.176ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Total falling width</h5><div class=\"math-display\"><img src=\"math/11fb664a99823789.svg\" alt=\"8-5=3\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide</h5><div class=\"math-display\"><img src=\"math/245668271fba02af.svg\" alt=\"\\mu(7)=1/3\\approx0.333333\" style=\"width:22.231ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Membership≈0.333333. Using distance already travelled would reverse the falling line.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Chadhti line: left se kitna aage? Utarti line: right tak kitna baaki? Dono mein poori width se divide.</p>"},{"id":"sums-averages","title":"Sum notation, ordinary averages and weighted averages","html":"<h2>Σ means add a list of terms</h2><p>The capital Greek letter <strong>Σ</strong> 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.</p><div class=\"math-display\"><img src=\"math/187790b2a1d823b4.svg\" alt=\"\\sum_{i=1}^{3}a_i=a_1+a_2+a_3\" style=\"width:20.683ex;height:6.711ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>For a₁=2, a₂=5 and a₃=8, calculate Σaᵢ and their mean.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Three numbers: 2,5,8.</p><h4>To find</h4><p>Sum and ordinary average.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/5c0dc23066626f45.svg\" alt=\"\\bar a=\\frac{a_1+a_2+a_3}{3}\" style=\"width:17.294ex;height:4.45ex\" loading=\"lazy\" decoding=\"async\"></div><p>The bar means average. Each number has equal weight.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Expand the sum symbol</h5><div class=\"math-display\"><img src=\"math/73da4a922a419fa3.svg\" alt=\"\\sum_{i=1}^3 a_i=2+5+8\" style=\"width:17.523ex;height:6.711ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/a4c248316325eed6.svg\" alt=\"2+5=7\\quad7+8=15\" style=\"width:21.747ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide by the count of numbers</h5><div class=\"math-display\"><img src=\"math/30b09f1f2d830b9a.svg\" alt=\"\\bar a=15/3=5\" style=\"width:12.887ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Sum=15; mean=5.</div></section><h2>A weighted average gives unequal influence</h2><p>If values 20 and 80 have weights 3 and 1, this is equivalent to averaging [20,20,20,80]. Therefore you divide by the <strong>sum of weights</strong>, not by the number of distinct values. Weights may also be decimals. Their total need not initially be 1.</p><div class=\"math-display\"><img src=\"math/b4ce56a94f70502d.svg\" alt=\"\\bar z=\\frac{w_1z_1+w_2z_2+\\cdots}{w_1+w_2+\\cdots}\" style=\"width:22.542ex;height:4.74ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>Find the weighted average of [20, 80] with corresponding weights [3, 1].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Value</th><th>Its weight</th></tr></thead><tbody><tr><td>20</td><td>3</td></tr><tr><td>80</td><td>1</td></tr></tbody></table><h4>To find</h4><p>The weighted average of the listed values.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/91cd48ba0a9e464c.svg\" alt=\"\\bar z=\\frac{\\sum_i w_i z_i}{\\sum_i w_i}\" style=\"width:12.722ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply value 1 by its weight</h5><div class=\"math-display\"><img src=\"math/6b7da7f3a0b59a78.svg\" alt=\"20\\times3=60\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply value 2 by its weight</h5><div class=\"math-display\"><img src=\"math/5b5619f67f240a03.svg\" alt=\"80\\times1=80\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the weighted products</h5><div class=\"math-display\"><img src=\"math/4012d4bc25614db2.svg\" alt=\"60+80=140\" style=\"width:13.701ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add the weights</h5><div class=\"math-display\"><img src=\"math/c37463b701447787.svg\" alt=\"3+1=4\" style=\"width:9.176ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Divide the two totals</h5><div class=\"math-display\"><img src=\"math/dbdc025973fedfed.svg\" alt=\"\\bar z=\\frac{140}{4}=35\" style=\"width:13.738ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 35.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the weighted average of [20, 50, 80] with corresponding weights [0.2, 0.6, 0.2].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Value</th><th>Its weight</th></tr></thead><tbody><tr><td>20</td><td>0.2</td></tr><tr><td>50</td><td>0.6</td></tr><tr><td>80</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>The weighted average of the listed values.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/91cd48ba0a9e464c.svg\" alt=\"\\bar z=\\frac{\\sum_i w_i z_i}{\\sum_i w_i}\" style=\"width:12.722ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply value 1 by its weight</h5><div class=\"math-display\"><img src=\"math/396c5c156cb14965.svg\" alt=\"20\\times0.2=4\" style=\"width:12.068ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply value 2 by its weight</h5><div class=\"math-display\"><img src=\"math/f5c2b1ec334e1160.svg\" alt=\"50\\times0.6=30\" style=\"width:13.199ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Multiply value 3 by its weight</h5><div class=\"math-display\"><img src=\"math/9cd289b939140103.svg\" alt=\"80\\times0.2=16\" style=\"width:13.199ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add the weighted products</h5><div class=\"math-display\"><img src=\"math/cd5630515c6da6da.svg\" alt=\"4+30+16=50\" style=\"width:16.467ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Add the weights</h5><div class=\"math-display\"><img src=\"math/62f59e75ba76247e.svg\" alt=\"0.2+0.6+0.2=1\" style=\"width:18.354ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Divide the two totals</h5><div class=\"math-display\"><img src=\"math/21b878898a4a0815.svg\" alt=\"\\bar z=\\frac{50}{1}=50\" style=\"width:12.607ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 50.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the weighted average of [65, 85] with corresponding weights [0.3, 0.5].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Value</th><th>Its weight</th></tr></thead><tbody><tr><td>65</td><td>0.3</td></tr><tr><td>85</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>The weighted average of the listed values.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/91cd48ba0a9e464c.svg\" alt=\"\\bar z=\\frac{\\sum_i w_i z_i}{\\sum_i w_i}\" style=\"width:12.722ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply value 1 by its weight</h5><div class=\"math-display\"><img src=\"math/3285138cffe8477f.svg\" alt=\"65\\times0.3=19.5\" style=\"width:14.959ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply value 2 by its weight</h5><div class=\"math-display\"><img src=\"math/bf9c01dfa8fdf718.svg\" alt=\"85\\times0.5=42.5\" style=\"width:14.959ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the weighted products</h5><div class=\"math-display\"><img src=\"math/6cfaa5029f5a6cb9.svg\" alt=\"19.5+42.5=62\" style=\"width:16.09ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add the weights</h5><div class=\"math-display\"><img src=\"math/8108e5ca96fd589b.svg\" alt=\"0.3+0.5=0.8\" style=\"width:14.457ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Divide the two totals</h5><div class=\"math-display\"><img src=\"math/a313fb00fc0904f5.svg\" alt=\"\\bar z=\\frac{62}{0.8}=77.5\" style=\"width:14.996ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 77.5.</div></section><h2>Π means multiply a list of terms</h2><div class=\"math-display\"><img src=\"math/40f044c5860eb614.svg\" alt=\"\\prod_{i=1}^{3}a_i=a_1a_2a_3\" style=\"width:14.776ex;height:6.711ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Sigma = sab jodo. Product Pi = sab multiply. Weighted mean = value×weight ke total ko weights ke total se divide.</p>"},{"id":"powers-exponentials","title":"Powers, roots, absolute values and exp on the calculator","html":"<h2>Powers, roots and exponentials used later</h2><p>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.</p><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>2⁰, 2¹, 2², 2³</td><td>Binary place values</td><td>1,2,4,8</td></tr><tr><td>|x|</td><td>Absolute value: distance from zero</td><td>|−3|=3 and |3|=3</td></tr><tr><td>e ≈ 2.71828</td><td>A fixed mathematical constant</td><td>e⁰=1</td></tr><tr><td>exp(u)</td><td>Another way of writing eᵘ</td><td>exp(−2)=e⁻²≈0.135335</td></tr><tr><td>ln(x)</td><td>The natural logarithm; the exponent giving x from e</td><td>ln(e²)=2; ln(1)=0</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>Calculate exp(−x²/2) at x=-2.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>x=-2; exp means e raised to the bracketed exponent.</p><h4>To find</h4><p>The exponential value.</p></div><h4>Formula and why it applies</h4><p>Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Square x</h5><div class=\"math-display\"><img src=\"math/4193a49c3f887499.svg\" alt=\"(-2)^2=4\" style=\"width:9.788ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Negate and divide by 2</h5><div class=\"math-display\"><img src=\"math/3d2cdafe17449912.svg\" alt=\"u=-\\frac{4}{2}=-2\" style=\"width:14.107ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate the exponential</h5><div class=\"math-display\"><img src=\"math/93bf357c53e138fe.svg\" alt=\"e^u=e^{-2}\\approx 0.135335283\" style=\"width:23.419ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.135335283.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate exp(−x²/2) at x=0.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>x=0; exp means e raised to the bracketed exponent.</p><h4>To find</h4><p>The exponential value.</p></div><h4>Formula and why it applies</h4><p>Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Square x</h5><div class=\"math-display\"><img src=\"math/cd561d277fcba773.svg\" alt=\"(0)^2=0\" style=\"width:8.027ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Negate and divide by 2</h5><div class=\"math-display\"><img src=\"math/4e1e416350f910b4.svg\" alt=\"u=-\\frac{0}{2}=0\" style=\"width:12.346ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate the exponential</h5><div class=\"math-display\"><img src=\"math/4263edec66681677.svg\" alt=\"e^u=e^{0}\\approx 1\" style=\"width:11.365ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 1.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate exp(−x²/2) at x=2.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>x=2; exp means e raised to the bracketed exponent.</p><h4>To find</h4><p>The exponential value.</p></div><h4>Formula and why it applies</h4><p>Calculate the complete exponent first. Then use the calculator’s e-to-the-power function.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Square x</h5><div class=\"math-display\"><img src=\"math/730976d327ad7f5e.svg\" alt=\"(2)^2=4\" style=\"width:8.027ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Negate and divide by 2</h5><div class=\"math-display\"><img src=\"math/3d2cdafe17449912.svg\" alt=\"u=-\\frac{4}{2}=-2\" style=\"width:14.107ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate the exponential</h5><div class=\"math-display\"><img src=\"math/93bf357c53e138fe.svg\" alt=\"e^u=e^{-2}\\approx 0.135335283\" style=\"width:23.419ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.135335283.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> exp ka matlab e ki power. Pehle exponent ka poora hisaab, phir eˣ.</p>"}]},{"id":"u1-zero","title":"Unit 1 · Probability from zero (AND, OR, given, Bayes)","unit":"1","scope":"Start here if probability is new: counting, AND/OR, conditional probability and Bayes with pictures","sections":[{"id":"and-or","title":"AND, OR and NOT with a picture","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Experiment</td><td>An observation with possible outcomes</td><td>One coin toss</td></tr><tr><td>Outcome</td><td>One complete result</td><td>Heads</td></tr><tr><td>Event</td><td>A set of outcomes satisfying a statement</td><td>Die result is even: {2,4,6}</td></tr><tr><td>A AND B</td><td>Both statements hold</td><td>Likes cricket and football</td></tr><tr><td>A OR B</td><td>At least one statement holds, including both</td><td>Likes either sport or both</td></tr><tr><td>NOT A</td><td>All outcomes outside A</td><td>Does not like cricket</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>Before this:</strong> read <a href=\"#tee/read/u1-zero/given\">Probability from zero</a>. Here we combine two events.</p>\r\n\r\n<h2>The picture: 100 students</h2>\r\n<p>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.</p>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/prob_venn.84491b9acc.svg\" width=\"640\" height=\"270\" alt=\"AND = the overlap, OR = everything inside either circle\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<h2>AND (both happen) = the overlap</h2>\r\n<div class=\"math-display\"><img src=\"math/a166ec0150b9d8e6.svg\" alt=\"P(C\\text{ and }F)=P(C\\cap F)=\\frac{10}{100}=0.1\" style=\"width:37.371ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h2>OR (at least one happens) = everything inside the circles</h2>\r\n<p>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>\r\n<div class=\"math-display\"><img src=\"math/e851c0d30cd17e85.svg\" alt=\"P(C\\cup F)=P(C)+P(F)-P(C\\cap F)=0.4+0.3-0.1=0.6\" style=\"width:60.788ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h2>NOT = outside</h2>\r\n<div class=\"math-display\"><img src=\"math/fd0572e2636f2a68.svg\" alt=\"P(\\text{not }C)=1-P(C)=1-0.4=0.6\\qquad P(\\text{neither})=1-P(C\\cup F)=0.4\" style=\"width:73.936ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h2>Independent events: multiply for AND</h2>\r\n<p>Two events are <strong>independent</strong> if one does not change the chance of the other (two separate coin tosses). Then</p>\r\n<div class=\"math-display\"><img src=\"math/9d043d505b5382fc.svg\" alt=\"P(A\\text{ and }B)=P(A)\\times P(B)\\qquad P(\\text{two heads})=0.5\\times0.5=0.25\" style=\"width:64.11ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cricket and football are <em>not</em> independent here: 0.4 × 0.3 = 0.12 ≠ 0.1.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Word in the question</th><th>Symbol</th><th>What to do</th></tr></thead><tbody>\r\n<tr><td>and / both</td><td>∩, ∧, comma</td><td>overlap; multiply only if independent</td></tr>\r\n<tr><td>or / at least one</td><td>∪, ∨</td><td>add, subtract the overlap</td></tr>\r\n<tr><td>not</td><td>¬, ′, c</td><td>1 minus</td></tr>\r\n<tr><td>given / if we know</td><td>|</td><td>next lesson: divide</td></tr>\r\n</tbody></table></div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> AND = dono (beech ka hissa). OR = koi bhi ek (jodo, overlap ek baar ghatao). NOT = 1 minus.</div>"},{"id":"given","title":"“Given”: conditional probability by shrinking the world","html":"<p class=\"cue\"><strong>In one line:</strong> “P(A given B)” means: forget everyone who is not B, and ask what fraction of the B group is also A.</p>\r\n\r\n<h2>Using the 100 students</h2>\r\n<p>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>\r\n<div class=\"math-display\"><img src=\"math/e504a0ad42ea83d7.svg\" alt=\"P(F\\mid C)=\\frac{\\text{both}}{\\text{cricket}}=\\frac{10}{40}=0.25\" style=\"width:32.691ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The same with probabilities instead of counts:</p>\r\n<div class=\"math-display\"><img src=\"math/06d91b8a011bacbf.svg\" alt=\"\\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\" style=\"width:52.859ex;height:6.683ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The thing after the bar “|” always goes in the denominator. Notice <span class=\"math-inline\"><img src=\"math/a402991a380b1d2f.svg\" alt=\"P(C\\mid F)=10/30=0.33\" style=\"width:24.472ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> is different: the world you shrink to changes.</p>\r\n\r\n<h2>Reading a joint table</h2>\r\n<p>A <strong>joint table</strong> lists the probability of every combination. Example: 200 patients.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Counts</th><th>Flu</th><th>No flu</th><th>Row total</th></tr></thead><tbody>\r\n<tr><td>Fever</td><td>30</td><td>20</td><td>50</td></tr>\r\n<tr><td>No fever</td><td>10</td><td>140</td><td>150</td></tr>\r\n<tr><td>Column total</td><td>40</td><td>160</td><td>200</td></tr></tbody></table></div>\r\n<p>Divide every cell by 200 to get the probability table:</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>P</th><th>Flu</th><th>No flu</th><th>Total</th></tr></thead><tbody>\r\n<tr><td>Fever</td><td>0.15</td><td>0.10</td><td>0.25</td></tr>\r\n<tr><td>No fever</td><td>0.05</td><td>0.70</td><td>0.75</td></tr>\r\n<tr><td>Total</td><td>0.20</td><td>0.80</td><td>1</td></tr></tbody></table></div>\r\n<ul>\r\n<li><strong>Joint</strong>: one cell. P(fever and flu) = 0.15.</li>\r\n<li><strong>Marginal</strong>: a row or column total. P(flu) = 0.15 + 0.05 = 0.20.</li>\r\n<li><strong>Conditional</strong>: a cell ÷ a total. P(flu | fever) = 0.15 / 0.25 = 0.6; P(fever | flu) = 0.15 / 0.20 = 0.75.</li>\r\n</ul>\r\n<p>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: <a href=\"#tee/read/u1-prob/full-joint\">full joint distribution</a>.</p>\r\n\r\n<h2>Product rule (just the formula turned around)</h2>\r\n<div class=\"math-display\"><img src=\"math/aec0a3a12cca75ad.svg\" alt=\"P(A\\text{ and }B)=P(A\\mid B)\\,P(B)\" style=\"width:28.982ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Bayesian networks use this again and again: multiply a “given” probability by the probability of the thing given.</p>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> “Given B” = duniya chhoti karke sirf B wale log dekho. Formula: dono ÷ given wala.</div>\r\n<h2>Two complete conditional-probability examples</h2><section class=\"example\"><p class=\"question\"><strong>A table of 200 patients has 160 patients without flu; 140 of those also have no fever. Find P(no fever | no flu).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>No-flu group=160; both no fever and no flu=140.</p><h4>To find</h4><p>The conditional probability.</p></div><h4>Formula and why it applies</h4><p>Keep only the evidence group. The denominator measures that group; the numerator measures the part satisfying both events.</p><div class=\"math-display\"><img src=\"math/af10b31123342cc5.svg\" alt=\"P(A\\mid B)=\\frac{P(A\\cap B)}{P(B)},\\qquad P(B)&gt;0\" style=\"width:37.015ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Choose numerator and denominator</h5><p>Numerator=140; denominator=160. The quantity after the bar identifies the denominator.</p></div><div class=\"step\"><h5>Step 2. Divide</h5><div class=\"math-display\"><img src=\"math/ed912694e6123813.svg\" alt=\"\\frac{140}{160}=0.875\" style=\"width:12.56ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.875.</div></section><section class=\"example\"><p class=\"question\"><strong>Given P(A and B)=0.12 and P(B)=0.30, find P(A | B).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Joint event probability=0.12; evidence probability=0.30.</p><h4>To find</h4><p>The conditional probability.</p></div><h4>Formula and why it applies</h4><p>Keep only the evidence group. The denominator measures that group; the numerator measures the part satisfying both events.</p><div class=\"math-display\"><img src=\"math/af10b31123342cc5.svg\" alt=\"P(A\\mid B)=\\frac{P(A\\cap B)}{P(B)},\\qquad P(B)&gt;0\" style=\"width:37.015ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Choose numerator and denominator</h5><p>Numerator=0.12; denominator=0.3. The quantity after the bar identifies the denominator.</p></div><div class=\"step\"><h5>Step 2. Divide</h5><div class=\"math-display\"><img src=\"math/2ef396ae4f7c0a1c.svg\" alt=\"\\frac{0.12}{0.3}=0.4\" style=\"width:10.927ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.4.</div></section>"},{"id":"bayes-tree","title":"Bayes' rule with a tree of 1000 people","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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 <strong>expected counts</strong> 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> to reverse a “given”, imagine a crowd, split it by the cause, then by the evidence, and count.</p>\r\n\r\n<h2>The question</h2>\r\n<p>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?</p>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/prob_tree.201d46f630.svg\" width=\"680\" height=\"340\" alt=\"Imagine 1000 people (disease 1 in 1000, test catches 99%, false alarm 2%)\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n<h2>Counting on the tree</h2>\r\n<ol>\r\n<li>Of 1000 people, 1 is sick and 999 are healthy.</li>\r\n<li>The sick person tests positive with 99%: 0.99 people.</li>\r\n<li>Healthy people test positive with 2%: 0.02 × 999 = 19.98 people.</li>\r\n<li>Everyone who tests positive: 0.99 + 19.98 = 20.97 people.</li>\r\n<li>Of those, sick: 0.99. So P(sick | positive) = 0.99 / 20.97 = 0.047.</li>\r\n</ol>\r\n<p>Only about 4.7%, because the healthy group is so much bigger that its small false-alarm rate still produces most positives.</p>\r\n\r\n<h2>The same thing as a formula</h2>\r\n<div class=\"math-display\"><img src=\"math/7999e36c046cbb22.svg\" alt=\"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\" style=\"width:99.715ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Each part of the formula is one branch of the tree. Names: P(sick) is the <strong>prior</strong> (before the test), P(+ | sick) the <strong>likelihood</strong>, the denominator the <strong>evidence</strong> (all positives), and the answer the <strong>posterior</strong> (after the test).</p>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Bayes = tree banao: pehle cause se baanto, phir evidence se. Answer = “jo humein chahiye” ÷ “saare jo evidence dikhate hain”.</div>\r\n<p>Next: the formal version and more examples in <a href=\"#tee/read/u1-prob/bayes-rule\">Bayes' rule</a>.</p>"}]},{"id":"u1-prob","title":"Unit 1 · Uncertainty, joint distributions and Bayes rule","unit":"1","scope":"Unit 1 · Quantifying uncertainty, inference using the full joint distribution, Bayes rule","sections":[{"id":"uncertainty","title":"Why agents need probability (and the basic rules)","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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?</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Expected score for each action.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/81d37eff7c373c7f.svg\" alt=\"\\mathbb E[R]=\\sum_i P_iR_i\" style=\"width:15.794ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><p>Expectation is a probability-weighted average. It need not equal any one actual outcome.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. A: weight each outcome</h5><div class=\"math-display\"><img src=\"math/6978caf34fd95e0c.svg\" alt=\"0.6\\times10=6\\qquad0.4\\times(-2)=-0.8\" style=\"width:34.57ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. A: add</h5><div class=\"math-display\"><img src=\"math/95811b7af645e1fd.svg\" alt=\"\\mathbb E[R_A]=6-0.8=5.2\" style=\"width:21.586ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. B: certain outcome</h5><div class=\"math-display\"><img src=\"math/bbe9161115867c07.svg\" alt=\"\\mathbb E[R_B]=1\\times4=4\" style=\"width:18.08ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Compare</h5><p>5.2>4, so A has the greater expected reward. A single attempt can still return −2.</p></div><div class=\"answer\"><strong>Final answer.</strong> A:5.2; B:4. Choose A under an expected-reward criterion.</div></section><p>Ω 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>Acting under uncertainty</h2>\r\n<p>An agent is uncertain because of <strong>partial observability</strong> (it cannot see everything) and <strong>non-determinism</strong> (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:</p>\r\n<ol>\r\n<li><strong>Laziness</strong>: listing every antecedent and consequent is too much work.</li>\r\n<li><strong>Theoretical ignorance</strong>: science has no complete theory of the domain.</li>\r\n<li><strong>Practical ignorance</strong>: we cannot run every test on every patient.</li>\r\n</ol>\r\n<p>So the agent assigns a <strong>degree of belief</strong> (probability), e.g. “80% of toothache patients have cavities”. <strong>Decision theory = probability theory + utility theory</strong>: a rational agent chooses the action with the <strong>maximum expected utility</strong> (e.g. a taxi choosing when to leave for the airport balances the chance of missing the flight against waiting time).</p>\r\n<p>Sources of uncertainty in AI: incomplete data, noise, ambiguity, stochastic environments, model and algorithm limits.</p>\r\n\r\n<h2>Basic notation</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Term</th><th>Meaning / rule</th></tr></thead><tbody>\r\n<tr><td>Sample space Ω</td><td>All possible worlds; <span class=\"math-inline\"><img src=\"math/7e932392a2d209b9.svg\" alt=\"0\\le P(\\omega)\\le1\" style=\"width:13.163ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/2e04a098f6f00102.svg\" alt=\"\\sum_\\omega P(\\omega)=1\" style=\"width:12.964ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Prior (unconditional)</td><td><span class=\"math-inline\"><img src=\"math/3ff7ba191ece3ffd.svg\" alt=\"P(a)\" style=\"width:4.656ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: belief before evidence, e.g. <span class=\"math-inline\"><img src=\"math/422e41a24d087e55.svg\" alt=\"P(cavity)=0.2\" style=\"width:15.347ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Posterior (conditional)</td><td><span class=\"math-inline\"><img src=\"math/b7aba0396dc1aeb0.svg\" alt=\"P(a\\mid b)=\\dfrac{P(a\\land b)}{P(b)}\" style=\"width:19.666ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/5a47a3fc657b0d7c.svg\" alt=\"P(b)&gt;0\" style=\"width:8.578ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Product rule</td><td><span class=\"math-inline\"><img src=\"math/7b86112b191ef76c.svg\" alt=\"P(a\\land b)=P(a\\mid b)P(b)=P(b\\mid a)P(a)\" style=\"width:38.287ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Complement</td><td><span class=\"math-inline\"><img src=\"math/1afe967401ee19dd.svg\" alt=\"P(\\lnot a)=1-P(a)\" style=\"width:17.735ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Inclusion–exclusion</td><td><span class=\"math-inline\"><img src=\"math/f67fe6f37e8347cc.svg\" alt=\"P(a\\lor b)=P(a)+P(b)-P(a\\land b)\" style=\"width:33.917ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Marginalisation</td><td><span class=\"math-inline\"><img src=\"math/e6ca224bc18b80c0.svg\" alt=\"P(Y)=\\sum_z P(Y,z)\" style=\"width:19.144ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Total probability</td><td><span class=\"math-inline\"><img src=\"math/2fd503c9ba9e8f6f.svg\" alt=\"P(b)=P(b\\mid a)P(a)+P(b\\mid\\lnot a)P(\\lnot a)\" style=\"width:37.568ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Independence</td><td><span class=\"math-inline\"><img src=\"math/ed94fa4d4b6553f6.svg\" alt=\"P(a\\land b)=P(a)P(b)\" style=\"width:20.244ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, equivalently <span class=\"math-inline\"><img src=\"math/1b8c2e9773a67bd2.svg\" alt=\"P(a\\mid b)=P(a)\" style=\"width:15.186ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Distribution</td><td>Bold <span class=\"math-inline\"><img src=\"math/ffe772be82ede0e4.svg\" alt=\"\\mathbf P(Weather)=\\langle0.6,0.1,0.29,0.01\\rangle\" style=\"width:33.979ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> lists all values</td></tr>\r\n</tbody></table></div>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Logic “haan/na” bolta hai; probability “kitna yakeen” batati hai. Conditional = joint ÷ evidence.</div>"},{"id":"full-joint","title":"Inference using the full joint distribution (5-mark PYQs)","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>Method</h2>\r\n<ol>\r\n<li><strong>Marginal</strong> <span class=\"math-inline\"><img src=\"math/3ff7ba191ece3ffd.svg\" alt=\"P(a)\" style=\"width:4.656ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: add every cell in which a is true.</li>\r\n<li><strong>Conditional</strong> <span class=\"math-inline\"><img src=\"math/e6e697dab9ccb462.svg\" alt=\"P(a\\mid e)=\\dfrac{P(a\\land e)}{P(e)}\" style=\"width:19.834ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></span>: add cells where both hold, divide by the sum of cells where e holds.</li>\r\n<li><strong>Normalisation</strong>: <span class=\"math-inline\"><img src=\"math/10d12eaae749bfb3.svg\" alt=\"\\mathbf P(A\\mid e)=\\alpha\\,\\mathbf P(A,e)\" style=\"width:20.314ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> with <span class=\"math-inline\"><img src=\"math/c3f28a2b8d2fb918.svg\" alt=\"\\alpha=1/P(e)\" style=\"width:11.241ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: compute the unnormalised values for every value of A, then scale them to sum to 1.</li>\r\n</ol>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. For the dentist table below find P(cavity ∨ toothache), P(cavity | toothache) and P(¬cavity | toothache).</strong> <span class=\"marks\">[class example · 3 marks]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.</p><h4>To find</h4><p>All requested marginal and conditional probabilities.</p></div><h4>Formula and why it applies</h4><p>Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum. <div class=\"math-display\"><img src=\"math/3b42af132ac8057a.svg\" alt=\"P(A\\mid E)=\\frac{P(A\\cap E)}{P(E)},\\quad P(E)&gt;0\" style=\"width:34.787ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>toothache, catch</th><th>toothache, ¬catch</th><th>¬toothache, catch</th><th>¬toothache, ¬catch</th></tr></thead><tbody>\r\n<tr><td><strong>cavity</strong></td><td>0.108</td><td>0.012</td><td>0.072</td><td>0.008</td></tr>\r\n<tr><td><strong>¬cavity</strong></td><td>0.016</td><td>0.064</td><td>0.144</td><td>0.576</td></tr></tbody></table></div>\r\n<div class=\"step\"><h5>Step 1. Disjunction</h5><div class=\"math-display\"><img src=\"math/93d535e63ac5c87c.svg\" alt=\"P(cavity\\lor toothache)=0.108+0.012+0.072+0.008+0.016+0.064=0.28\" style=\"width:76.427ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Conditionals</h5><div class=\"math-display\"><img src=\"math/9b888308d7a5d7e4.svg\" alt=\"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\" style=\"width:133.401ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>With α: <span class=\"math-inline\"><img src=\"math/473e1cb48309ce75.svg\" alt=\"\\mathbf P(Cavity\\mid toothache)=\\alpha\\langle0.12,\\,0.08\\rangle=\\langle0.6,\\,0.4\\rangle\" style=\"width:49.407ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/7ce6fe6ef36e3167.svg\" alt=\"\\alpha=1/0.2=5\" style=\"width:13.767ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p></div>\r\n<div class=\"answer\" id=\"dentist-final\"><strong>Final answer.</strong> P(cavity OR toothache)=0.28; P(cavity | toothache)=0.6; P(no cavity | toothache)=0.4.</div></section>\r\n\r\n<section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks · Final Nov 2025 Q1a]</span></p><div class=\"given\"><h4>Given</h4><p>The printed eight entries are reproduced below. Their total is 1.002, not 1. Therefore the table is inconsistent as a probability distribution.</p><div class=\"table-wrap\"><table><thead><tr><th></th><th>Credit, female</th><th>Credit, male</th><th>Debit, female</th><th>Debit, male</th></tr></thead><tbody>\r\n<tr><td><strong>Premium (Y=1)</strong></td><td>0.08</td><td>0.10</td><td>0.072</td><td>0.05</td></tr>\r\n<tr><td><strong>Regular (Y=0)</strong></td><td>0.10</td><td>0.15</td><td>0.25</td><td>0.20</td></tr></tbody></table></div><h4>To find</h4><p>The five requested probabilities, stating how the inconsistent data are interpreted.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/e29a33f81d36c3d3.svg\" alt=\"P(E)=\\frac{\\text{sum of weights for }E}{\\text{sum of all weights}}\" style=\"width:29.187ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/656f97e9f0aa20fc.svg\" alt=\"P(A\\mid E)=\\frac{\\text{sum of weights for }A\\cap E}{\\text{sum of weights for }E}\" style=\"width:36.981ex;height:5.167ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Validate the full table</h5><div class=\"math-display\"><img src=\"math/96cf20835aaf1e81.svg\" alt=\"0.08+0.10+0.072+0.05+0.10+0.15+0.25+0.20=1.002\" style=\"width:60.843ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><p>Use total weight 1.002 consistently for unconditional probabilities.</p></div><div class=\"step\"><h5>Step 2. Premium row total</h5><div class=\"math-display\"><img src=\"math/455884f740d33473.svg\" alt=\"w(premium)=0.08+0.10+0.072+0.05=0.302\" style=\"width:49.347ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Female given premium</h5><div class=\"math-display\"><img src=\"math/61d38ae71dd8a06e.svg\" alt=\"P(female\\mid premium)=\\frac{0.08+0.072}{0.302}=\\frac{0.152}{0.302}\\approx0.503311\" style=\"width:58.502ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Credit given premium</h5><div class=\"math-display\"><img src=\"math/f1511f5b6ec07db0.svg\" alt=\"P(credit\\mid premium)=\\frac{0.08+0.10}{0.302}=\\frac{0.18}{0.302}\\approx0.596026\" style=\"width:55.988ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Normalised premium marginal</h5><div class=\"math-display\"><img src=\"math/3465c1e9a29a79c1.svg\" alt=\"P(premium)=\\frac{0.302}{1.002}\\approx0.301397\" style=\"width:33.45ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Normalised credit marginal</h5><div class=\"math-display\"><img src=\"math/594c62fd5c571144.svg\" alt=\"P(credit)=\\frac{0.08+0.10+0.10+0.15}{1.002}=\\frac{0.43}{1.002}\\approx0.429142\" style=\"width:58.419ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Regular given male and debit</h5><div class=\"math-display\"><img src=\"math/7f500d88c2aab86f.svg\" alt=\"P(regular\\mid male,debit)=\\frac{0.20}{0.05+0.20}=0.8\" style=\"width:44.133ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Under common normalisation: (a) 0.503311 and 0.596026; (b) 0.301397 and 0.429142; (c) 0.8.</div><p><strong>Alternative correction:</strong> 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.</p></section>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. For a disease Y with fever X as a symptom, a test Z is conducted. Joint probabilities: Disease (Y=1): fever &amp; test+ 0.576, fever &amp; test− 0.144, no fever &amp; test+ 0.072, no fever &amp; 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?</strong> <span class=\"marks\">[5 marks · Re-exam Jan 2026 Q1a]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.</p><h4>To find</h4><p>All requested marginal and conditional probabilities.</p></div><h4>Formula and why it applies</h4><p>Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum. <div class=\"math-display\"><img src=\"math/3b42af132ac8057a.svg\" alt=\"P(A\\mid E)=\\frac{P(A\\cap E)}{P(E)},\\quad P(E)&gt;0\" style=\"width:34.787ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. (1)</h5><div class=\"math-display\"><img src=\"math/e2428bb7484a2222.svg\" alt=\"P(Y{=}1\\mid X{=}1,Z{=}1)=\\frac{0.576}{0.576+0.008}=\\frac{0.576}{0.584}=0.986\" style=\"width:54.738ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. (2) Add every test-positive cell</h5><div class=\"math-display\"><img src=\"math/4ae537c83ce53b71.svg\" alt=\"P(Z{=}1)=0.576+0.072+0.008+0.012=0.668\" style=\"width:48.087ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. (3)</h5><div class=\"math-display\"><img src=\"math/ab59aa2401b72e20.svg\" alt=\"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\" style=\"width:103.115ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> (1) 0.986; (2) 0.668; (3) 0.423.</div>\r\n<div class=\"keyfix\"><strong>Key correction.</strong> 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.</div>\r\n</section>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> “Given” wali cheez denominator mein jaati hai. Pehle evidence ke saare cells jodo, phir upar wale.</div>"},{"id":"bayes-rule","title":"Bayes’ rule: meaning, derivation and three complete examples","html":"<h2>What Bayes’ rule reverses</h2><p>A <strong>prior</strong> is the probability of a cause before the new evidence. A <strong>likelihood</strong> is the probability of that evidence if the cause is true. A <strong>posterior</strong> is the probability of the cause after observing the evidence. These are different conditional directions: P(positive | disease) is not P(disease | positive).</p>\r\n<h2>Derivation</h2><div class=\"math-display\"><img src=\"math/174a2d1dd45a6fd5.svg\" alt=\"P(A\\cap B)=P(B\\mid A)P(A)=P(A\\mid B)P(B)\" style=\"width:43.273ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Divide both sides by P(B), provided that P(B)&gt;0.</p><div class=\"math-display\"><img src=\"math/f27b652409444deb.svg\" alt=\"P(A\\mid B)=\\frac{P(B\\mid A)P(A)}{P(B)}\" style=\"width:26.687ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><p>If A and its complement are the only two possibilities, evidence B can arise by either path. Add both paths in the denominator.</p><div class=\"math-display\"><img src=\"math/715ffe0029a7c804.svg\" alt=\"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)}\" style=\"width:46.386ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Symbol</th><th>Read it as</th></tr></thead><tbody><tr><td>P(A)</td><td>Prior: how common is A?</td></tr><tr><td>P(B | A)</td><td>Likelihood: if A is true, how likely is B?</td></tr><tr><td>P(B)</td><td>Evidence: how common is B through all possible causes?</td></tr><tr><td>P(A | B)</td><td>Posterior: among B cases, what fraction come from A?</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[4 marks · Worked probability example]</span></p><div class=\"given\"><h4>Given</h4><p>A = disease; B = positive test. P(A)=0.001; P(B|A)=0.99; P(B|not A)=0.02.</p><h4>To find</h4><p>The reversed conditional probability P(A | B).</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/715ffe0029a7c804.svg\" alt=\"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)}\" style=\"width:46.386ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the other prior</h5><div class=\"math-display\"><img src=\"math/eba03740537f2993.svg\" alt=\"P(\\neg A)=1-0.001=0.999\" style=\"width:26.904ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evidence through the requested cause</h5><p>Multiply the prior for disease by the likelihood within that group.</p><div class=\"math-display\"><img src=\"math/44ef59701ff8e69a.svg\" alt=\"P(A\\cap B)=0.001\\times0.99=0.00099\" style=\"width:34.781ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evidence through the other cause</h5><p>Now include the path through healthy.</p><div class=\"math-display\"><img src=\"math/f8f7a41ed738725f.svg\" alt=\"P(\\neg A\\cap B)=0.999\\times0.02=0.01998\" style=\"width:36.29ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add both paths for total evidence</h5><div class=\"math-display\"><img src=\"math/588fc60be824b4ec.svg\" alt=\"P(B)=0.00099+0.01998=0.02097\" style=\"width:36.225ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Normalise the requested path</h5><div class=\"math-display\"><img src=\"math/b015ca384b1a70e6.svg\" alt=\"P(A\\mid B)=\\frac{0.00099}{0.02097}\\approx0.0472103\" style=\"width:32.884ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.0472103 ≈ 4.721030043%.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Worked probability example]</span></p><div class=\"given\"><h4>Given</h4><p>A = male; B = high-risk category. P(A)=0.51; P(B|A)=0.12; P(B|not A)=0.08.</p><h4>To find</h4><p>The reversed conditional probability P(A | B).</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/715ffe0029a7c804.svg\" alt=\"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)}\" style=\"width:46.386ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the other prior</h5><div class=\"math-display\"><img src=\"math/8cc383cc77727275.svg\" alt=\"P(\\neg A)=1-0.51=0.49\" style=\"width:24.642ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evidence through the requested cause</h5><p>Multiply the prior for male by the likelihood within that group.</p><div class=\"math-display\"><img src=\"math/b7d733145715c7d9.svg\" alt=\"P(A\\cap B)=0.51\\times0.12=0.0612\" style=\"width:32.518ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evidence through the other cause</h5><p>Now include the path through female.</p><div class=\"math-display\"><img src=\"math/916824e2b1c49a5f.svg\" alt=\"P(\\neg A\\cap B)=0.49\\times0.08=0.0392\" style=\"width:34.027ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add both paths for total evidence</h5><div class=\"math-display\"><img src=\"math/eafd0d70d15c9138.svg\" alt=\"P(B)=0.0612+0.0392=0.1004\" style=\"width:32.832ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Normalise the requested path</h5><div class=\"math-display\"><img src=\"math/35fed556321f4dd0.svg\" alt=\"P(A\\mid B)=\\frac{0.0612}{0.1004}\\approx0.609561753\" style=\"width:34.015ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.609561753 ≈ 60.956175299%.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Worked probability example]</span></p><div class=\"given\"><h4>Given</h4><p>Cause A = Machine A; evidence B = defective item. P(A)=0.60; P(B|A)=0.04; P(B|not A)=0.01.</p><h4>To find</h4><p>The reversed conditional probability P(A | B).</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/715ffe0029a7c804.svg\" alt=\"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)}\" style=\"width:46.386ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the other prior</h5><div class=\"math-display\"><img src=\"math/2d95ba220d546868.svg\" alt=\"P(\\neg A)=1-0.6=0.4\" style=\"width:22.379ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evidence through the requested cause</h5><p>Multiply the prior for Machine A by the likelihood within that group.</p><div class=\"math-display\"><img src=\"math/69ed4b855796ade5.svg\" alt=\"P(A\\cap B)=0.6\\times0.04=0.024\" style=\"width:30.256ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evidence through the other cause</h5><p>Now include the path through Machine B.</p><div class=\"math-display\"><img src=\"math/43a91fadefff9097.svg\" alt=\"P(\\neg A\\cap B)=0.4\\times0.01=0.004\" style=\"width:31.765ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add both paths for total evidence</h5><div class=\"math-display\"><img src=\"math/7297bb21152d3d31.svg\" alt=\"P(B)=0.024+0.004=0.028\" style=\"width:29.438ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Normalise the requested path</h5><div class=\"math-display\"><img src=\"math/c6539c9bc8ea7676.svg\" alt=\"P(A\\mid B)=\\frac{0.024}{0.028}\\approx0.857142857\" style=\"width:32.884ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.857142857 ≈ 85.714285714%.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Pehle requested cause ka path multiply. Neeche evidence tak pahunchne wale saare paths add.</p>"}]},{"id":"u1-nb","title":"Unit 1 · Naive Bayes classifier","unit":"1","scope":"Unit 1 · Naive Bayes model · 10-mark PYQ in both papers","sections":[{"id":"model","title":"The naive Bayes model (worked on PlayTennis)","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>What the data and the question represent</h2><p>A <strong>training row</strong> is one past case whose correct class is known. Its <strong>features</strong> 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 <strong>query</strong> is the new case whose features are known but whose class must be predicted.</p><p>A <strong>prior</strong> is the class share before using the query features. A <strong>likelihood</strong> asks how common one query feature is inside that class. A <strong>posterior</strong> 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.</p><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Π likelihoods</td><td>Multiply every feature factor</td><td>With factors .5,.2,.4: .5×.2=.1; .1×.4=.04</td></tr><tr><td>score(C)</td><td>An unnormalised class weight</td><td>Prior .3 times .04 gives .012</td></tr><tr><td>max</td><td>The largest numerical score</td><td>max(.012,.008)=.012</td></tr><tr><td>argmax</td><td>The label attaining the largest score</td><td>The winning label is the class with score .012</td></tr><tr><td>Laplace denominator N꜀+k</td><td>Class count plus number of possible values for this feature</td><td>Temperature has three values, so k=3; a Yes/No feature has k=2</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> assume the features are independent given the class; then score each class as prior × product of feature likelihoods and pick the largest.</p>\r\n\r\n<h2>Definition</h2>\r\n<p><strong>Naive Bayes</strong> is a supervised probabilistic classifier based on Bayes' rule with the <strong>naive assumption</strong> that all features are conditionally independent given the class:</p>\r\n<div class=\"math-display\"><img src=\"math/b770ed6380567e45.svg\" alt=\"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)\" style=\"width:76.04ex;height:6.354ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>“Naive” because real features are often correlated; it still works very well for spam filtering, sentiment analysis and medical screening.</p>\r\n<h2>Steps (as taught)</h2>\r\n<ol>\r\n<li><strong>Priors</strong>: <span class=\"math-inline\"><img src=\"math/73533725519e6dc2.svg\" alt=\"P(c)=\" style=\"width:6.828ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (rows of class c) / (total rows).</li>\r\n<li><strong>Likelihood tables</strong>: for each attribute value, <span class=\"math-inline\"><img src=\"math/51ff85a257c034ba.svg\" alt=\"P(a_i\\mid c)=\" style=\"width:10.65ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (rows of class c with that value) / (rows of class c).</li>\r\n<li><strong>Score</strong> each class for the new instance and choose the larger. Optionally normalise: divide each score by their sum.</li>\r\n</ol>\r\n<div class=\"note\"><strong>Zero-frequency problem.</strong> 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 <strong>Laplace smoothing</strong>: <span class=\"math-inline\"><img src=\"math/55066f62fb8b94f2.svg\" alt=\"P(a\\mid c)=\\dfrac{\\text{count}+1}{N_c+k}\" style=\"width:20.963ex;height:4.945ex\" loading=\"lazy\" decoding=\"async\"></span>, k = number of values of the attribute. Mention it in one line; it can change the answer.</div>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. Using the 14-day PlayTennis data (9 Yes, 5 No), classify ⟨Outlook = Sunny, Temperature = Cool, Humidity = High, Wind = Strong⟩.</strong> <span class=\"marks\">[class example · 6 marks]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Both class scores and the predicted class.</p></div><h4>Formula and why it applies</h4><p>Conditional independence given the class allows the product of feature likelihoods. <div class=\"math-display\"><img src=\"math/e0195b1e4ddb0473.svg\" alt=\"score(C)=P(C)\\prod_jP(a_j\\mid C)\" style=\"width:29.642ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div> Divide each score by their sum only after computing both.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Priors</h5><div class=\"math-display\"><img src=\"math/be7de04ac2f36060.svg\" alt=\"P(yes)=\\tfrac9{14}\\approx0.643,\\qquad P(no)=\\tfrac5{14}\\approx0.357\" style=\"width:45.695ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Likelihoods needed</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>Sunny</th><th>Cool</th><th>High</th><th>Strong</th></tr></thead><tbody>\r\n<tr><td>Yes</td><td>2/9</td><td>3/9</td><td>3/9</td><td>3/9</td></tr><tr><td>No</td><td>3/5</td><td>1/5</td><td>4/5</td><td>3/5</td></tr></tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Scores</h5>\r\n<div class=\"math-display\"><img src=\"math/21600d7754c6d954.svg\" alt=\"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\" style=\"width:85.505ex;height:2.79ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Normalise</h5><div class=\"math-display\"><img src=\"math/183b5657f9957d15.svg\" alt=\"P(yes\\mid x)=\\frac{1/189}{1/189+18/875}\\approx0.204582651,\\qquad P(no\\mid x)\\approx0.795417349\" style=\"width:73.626ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> PlayTennis = <strong>No</strong> (0.795).</div>\r\n</section>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Naive Bayes = prior × (har feature ka fraction) ka guna. Jo bada, wohi class.</div>"},{"id":"flu","title":"Solved PYQ: naive Bayes for flu (Final 2025, 10 marks)","html":"<section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Final Nov 2025 Q4b]</span></p><div class=\"given\"><h4>Given</h4><p>The full training data are in Step 1. Query: Fever=Yes, Cough=Yes, Temperature=Normal. The main calculation uses unsmoothed counts.</p><h4>To find</h4><p>Both class scores and the predicted class.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/e0195b1e4ddb0473.svg\" alt=\"score(C)=P(C)\\prod_jP(a_j\\mid C)\" style=\"width:29.642ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the training rows as a table</h5><table><thead><tr><th>Row</th><th>Fever</th><th>Cough</th><th>Temperature</th><th>Class</th></tr></thead><tbody><tr><td>1</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>2</td><td>No</td><td>No</td><td>Normal</td><td>No</td></tr><tr><td>3</td><td>Yes</td><td>No</td><td>Low</td><td>No</td></tr><tr><td>4</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>5</td><td>No</td><td>Yes</td><td>Normal</td><td>No</td></tr><tr><td>6</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>7</td><td>No</td><td>No</td><td>Low</td><td>No</td></tr><tr><td>8</td><td>Yes</td><td>No</td><td>Normal</td><td>No</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Separate the two class groups</h5><table><thead><tr><th>Class</th><th>Rows in this group</th><th>Class count</th><th>Prior</th></tr></thead><tbody><tr><td>Yes</td><td>1, 4, 6</td><td>3</td><td>3/8 = 0.375</td></tr><tr><td>No</td><td>2, 3, 5, 7, 8</td><td>5</td><td>5/8 = 0.625</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. For class Yes, count Fever=Yes</h5><p>Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.</p><div class=\"math-display\"><img src=\"math/bf71c2b5401bc336.svg\" alt=\"P(\\text{Fever}=\\text{Yes}\\mid C=\\text{Yes})=\\frac{3}{3}=1\" style=\"width:35.144ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. For class Yes, count Cough=Yes</h5><p>Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.</p><div class=\"math-display\"><img src=\"math/a6ffcdb19b7e5a36.svg\" alt=\"P(\\text{Cough}=\\text{Yes}\\mid C=\\text{Yes})=\\frac{3}{3}=1\" style=\"width:35.988ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. For class Yes, count Temperature=Normal</h5><p>Look only at class Yes rows 1, 4, 6. No row in this class has that feature value.</p><div class=\"math-display\"><img src=\"math/2bcd33037561157b.svg\" alt=\"P(\\text{Temperature}=\\text{Normal}\\mid C=\\text{Yes})=\\frac{0}{3}=0\" style=\"width:46.176ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the Yes score one factor at a time</h5><div class=\"math-display\"><img src=\"math/c3f053c53b40a9b7.svg\" alt=\"P(Yes)=3/8=0.375\" style=\"width:21.883ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f8249f6f69de64a.svg\" alt=\"0.375\\times1=0.375\" style=\"width:17.222ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f8249f6f69de64a.svg\" alt=\"0.375\\times1=0.375\" style=\"width:17.222ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e5245fc04fe5be62.svg\" alt=\"0.375\\times0=0\" style=\"width:13.199ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. For class No, count Fever=Yes</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 3, 8.</p><div class=\"math-display\"><img src=\"math/2feb71df5b426bfc.svg\" alt=\"P(\\text{Fever}=\\text{Yes}\\mid C=\\text{No})=\\frac{2}{5}=0.4\" style=\"width:36.14ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. For class No, count Cough=Yes</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/d406a69469adaf9b.svg\" alt=\"P(\\text{Cough}=\\text{Yes}\\mid C=\\text{No})=\\frac{1}{5}=0.2\" style=\"width:36.984ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. For class No, count Temperature=Normal</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 2, 5, 8.</p><div class=\"math-display\"><img src=\"math/738acde5b7f3afea.svg\" alt=\"P(\\text{Temperature}=\\text{Normal}\\mid C=\\text{No})=\\frac{3}{5}=0.6\" style=\"width:47.171ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Multiply the No score one factor at a time</h5><div class=\"math-display\"><img src=\"math/b83bf0fcbd8f3bee.svg\" alt=\"P(No)=5/8=0.625\" style=\"width:21.147ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ccabec7597d2610a.svg\" alt=\"0.625\\times0.4=0.25\" style=\"width:17.851ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4b7931095eb1884c.svg\" alt=\"0.25\\times0.2=0.05\" style=\"width:16.719ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fcec3b47d13c61a4.svg\" alt=\"0.05\\times0.6=0.03\" style=\"width:16.719ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Compare the scores</h5><div class=\"math-display\"><img src=\"math/9f7a6514218ef651.svg\" alt=\"score(Yes)=0\\qquad score(No)=0.03\" style=\"width:36.607ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The larger score belongs to No. Normalise only if a posterior probability is requested: divide each score by their total 0.03.</p></div><div class=\"answer\"><strong>Final answer.</strong> Predict No. Yes score=0; No score=0.03.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.</p>"},{"id":"job-offer","title":"Solved PYQ: naive Bayes for a job offer (Re-exam 2026, 10 marks)","html":"<section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Re-exam Jan 2026 Q4b]</span></p><div class=\"given\"><h4>Given</h4><p>The full training data are in Step 1. Query: Experience=Mid, Salary=Low, Reputation=Good. The main calculation uses unsmoothed counts.</p><h4>To find</h4><p>Both class scores and the predicted class.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/e0195b1e4ddb0473.svg\" alt=\"score(C)=P(C)\\prod_jP(a_j\\mid C)\" style=\"width:29.642ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the training rows as a table</h5><table><thead><tr><th>Row</th><th>Experience</th><th>Salary</th><th>Reputation</th><th>Class</th></tr></thead><tbody><tr><td>1</td><td>Fresher</td><td>Low</td><td>Good</td><td>Yes</td></tr><tr><td>2</td><td>Mid</td><td>High</td><td>Good</td><td>Yes</td></tr><tr><td>3</td><td>Senior</td><td>High</td><td>Average</td><td>No</td></tr><tr><td>4</td><td>Fresher</td><td>Medium</td><td>Average</td><td>Yes</td></tr><tr><td>5</td><td>Senior</td><td>Low</td><td>Good</td><td>No</td></tr><tr><td>6</td><td>Mid</td><td>Medium</td><td>Good</td><td>Yes</td></tr><tr><td>7</td><td>Fresher</td><td>High</td><td>Average</td><td>No</td></tr><tr><td>8</td><td>Senior</td><td>Medium</td><td>Average</td><td>No</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Separate the two class groups</h5><table><thead><tr><th>Class</th><th>Rows in this group</th><th>Class count</th><th>Prior</th></tr></thead><tbody><tr><td>Yes</td><td>1, 2, 4, 6</td><td>4</td><td>4/8 = 0.5</td></tr><tr><td>No</td><td>3, 5, 7, 8</td><td>4</td><td>4/8 = 0.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. For class Yes, count Experience=Mid</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 2, 6.</p><div class=\"math-display\"><img src=\"math/d14d2e65e85aa98c.svg\" alt=\"P(\\text{Experience}=\\text{Mid}\\mid C=\\text{Yes})=\\frac{2}{4}=0.5\" style=\"width:42.49ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. For class Yes, count Salary=Low</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1.</p><div class=\"math-display\"><img src=\"math/b6e871091f36d8f9.svg\" alt=\"P(\\text{Salary}=\\text{Low}\\mid C=\\text{Yes})=\\frac{1}{4}=0.25\" style=\"width:39.285ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. For class Yes, count Reputation=Good</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1, 2, 6.</p><div class=\"math-display\"><img src=\"math/00e0bac1e035a9f7.svg\" alt=\"P(\\text{Reputation}=\\text{Good}\\mid C=\\text{Yes})=\\frac{3}{4}=0.75\" style=\"width:45.266ex;height:4.586ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the Yes score one factor at a time</h5><div class=\"math-display\"><img src=\"math/fa6d94e12c8c8a44.svg\" alt=\"P(Yes)=4/8=0.5\" style=\"width:19.62ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cd8320ff28f21681.svg\" alt=\"0.5\\times0.5=0.25\" style=\"width:15.588ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/646a455657cc6928.svg\" alt=\"0.25\\times0.25=0.0625\" style=\"width:20.113ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9df28e0200ccc17b.svg\" alt=\"0.0625\\times0.75=0.046875\" style=\"width:24.638ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. For class No, count Experience=Mid</h5><p>Look only at class No rows 3, 5, 7, 8. No row in this class has that feature value.</p><div class=\"math-display\"><img src=\"math/210f557f91613842.svg\" alt=\"P(\\text{Experience}=\\text{Mid}\\mid C=\\text{No})=\\frac{0}{4}=0\" style=\"width:39.966ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. For class No, count Salary=Low</h5><p>Look only at class No rows 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/e95fc4843fd44476.svg\" alt=\"P(\\text{Salary}=\\text{Low}\\mid C=\\text{No})=\\frac{1}{4}=0.25\" style=\"width:38.52ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. For class No, count Reputation=Good</h5><p>Look only at class No rows 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/6f502d0eec66aa0e.svg\" alt=\"P(\\text{Reputation}=\\text{Good}\\mid C=\\text{No})=\\frac{1}{4}=0.25\" style=\"width:44.502ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Multiply the No score one factor at a time</h5><div class=\"math-display\"><img src=\"math/7ee037eb525f597a.svg\" alt=\"P(No)=4/8=0.5\" style=\"width:18.885ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e71e2d0a61e9d301.svg\" alt=\"0.5\\times0=0\" style=\"width:10.937ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cf25ab85b70dd28a.svg\" alt=\"0\\times0.25=0\" style=\"width:12.068ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cf25ab85b70dd28a.svg\" alt=\"0\\times0.25=0\" style=\"width:12.068ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Compare the scores</h5><div class=\"math-display\"><img src=\"math/14926697646660d6.svg\" alt=\"score(Yes)=0.046875\\qquad score(No)=0\" style=\"width:41.131ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The larger score belongs to Yes. Normalise only if a posterior probability is requested: divide each score by their total 0.046875.</p></div><div class=\"answer\"><strong>Final answer.</strong> Predict Yes. Yes score=0.046875; No score=0.</div></section><div class=\"keyfix\"><strong>Official key note.</strong> 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.</div><p class=\"memory\"><strong>Yaad rakho:</strong> Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.</p>"}]},{"id":"u1-bn","title":"Unit 1 · Bayesian networks","unit":"1","scope":"Unit 1 · Semantics of Bayesian networks and exact inference · 10-mark PYQ in both papers","sections":[{"id":"semantics","title":"Bayesian networks: structure, CPTs and the chain rule","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>A Bayesian network starts as a diagram of variables</h2><p>A <strong>node</strong> is a variable, such as Rain. An <strong>edge</strong> is an arrow representing a direct dependency in the model. A <strong>parent</strong> has an arrow into a node. A <strong>root</strong> has no parents. <strong>Directed acyclic graph (DAG)</strong> 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.</p><p>A <strong>CPT</strong> is a conditional probability table: for each parent configuration, it states the probabilities of the child’s values. A <strong>Boolean</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>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).</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>A joint probability, a marginal probability and a posterior.</p></div><h4>Formula and why it applies</h4><p>Multiply down one complete case, add the alternative ways to get Wet, then divide by the evidence probability.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Rain and wet</h5><div class=\"math-display\"><img src=\"math/7395138baece4728.svg\" alt=\"P(R,W)=0.2\\times0.9=0.18\" style=\"width:27.159ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. No rain and wet</h5><div class=\"math-display\"><img src=\"math/1b0b61dc6cadc7a7.svg\" alt=\"P(\\neg R,W)=(1-0.2)\\times0.1=0.8\\times0.1=0.08\" style=\"width:45.891ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Total wet</h5><div class=\"math-display\"><img src=\"math/6c276fca73f350e2.svg\" alt=\"P(W)=0.18+0.08=0.26\" style=\"width:26.698ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Restrict to the wet cases</h5><div class=\"math-display\"><img src=\"math/000872ced145bc03.svg\" alt=\"P(R\\mid W)=0.18/0.26=9/13\\approx0.692307692\" style=\"width:44.127ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Joint .18; marginal .26; posterior≈.692308.</div></section></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>Definition</h2>\r\n<p>A <strong>Bayesian network</strong> (belief network) is a directed acyclic graph in which:</p>\r\n<ol>\r\n<li>each <strong>node</strong> is a random variable;</li>\r\n<li>a directed <strong>edge</strong> 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;</li>\r\n<li>each node has a <strong>conditional probability table (CPT)</strong> <span class=\"math-inline\"><img src=\"math/e2e32da4799205fe.svg\" alt=\"\\mathbf P(X_i\\mid Parents(X_i))\" style=\"width:20.616ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. A root node stores its prior.</li>\r\n</ol>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/bn_burglary.9802d6d53d.svg\" width=\"600\" height=\"370\" alt=\"Burglary network (Russell and Norvig)\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<h2>Semantics: the chain rule for Bayesian networks</h2>\r\n<div class=\"math-display\"><img src=\"math/228b443a51a8c577.svg\" alt=\"P(x_1,\\dots,x_n)=\\prod_{i=1}^{n}P\\big(x_i\\mid parents(X_i)\\big)\" style=\"width:39.218ex;height:6.354ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>So the network <em>is</em> a compact description of the full joint distribution. For the burglary network:</p>\r\n<div class=\"math-display\"><img src=\"math/d065035a53d0c75c.svg\" alt=\"P(J,M,A,B,E)=P(J\\mid A)\\,P(M\\mid A)\\,P(A\\mid B,E)\\,P(B)\\,P(E)\" style=\"width:60.716ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Conditional independence:</strong> each node is conditionally independent of its non-descendants given its parents (e.g. JohnCalls is independent of Burglary once Alarm is known).</p>\r\n<p><strong>Compactness:</strong> a Boolean node with k Boolean parents needs <span class=\"math-inline\"><img src=\"math/1e088370ad90412f.svg\" alt=\"2^k\" style=\"width:2.152ex;height:1.932ex\" loading=\"lazy\" decoding=\"async\"></span> numbers. The burglary network needs 1 + 1 + 4 + 2 + 2 = 10 numbers instead of <span class=\"math-inline\"><img src=\"math/2bd250ce49e6fced.svg\" alt=\"2^5-1=31\" style=\"width:11.295ex;height:2.072ex\" loading=\"lazy\" decoding=\"async\"></span> for the full joint.</p>\r\n\r\n<h2>Building a network</h2>\r\n<ol><li>Choose the variables.</li><li>Choose an acyclic variable order; when a causal model is justified, cause-before-effect is often useful.</li><li>For each variable, choose as parents a suitable set of earlier variables that captures its conditional dependencies.</li><li>Write its CPT.</li></ol>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Har node sirf apne parents se baat karta hai. Joint = sab nodes ka P(node | parents) ka guna.</div>"},{"id":"inference","title":"Inference in Bayesian networks: enumeration, α and variable elimination","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Expand the hidden-variable calculation before the compact formula</h2><p>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.</p><table><thead><tr><th>Calculation</th><th>Burglary true</th><th>Burglary false</th></tr></thead><tbody><tr><td>Average alarm probability over E</td><td>.95×.002 + .94×.998 = .94002</td><td>.29×.002 + .001×.998 = .001578</td></tr><tr><td>No-alarm probability</td><td>1−.94002=.05998</td><td>1−.001578=.998422</td></tr><tr><td>Both calls if alarm</td><td>.9×.7=.63</td><td>.9×.7=.63</td></tr><tr><td>Both calls if no alarm</td><td>.05×.01=.0005</td><td>.05×.01=.0005</td></tr><tr><td>Calls and this B value</td><td>.001×(.63×.94002 + .0005×.05998)=.00059224259</td><td>.999×(.63×.001578 + .0005×.998422)=.001491857649</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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 α.</p>\r\n\r\n<h2>Three kinds of question</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Question type</th><th>Method</th></tr></thead><tbody>\r\n<tr><td>Every variable's value given</td><td>Multiply the CPT entries (chain rule)</td></tr>\r\n<tr><td>One marginal, e.g. P(J)</td><td>Sum over hidden variables; no α</td></tr>\r\n<tr><td>Query given evidence, e.g. P(B | j, m)</td><td>Enumerate for each value of B, then <span class=\"math-inline\"><img src=\"math/0666d2fea1f0f562.svg\" alt=\"\\alpha=1/\\text{(sum)}\" style=\"width:12.522ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n</tbody></table></div>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. In the burglary network find (a) P(j, m, a, ¬b, ¬e), (b) P(JohnCalls), (c) P(Burglary | John and Mary call).</strong> <span class=\"marks\">[class examples · 10 marks]</span></p><!-- complete-cpt --><p>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.</p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The network, root probabilities and conditional probability tables stated in the question.</p><h4>To find</h4><p>The requested joint, marginal or evidence-conditioned probability.</p></div><h4>Formula and why it applies</h4><p>A Bayesian network factorises the joint using each node conditioned on its parents. Sum over hidden values; normalise for evidence. <div class=\"math-display\"><img src=\"math/fbf52d09e73db054.svg\" alt=\"P(x_1,\\ldots,x_n)=\\prod_iP(x_i\\mid parents_i)\" style=\"width:35.273ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>(a) Chain rule</h5><div class=\"math-display\"><img src=\"math/ac4abea66468645f.svg\" alt=\"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\" style=\"width:94.423ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>(b) Marginal: first P(a)</h5>\r\n<div class=\"math-display\"><img src=\"math/c16479d9b9398167.svg\" alt=\"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\" style=\"width:100.069ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/6aa5c702fa516ce7.svg\" alt=\"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\" style=\"width:81.198ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>(c) Enumeration with α (hidden: E, A)</h5>\r\n<div class=\"math-display\"><img src=\"math/5648415bb994a47e.svg\" alt=\"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)\" style=\"width:57.644ex;height:4.769ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c977798f6840354f.svg\" alt=\"=\\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\" style=\"width:105.728ex;height:2.713ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/57244f2b9ccfa07b.svg\" alt=\"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\" style=\"width:120.369ex;height:2.713ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/57f47697add29181.svg\" alt=\"\\alpha=\\frac1{0.000592+0.001492}=479.8\\;\\Rightarrow\\;P(b\\mid j,m)=0.284,\\;P(\\lnot b\\mid j,m)=0.716\" style=\"width:78.236ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> (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.</div>\r\n<div class=\"keyfix\"><strong>Slide note.</strong> One slide prints .71 for <span class=\"math-inline\"><img src=\"math/f2ae2e9bf6ce6704.svg\" alt=\"P(\\lnot a\\mid b,\\lnot e)\" style=\"width:12.591ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>; it is 1 − 0.94 = 0.06 (corrected by hand on the slide).</div>\r\n</section>\r\n\r\n<h2>Variable elimination (why it is faster)</h2>\r\n<p>Enumeration repeats the same products many times (exponential, <span class=\"math-inline\"><img src=\"math/4c7e79dfd318e20b.svg\" alt=\"O(2^n)\" style=\"width:5.765ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>). <strong>Variable elimination</strong> pushes each sum as far inside as possible, computes it once and stores the result as a <strong>factor</strong>; hidden variables are “summed out” one at a time:</p>\r\n<div class=\"math-display\"><img src=\"math/5ea704a1fb57ef3a.svg\" alt=\"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)}\" style=\"width:62.991ex;height:8.466ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Any sum of a CPT over its own variable is 1 (e.g. <span class=\"math-inline\"><img src=\"math/6230fbd1828345e4.svg\" alt=\"\\sum_MP(M\\mid A)=1\" style=\"width:18.204ex;height:2.342ex\" loading=\"lazy\" decoding=\"async\"></span>), so irrelevant (barren) nodes drop out.</p>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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).</strong> <span class=\"marks\">[class example · 6 marks]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The network, root probabilities and conditional probability tables stated in the question.</p><h4>To find</h4><p>The requested joint, marginal or evidence-conditioned probability.</p></div><h4>Formula and why it applies</h4><p>A Bayesian network factorises the joint using each node conditioned on its parents. Sum over hidden values; normalise for evidence. <div class=\"math-display\"><img src=\"math/fbf52d09e73db054.svg\" alt=\"P(x_1,\\ldots,x_n)=\\prod_iP(x_i\\mid parents_i)\" style=\"width:35.273ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. P(HD) by summing out E and D</h5><div class=\"math-display\"><img src=\"math/3485875632aa8ada.svg\" alt=\"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\" style=\"width:97.709ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Unnormalised</h5><div class=\"math-display\"><img src=\"math/9429a00abcd3cccf.svg\" alt=\"\\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\" style=\"width:96ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. Normalise</h5><div class=\"math-display\"><img src=\"math/13277c3f7f4e8b01.svg\" alt=\"\\alpha=\\frac1{0.5185},\\quad P(hd\\mid bp)=0.803,\\quad P(\\lnot hd\\mid bp)=0.197\" style=\"width:56ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 0.803.</div>\r\n</section>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Hidden variables par sum, query ki dono values nikaalo, α se 1 banao. Sirf marginal (P(J)) ho to α nahi.</div>"},{"id":"sprinkler","title":"Solved PYQ: wet grass given no rain (Final 2025, 10 marks)","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Final Nov 2025 Q3a]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>C→S, C→R, (S,R)→W. Root and conditional probabilities are listed in the question. Evidence R=false.</p><h4>To find</h4><p>P(W=true | R=false). Hidden variables C and S must be summed out.</p></div><h4>Formula and why it applies</h4><p>Use the network joint and divide by the evidence probability. <div class=\"math-display\"><img src=\"math/ec8db3b28ef749de.svg\" alt=\"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)}\" style=\"width:54.182ex;height:5.963ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/bn_sprinkler.a251583272.svg\" width=\"600\" height=\"360\" alt=\"Final 2025 Q3a: sprinkler network\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<div class=\"step\"><h5>Step 1. Joint by the chain rule</h5><div class=\"math-display\"><img src=\"math/62a8884ca57ac2e6.svg\" alt=\"P(C,S,R,W)=P(C)\\,P(S\\mid C)\\,P(R\\mid C)\\,P(W\\mid S,R)\" style=\"width:52.278ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Sum over C and S with R = false, W = true</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>C</th><th>S</th><th>P(C)</th><th>P(S|C)</th><th>P(¬R|C)</th><th>P(W|S,¬R)</th><th>Product</th></tr></thead><tbody>\r\n<tr><td>T</td><td>T</td><td>0.5</td><td>0.1</td><td>0.2</td><td>0.90</td><td>0.0090</td></tr>\r\n<tr><td>T</td><td>F</td><td>0.5</td><td>0.9</td><td>0.2</td><td>0.01</td><td>0.0009</td></tr>\r\n<tr><td>F</td><td>T</td><td>0.5</td><td>0.5</td><td>0.8</td><td>0.90</td><td>0.1800</td></tr>\r\n<tr><td>F</td><td>F</td><td>0.5</td><td>0.5</td><td>0.8</td><td>0.01</td><td>0.0020</td></tr>\r\n<tr><td colspan=\"6\"><strong>P(W, ¬R)</strong></td><td><strong>0.1919</strong></td></tr></tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Evidence</h5><div class=\"math-display\"><img src=\"math/97de213766352c7b.svg\" alt=\"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\" style=\"width:73.203ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/c18c31810569b62d.svg\" alt=\"P(W\\mid\\lnot R)=\\frac{0.1919}{0.5}=0.3838\" style=\"width:30.542ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> P(grass wet | no rain) ≈ <strong>0.384</strong>. Without rain, the grass is wet mainly when the sprinkler runs (more likely on non-cloudy days).</div>\r\n<div class=\"keyfix\"><strong>Keep the requested conditional probability separate.</strong> 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.</div>\r\n<h4>Optional comparison: calculate P(Wet) from the same network</h4>\r\n<p>The four no-rain cases already total 0.1919. Now add the four rain cases, keeping the same Cloudy/Sprinkler order.</p>\r\n<div class=\"math-display\"><img src=\"math/fa867c388246e93b.svg\" alt=\"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)\" style=\"width:91.777ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/43750abdd00f3218.svg\" alt=\"P(W,R)=0.0396+0.324+0.0495+0.045=0.4581\" style=\"width:52.048ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/9357fadf4faa85ed.svg\" alt=\"P(W)=P(W,R)+P(W,\\neg R)=0.4581+0.1919=0.6500\" style=\"width:57.884ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/a03cc788f3ded23d.svg\" alt=\"P(R\\mid W)=\\frac{0.4581}{0.6500}\\approx0.704769231\" style=\"width:34.689ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Meaning:</strong> 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.</p>\r\n<div class=\"trap\"><strong>Trap.</strong> 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).</div>\r\n</section>"},{"id":"flu-network","title":"Solved PYQ: fever given no flu (Re-exam 2026, 10 marks)","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Re-exam Jan 2026 Q3a]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>W→F, W→C, (F,C)→V. The complete probabilities are in the question. Evidence F=false.</p><h4>To find</h4><p>P(V=true | F=false), summing hidden W and C.</p></div><h4>Formula and why it applies</h4><p>Use the network joint and normalise by the no-Flu evidence. <div class=\"math-display\"><img src=\"math/e2104f63677bf585.svg\" alt=\"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)}\" style=\"width:55.005ex;height:5.963ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/bn_flu.1d732f0fb6.svg\" width=\"600\" height=\"360\" alt=\"Re-exam 2026 Q3a: weather–flu–cough–fever network\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<div class=\"step\"><h5>Step 1. Chain rule</h5><div class=\"math-display\"><img src=\"math/73135e72ac19cca4.svg\" alt=\"P(W,F,C,V)=P(W)\\,P(F\\mid W)\\,P(C\\mid W)\\,P(V\\mid F,C)\" style=\"width:54.335ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Sum over W and C with F = false, V = true</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>W</th><th>C</th><th>P(W)</th><th>P(¬F|W)</th><th>P(C|W)</th><th>P(V|¬F,C)</th><th>Product</th></tr></thead><tbody>\r\n<tr><td>T</td><td>T</td><td>0.75</td><td>0.8</td><td>0.70</td><td>0.60</td><td>0.252</td></tr>\r\n<tr><td>T</td><td>F</td><td>0.75</td><td>0.8</td><td>0.30</td><td>0.01</td><td>0.0018</td></tr>\r\n<tr><td>F</td><td>T</td><td>0.25</td><td>0.5</td><td>0.25</td><td>0.60</td><td>0.01875</td></tr>\r\n<tr><td>F</td><td>F</td><td>0.25</td><td>0.5</td><td>0.75</td><td>0.01</td><td>0.0009375</td></tr>\r\n<tr><td colspan=\"6\"><strong>P(V, ¬F)</strong></td><td><strong>0.2734875</strong></td></tr></tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Evidence</h5><div class=\"math-display\"><img src=\"math/a396371c860e59b0.svg\" alt=\"P(\\lnot F)=0.75(0.8)+0.25(0.5)=0.6+0.125=0.725\" style=\"width:51.793ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/a27699b35a63a308.svg\" alt=\"P(V\\mid\\lnot F)=\\frac{0.2734875}{0.725}=0.3772\" style=\"width:33.282ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> P(fever | no flu) ≈ <strong>0.377</strong> (fever without flu comes mostly from cough).</div>\r\n<div class=\"keyfix\"><strong>Key correction.</strong> 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).</div>\r\n</section>"}]},{"id":"u1-gmm","title":"Unit 1 · Gaussian mixture models and EM","unit":"1","scope":"Unit 1 · Mixture models, GMM, expectation maximization, clustering using GMM · 10-mark PYQ in both papers","sections":[{"id":"centre-spread","title":"Before GMM: centre, spread, density and likelihood","html":"<h2>Mean, variance and standard deviation</h2><p>A Gaussian component describes a cluster using its <strong>mean</strong> (centre) and <strong>variance</strong> (spread). The <strong>standard deviation</strong> is the square root of variance. The Greek letters μ and σ name these two quantities; σ² is the variance.</p><section class=\"example\"><p class=\"question\"><strong>Calculate the mean, population variance and standard deviation of [1, 3, 5].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Data values: [1, 3, 5]. Number of observations n=3. Use population variance, dividing by n.</p><h4>To find</h4><p>The mean μ, population variance σ², and standard deviation σ.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/13c92c5c73ee1c2f.svg\" alt=\"\\mu=\\frac{\\sum_i x_i}{n}\\quad\\sigma^2=\\frac{\\sum_i(x_i-\\mu)^2}{n}\\quad\\sigma=\\sqrt{\\sigma^2}\" style=\"width:42.67ex;height:5.168ex\" loading=\"lazy\" decoding=\"async\"></div><p>This descriptive/maximum-likelihood convention divides by n. The n−1 sample-variance estimator is a different convention.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Add and divide for the mean</h5><div class=\"math-display\"><img src=\"math/c0bd139e7dbf3b1f.svg\" alt=\"\\mu=\\frac{1+3+5}{3}=3\" style=\"width:18.45ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Subtract the mean, then square</h5><table><thead><tr><th>x</th><th>x−mean</th><th>Squared deviation</th></tr></thead><tbody><tr><td>1</td><td>-2</td><td>4</td></tr><tr><td>3</td><td>0</td><td>0</td></tr><tr><td>5</td><td>2</td><td>4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Average the squared deviations</h5><div class=\"math-display\"><img src=\"math/f8055b1e2e609fe7.svg\" alt=\"\\sigma^2=\\frac{4+0+4}{3}=2.666666667\" style=\"width:30.175ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Take the square root</h5><div class=\"math-display\"><img src=\"math/f193c4f2114bfb50.svg\" alt=\"\\sigma=\\sqrt{2.666666667}\\approx1.632993162\" style=\"width:33.138ex;height:2.453ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Mean=3; variance=2.666666667; standard deviation≈1.632993162.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the mean, population variance and standard deviation of [2, 4].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Data values: [2, 4]. Number of observations n=2. Use population variance, dividing by n.</p><h4>To find</h4><p>The mean μ, population variance σ², and standard deviation σ.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/13c92c5c73ee1c2f.svg\" alt=\"\\mu=\\frac{\\sum_i x_i}{n}\\quad\\sigma^2=\\frac{\\sum_i(x_i-\\mu)^2}{n}\\quad\\sigma=\\sqrt{\\sigma^2}\" style=\"width:42.67ex;height:5.168ex\" loading=\"lazy\" decoding=\"async\"></div><p>This descriptive/maximum-likelihood convention divides by n. The n−1 sample-variance estimator is a different convention.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Add and divide for the mean</h5><div class=\"math-display\"><img src=\"math/0c66b5b185711660.svg\" alt=\"\\mu=\\frac{2+4}{2}=3\" style=\"width:14.553ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Subtract the mean, then square</h5><table><thead><tr><th>x</th><th>x−mean</th><th>Squared deviation</th></tr></thead><tbody><tr><td>2</td><td>-1</td><td>1</td></tr><tr><td>4</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Average the squared deviations</h5><div class=\"math-display\"><img src=\"math/7740370cf600b4a5.svg\" alt=\"\\sigma^2=\\frac{1+1}{2}=1\" style=\"width:15.469ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Take the square root</h5><div class=\"math-display\"><img src=\"math/dc84a3fdebee073d.svg\" alt=\"\\sigma=\\sqrt{1}\\approx1\" style=\"width:11.518ex;height:2.467ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Mean=3; variance=1; standard deviation≈1.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the mean, population variance and standard deviation of [4, 4, 4].</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Data values: [4, 4, 4]. Number of observations n=3. Use population variance, dividing by n.</p><h4>To find</h4><p>The mean μ, population variance σ², and standard deviation σ.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/13c92c5c73ee1c2f.svg\" alt=\"\\mu=\\frac{\\sum_i x_i}{n}\\quad\\sigma^2=\\frac{\\sum_i(x_i-\\mu)^2}{n}\\quad\\sigma=\\sqrt{\\sigma^2}\" style=\"width:42.67ex;height:5.168ex\" loading=\"lazy\" decoding=\"async\"></div><p>This descriptive/maximum-likelihood convention divides by n. The n−1 sample-variance estimator is a different convention.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Add and divide for the mean</h5><div class=\"math-display\"><img src=\"math/133ab42db9ac4f4c.svg\" alt=\"\\mu=\\frac{4+4+4}{3}=4\" style=\"width:18.45ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Subtract the mean, then square</h5><table><thead><tr><th>x</th><th>x−mean</th><th>Squared deviation</th></tr></thead><tbody><tr><td>4</td><td>0</td><td>0</td></tr><tr><td>4</td><td>0</td><td>0</td></tr><tr><td>4</td><td>0</td><td>0</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Average the squared deviations</h5><div class=\"math-display\"><img src=\"math/8148ccf99111a269.svg\" alt=\"\\sigma^2=\\frac{0+0+0}{3}=0\" style=\"width:19.366ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Take the square root</h5><div class=\"math-display\"><img src=\"math/56fce38f6a89699b.svg\" alt=\"\\sigma=\\sqrt{0}\\approx0\" style=\"width:11.518ex;height:2.442ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Mean=4; variance=0; standard deviation≈0.</div></section><p>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.</p><h2>Density, likelihood and logarithm have different jobs</h2><p>A <strong>density</strong> is the height of a continuous distribution. Probability over an interval is area, so density height can exceed 1 without violating probability rules. A <strong>likelihood</strong> treats the observed data as fixed and scores candidate model parameters. For independent observations, their densities multiply.</p><section class=\"example\"><p class=\"question\"><strong>A model assigns density 0.2 to one observation and 0.5 to a second independent observation. Find likelihood and natural log-likelihood.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Two density values .2 and .5.</p><h4>To find</h4><p>Product and its natural logarithm.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/8e3c44857ba18435.svg\" alt=\"L=p(x_1)p(x_2)\\qquad\\ln L=\\ln p(x_1)+\\ln p(x_2)\" style=\"width:44.295ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The logarithm turns a product into a sum.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply the densities</h5><div class=\"math-display\"><img src=\"math/b651f1b57b4503e2.svg\" alt=\"L=0.2\\times0.5=0.1\" style=\"width:19.015ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Take ln of that product</h5><div class=\"math-display\"><img src=\"math/47a26d7f62e313c6.svg\" alt=\"\\ln L=\\ln(0.1)\\approx-2.302585093\" style=\"width:30.079ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Show the equivalent sum</h5><div class=\"math-display\"><img src=\"math/5a43c9ee348bb3a2.svg\" alt=\"\\ln(0.2)+\\ln(0.5)\\approx-1.609437912-0.693147181=-2.302585093\" style=\"width:63.986ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Likelihood .1; log-likelihood≈−2.302585093.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Mean = centre. Variance = squared distance ka average. Likelihood = fixed data ko model kitna support karta hai.</p>"},{"id":"mixture-models","title":"GMM prerequisites: mean, variance, density and mixture","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Component k</td><td>One Gaussian group in the mixture</td><td>Component 1 may have mean 2; component 2 mean 4</td></tr><tr><td>Mixing weight πₖ</td><td>The prior share assigned to component k</td><td>π₁=.4 and π₂=.6 sum to 1</td></tr><tr><td>N(x|μ,σ²)</td><td>The Gaussian density evaluated at x</td><td>The vertical bar supplies parameters; it is not division</td></tr><tr><td>Σ over k</td><td>Add contributions of every component</td><td>p(x)=.4N₁(x)+.6N₂(x)</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Mean, spread and a Gaussian component</h2><p>A <strong>mean</strong> is the centre, found by adding observations and dividing by their count. A <strong>variance</strong> 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.</p><p>A <strong>density</strong> 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.</p><div class=\"math-display\"><img src=\"math/a9b2cdf84258b1c9.svg\" alt=\"\\mathcal N(x\\mid\\mu,\\sigma^2)=\\frac1{\\sqrt{2\\pi}\\,\\sigma}\\exp\\left(-\\frac{(x-\\mu)^2}{2\\sigma^2}\\right)\" style=\"width:39.93ex;height:5.801ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>For a standard Gaussian with μ=0 and σ²=1, find the density at x=0.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=0; μ=0; σ=1.</p><h4>To find</h4><p>Density N(x|0,1).</p></div><h4>Formula and why it applies</h4><p>Use the Gaussian density with the supplied mean and variance.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Squared distance</h5><div class=\"math-display\"><img src=\"math/faf8b496eb6d2931.svg\" alt=\"(0-0)^2=0\" style=\"width:11.924ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Exponent</h5><div class=\"math-display\"><img src=\"math/52577cebaa3ae73f.svg\" alt=\"-0/(2\\times1)=0\" style=\"width:14.959ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponential</h5><div class=\"math-display\"><img src=\"math/86787607e49b39df.svg\" alt=\"e^{0}\\approx1\" style=\"width:6.19ex;height:2.025ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide by the normalising factor</h5><div class=\"math-display\"><img src=\"math/187fc723b4884bed.svg\" alt=\"\\frac{1}{\\sqrt{2\\pi}}\\approx0.39894228\" style=\"width:19.173ex;height:5.344ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.39894228 (a density, not an exact-point probability).</div></section><section class=\"example\"><p class=\"question\"><strong>For a standard Gaussian with μ=0 and σ²=1, find the density at x=1.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=1; μ=0; σ=1.</p><h4>To find</h4><p>Density N(x|0,1).</p></div><h4>Formula and why it applies</h4><p>Use the Gaussian density with the supplied mean and variance.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Squared distance</h5><div class=\"math-display\"><img src=\"math/39a0d42c254cae5b.svg\" alt=\"(1-0)^2=1\" style=\"width:11.924ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Exponent</h5><div class=\"math-display\"><img src=\"math/a4066df8f72b8058.svg\" alt=\"-1/(2\\times1)=-0.5\" style=\"width:18.48ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponential</h5><div class=\"math-display\"><img src=\"math/9fa1a1619e482083.svg\" alt=\"e^{-0.5}\\approx0.60653066\" style=\"width:18.358ex;height:2.05ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide by the normalising factor</h5><div class=\"math-display\"><img src=\"math/7893b72b8b5aa648.svg\" alt=\"\\frac{0.60653066}{\\sqrt{2\\pi}}\\approx0.241970725\" style=\"width:26.764ex;height:5.344ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.241970725 (a density, not an exact-point probability).</div></section><section class=\"example\"><p class=\"question\"><strong>For a standard Gaussian with μ=0 and σ²=1, find the density at x=2.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=2; μ=0; σ=1.</p><h4>To find</h4><p>Density N(x|0,1).</p></div><h4>Formula and why it applies</h4><p>Use the Gaussian density with the supplied mean and variance.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Squared distance</h5><div class=\"math-display\"><img src=\"math/9da874308fbfbb30.svg\" alt=\"(2-0)^2=4\" style=\"width:11.924ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Exponent</h5><div class=\"math-display\"><img src=\"math/aa2983139384fc61.svg\" alt=\"-4/(2\\times1)=-2\" style=\"width:16.719ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponential</h5><div class=\"math-display\"><img src=\"math/37f9ca8ef53fee4b.svg\" alt=\"e^{-2}\\approx0.135335283\" style=\"width:18.245ex;height:2.05ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide by the normalising factor</h5><div class=\"math-display\"><img src=\"math/70e444d7db1b7149.svg\" alt=\"\\frac{0.135335283}{\\sqrt{2\\pi}}\\approx0.053990967\" style=\"width:27.895ex;height:5.344ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.053990967 (a density, not an exact-point probability).</div></section><h2>Mixture model and hidden component</h2><p>A <strong>mixture model</strong> 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><div class=\"math-display\"><img src=\"math/8c4c98f40f54268b.svg\" alt=\"p(x)=\\sum_{k=1}^K\\pi_k\\mathcal N(x\\mid\\mu_k,\\sigma_k^2)\" style=\"width:26.024ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div><p>For two components this means π₁×density₁ + π₂×density₂. A GMM can represent several concentrations of data rather than forcing all points around one mean.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/gmm_mix.84e959698a.svg\" width=\"680\" height=\"300\" alt=\"The total density is a weighted sum of component densities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The total density is a weighted sum of component densities.</figcaption></figure><section class=\"example\"><p class=\"question\"><strong>At x, two component densities are 0.2 and 0.05, with weights 0.6 and 0.4. Find the mixture density.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>π₁=.6, π₂=.4; densities=.2,.05.</p><h4>To find</h4><p>p(x).</p></div><h4>Formula and why it applies</h4><p>Weight each component density, then add.</p><div class=\"math-display\"><img src=\"math/91ef77408ecb18fc.svg\" alt=\"p(x)=\\pi_1N_1+\\pi_2N_2\" style=\"width:20.138ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. First contribution</h5><div class=\"math-display\"><img src=\"math/b90648f46ba2060f.svg\" alt=\"0.6(0.2)=0.12\" style=\"width:14.583ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second contribution</h5><div class=\"math-display\"><img src=\"math/1cee8e50d6767b0f.svg\" alt=\"0.4(0.05)=0.02\" style=\"width:15.714ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add</h5><div class=\"math-display\"><img src=\"math/70eb8d3c0588a981.svg\" alt=\"p(x)=0.12+0.02=0.14\" style=\"width:25.06ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Mixture density = 0.14.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Har Gaussian ek group ka model; mixture = weights ke saath sab densities ka sum.</p>"},{"id":"em","title":"EM for GMM: every responsibility and parameter update","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Two responsibilities and a weighted mean.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/5add87e9c47f7469.svg\" alt=\"\\gamma_{ik}=q_{ik}/\\sum_jq_{ij}\\qquad\\mu_k^{new}=\\frac{\\sum_i\\gamma_{ik}x_i}{\\sum_i\\gamma_{ik}}\" style=\"width:37.13ex;height:6.407ex\" loading=\"lazy\" decoding=\"async\"></div><p>i identifies an observation; k identifies a component. Notice which index is being added in each formula.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Normalise one observation</h5><div class=\"math-display\"><img src=\"math/b318c8654f7774af.svg\" alt=\"q_1+q_2=0.12+0.03=0.15\" style=\"width:27.627ex;height:1.946ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/867693405ef3ab51.svg\" alt=\"\\gamma_1=0.12/0.15=0.8\\quad\\gamma_2=0.03/0.15=0.2\" style=\"width:42.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find the effective component count</h5><div class=\"math-display\"><img src=\"math/860f0958878c117d.svg\" alt=\"N_k=0.8+0.2=1\" style=\"width:18.552ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Weight each observation</h5><div class=\"math-display\"><img src=\"math/bf3d6ca02caff691.svg\" alt=\"0.8\\times1=0.8\\qquad0.2\\times5=1\" style=\"width:28.158ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add and divide</h5><div class=\"math-display\"><img src=\"math/5699fad0064a323f.svg\" alt=\"\\mu_k^{new}=(0.8+1)/1=1.8\" style=\"width:24.139ex;height:2.315ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Responsibilities [.8,.2]; new mean 1.8. A point contributes a fraction of a count instead of being assigned wholly to one component.</div></section></div>\r\n<!-- depth:bridge:end -->\r\n<h2>What EM is estimating</h2><p><strong>Expectation–maximisation (EM)</strong> 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.</p><p>A <strong>responsibility</strong> γᵢₖ 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.</p><table><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>i / k</td><td>Observation number / component number</td></tr><tr><td>γᵢₖ</td><td>Responsibility of component k for observation i</td></tr><tr><td>Nₖ</td><td>Sum of responsibilities for component k: an effective count</td></tr><tr><td>μₖ</td><td>Component mean</td></tr><tr><td>σ²ₖ</td><td>Component variance</td></tr><tr><td>πₖ</td><td>Component mixing weight</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/1d66a1a364cc52ce.svg\" alt=\"\\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)}\" style=\"width:25.899ex;height:6.407ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3aff5f591828cac6.svg\" alt=\"N_k=\\sum_i\\gamma_{ik},\\quad\\mu_k^{new}=\\frac{\\sum_i\\gamma_{ik}x_i}{N_k}\" style=\"width:32.213ex;height:6.098ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/10983e175fb2b145.svg\" alt=\"(\\sigma_k^2)^{new}=\\frac{\\sum_i\\gamma_{ik}(x_i-\\mu_k^{new})^2}{N_k},\\quad\\pi_k^{new}=N_k/n\" style=\"width:45.266ex;height:5.568ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[6 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>n=3, K=2, μ₁=2, μ₂=4; σ₁²=σ₂²=1; π₁=π₂=.5.</p><h4>To find</h4><p>Six responsibilities and the new weights, means and variances.</p></div><h4>Formula and why it applies</h4><p>Apply the E-step and M-step equations above. Calculate with full precision; decimals below are displayed to nine places.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. E-step: weighted densities for x=1</h5><div class=\"math-display\"><img src=\"math/8c570fbfdd0a7367.svg\" alt=\"q_1=0.5\\frac{e^{-(1-2)^2/2}}{\\sqrt{2\\pi}}\\approx0.120985362\" style=\"width:32.733ex;height:5.992ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/00ad8a0accc6492e.svg\" alt=\"q_2=0.5\\frac{e^{-(1-4)^2/2}}{\\sqrt{2\\pi}}\\approx0.002215924\" style=\"width:32.733ex;height:5.992ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. E-step: weighted densities for x=3</h5><div class=\"math-display\"><img src=\"math/abfe7f04db4f042d.svg\" alt=\"q_1=0.5\\frac{e^{-(3-2)^2/2}}{\\sqrt{2\\pi}}\\approx0.120985362\" style=\"width:32.733ex;height:5.992ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5c2d2f7bb6375554.svg\" alt=\"q_2=0.5\\frac{e^{-(3-4)^2/2}}{\\sqrt{2\\pi}}\\approx0.120985362\" style=\"width:32.733ex;height:5.992ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. E-step: weighted densities for x=5</h5><div class=\"math-display\"><img src=\"math/1433e6810e632ac7.svg\" alt=\"q_1=0.5\\frac{e^{-(5-2)^2/2}}{\\sqrt{2\\pi}}\\approx0.002215924\" style=\"width:32.733ex;height:5.992ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ad6c931c7f9ef8f8.svg\" alt=\"q_2=0.5\\frac{e^{-(5-4)^2/2}}{\\sqrt{2\\pi}}\\approx0.120985362\" style=\"width:32.733ex;height:5.992ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. E-step: normalise responsibilities for x=1</h5><div class=\"math-display\"><img src=\"math/aded404e73fc7586.svg\" alt=\"\\gamma_1=\\frac{0.120985362}{0.120985362+0.002215924}\\approx0.98201379\" style=\"width:46.647ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e951eddaa67ec02a.svg\" alt=\"\\gamma_2=1-\\gamma_1\\approx0.01798621\" style=\"width:25.06ex;height:2.018ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. E-step: normalise responsibilities for x=3</h5><div class=\"math-display\"><img src=\"math/4db037db96f3bfa7.svg\" alt=\"\\gamma_1=\\frac{0.120985362}{0.120985362+0.120985362}\\approx0.5\" style=\"width:38.729ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4ed7d74583102629.svg\" alt=\"\\gamma_2=1-\\gamma_1\\approx0.5\" style=\"width:17.142ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. E-step: normalise responsibilities for x=5</h5><div class=\"math-display\"><img src=\"math/f0ca8e430dd11e63.svg\" alt=\"\\gamma_1=\\frac{0.002215924}{0.002215924+0.120985362}\\approx0.01798621\" style=\"width:46.647ex;height:4.799ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/50f16fe4d69df396.svg\" alt=\"\\gamma_2=1-\\gamma_1\\approx0.98201379\" style=\"width:25.06ex;height:2.018ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. M-step: effective count for component 1</h5><div class=\"math-display\"><img src=\"math/eb730836d82ad0e1.svg\" alt=\"N_1=0.98201379+0.5+0.01798621=1.5\" style=\"width:41.773ex;height:1.885ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. M-step: mean for component 1</h5><div class=\"math-display\"><img src=\"math/eac77d4f47719aec.svg\" alt=\"\\mu_1^{new}=\\frac{0.98201379(1)+0.5(3)+0.01798621(5)}{1.5}\\approx1.714629893\" style=\"width:62.091ex;height:4.905ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. M-step: variance for component 1</h5><table><thead><tr><th>x</th><th>Responsibility</th><th>Squared deviation from new mean</th><th>Weighted squared deviation</th></tr></thead><tbody><tr><td>1</td><td>0.98201379</td><td>0.510695884</td><td>0.501510401</td></tr><tr><td>3</td><td>0.5</td><td>1.652176311</td><td>0.826088156</td></tr><tr><td>5</td><td>0.01798621</td><td>10.793656738</td><td>0.194136976</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/23888cceffe7f895.svg\" alt=\"(\\sigma_1^2)^{new}=\\frac{1.521735533}{1.5}\\approx1.014490355\" style=\"width:37.99ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. M-step: mixture weight for component 1</h5><div class=\"math-display\"><img src=\"math/221d1a6298a7ea65.svg\" alt=\"\\pi_1^{new}=1.5/3=0.5\" style=\"width:18.408ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. M-step: effective count for component 2</h5><div class=\"math-display\"><img src=\"math/04b9a1a1ff3b0c25.svg\" alt=\"N_2=0.01798621+0.5+0.98201379=1.5\" style=\"width:41.773ex;height:1.885ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. M-step: mean for component 2</h5><div class=\"math-display\"><img src=\"math/c4600c4965dd3721.svg\" alt=\"\\mu_2^{new}=\\frac{0.01798621(1)+0.5(3)+0.98201379(5)}{1.5}\\approx4.285370107\" style=\"width:62.091ex;height:4.905ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. M-step: variance for component 2</h5><table><thead><tr><th>x</th><th>Responsibility</th><th>Squared deviation from new mean</th><th>Weighted squared deviation</th></tr></thead><tbody><tr><td>1</td><td>0.01798621</td><td>10.793656738</td><td>0.194136976</td></tr><tr><td>3</td><td>0.5</td><td>1.652176311</td><td>0.826088156</td></tr><tr><td>5</td><td>0.98201379</td><td>0.510695884</td><td>0.501510401</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/a7522d8383a399aa.svg\" alt=\"(\\sigma_2^2)^{new}=\\frac{1.521735533}{1.5}\\approx1.014490355\" style=\"width:37.99ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 14. M-step: mixture weight for component 2</h5><div class=\"math-display\"><img src=\"math/a4b477c2cff182c7.svg\" alt=\"\\pi_2^{new}=1.5/3=0.5\" style=\"width:18.408ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Means ≈ [1.714629893, 4.285370107]; variances ≈ [1.014490355, 1.014490355]; weights [0.5,0.5].</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> E: har point ki responsibility. M: responsibilities se weighted mean, variance, weight.</p>"},{"id":"ten-mark-answer","title":"10-mark answer: GMM vs k-means, log-likelihood derivation, parameters for K = 5","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Read the derivation’s symbols first</h2><p>“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. λ<sub>k</sub><sup>i</sup> in some notes is the same responsibility that other sections call γ<sub>ik</sub>. A superscript i here labels the observation, not an exponent.</p><p>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.</p><table><thead><tr><th>Parameter</th><th>Number in a 1D K-component GMM</th><th>Why</th></tr></thead><tbody><tr><td>Means</td><td>K</td><td>One centre for each component</td></tr><tr><td>Variances</td><td>K</td><td>One spread for each component</td></tr><tr><td>Independent mixing weights</td><td>K−1</td><td>The last weight is 1 minus the others</td></tr><tr><td>Total</td><td>3K−1</td><td>K+K+(K−1)</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>Asked twice as:</strong> “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?” <span class=\"marks\">[10 marks · Final 2025 Q2b and Re-exam 2026 Q2b; key: up to the maximum-likelihood equation 5, estimation 5]</span></p>\r\n\r\n<div class=\"answer-box\">\r\n<h3>1. GMM versus k-means</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Aspect</th><th>k-means</th><th>GMM</th></tr></thead><tbody>\r\n<tr><td>Assignment</td><td>Hard: each point in exactly one cluster</td><td>Soft: probability <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> of belonging to each cluster</td></tr>\r\n<tr><td>Model</td><td>Geometric: nearest centroid</td><td>Probabilistic generative model <span class=\"math-inline\"><img src=\"math/04ce4e1e89065414.svg\" alt=\"\\sum_k\\pi_k\\mathcal N(\\mu_k,\\Sigma_k)\" style=\"width:16.12ex;height:2.448ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Cluster shape</td><td>Spherical, similar size</td><td>Elliptical, any size/orientation; overlapping clusters</td></tr>\r\n<tr><td>Parameters</td><td>K centroids</td><td>Weights, means, covariances (1-D: 3K − 1)</td></tr>\r\n<tr><td>Algorithm / objective</td><td>Assign–update; minimise squared distances</td><td>EM; maximise log-likelihood</td></tr>\r\n<tr><td>Output</td><td>Hard labels and fitted centroids</td><td>Labels, membership probabilities and a density (useful for anomaly detection)</td></tr>\r\n<tr><td>Relation</td><td colspan=\"2\">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.</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>2. Derivation of the log-likelihood</h3>\r\n<p><strong>Step 1. Model.</strong> Each point is generated by choosing component k with probability <span class=\"math-inline\"><img src=\"math/e60970d7047375ff.svg\" alt=\"\\pi_k\" style=\"width:2.311ex;height:1.332ex\" loading=\"lazy\" decoding=\"async\"></span> and drawing <span class=\"math-inline\"><img src=\"math/f66cfb5e517110e8.svg\" alt=\"x_i\\sim\\mathcal N(\\mu_k,\\sigma_k^2)\" style=\"width:14.731ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>, so its density is <span class=\"math-inline\"><img src=\"math/6550a4aaf9e87286.svg\" alt=\"f_{mix}(x_i)=\\sum_k\\pi_k\\mathcal N(x_i\\mid\\mu_k,\\sigma_k^2)\" style=\"width:30.677ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<p><strong>Step 2. Likelihood.</strong> Points are i.i.d., so the likelihood is a product (θ = all parameters):</p>\r\n<div class=\"math-display\"><img src=\"math/41dc390b2652cd78.svg\" alt=\"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]\" style=\"width:35.259ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 3. Log-likelihood.</strong> Logs turn the product into a sum:</p>\r\n<div class=\"math-display\"><img src=\"math/9a0bb26e3ef13adb.svg\" alt=\"\\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)\" style=\"width:42.737ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 4. Why it cannot be solved directly.</strong> The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.</p>\r\n<p><strong>Step 5. Jensen's inequality.</strong> log is concave, so for weights <span class=\"math-inline\"><img src=\"math/5006fcb64f6c3cf6.svg\" alt=\"\\lambda_k\\ge0,\\;\\sum\\lambda_k=1\" style=\"width:17.378ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: <span class=\"math-inline\"><img src=\"math/742b7c09a1ce32a4.svg\" alt=\"\\log\\big(\\sum_k\\lambda_ka_k\\big)\\ge\\sum_k\\lambda_k\\log a_k\" style=\"width:29.072ex;height:2.713ex\" loading=\"lazy\" decoding=\"async\"></span>. Introduce <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> for every point (<span class=\"math-inline\"><img src=\"math/fbe0441b97e0b9c1.svg\" alt=\"\\sum_k\\lambda_k^i=1\" style=\"width:10.276ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span>), multiply and divide inside the log:</p>\r\n<div class=\"math-display\"><img src=\"math/06dff5bae3d2cfe1.svg\" alt=\"\\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}\" style=\"width:78.361ex;height:6.391ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 6. Estimation (EM).</strong> Maximise the lower bound alternately. Fixing θ gives the E-step <span class=\"math-inline\"><img src=\"math/662cdc674fe7b2c5.svg\" alt=\"\\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)\" style=\"width:41.37ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></span>. Fixing λ and differentiating (with a Lagrange multiplier for <span class=\"math-inline\"><img src=\"math/131aa1c87311a5f9.svg\" alt=\"\\sum\\pi_k=1\" style=\"width:9.225ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>) gives the M-step:</p>\r\n<div class=\"math-display\"><img src=\"math/ffbe3f9b626d2a86.svg\" alt=\"\\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}\" style=\"width:59.614ex;height:6.179ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h3>3. Number of parameters for K = 5</h3><p>The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:</p>\r\n<div class=\"math-display\"><img src=\"math/5d57bdfd8f83239c.svg\" alt=\"2K+(K-1)=3K-1=3(5)-1=\\mathbf{14}\" style=\"width:40.189ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>(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.</p>\r\n</div>\r\n<div class=\"keyfix\"><strong>Slide note.</strong> One slide puts the convex inequality under the “concave” heading. Correct: log is <em>concave</em>, so <span class=\"math-inline\"><img src=\"math/2ddf537dc44d74a6.svg\" alt=\"f(\\sum\\lambda a)\\ge\\sum\\lambda f(a)\" style=\"width:19.59ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (≥, not &gt;).</div>"},{"id":"clustering-applications","title":"Clustering with GMM: uses, advantages and limits","html":"<h2>Clustering using GMM</h2>\r\n<ol>\r\n<li>Choose K (domain knowledge, or a criterion such as BIC).</li>\r\n<li>Fit the GMM with EM.</li>\r\n<li>For each point compute <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span>; the largest gives its cluster, and the values show how confident the assignment is.</li>\r\n<li>Points with very low <span class=\"math-inline\"><img src=\"math/8f52f259a1ffabd6.svg\" alt=\"p(x)\" style=\"width:4.192ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> under every component are anomalies.</li>\r\n</ol>\r\n<p><strong>Example (class).</strong> 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.</p>\r\n<h2>Applications</h2>\r\n<ul><li>Customer segmentation in marketing</li><li>Image segmentation (pixel colours) and background subtraction in video</li><li>Speaker identification and speech recognition</li><li>Anomaly and fraud detection (low-density points)</li><li>Density estimation and generating new samples</li></ul>\r\n<h2>Advantages and limitations</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody>\r\n<tr><td>Soft assignments with probabilities</td><td>K must be chosen in advance</td></tr>\r\n<tr><td>Flexible elliptical, overlapping clusters</td><td>Sensitive to initialisation; can stop at a local optimum</td></tr>\r\n<tr><td>Interpretable parameters (weights, means, covariances)</td><td>Assumes each cluster is Gaussian</td></tr>\r\n<tr><td>Gives a full density model</td><td>Costly for many dimensions (covariance matrices)</td></tr>\r\n</tbody></table></div>\r\n<p class=\"note\"><strong>Probability vs likelihood</strong> (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.</p>\r\n<h3>Why an unrestricted GMM can collapse</h3><p>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.</p><p>Primary reference: <a href=\"https://www.microsoft.com/en-us/research/wp-content/uploads/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf\" target=\"_blank\" rel=\"noopener\">Bishop, Pattern Recognition and Machine Learning, chapter 9</a>.</p>"}]},{"id":"fuzzy-core","title":"2. Fuzzy logic, from meaning to full solutions","unit":"Unit 2","scope":"Definitions → membership graphs → operations → rules → defuzzification → complete controller.","sections":[{"id":"membership-meaning","title":"Fuzzy sets: what membership actually means","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Start with an input and a label</h2><p>Suppose the input is <strong>temperature 32°C</strong> and the fuzzy label is <strong>Hot</strong>. A membership function is the rule that converts that temperature into a degree of matching the label. If μ<sub>Hot</sub>(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.</p><p>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.</p><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Universe U</td><td>All input values being considered</td><td>Temperatures from 0 to 40°C</td></tr><tr><td>Crisp value</td><td>One definite measured number</td><td>32°C</td></tr><tr><td>Linguistic term</td><td>A word naming a fuzzy category</td><td>Low, Medium, High</td></tr><tr><td>μA(x)</td><td>Degree to which input x fits category A</td><td>μHot(32)=0.7</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> 32 temperature hai; 0.7 us temperature ka Hot label mein degree hai. Dono ko mix mat karo.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Why “true or false” is sometimes too rigid</h2>\r\n<p>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 <strong>crisp</strong> rule. Fuzzy logic allows a gradual degree of belonging to the category “Hot”.</p>\r\n<p><strong>Definition.</strong> 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”.</p><div class=\"math-display\"><img src=\"math/d2598c83177cc2bf.svg\" alt=\"\\mu_A:U\\rightarrow[0,1]\" style=\"width:14.419ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Term</th><th>Meaning</th><th>Temperature example</th></tr></thead><tbody><tr><td>Universe U</td><td>All allowed input values</td><td>Temperatures from 0°C to 40°C</td></tr><tr><td>Element x</td><td>The particular input being considered</td><td>32°C</td></tr><tr><td>Fuzzy set A</td><td>A category described by a membership function</td><td>Hot</td></tr><tr><td>Membership μA(x)</td><td>How strongly x fits that category</td><td>μHot(32) = 0.7</td></tr></tbody></table>\r\n<h2>Read membership correctly</h2><p>Membership 0 means no belonging; 1 means full belonging; 0.7 means partial belonging under the chosen definition. <strong>It does not mean a 70% chance that the measured temperature is 32°C.</strong> 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.</p><table><thead><tr><th>Input</th><th>Warm membership</th><th>Hot membership</th><th>Interpretation</th></tr></thead><tbody><tr><td>28</td><td>0.8</td><td>0.1</td><td>Fits Warm strongly and Hot weakly</td></tr><tr><td>32</td><td>0.3</td><td>0.7</td><td>Fits Hot more than Warm</td></tr><tr><td>35</td><td>0</td><td>1</td><td>Fully Hot in this chosen model</td></tr></tbody></table><p>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”.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered inputs [20, 25, 30, 35]; memberships [0, 0.2, 0.6, 1].</p><h4>To find</h4><p>The set notation and interpretation.</p></div><h4>Formula and why it applies</h4><p>In the common fuzzy-set notation μ/x, the slash separates membership from element; it is not division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Pair each input with its membership</h5><table><thead><tr><th>x</th><th>μHot(x)</th></tr></thead><tbody><tr><td>20</td><td>0</td></tr><tr><td>25</td><td>0.2</td></tr><tr><td>30</td><td>0.6</td></tr><tr><td>35</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Write the set</h5><div class=\"math-display\"><img src=\"math/5a7f23351df5307b.svg\" alt=\"Hot=\\{0/20,\\;0.2/25,\\;0.6/30,\\;1/35\\}\" style=\"width:35.728ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret</h5><p>35 fully belongs; 25 and 30 partly belong; 20 does not belong.</p></div><div class=\"answer\"><strong>Final answer.</strong> Hot = {0/20, 0.2/25, 0.6/30, 1/35}.</div></section><section class=\"example\"><p class=\"question\"><strong>Distinguish crisp and fuzzy sets.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><table><thead><tr><th>Crisp set</th><th>Fuzzy set</th></tr></thead><tbody><tr><td>Membership is 0 or 1</td><td>Membership is any value in [0,1]</td></tr><tr><td>A sharp boundary separates members</td><td>A membership function permits gradual boundaries</td></tr><tr><td>Example: temperature ≥ 30°C</td><td>Example: degree of being Hot increases gradually</td></tr></tbody></table></section><p class=\"memory\"><strong>Yaad rakho:</strong> μ ka matlab: is category mein kitna fit hota hai. Chance nahi.</p>"},{"id":"triangle","title":"Triangular membership: choose the side, then calculate","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Why the triangle has two different fractions</h2><p>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 <strong>input positions</strong>, not three membership degrees.</p><table><thead><tr><th>Where is x?</th><th>Meaning</th><th>Calculation</th></tr></thead><tbody><tr><td>x≤2 or x≥8</td><td>Outside, or at a zero-height endpoint</td><td>0</td></tr><tr><td>2&lt;x&lt;5</td><td>Part-way up the rising edge</td><td>(x−2)/(5−2)</td></tr><tr><td>x=5</td><td>At the peak</td><td>1</td></tr><tr><td>5&lt;x&lt;8</td><td>Part-way down the falling edge</td><td>(8−x)/(8−5)</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> a = start, b = peak, c = end. x kahan pada hai, wahi fraction decide karega.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>A graph is a rule for assigning membership</h2><p>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.</p><p>A triangle has three parameters: <strong>a</strong> is the left zero, <strong>b</strong> is the peak with membership 1, and <strong>c</strong> is the right zero. We assume a &lt; b &lt; c.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_triangle.4eb0b27c9d.svg\" width=\"680\" height=\"300\" alt=\"Rising side: use distance from the left end. Falling side: use distance from the right end.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Rising side: use distance from the left end. Falling side: use distance from the right end.</figcaption></figure><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<h2>Why the two fractions have these forms</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 3.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 3.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>2 < 3 ≤ 5, so membership increases as x moves toward the peak.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Rising side</p><div class=\"math-display\"><img src=\"math/feefc8b7a33635af.svg\" alt=\"\\mu_A(3)=\\frac{3-2}{5-2}=\\frac{1}{3}=0.333333333\" style=\"width:34.786ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(3) = 0.333333333.</div></section><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 7.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 7.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>5 < 7 < 8, so membership decreases as x moves away from the peak.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Falling side</p><div class=\"math-display\"><img src=\"math/379229dc05ca4e37.svg\" alt=\"\\mu_A(7)=\\frac{8-7}{8-5}=\\frac{1}{3}=0.333333333\" style=\"width:34.786ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 0.333333333. It is a membership degree, not a probability.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(7) = 0.333333333.</div></section><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 5.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 5.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>2 < 5 ≤ 5, so membership increases as x moves toward the peak.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Rising side</p><div class=\"math-display\"><img src=\"math/650bc1ad2a8788e3.svg\" alt=\"\\mu_A(5)=\\frac{5-2}{5-2}=\\frac{3}{3}=1\" style=\"width:23.976ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 1. This is full membership at the peak.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(5) = 1.</div></section><section class=\"example\"><p class=\"question\"><strong>A fuzzy set A has triangular membership Tri(2, 5, 8). Find membership at x = 9.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Left endpoint a = 2; peak b = 5; right endpoint c = 8; input x = 9.</p><h4>To find</h4><p>The membership degree μA(x), a number from 0 to 1.</p></div><h4>Formula and why it applies</h4><p>Locate x relative to a, b, c before choosing the branch.</p><div class=\"math-display\"><img src=\"math/4010d79d1ea394d4.svg\" alt=\"\\mu_A(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge c\\\\\\dfrac{x-a}{b-a},&amp;a&lt;x\\le b\\\\\\dfrac{c-x}{c-b},&amp;b&lt;x&lt;c\\end{cases}\" style=\"width:33.926ex;height:12.339ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>9 is outside the open support (2, 8) or at an endpoint.</p></div><div class=\"step\"><h5>Step 2. Choose the correct expression</h5><p>Outside the triangle</p><div class=\"math-display\"><img src=\"math/857573d5b79c2b73.svg\" alt=\"\\mu_A(9)=0\" style=\"width:9.792ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Interpret the value</h5><p>The degree of belonging to A is 0. It is a membership degree, not a probability.</p></div><div class=\"answer\"><strong>Final answer.</strong> μA(9) = 0.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Peak se left: x − a. Peak se right: c − x. Neeche usi side ki poori width.</p>"},{"id":"trapezoid-intuition","title":"Trapezoids, shoulders and intuition-based fuzzification","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>The middle is a flat top, not another slope</h2><p>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.</p><table><thead><tr><th>Input</th><th>Locate it</th><th>Numerator</th><th>Denominator</th><th>Membership</th></tr></thead><tbody><tr><td>1</td><td>Rising: 0<1<2</td><td>1−0=1</td><td>2−0=2</td><td>1/2=0.5</td></tr><tr><td>4</td><td>Flat top: 2≤4≤6</td><td>No division</td><td>No division</td><td>1</td></tr><tr><td>7</td><td>Falling: 6<7<8</td><td>8−7=1</td><td>8−6=2</td><td>1/2=0.5</td></tr><tr><td>9</td><td>Beyond right endpoint</td><td>No division</td><td>No division</td><td>0</td></tr></tbody></table><p>A <strong>left shoulder</strong> 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Trapezoidal membership</h2><p>A trapezoid has four parameters a &lt; b ≤ c &lt; 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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_trapezoid.dbfff598ea.svg\" width=\"680\" height=\"300\" alt=\"From 20 to 30, the membership is exactly 1.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>From 20 to 30, the membership is exactly 1.</figcaption></figure><div class=\"math-display\"><img src=\"math/8db3f8710aa967fd.svg\" alt=\"\\mu(x)=\\begin{cases}0,&amp;x\\le a\\text{ or }x\\ge d\\\\(x-a)/(b-a),&amp;a&lt;x&lt;b\\\\1,&amp;b\\le x\\le c\\\\(d-x)/(d-c),&amp;c&lt;x&lt;d\\end{cases}\" style=\"width:41.325ex;height:10.407ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(15).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=15.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 15 lies on the rising side.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/dcb555d1584d4cd8.svg\" alt=\"\\mu(15)=(15-10)/(20-10)=5/10=0.5\" style=\"width:41.087ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(15) = 0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(25).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=25.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 25 lies on the flat top.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/3a0f8e229e9dd73e.svg\" alt=\"\\mu(25)=1\" style=\"width:9.535ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(25) = 1.</div></section><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(35).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=35.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 35 lies on the falling side.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/b4c061d09e040d15.svg\" alt=\"\\mu(35)=(40-35)/(40-30)=5/10=0.5\" style=\"width:41.087ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(35) = 0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>For Trap(10,20,30,40), calculate μ(45).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=10, b=20, c=30, d=40; x=45.</p><h4>To find</h4><p>Membership at the input.</p></div><h4>Formula and why it applies</h4><p>Choose the piece of the trapezoid containing x. A plateau needs no division.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the input</h5><p>x = 45 lies on the outside support.</p></div><div class=\"step\"><h5>Step 2. Apply that branch</h5><div class=\"math-display\"><img src=\"math/e052435017d8c2af.svg\" alt=\"\\mu(45)=0\" style=\"width:9.535ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> μ(45) = 0.</div></section><h2>Other membership shapes</h2><p>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”.</p>\r\n<h2>Fuzzification by the intuition method</h2><p><strong>Fuzzification</strong> converts a measured crisp input into its membership degrees. In the <strong>intuition method</strong>, 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.</p>\r\n<ol><li>Specify the variable and its allowed range.</li><li>Choose linguistic labels such as Low, Medium and High.</li><li>Specify each shape and every breakpoint.</li><li>Evaluate the functions at the actual input.</li><li>Validate the controller on representative inputs and adjust the design if needed.</li></ol><p class=\"memory\"><strong>Yaad rakho:</strong> Shape banana design choice; shape milne ke baad membership calculate karni hai.</p>"},{"id":"set-operations","title":"Union, intersection, complement and difference","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Work on one element before working on a whole set</h2><p>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”).</p><section class=\"example\"><p class=\"question\"><strong>At one element u, μA(u)=0.7 and μB(u)=0.4. Find union, intersection, complement of B and A\\B.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>At the same element u, A assigns membership 0.7 and B assigns membership 0.4.</p><h4>To find</h4><p>The membership at u in A∪B, A∩B, Bᶜ and A minus B.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1 minus membership for NOT. Difference is A AND NOT B.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Union: choose the larger</h5><div class=\"math-display\"><img src=\"math/709d5f49fad6a33b.svg\" alt=\"\\max(0.7,0.4)=0.7\" style=\"width:18.668ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Intersection: choose the smaller</h5><div class=\"math-display\"><img src=\"math/f5bde40636dee1a9.svg\" alt=\"\\min(0.7,0.4)=0.4\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Complement B first</h5><div class=\"math-display\"><img src=\"math/553cb087421dc8d7.svg\" alt=\"1-0.4=0.6\" style=\"width:12.697ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Intersect A with complement B</h5><div class=\"math-display\"><img src=\"math/d73caed266f7eed3.svg\" alt=\"\\min(0.7,0.6)=0.6\" style=\"width:18.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section></div>\r\n<!-- depth:bridge:end -->\r\n<h2>The four operations used in Q1</h2><p>Use the <strong>standard max–min convention</strong> 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.</p><table><thead><tr><th>Operation</th><th>Meaning</th><th>Rule</th></tr></thead><tbody><tr><td>Union A ∪ B</td><td>A OR B</td><td>Take the larger membership</td></tr><tr><td>Intersection A ∩ B</td><td>A AND B</td><td>Take the smaller membership</td></tr><tr><td>Complement Aᶜ</td><td>NOT A</td><td>1 − membership of A</td></tr><tr><td>Difference A ∖ B</td><td>A AND NOT B</td><td>min(μA, 1 − μB)</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th></tr></thead><tbody><tr><td>A</td><td>0.2</td><td>0.8</td><td>0.6</td></tr><tr><td>B</td><td>0.7</td><td>0.3</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/ad1dcd17cbaf20b9.svg\" alt=\"\\mu_{B^c}(u_1)=1-0.7=0.3\" style=\"width:23.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3b878090c37dc92f.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0.2,0.3)=0.2\" style=\"width:30.054ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0.2</td><td>0.7</td><td>max(0.2, 0.7) = 0.7</td><td>min(0.2, 0.7) = 0.2</td><td>1 − 0.7 = 0.3</td><td>min(0.2, 0.3) = 0.2</td></tr><tr><td>u2</td><td>0.8</td><td>0.3</td><td>max(0.8, 0.3) = 0.8</td><td>min(0.8, 0.3) = 0.3</td><td>1 − 0.3 = 0.7</td><td>min(0.8, 0.7) = 0.7</td></tr><tr><td>u3</td><td>0.6</td><td>0.5</td><td>max(0.6, 0.5) = 0.6</td><td>min(0.6, 0.5) = 0.5</td><td>1 − 0.5 = 0.5</td><td>min(0.6, 0.5) = 0.5</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th></tr></thead><tbody><tr><td>A</td><td>0</td><td>1</td><td>0.4</td></tr><tr><td>B</td><td>1</td><td>0</td><td>0.4</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/2890d976bd930ef0.svg\" alt=\"\\mu_{B^c}(u_1)=1-1=0\" style=\"width:19.624ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/478aba1f930ec419.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0,0)=0\" style=\"width:24.774ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0</td><td>1</td><td>max(0, 1) = 1</td><td>min(0, 1) = 0</td><td>1 − 1 = 0</td><td>min(0, 0) = 0</td></tr><tr><td>u2</td><td>1</td><td>0</td><td>max(1, 0) = 1</td><td>min(1, 0) = 0</td><td>1 − 0 = 1</td><td>min(1, 1) = 1</td></tr><tr><td>u3</td><td>0.4</td><td>0.4</td><td>max(0.4, 0.4) = 0.4</td><td>min(0.4, 0.4) = 0.4</td><td>1 − 0.4 = 0.6</td><td>min(0.4, 0.6) = 0.4</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Element</th><th>u1</th><th>u2</th><th>u3</th><th>u4</th></tr></thead><tbody><tr><td>A</td><td>0.9</td><td>0.2</td><td>0.5</td><td>0.7</td></tr><tr><td>B</td><td>0.6</td><td>0.8</td><td>0.1</td><td>0.7</td></tr></tbody></table><h4>To find</h4><p>Four membership lists in exactly the same element order.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/d5a9710049ed9d75.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\qquad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:45.176ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a10c281d39aeb04c.svg\" alt=\"\\mu_{B^c}=1-\\mu_B\\qquad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:41.33ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Align the same element</h5><p>All operations compare the two memberships of the same u. Do not compare A at u₁ with B at u₂.</p></div><div class=\"step\"><h5>Step 2. Calculate one element completely</h5><div class=\"math-display\"><img src=\"math/c9c6864aea087c58.svg\" alt=\"\\mu_{B^c}(u_1)=1-0.6=0.4\" style=\"width:23.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b891d5b3e6b00766.svg\" alt=\"\\mu_{A\\setminus B}(u_1)=\\min(0.9,0.4)=0.4\" style=\"width:30.054ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Repeat for each element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>Union</th><th>Intersection</th><th>Bᶜ</th><th>A ∖ B</th></tr></thead><tbody><tr><td>u1</td><td>0.9</td><td>0.6</td><td>max(0.9, 0.6) = 0.9</td><td>min(0.9, 0.6) = 0.6</td><td>1 − 0.6 = 0.4</td><td>min(0.9, 0.4) = 0.4</td></tr><tr><td>u2</td><td>0.2</td><td>0.8</td><td>max(0.2, 0.8) = 0.8</td><td>min(0.2, 0.8) = 0.2</td><td>1 − 0.8 = 0.2</td><td>min(0.2, 0.2) = 0.2</td></tr><tr><td>u3</td><td>0.5</td><td>0.1</td><td>max(0.5, 0.1) = 0.5</td><td>min(0.5, 0.1) = 0.1</td><td>1 − 0.1 = 0.9</td><td>min(0.5, 0.9) = 0.5</td></tr><tr><td>u4</td><td>0.7</td><td>0.7</td><td>max(0.7, 0.7) = 0.7</td><td>min(0.7, 0.7) = 0.7</td><td>1 − 0.7 = 0.3</td><td>min(0.7, 0.3) = 0.3</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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].</div></section><p><strong>Why not subtract A − B?</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Union bada; intersection chhota; complement 1 se ghata; difference = pehle B ka complement, phir min.</p>"},{"id":"properties","title":"Fuzzy properties, De Morgan laws and α-cuts","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Translate the property names</h2><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Commutative</td><td>Changing order changes nothing</td><td>max(0.3,0.8)=max(0.8,0.3)=0.8</td></tr><tr><td>Associative</td><td>Regroup the same operation</td><td>max(max(0.2,0.7),0.4)=max(0.2,max(0.7,0.4))=0.7</td></tr><tr><td>Idempotent</td><td>Combining a membership with itself keeps it</td><td>min(0.6,0.6)=0.6</td></tr><tr><td>Involution</td><td>Complement twice returns the original</td><td>1−(1−0.4)=1−0.6=0.4</td></tr><tr><td>De Morgan</td><td>NOT swaps AND and OR while complementing each operand</td><td>1−max(a,b)=min(1−a,1−b)</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Properties that remain valid</h2><table><thead><tr><th>Property</th><th>Statement for max–min operations</th></tr></thead><tbody><tr><td>Commutative</td><td>A ∪ B = B ∪ A; A ∩ B = B ∩ A</td></tr><tr><td>Associative</td><td>(A ∪ B) ∪ C = A ∪ (B ∪ C); likewise for intersection</td></tr><tr><td>Idempotent</td><td>A ∪ A = A; A ∩ A = A</td></tr><tr><td>Distributive</td><td>A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C); and its dual</td></tr><tr><td>Involution</td><td>(Aᶜ)ᶜ = A</td></tr><tr><td>De Morgan</td><td>(A ∪ B)ᶜ = Aᶜ ∩ Bᶜ; (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ</td></tr></tbody></table><h2>Two crisp identities do not generally hold</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>At an element x, μA(x)=0.4. Calculate μ(A ∪ Aᶜ) and μ(A ∩ Aᶜ).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>μA(x)=0.4; standard complement/max/min.</p><h4>To find</h4><p>Whether excluded middle and non-contradiction hold at this element.</p></div><h4>Formula and why it applies</h4><p>Complement first, then use max or min.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Complement</h5><div class=\"math-display\"><img src=\"math/54b240c60f89d754.svg\" alt=\"\\mu_{A^c}(x)=1-0.4=0.6\" style=\"width:22.143ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Union</h5><div class=\"math-display\"><img src=\"math/fbe8846f3efa93f5.svg\" alt=\"\\max(0.4,0.6)=0.6\\ne1\" style=\"width:22.816ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Intersection</h5><div class=\"math-display\"><img src=\"math/4fcb041eeb76aeb4.svg\" alt=\"\\min(0.4,0.6)=0.4\\ne0\" style=\"width:22.377ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The union is 0.6 and the intersection is 0.4; the crisp identities fail here.</div></section><section class=\"example\"><p class=\"question\"><strong>Verify the first De Morgan law for μA=0.3 and μB=0.8.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>A=0.3, B=0.8 at the same element.</p><h4>To find</h4><p>Both sides of (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ.</p></div><h4>Formula and why it applies</h4><p>Evaluate the operations independently on each side.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Left side</h5><div class=\"math-display\"><img src=\"math/8bcb03e96487eae0.svg\" alt=\"1-\\max(0.3,0.8)=1-0.8=0.2\" style=\"width:32.37ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Right side</h5><div class=\"math-display\"><img src=\"math/902b79a384f1ef2a.svg\" alt=\"\\min(1-0.3,1-0.8)=\\min(0.7,0.2)=0.2\" style=\"width:41.36ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Both sides equal 0.2.</div></section><!-- depth:cuts:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>The support, core, boundary and 0.7-cut as sets of elements, and the height as one membership value.</p></div><h4>Formula and why it applies</h4><p>Support: degree>0; core: degree=1; boundary: 0&lt;degree&lt;1; height: largest degree; α-cut: degree≥α.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inspect each element</h5><table><thead><tr><th>Element</th><th>Degree</th><th>Positive?</th><th>Exactly 1?</th><th>At least 0.7?</th></tr></thead><tbody><tr><td>a</td><td>0</td><td>No</td><td>No</td><td>No</td></tr><tr><td>b</td><td>0.3</td><td>Yes</td><td>No</td><td>No</td></tr><tr><td>c</td><td>1</td><td>Yes</td><td>Yes</td><td>Yes</td></tr><tr><td>d</td><td>0.7</td><td>Yes</td><td>No</td><td>Yes</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Collect the requested elements</h5><p>Support={b,c,d}. Core={c}. Boundary={b,d}. The 0.7-cut={c,d}.</p></div><div class=\"step\"><h5>Step 3. Read the height</h5><p>The maximum degree is 1, so the height is 1 and the set is normal.</p></div><div class=\"answer\"><strong>Final answer.</strong> Support {b,c,d}; core {c}; boundary {b,d}; height 1; 0.7-cut {c,d}.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the 0.5-cut of the triangular fuzzy set Tri(2,5,8).</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Triangle start a=2, peak b=5, end c=8; cut level α=0.5. Retain all inputs whose membership is at least 0.5.</p><h4>To find</h4><p>Left and right endpoints of the retained interval.</p></div><h4>Formula and why it applies</h4><p>The triangle rises past 0.5, remains above it, then falls through 0.5. Solve height=0.5 on both slopes.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Left slope: multiply both sides by 3</h5><div class=\"math-display\"><img src=\"math/60bd77c1b7954114.svg\" alt=\"(x-2)/3=0.5\" style=\"width:15.122ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/58646302eb803fe5.svg\" alt=\"x-2=0.5\\times3=1.5\" style=\"width:20.905ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Isolate the left input</h5><div class=\"math-display\"><img src=\"math/5def47a62d44d4a8.svg\" alt=\"x=1.5+2=3.5\" style=\"width:17.008ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Right slope: multiply both sides by 3</h5><div class=\"math-display\"><img src=\"math/101167a6754cbdc0.svg\" alt=\"(8-x)/3=0.5\" style=\"width:15.122ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/35ee639a9616fa80.svg\" alt=\"8-x=1.5\" style=\"width:11.1ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Isolate the right input</h5><div class=\"math-display\"><img src=\"math/4ae644eed157e001.svg\" alt=\"x=8-1.5=6.5\" style=\"width:17.008ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Include all inputs between them</h5><p>The graph is at or above 0.5 for 3.5≤x≤6.5. Include the endpoints because the condition is ≥.</p></div><div class=\"answer\"><strong>Final answer.</strong> The 0.5-cut is [3.5,6.5].</div></section></div>\r\n<!-- depth:cuts:end -->\r\n<h2>Describing a fuzzy set</h2><p><strong>Support:</strong> inputs with μ &gt; 0. <strong>Core:</strong> inputs with μ = 1. <strong>Boundary:</strong> inputs with 0 &lt; μ &lt; 1. <strong>Height:</strong> 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 μ ≥ α.</p><p>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.</p><p>A one-dimensional fuzzy set is <strong>convex</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Fuzzy A aur NOT A dono partial ho sakte hain. Isliye crisp waali 1 aur 0 identities blindly nahi lagani.</p>"},{"id":"mamdani-architecture","title":"Mamdani architecture: what every block does","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Follow one measurement through the controller</h2><p>A <strong>controller</strong> 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.</p><table><thead><tr><th>Stage</th><th>What goes in</th><th>Operation</th><th>What comes out</th></tr></thead><tbody><tr><td>Fuzzifier</td><td>32°C and 7 people</td><td>Use the supplied membership graphs</td><td>Temperature Medium=.3, High=.7; occupancy High=.5</td></tr><tr><td>Knowledge base</td><td>Chosen labels and their shapes</td><td>Store graphs and IF–THEN rules</td><td>A reusable definition of how the controller works</td></tr><tr><td>Inference</td><td>Medium=.3 AND High=.5</td><td>Rule strength=min(.3,.5)=.3</td><td>“Fan High” fires at .3</td></tr><tr><td>Aggregation</td><td>All clipped output sets</td><td>Take the largest output degree at each speed</td><td>One combined fuzzy output shape</td></tr><tr><td>Defuzzifier</td><td>Combined shape</td><td>Apply the specified MoM, centroid or representative method</td><td>One numerical speed</td></tr></tbody></table><p>The <strong>antecedent</strong> is the IF part (“temperature is Medium AND occupancy is High”). The <strong>consequent</strong> 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%.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Definition: a fuzzy inference system</h2><p>A <strong>fuzzy inference system (FIS)</strong> maps inputs to an output by evaluating fuzzy IF–THEN rules. A <strong>Mamdani FIS</strong> uses fuzzy sets in the rule consequents, combines their inferred output sets, and defuzzifies the result.</p>\r\n<div class=\"flow\"><div class=\"node\">Crisp inputs<small>32°C; 7 people</small></div><span class=\"arrow\">→</span><div class=\"node\">Fuzzification<small>degrees of Warm/Hot etc.</small></div><span class=\"arrow\">→</span><div class=\"node\">Rules + inference<small>rule strengths and clipped outputs</small></div><span class=\"arrow\">→</span><div class=\"node\">Aggregation<small>one combined output shape</small></div><span class=\"arrow\">→</span><div class=\"node\">Defuzzification<small>one fan-speed number</small></div></div>\r\n<h2>Architecture: what each block contributes</h2><table><thead><tr><th>Block</th><th>What it stores or calculates</th><th>Concrete meaning</th></tr></thead><tbody><tr><td>Fuzzifier</td><td>Membership values of the measured inputs</td><td>32°C may be Medium to degree 0.3 and High to degree 0.7</td></tr><tr><td>Knowledge base: database</td><td>Ranges and membership functions</td><td>Medium = Tri(15,25,35)</td></tr><tr><td>Knowledge base: rule base</td><td>IF–THEN rules</td><td>IF temperature High AND occupancy High THEN fan Very High</td></tr><tr><td>Inference engine</td><td>Combines conditions and applies consequents</td><td>min for AND; clips the output triangle at the rule strength</td></tr><tr><td>Aggregator</td><td>Combines all rule outputs</td><td>At every output location, take the maximum clipped membership</td></tr><tr><td>Defuzzifier</td><td>Converts the aggregate to one crisp value</td><td>Use centroid or mean of maxima, as requested</td></tr></tbody></table>\r\n<h2>Parts of an IF–THEN rule</h2><p>In “IF temperature is High AND occupancy is High THEN fan speed is Very High”, the IF part is the <strong>antecedent</strong> (condition), and the THEN part is the <strong>consequent</strong> (output category). The input variable temperature, the label High, and the numerical membership μHigh(32) are different things.</p>\r\n<h2>Why a rule strength is not yet the fan speed</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Explain the architecture of a Mamdani fuzzy inference system.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><p class=\"memory\"><strong>Yaad rakho:</strong> Input ka degree → rule ka strength → output ka shape → final number.</p>"},{"id":"rules-clipping","title":"Rule firing, clipping and aggregation: four solved cases","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Clipping means limiting a height</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Speed</th><th>Original A membership</th><th>Original B membership</th></tr></thead><tbody><tr><td>40</td><td>0.1</td><td>0</td></tr><tr><td>60</td><td>0.8</td><td>0.4</td></tr><tr><td>80</td><td>0.2</td><td>1</td></tr></tbody></table><p>Rule A strength=0.3; rule B strength=0.5. Compare memberships at the same speed.</p><h4>To find</h4><p>The combined membership at each speed.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/89f0491f916a2f27.svg\" alt=\"\\mu_{out}(z)=\\max(\\min(0.3,\\mu_A(z)),\\min(0.5,\\mu_B(z)))\" style=\"width:46.627ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Inner min limits a rule’s height; outer max keeps the stronger support at that speed.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Clip A</h5><p>At 40: min(.3,.1)=.1. At 60: min(.3,.8)=.3. At 80: min(.3,.2)=.2.</p></div><div class=\"step\"><h5>Step 2. Clip B</h5><p>At 40: min(.5,0)=0. At 60: min(.5,.4)=.4. At 80: min(.5,1)=.5.</p></div><div class=\"step\"><h5>Step 3. Aggregate at each speed</h5><table><thead><tr><th>Speed</th><th>Clipped A</th><th>Clipped B</th><th>max(A,B)</th></tr></thead><tbody><tr><td>40</td><td>0.1</td><td>0</td><td>0.1</td></tr><tr><td>60</td><td>0.3</td><td>0.4</td><td>0.4</td></tr><tr><td>80</td><td>0.2</td><td>0.5</td><td>0.5</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Combined degrees [0.1,0.4,0.5] at speeds [40,60,80]. A separate defuzzification step is still required.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Clip = height ki ceiling. Aggregate = har same x par sabse upar wala height.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Four different calculations happen in inference</h2><p><strong>AND/OR</strong> combine conditions within a rule. <strong>Implication</strong> uses the resulting strength to modify that rule’s output membership function. <strong>Aggregation</strong> merges different rule outputs. Here we use min-AND, max-OR, min-implication and max-aggregation.</p><div class=\"math-display\"><img src=\"math/e446839a4e5e2d93.svg\" alt=\"\\alpha_{AND}=\\min(a,b)\\qquad\\alpha_{OR}=\\max(a,b)\" style=\"width:38.06ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/32c896372ab93b2e.svg\" alt=\"\\mu_{\\mathrm{rule}}(z)=\\min(\\alpha,\\mu_{\\mathrm{consequent}}(z))\" style=\"width:30.1ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd5c7064495bb995.svg\" alt=\"\\mu_{\\mathrm{aggregate}}(z)=\\max_r\\mu_{\\mathrm{rule}\\ r}(z)\" style=\"width:26.796ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><p>α (“alpha”) is the rule firing strength. z names a possible output value. The subscript r labels a rule, not a multiplication.</p><section class=\"example\"><p class=\"question\"><strong>A rule has two condition degrees 0.7 and 0.5, joined by AND. Find its firing strength.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=0.7; b=0.5; connective=AND.</p><h4>To find</h4><p>The strength α.</p></div><h4>Formula and why it applies</h4><p>Use the smaller degree because both conditions must hold.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Select the operator</h5><div class=\"math-display\"><img src=\"math/c7cb0e48bf98cd0f.svg\" alt=\"\\alpha=\\min(0.7,0.5)\" style=\"width:16.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evaluate</h5><div class=\"math-display\"><img src=\"math/45f07f09a68169c8.svg\" alt=\"\\alpha=0.5\" style=\"width:7.356ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.5.</div></section><section class=\"example\"><p class=\"question\"><strong>A rule has two condition degrees 0.3 and 0, joined by AND. Find its firing strength.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=0.3; b=0; connective=AND.</p><h4>To find</h4><p>The strength α.</p></div><h4>Formula and why it applies</h4><p>Use the smaller degree because both conditions must hold.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Select the operator</h5><div class=\"math-display\"><img src=\"math/7194f00ae81bc1b1.svg\" alt=\"\\alpha=\\min(0.3,0)\" style=\"width:15.025ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evaluate</h5><div class=\"math-display\"><img src=\"math/7b95185b7bc8e8a2.svg\" alt=\"\\alpha=0\" style=\"width:5.596ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.</div></section><section class=\"example\"><p class=\"question\"><strong>A rule has two condition degrees 0.2 and 0.8, joined by OR. Find its firing strength.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=0.2; b=0.8; connective=OR.</p><h4>To find</h4><p>The strength α.</p></div><h4>Formula and why it applies</h4><p>Use the larger degree because either condition is sufficient.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Select the operator</h5><div class=\"math-display\"><img src=\"math/a8a03390bc687846.svg\" alt=\"\\alpha=\\max(0.2,0.8)\" style=\"width:17.224ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Evaluate</h5><div class=\"math-display\"><img src=\"math/2a9a9be0e9cd69dc.svg\" alt=\"\\alpha=0.8\" style=\"width:7.356ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.8.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Rule 1: α₁=0.3, μ₁(60)=0.8. Rule 2: α₂=0.6, μ₂(60)=0.2.</p><h4>To find</h4><p>Membership at the single output location z=60 after implication and aggregation.</p></div><h4>Formula and why it applies</h4><p>Clip each original degree at its rule strength; then take the larger clipped degree.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Clip rule 1</h5><div class=\"math-display\"><img src=\"math/e2cf40ea63fed461.svg\" alt=\"\\mu_{R1}(60)=\\min(0.3,0.8)=0.3\" style=\"width:28.835ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Clip rule 2</h5><div class=\"math-display\"><img src=\"math/a21d3bc0188016ea.svg\" alt=\"\\mu_{R2}(60)=\\min(0.6,0.2)=0.2\" style=\"width:28.835ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Aggregate at this output location</h5><div class=\"math-display\"><img src=\"math/84156b76989dd58e.svg\" alt=\"\\mu_{out}(60)=\\max(0.3,0.2)=0.3\" style=\"width:29.528ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> The aggregate membership at z=60 is 0.3. This is not a crisp fan-speed answer.</div></section><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_clip.f101b5cfa9.svg\" width=\"680\" height=\"300\" alt=\"Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Above the 0.3 level, the original triangle is cut off. Below 0.3, the original slope remains.</figcaption></figure><p class=\"memory\"><strong>Yaad rakho:</strong> AND ke liye min; output clip karne ke liye bhi min; rules ko jodne ke liye max. Har min ka role alag hai.</p>"},{"id":"mom","title":"Mean of maxima: discrete peaks and clipped plateaus","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p><strong>Maximum membership</strong> is a height. <strong>Mean of maxima</strong> 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Mean of maxima (MoM)</h2><p><strong>Defuzzification</strong> 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.</p><div class=\"math-display\"><img src=\"math/bfe66044c82b5d4a.svg\" alt=\"z^*_{MoM}=\\frac{z_1+\\cdots+z_m}{m}\" style=\"width:22.258ex;height:4.425ex\" loading=\"lazy\" decoding=\"async\"></div><p>For a continuous flat maximum from a to b, the mean is its midpoint:</p><div class=\"math-display\"><img src=\"math/5be124f1bdbedfca.svg\" alt=\"z^*_{MoM}=\\frac{a+b}{2}\" style=\"width:14.324ex;height:4.652ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>For the following discrete aggregate, find the mean-of-maxima output.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output z</th><th>Membership μ</th></tr></thead><tbody><tr><td>10</td><td>0.2</td></tr><tr><td>20</td><td>0.8</td></tr><tr><td>30</td><td>0.8</td></tr><tr><td>40</td><td>0.3</td></tr></tbody></table><h4>To find</h4><p>MoM crisp output.</p></div><h4>Formula and why it applies</h4><p>Find all locations at the largest height, then average only those locations.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the maximum height</h5><div class=\"math-display\"><img src=\"math/55721303722e693a.svg\" alt=\"\\mu_{max}=0.8\" style=\"width:10.627ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. List the locations attaining it</h5><p>20, 30</p></div><div class=\"step\"><h5>Step 3. Average these locations</h5><div class=\"math-display\"><img src=\"math/caf06fb51932ddd6.svg\" alt=\"z^*=\\frac{20+30}{2}=25\" style=\"width:18.622ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 25.</div></section><section class=\"example\"><p class=\"question\"><strong>For the following discrete aggregate, find the mean-of-maxima output.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output z</th><th>Membership μ</th></tr></thead><tbody><tr><td>1</td><td>0.1</td></tr><tr><td>2</td><td>0.4</td></tr><tr><td>3</td><td>0.9</td></tr><tr><td>4</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>MoM crisp output.</p></div><h4>Formula and why it applies</h4><p>Find all locations at the largest height, then average only those locations.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the maximum height</h5><div class=\"math-display\"><img src=\"math/c286f3dd87b25655.svg\" alt=\"\\mu_{max}=0.9\" style=\"width:10.627ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. List the locations attaining it</h5><p>3</p></div><div class=\"step\"><h5>Step 3. Average these locations</h5><div class=\"math-display\"><img src=\"math/fc739e8ece1c9e47.svg\" alt=\"z^*=\\frac{3}{1}=3\" style=\"width:11.332ex;height:4.586ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 3.</div></section><section class=\"example\"><p class=\"question\"><strong>A single triangular output Tri(50,65,80) is clipped at α=0.3. Find its crisp value by mean of maxima.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=50, b=65, c=80; clip height α=0.3.</p><h4>To find</h4><p>Both plateau endpoints and their mean.</p></div><h4>Formula and why it applies</h4><p>Set the rising and falling membership fractions equal to 0.3. Every point between those intersections has the maximum height.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the left endpoint</h5><div class=\"math-display\"><img src=\"math/145de080f101d4ed.svg\" alt=\"\\frac{z_L-50}{65-50}=0.3\" style=\"width:14.261ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/39a20fc95a439ada.svg\" alt=\"z_L-50=0.3\\times15=4.5\" style=\"width:24.203ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5ce2529d6b5b0ef5.svg\" alt=\"z_L=54.5\" style=\"width:9.369ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find the right endpoint</h5><div class=\"math-display\"><img src=\"math/cbfa4bdb9123ba28.svg\" alt=\"\\frac{80-z_R}{80-65}=0.3\" style=\"width:14.386ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9c5f88f119fb8224.svg\" alt=\"80-z_R=4.5\" style=\"width:13.391ex;height:1.905ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d02ea96dcfb95060.svg\" alt=\"z_R=75.5\" style=\"width:9.494ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Average endpoints</h5><div class=\"math-display\"><img src=\"math/fd9133cfe48a7467.svg\" alt=\"z^*=(54.5+75.5)/2=65\" style=\"width:25.17ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> MoM = 65.</div></section><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_clip.f101b5cfa9.svg\" width=\"680\" height=\"300\" alt=\"The maximum extends over [54.5,75.5], whose midpoint is 65.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The maximum extends over [54.5,75.5], whose midpoint is 65.</figcaption></figure><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Sabse upar ka level dekho; us level par x-values ka mean lo.</p>"},{"id":"centroid","title":"Centroid: three table sums and one area calculation","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Centroid means the balance point of the whole shape</h2><p>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.</p><p>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 <strong>first moment</strong>: position multiplied by area, accumulated across the shape. Their ratio has units of the output, such as fan-speed percent.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Rectangle: width 4, height 0.5, horizontal centre 2. Triangle: base 4, height 0.5, horizontal centroid 6. Their areas do not overlap.</p><h4>To find</h4><p>The combined horizontal centroid.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/97228eac9007fb53.svg\" alt=\"z^*=\\frac{A_1c_1+A_2c_2}{A_1+A_2}\" style=\"width:18.122ex;height:5.041ex\" loading=\"lazy\" decoding=\"async\"></div><p>Each piece contributes area times its own centre. Use this only for a valid decomposition of the aggregate.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Rectangle area</h5><div class=\"math-display\"><img src=\"math/925738e6d7bc9738.svg\" alt=\"A_1=4\\times0.5=2\" style=\"width:16.638ex;height:1.959ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Triangle area</h5><div class=\"math-display\"><img src=\"math/39c5ce3ae9dbf13b.svg\" alt=\"A_2=\\tfrac12\\times4\\times0.5=1\" style=\"width:21.199ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. First moments</h5><div class=\"math-display\"><img src=\"math/3e993e836c87a393.svg\" alt=\"A_1c_1=2\\times2=4\" style=\"width:16.845ex;height:1.959ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c3ef1e042430e3fc.svg\" alt=\"A_2c_2=1\\times6=6\" style=\"width:16.845ex;height:1.959ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Totals</h5><div class=\"math-display\"><img src=\"math/0582db5cb8a7455e.svg\" alt=\"A=2+1=3\\qquad M=4+6=10\" style=\"width:34.118ex;height:1.805ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Divide</h5><div class=\"math-display\"><img src=\"math/772602a59fae475c.svg\" alt=\"z^*=10/3\\approx3.333333\" style=\"width:21.146ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Centroid≈3.333333, closer to the larger-area piece.</div></section><p>For overlapping clipped sets, first form their max-aggregate. Adding the areas of the original overlapping sets would count the overlap twice.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Centroid: the balance point of the output</h2><p>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.</p><div class=\"math-display\"><img src=\"math/4ca780545740bc9c.svg\" alt=\"z^*=\\frac{\\sum_i z_i\\mu(z_i)}{\\sum_i\\mu(z_i)}\" style=\"width:16.266ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>The index i simply numbers table entries. Σ (“sigma”) means add all listed terms. The denominator must be nonzero.</p><section class=\"example\"><p class=\"question\"><strong>Find the discrete centroid of the aggregate membership table.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>z</th><th>μ(z)</th></tr></thead><tbody><tr><td>10</td><td>0.2</td></tr><tr><td>20</td><td>0.6</td></tr><tr><td>30</td><td>0.4</td></tr></tbody></table><h4>To find</h4><p>One centroid value on the output scale.</p></div><h4>Formula and why it applies</h4><p>This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.</p><div class=\"math-display\"><img src=\"math/0daa1f2e296038c3.svg\" alt=\"z^*=\\frac{\\sum z_i\\mu_i}{\\sum\\mu_i}\" style=\"width:12.714ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply every location by its membership</h5><table><thead><tr><th>z</th><th>μ</th><th>z × μ</th></tr></thead><tbody><tr><td>10</td><td>0.2</td><td>2</td></tr><tr><td>20</td><td>0.6</td><td>12</td></tr><tr><td>30</td><td>0.4</td><td>12</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the numerator</h5><div class=\"math-display\"><img src=\"math/1b63f80f68e4f903.svg\" alt=\"2+12+12=26\" style=\"width:16.467ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the denominator</h5><div class=\"math-display\"><img src=\"math/762eaecf8eca8b36.svg\" alt=\"0.2+0.6+0.4=1.2\" style=\"width:20.114ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/f7410bf10136fdc7.svg\" alt=\"z^*=\\frac{26}{1.2}=21.666666667\" style=\"width:25.033ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 21.666666667.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the discrete centroid of the aggregate membership table.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>z</th><th>μ(z)</th></tr></thead><tbody><tr><td>0</td><td>0.5</td></tr><tr><td>5</td><td>1</td></tr><tr><td>10</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>One centroid value on the output scale.</p></div><h4>Formula and why it applies</h4><p>This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.</p><div class=\"math-display\"><img src=\"math/0daa1f2e296038c3.svg\" alt=\"z^*=\\frac{\\sum z_i\\mu_i}{\\sum\\mu_i}\" style=\"width:12.714ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply every location by its membership</h5><table><thead><tr><th>z</th><th>μ</th><th>z × μ</th></tr></thead><tbody><tr><td>0</td><td>0.5</td><td>0</td></tr><tr><td>5</td><td>1</td><td>5</td></tr><tr><td>10</td><td>0.5</td><td>5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the numerator</h5><div class=\"math-display\"><img src=\"math/31c26d8043dbf781.svg\" alt=\"0+5+5=10\" style=\"width:14.205ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the denominator</h5><div class=\"math-display\"><img src=\"math/723c388b267a6d46.svg\" alt=\"0.5+1+0.5=2\" style=\"width:16.594ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/6b4a65f7e66f3cfb.svg\" alt=\"z^*=\\frac{10}{2}=5\" style=\"width:12.463ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 5.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the discrete centroid of the aggregate membership table.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>z</th><th>μ(z)</th></tr></thead><tbody><tr><td>20</td><td>0</td></tr><tr><td>40</td><td>0.3</td></tr><tr><td>60</td><td>0.6</td></tr><tr><td>80</td><td>0.1</td></tr></tbody></table><h4>To find</h4><p>One centroid value on the output scale.</p></div><h4>Formula and why it applies</h4><p>This question supplies memberships at discrete output locations; use the discrete centroid, not a peak-only approximation.</p><div class=\"math-display\"><img src=\"math/0daa1f2e296038c3.svg\" alt=\"z^*=\\frac{\\sum z_i\\mu_i}{\\sum\\mu_i}\" style=\"width:12.714ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply every location by its membership</h5><table><thead><tr><th>z</th><th>μ</th><th>z × μ</th></tr></thead><tbody><tr><td>20</td><td>0</td><td>0</td></tr><tr><td>40</td><td>0.3</td><td>12</td></tr><tr><td>60</td><td>0.6</td><td>36</td></tr><tr><td>80</td><td>0.1</td><td>8</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the numerator</h5><div class=\"math-display\"><img src=\"math/eacf08e4fd9566bf.svg\" alt=\"0+12+36+8=56\" style=\"width:20.364ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the denominator</h5><div class=\"math-display\"><img src=\"math/0cd832e4cf2e8857.svg\" alt=\"0+0.3+0.6+0.1=1\" style=\"width:22.251ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/8184446a5afe0a48.svg\" alt=\"z^*=\\frac{56}{1}=56\" style=\"width:13.594ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 56.</div></section><h2>For a continuous shape, integrate the area</h2><div class=\"math-display\"><img src=\"math/a3227ed1a9289bb5.svg\" alt=\"z^*=\\frac{\\int z\\mu(z)\\,dz}{\\int\\mu(z)\\,dz}\" style=\"width:15.644ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><p>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 <span class=\"math-inline\"><img src=\"math/033d1d87c88bf6a8.svg\" alt=\"z^*=(\\sum A_jc_j)/(\\sum A_j)\" style=\"width:22.155ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>. Overlapping regions of a max-aggregate must not be counted twice.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Rectangle [0,4], height 0.5; triangle with vertices (4,0),(4,0.5),(6,0).</p><h4>To find</h4><p>Centroid of the combined area.</p></div><h4>Formula and why it applies</h4><p>The parts do not overlap except at their boundary. Weight each part’s horizontal centroid by its area.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Rectangle area and centre</h5><div class=\"math-display\"><img src=\"math/478220c1039e3c18.svg\" alt=\"A_1=4\\times0.5=2\\qquad c_1=(0+4)/2=2\" style=\"width:39.347ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Triangle area and centre</h5><div class=\"math-display\"><img src=\"math/931f8a69a034cfb8.svg\" alt=\"A_2=\\tfrac12\\times2\\times0.5=0.5\" style=\"width:22.96ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9b85cc1cdfb06f4d.svg\" alt=\"c_2=(4+4+6)/3=14/3\" style=\"width:25.474ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add first moments</h5><div class=\"math-display\"><img src=\"math/f37e6894a3c89e61.svg\" alt=\"A_1c_1+A_2c_2=2(2)+0.5(14/3)=19/3\" style=\"width:38.593ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide by total area</h5><div class=\"math-display\"><img src=\"math/c0212421c50f4e75.svg\" alt=\"z^*=(19/3)/(2+0.5)=38/15\\approx2.533333\" style=\"width:41.259ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Centroid ≈ 2.533333. The plateau MoM would be 2, so different methods can legitimately give different results.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Centroid = har location × uska weight, total karke total weight se divide.</p>"},{"id":"weighted-average","title":"Weighted average and centroid are not automatically the same","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Weighted average of output representatives</h2><p>Some classroom solutions use one representative (often the peak) per output label and weight it by the firing strength. That is a <strong>weighted-average or height-based calculation</strong>. It is exact for a specified weighted combination of singleton outputs, but is not generally the centroid of a max-aggregated, clipped Mamdani shape.</p><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [25, 75] mph with respective strengths [0.1, 0.7].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>25</td><td>0.1</td></tr><tr><td>75</td><td>0.7</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0.1 × 25</td><td>2.5</td></tr><tr><td>0.7 × 75</td><td>52.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/648cd602080c422e.svg\" alt=\"2.5+52.5=55\" style=\"width:14.959ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/e794808140502a26.svg\" alt=\"0.1+0.7=0.8\" style=\"width:14.457ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/5b92e77608da1213.svg\" alt=\"z^*=\\frac{55}{0.8}=68.75\" style=\"width:17.115ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 68.75 mph.</div></section><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [40, 65, 85] % fan speed with respective strengths [0, 0.3, 0.5].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>40</td><td>0</td></tr><tr><td>65</td><td>0.3</td></tr><tr><td>85</td><td>0.5</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0 × 40</td><td>0</td></tr><tr><td>0.3 × 65</td><td>19.5</td></tr><tr><td>0.5 × 85</td><td>42.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/0bdf70679aafe819.svg\" alt=\"0+19.5+42.5=62\" style=\"width:19.987ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/76b7c63a5ed0de17.svg\" alt=\"0+0.3+0.5=0.8\" style=\"width:18.354ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/31b2865a5ddd122a.svg\" alt=\"z^*=\\frac{62}{0.8}=77.5\" style=\"width:15.983ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 77.5 % fan speed.</div></section><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [25, 40, 60] minutes with respective strengths [0.6, 0.4, 0.2].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>25</td><td>0.6</td></tr><tr><td>40</td><td>0.4</td></tr><tr><td>60</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0.6 × 25</td><td>15</td></tr><tr><td>0.4 × 40</td><td>16</td></tr><tr><td>0.2 × 60</td><td>12</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/368823bf9efe0162.svg\" alt=\"15+16+12=43\" style=\"width:17.598ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/9f1b10f7784e3b8c.svg\" alt=\"0.6+0.4+0.2=1.2\" style=\"width:20.114ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/603521823aee6db6.svg\" alt=\"z^*=\\frac{43}{1.2}=35.833333333\" style=\"width:25.033ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 35.833333333 minutes.</div></section><table><thead><tr><th>Method</th><th>What it uses</th><th>Limitation</th></tr></thead><tbody><tr><td>MoM</td><td>Locations at maximum membership</td><td>Ignores lower portions of the shape; can change abruptly</td></tr><tr><td>Area centroid</td><td>Entire aggregated output area</td><td>Needs an area/moment calculation or numerical integration</td></tr><tr><td>Representative weighted average</td><td>Supplied representative values and strengths</td><td>Not interchangeable with a clipped Mamdani area centroid</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Formula similar dikhega, par weight kya hai? Membership, area, ya rule strength—pehle woh identify karo.</p>\r\n<h2>Faculty slide example: one temperature input</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Using the weighted-average method, combine output representatives [50, 80] % fan speed with respective strengths [0.8, 0.2].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Output representative</th><th>Strength</th></tr></thead><tbody><tr><td>50</td><td>0.8</td></tr><tr><td>80</td><td>0.2</td></tr></tbody></table><h4>To find</h4><p>One crisp output by the specified weighted-average method.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b26ca7a8925830d0.svg\" alt=\"z^*=\\frac{\\sum_i\\alpha_i z_i}{\\sum_i\\alpha_i}\" style=\"width:13.538ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Multiply each value by its strength</h5><table><thead><tr><th>Strength × value</th><th>Product</th></tr></thead><tbody><tr><td>0.8 × 50</td><td>40</td></tr><tr><td>0.2 × 80</td><td>16</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add the products</h5><div class=\"math-display\"><img src=\"math/dc4a907872eaaa0b.svg\" alt=\"40+16=56\" style=\"width:12.57ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add the strengths</h5><div class=\"math-display\"><img src=\"math/ffd94fb58f716964.svg\" alt=\"0.8+0.2=1\" style=\"width:12.697ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/8184446a5afe0a48.svg\" alt=\"z^*=\\frac{56}{1}=56\" style=\"width:13.594ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 56 % fan speed.</div></section>"},{"id":"class-fan","title":"Class fan question: 32°C, 7 people, every rule and step","html":"<!-- depth:rules-grid:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:rules-grid:end -->\r\n<p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Class-question adaptation; full design]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Low / Very Low</th><th>Medium / Low</th><th>High / Medium</th><th>High output</th><th>Very High output</th></tr></thead><tbody><tr><td>Temperature</td><td>Tri(0,10,20)</td><td>Tri(15,25,35)</td><td>Tri(25,35,40)</td><td>—</td><td>—</td></tr><tr><td>Occupancy</td><td>Tri(0,2,4)</td><td>Tri(3,5,7)</td><td>Tri(6,8,10)</td><td>—</td><td>—</td></tr><tr><td>Fan speed</td><td>Tri(0,10,20)</td><td>Tri(10,25,40)</td><td>Tri(20,40,60)</td><td>Tri(50,65,80)</td><td>Tri(70,85,100)</td></tr></tbody></table><p>Input T=32°C; occupancy=7. Use min-AND, min-clipping and max-aggregation.</p><table><thead><tr><th>Temperature</th><th>Occupancy</th><th>Fan output</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>Very Low</td></tr><tr><td>Low</td><td>Medium</td><td>Low</td></tr><tr><td>Low</td><td>High</td><td>Medium</td></tr><tr><td>Medium</td><td>Low</td><td>Low</td></tr><tr><td>Medium</td><td>Medium</td><td>Medium</td></tr><tr><td>Medium</td><td>High</td><td>High</td></tr><tr><td>High</td><td>Low</td><td>Medium</td></tr><tr><td>High</td><td>Medium</td><td>High</td></tr><tr><td>High</td><td>High</td><td>Very High</td></tr></tbody></table><h4>To find</h4><p>Input memberships → nine rule strengths → clipped output → two named crisp outputs.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/2e1abd53c3392e1f.svg\" alt=\"\\alpha_r=\\min(\\mu_{T,r},\\mu_{O,r})\\quad\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:51.241ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Read the temperature graph</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fan_temp.434c9b6635.svg\" width=\"680\" height=\"300\" alt=\"At 32, Medium is on its falling side; High is on its rising side.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>At 32, Medium is on its falling side; High is on its rising side.</figcaption></figure><div class=\"math-display\"><img src=\"math/90541f01c8f3e577.svg\" alt=\"\\mu_L(32)=0\" style=\"width:10.812ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8b417cc7c6fd3b3f.svg\" alt=\"\\mu_M(32)=\\frac{35-32}{35-25}=\\frac3{10}=0.3\" style=\"width:30.743ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1456bdcfcdae3dcf.svg\" alt=\"\\mu_H(32)=\\frac{32-25}{35-25}=\\frac7{10}=0.7\" style=\"width:30.482ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Read the occupancy graph</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fan_people.1861531dd1.svg\" width=\"680\" height=\"300\" alt=\"At 7, Medium reaches its right zero and High is halfway up its rising edge.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>At 7, Medium reaches its right zero and High is halfway up its rising edge.</figcaption></figure><div class=\"math-display\"><img src=\"math/0dc9da58647d7498.svg\" alt=\"\\mu_L(7)=0\\qquad\\mu_M(7)=0\" style=\"width:24.479ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/527793f08bd07193.svg\" alt=\"\\mu_H(7)=\\frac{7-6}{8-6}=\\frac12=0.5\" style=\"width:25.957ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Evaluate all nine rules</h5><table><thead><tr><th>T label / degree</th><th>O label / degree</th><th>min = strength</th><th>Output</th></tr></thead><tbody><tr><td>Low / 0</td><td>Low / 0</td><td>0</td><td>Very Low</td></tr><tr><td>Low / 0</td><td>Medium / 0</td><td>0</td><td>Low</td></tr><tr><td>Low / 0</td><td>High / 0.5</td><td>0</td><td>Medium</td></tr><tr><td>Medium / 0.3</td><td>Low / 0</td><td>0</td><td>Low</td></tr><tr><td>Medium / 0.3</td><td>Medium / 0</td><td>0</td><td>Medium</td></tr><tr><td>Medium / 0.3</td><td>High / 0.5</td><td>0.3</td><td>High</td></tr><tr><td>High / 0.7</td><td>Low / 0</td><td>0</td><td>Medium</td></tr><tr><td>High / 0.7</td><td>Medium / 0</td><td>0</td><td>High</td></tr><tr><td>High / 0.7</td><td>High / 0.5</td><td>0.5</td><td>Very High</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Clip and aggregate</h5><div class=\"math-display\"><img src=\"math/2ead49cb7f0674dc.svg\" alt=\"\\mu_{out}(z)=\\max\\{\\min(0.3,\\mu_H(z)),\\min(0.5,\\mu_{VH}(z))\\}\" style=\"width:48.787ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fan_output.8708d0ea77.svg\" width=\"680\" height=\"300\" alt=\"High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>High is clipped at 0.3; Very High is clipped at 0.5. Use the upper envelope where the two shapes overlap.</figcaption></figure></div><div class=\"step\"><h5>Step 5. Find the highest plateau for MoM</h5><p>The maximum is 0.5, belonging to Very High. Its triangle is (70,85,100).</p><div class=\"math-display\"><img src=\"math/a4fdc221a6cfa166.svg\" alt=\"\\frac{z_L-70}{15}=0.5\\Rightarrow z_L=77.5\" style=\"width:27.15ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fba2b937f7b534a8.svg\" alt=\"\\frac{100-z_R}{15}=0.5\\Rightarrow z_R=92.5\" style=\"width:28.531ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a4e234f2232ff44d.svg\" alt=\"z^*_{MoM}=\\frac{77.5+92.5}{2}=85\" style=\"width:25.482ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the representatives by strengths</h5><div class=\"math-display\"><img src=\"math/e44a237331cdc730.svg\" alt=\"0.3\\times65=19.5\" style=\"width:14.959ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dfe0b2ebeb9b2e0c.svg\" alt=\"0.5\\times85=42.5\" style=\"width:14.959ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Add, then divide for the weighted average</h5><div class=\"math-display\"><img src=\"math/1cf8861b16222d21.svg\" alt=\"z^*_{WA}=\\frac{19.5+42.5}{0.3+0.5}=\\frac{62}{0.8}=77.5\" style=\"width:32.883ex;height:4.799ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p><strong>How to adapt it in the exam:</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Temperature aur people ka degree nikalo → 9 min → active outputs clip → jo method poocha hai woh lagao.</p>\r\n\r\n<!-- depth:plateau:start -->\r\n<div class=\"concept-bridge\"><h2>Why the Very High plateau has midpoint 85</h2><p>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.</p></div>\r\n<!-- depth:plateau:end -->\r\n<p>Continue with the <a href=\"#tee/read/fuzzy-core/centroid-comparison\">complete area-centroid calculation for this same fan design</a>: 77.086956522%, with all overlap breakpoints and area/moment arithmetic shown.</p>"},{"id":"centroid-comparison","title":"The same fan controller: true area centroid versus MoM and weighted average","html":"<p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[6 marks]</span></p><p>Worked teaching continuation of the class-design adaptation; the mark allocation here is for practice.</p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Every visible segment of the aggregate, its area and first moment, the centroid, and the differences between the three crisp answers.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/2ead49cb7f0674dc.svg\" alt=\"\\mu_{out}(z)=\\max\\{\\min(0.3,\\mu_H(z)),\\min(0.5,\\mu_{VH}(z))\\}\" style=\"width:48.787ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/175fa0720f954403.svg\" alt=\"z^*_{COA}=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:20.937ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><div class=\"math-display\"><img src=\"math/10dac72a97306eb6.svg\" alt=\"A=\\frac{(b-a)(u+v)}2,\\qquad M=\\frac{b-a}{6}[(2a+b)u+(a+2b)v]\" style=\"width:58.239ex;height:4.905ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Locate the two clipped plateaus</h5><div class=\"math-display\"><img src=\"math/6757779ccc7556ad.svg\" alt=\"H:\\quad z_L=50+0.3(65-50)=54.5,\\quad z_R=80-0.3(80-65)=75.5\" style=\"width:68.263ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/19f28361b506bad3.svg\" alt=\"VH:\\quad z_L=70+0.5(85-70)=77.5,\\quad z_R=100-0.5(100-85)=92.5\" style=\"width:72.266ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 2. Find where the upper envelope changes owner</h5><p>Very High rises through the High plateau at height 0.3. Solve its rising equation:</p><div class=\"math-display\"><img src=\"math/d00383e24c2ca74a.svg\" alt=\"(z-70)/15=0.3\\quad\\Rightarrow\\quad z=74.5\" style=\"width:33.279ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 3. Trace the aggregate graph</h5><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/deep_fan_centroid.98bf1c217d.svg\" width=\"980\" height=\"500\" alt=\"Fan output: trace the upper envelope before finding its centroid\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 4. Work the rising first strip explicitly</h5><div class=\"math-display\"><img src=\"math/5c3f2b7a4bd76f0b.svg\" alt=\"A_1=(54.5-50)(0+0.3)/2=0.675\" style=\"width:35.494ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5570b4038f564dfd.svg\" alt=\"M_1=\\frac{4.5}{6}[(100+54.5)0+(50+109)0.3]=35.775\" style=\"width:49.559ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div><p>The first moment has units of speed multiplied by area. Dividing total moment by total area returns speed.</p></div><div class=\"step\"><h5>Step 5. Calculate all disjoint strips</h5><div class=\"table-scroll\"><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>First moment M</th></tr></thead><tbody><tr><td>50</td><td>54.5</td><td>0</td><td>0.3</td><td>0.675</td><td>35.775</td></tr><tr><td>54.5</td><td>74.5</td><td>0.3</td><td>0.3</td><td>6</td><td>387</td></tr><tr><td>74.5</td><td>77.5</td><td>0.3</td><td>0.5</td><td>1.2</td><td>91.35</td></tr><tr><td>77.5</td><td>92.5</td><td>0.5</td><td>0.5</td><td>7.5</td><td>637.5</td></tr><tr><td>92.5</td><td>100</td><td>0.5</td><td>0</td><td>1.875</td><td>178.125</td></tr></tbody></table></div><div class=\"math-display\"><img src=\"math/1a4fac5b0fc5e065.svg\" alt=\"\\sum A=0.675+6+1.2+7.5+1.875=17.25\" style=\"width:44.813ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3f79a707c0d7b969.svg\" alt=\"\\sum M=35.775+387+91.35+637.5+178.125=1329.75\" style=\"width:57.938ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Divide for the actual centroid</h5><div class=\"math-display\"><img src=\"math/cf56069827f681bb.svg\" alt=\"z^*_{COA}=1329.75/17.25=1773/23\\approx77.086956522\\%\" style=\"width:50.504ex;height:2.294ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Compare methods on the same aggregate</h5><div class=\"table-scroll\"><table><thead><tr><th>Method</th><th>Calculation</th><th>Answer</th></tr></thead><tbody><tr><td>Area centroid</td><td>1329.75 ÷ 17.25</td><td>77.086956522%</td></tr><tr><td>Mean of maxima</td><td>(77.5+92.5) ÷ 2</td><td>85%</td></tr><tr><td>Specified representative weighted average</td><td>(0.3×65+0.5×85) ÷ (0.3+0.5)</td><td>77.5%</td></tr></tbody></table></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p><strong>Boundary coverage of this teaching design.</strong> 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.</p><p><strong>Yaad rakho:</strong> Centroid mein poore shaded area ka balance chahiye. Peak × strength wala shortcut same calculation nahi hai.</p>"},{"id":"exam-theory","title":"Fuzzy theory: definitions, architecture, advantages and applications","html":"<section class=\"example\"><p class=\"question\"><strong>Explain fuzzy logic with one application.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><section class=\"example\"><p class=\"question\"><strong>Give the advantages and limitations of a Mamdani fuzzy controller.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td>Human-readable rules express expert knowledge</td><td>Membership functions and rules require careful design</td></tr><tr><td>Can model gradual boundaries without an exact analytic plant model</td><td>Rule count can grow rapidly with more inputs and categories</td></tr><tr><td>Handles overlapping linguistic descriptions</td><td>A poorly chosen rule base can produce poor or uncovered outputs</td></tr><tr><td>Suitable for many control applications</td><td>Does not automatically learn or guarantee optimal control</td></tr></tbody></table></section><section class=\"example\"><p class=\"question\"><strong>Describe the design of a fuzzy fan controller.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><h2>Other applications you can explain</h2><table><thead><tr><th>Application</th><th>Inputs</th><th>Example rule</th><th>Output</th></tr></thead><tbody><tr><td>Washing machine</td><td>Dirtiness, load</td><td>IF dirt High AND load High THEN wash time Long</td><td>Wash duration</td></tr><tr><td>Loan decision support</td><td>Income, credit score</td><td>IF income High AND credit Good THEN approval suitability High</td><td>Suitability score (not an automatic legal lending decision)</td></tr><tr><td>Fire warning</td><td>Temperature, smoke</td><td>IF temperature High OR smoke High THEN risk High</td><td>Alarm-risk score</td></tr><tr><td>Vehicle control</td><td>Distance, relative speed</td><td>IF distance Small AND closing speed High THEN braking Strong</td><td>Braking command</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Theory answer mein definition → blocks/steps → ek concrete example. Sirf headings se marks nahi milte.</p>"},{"id":"smooth-memberships","title":"Gaussian, singleton and bell memberships","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>A smooth membership function</h2><p>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.</p><div class=\"math-display\"><img src=\"math/518c1dcbf29cffeb.svg\" alt=\"\\mu(x)=\\exp\\left(-\\frac{(x-c)^2}{2\\sigma^2}\\right)\" style=\"width:25.143ex;height:5.641ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>For Gaussian membership with c=10 and σ=2, find μ(10).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=10; centre c=10; width σ=2.</p><h4>To find</h4><p>Membership degree.</p></div><h4>Formula and why it applies</h4><p>Use squared distance from the centre in the Gaussian membership formula.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Distance from the centre</h5><div class=\"math-display\"><img src=\"math/321dce230aba9ce3.svg\" alt=\"10-10=0\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the distance and width</h5><div class=\"math-display\"><img src=\"math/2fa85e59ecadded4.svg\" alt=\"(0)^2=0\\qquad2\\sigma^2=2(2^2)=8\" style=\"width:28.139ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponent</h5><div class=\"math-display\"><img src=\"math/7875a0b4018e0854.svg\" alt=\"-0/8=0\" style=\"width:9.302ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Evaluate e to this power</h5><div class=\"math-display\"><img src=\"math/db4e90ad0923df06.svg\" alt=\"\\mu(10)=e^{0}\\approx1\" style=\"width:14.594ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 1.</div></section><section class=\"example\"><p class=\"question\"><strong>For Gaussian membership with c=10 and σ=2, find μ(12).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=12; centre c=10; width σ=2.</p><h4>To find</h4><p>Membership degree.</p></div><h4>Formula and why it applies</h4><p>Use squared distance from the centre in the Gaussian membership formula.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Distance from the centre</h5><div class=\"math-display\"><img src=\"math/97fe26072a5dade9.svg\" alt=\"12-10=2\" style=\"width:11.439ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the distance and width</h5><div class=\"math-display\"><img src=\"math/0776e93b48581bdc.svg\" alt=\"(2)^2=4\\qquad2\\sigma^2=2(2^2)=8\" style=\"width:28.139ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponent</h5><div class=\"math-display\"><img src=\"math/31d0827fcff0f487.svg\" alt=\"-4/8=-0.5\" style=\"width:12.823ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Evaluate e to this power</h5><div class=\"math-display\"><img src=\"math/3045651368f264c4.svg\" alt=\"\\mu(12)=e^{-0.5}\\approx0.60653066\" style=\"width:26.762ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.60653066.</div></section><section class=\"example\"><p class=\"question\"><strong>For Gaussian membership with c=10 and σ=2, find μ(14).</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=14; centre c=10; width σ=2.</p><h4>To find</h4><p>Membership degree.</p></div><h4>Formula and why it applies</h4><p>Use squared distance from the centre in the Gaussian membership formula.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Distance from the centre</h5><div class=\"math-display\"><img src=\"math/83b853a2ad6339ff.svg\" alt=\"14-10=4\" style=\"width:11.439ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Square the distance and width</h5><div class=\"math-display\"><img src=\"math/8237f522c90ae910.svg\" alt=\"(4)^2=16\\qquad2\\sigma^2=2(2^2)=8\" style=\"width:29.27ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Exponent</h5><div class=\"math-display\"><img src=\"math/6189f75f7af84207.svg\" alt=\"-16/8=-2\" style=\"width:12.194ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Evaluate e to this power</h5><div class=\"math-display\"><img src=\"math/a282bbe0d0c6f2b0.svg\" alt=\"\\mu(14)=e^{-2}\\approx0.135335283\" style=\"width:26.649ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.135335283.</div></section><h2>Singleton</h2><p>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.</p>\r\n<h2>Generalised bell (when its formula is supplied)</h2><div class=\"math-display\"><img src=\"math/5710690d4b19691e.svg\" alt=\"\\mu(x)=\\frac1{1+\\left|\\frac{x-c}{a}\\right|^{2b}}\" style=\"width:19.357ex;height:6.163ex\" loading=\"lazy\" decoding=\"async\"></div><p>c is the centre, a&gt;0 controls width and b&gt;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.</p><section class=\"example\"><p class=\"question\"><strong>For a=2, b=1 and c=10, find generalised-bell membership at x=14.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>a=2, b=1, c=10; x=14.</p><h4>To find</h4><p>μ(14).</p></div><h4>Formula and why it applies</h4><p>Subtract the centre, divide by a, take the absolute value, raise to 2b, then use the reciprocal.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Scaled distance</h5><div class=\"math-display\"><img src=\"math/76742f554dcbda62.svg\" alt=\"|(14-10)/2|=|2|=2\" style=\"width:22.126ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Power</h5><div class=\"math-display\"><img src=\"math/de2c89102c7ce99d.svg\" alt=\"2^{2(1)}=4\" style=\"width:8.312ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Final reciprocal</h5><div class=\"math-display\"><img src=\"math/d1a7dee6fdbdc5f8.svg\" alt=\"\\mu(14)=1/(1+4)=0.2\" style=\"width:23.363ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 0.2.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Gaussian MF ka centre 1 hota hai. GMM density ke normalising factor ko yahan mat lagao.</p>"}]},{"id":"fuzzy-relations","title":"Fuzzy relations and matrices","unit":"Unit 2","scope":"Longer Unit 2 numerical practice, also useful for TEE.","sections":[{"id":"cartesian","title":"Cartesian product: every cell explained","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>How a row membership and a column membership meet</h2><p>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.</p><div class=\"math-display\"><img src=\"math/59fc3a309a7ab813.svg\" alt=\"R_{23}=\\min(A_2,B_3)=\\min(0.2,0.5)=0.2\" style=\"width:39.695ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>What is a fuzzy relation?</h2><p>A fuzzy set gives a membership to one element. A <strong>fuzzy relation</strong> gives a degree to an ordered pair. A matrix is a convenient table: rows name the first element and columns name the second.</p><p>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.</p><div class=\"math-display\"><img src=\"math/1132359c819cab8a.svg\" alt=\"R_{ij}=\\min(\\mu_A(a_i),\\mu_B(b_j))\" style=\"width:25.463ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>Find the fuzzy Cartesian product A×B for memberships A=[0.6, 0.2] and B=[0.3, 0.8, 0.5].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered A memberships [0.6, 0.2]; B memberships [0.3, 0.8, 0.5].</p><h4>To find</h4><p>A 2×3 relation matrix.</p></div><h4>Formula and why it applies</h4><p>Every row corresponds to an A element and every column to a B element; apply min in every cell.</p><div class=\"math-display\"><img src=\"math/50b8f8fcf2c15000.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\" style=\"width:17.671ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Determine dimensions</h5><p>2 row elements × 3 column elements.</p></div><div class=\"step\"><h5>Step 2. Compute each cell</h5><table><thead><tr><th>A ↓ / B →</th><th>0.3</th><th>0.8</th><th>0.5</th></tr></thead><tbody><tr><td>0.6</td><td>min(0.6,0.3) = 0.3</td><td>min(0.6,0.8) = 0.6</td><td>min(0.6,0.5) = 0.5</td></tr><tr><td>0.2</td><td>min(0.2,0.3) = 0.2</td><td>min(0.2,0.8) = 0.2</td><td>min(0.2,0.5) = 0.2</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Write the matrix</h5><div class=\"math-display\"><img src=\"math/eb5e24dcbf5263d2.svg\" alt=\"R=\\begin{bmatrix}0.3&amp;0.6&amp;0.5\\\\0.2&amp;0.2&amp;0.2\\end{bmatrix}\" style=\"width:20.323ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> R is the matrix in Step 3.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the fuzzy Cartesian product A×B for memberships A=[1, 0.4] and B=[0.7, 0].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered A memberships [1, 0.4]; B memberships [0.7, 0].</p><h4>To find</h4><p>A 2×2 relation matrix.</p></div><h4>Formula and why it applies</h4><p>Every row corresponds to an A element and every column to a B element; apply min in every cell.</p><div class=\"math-display\"><img src=\"math/50b8f8fcf2c15000.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\" style=\"width:17.671ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Determine dimensions</h5><p>2 row elements × 2 column elements.</p></div><div class=\"step\"><h5>Step 2. Compute each cell</h5><table><thead><tr><th>A ↓ / B →</th><th>0.7</th><th>0</th></tr></thead><tbody><tr><td>1</td><td>min(1,0.7) = 0.7</td><td>min(1,0) = 0</td></tr><tr><td>0.4</td><td>min(0.4,0.7) = 0.4</td><td>min(0.4,0) = 0</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Write the matrix</h5><div class=\"math-display\"><img src=\"math/00a9ec4b6529a3a5.svg\" alt=\"R=\\begin{bmatrix}0.7&amp;0\\\\0.4&amp;0\\end{bmatrix}\" style=\"width:13.408ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> R is the matrix in Step 3.</div></section><section class=\"example\"><p class=\"question\"><strong>Find the fuzzy Cartesian product A×B for memberships A=[0.2, 0.9, 0.5] and B=[0.6, 0.1].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Ordered A memberships [0.2, 0.9, 0.5]; B memberships [0.6, 0.1].</p><h4>To find</h4><p>A 3×2 relation matrix.</p></div><h4>Formula and why it applies</h4><p>Every row corresponds to an A element and every column to a B element; apply min in every cell.</p><div class=\"math-display\"><img src=\"math/50b8f8fcf2c15000.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\" style=\"width:17.671ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Determine dimensions</h5><p>3 row elements × 2 column elements.</p></div><div class=\"step\"><h5>Step 2. Compute each cell</h5><table><thead><tr><th>A ↓ / B →</th><th>0.6</th><th>0.1</th></tr></thead><tbody><tr><td>0.2</td><td>min(0.2,0.6) = 0.2</td><td>min(0.2,0.1) = 0.1</td></tr><tr><td>0.9</td><td>min(0.9,0.6) = 0.6</td><td>min(0.9,0.1) = 0.1</td></tr><tr><td>0.5</td><td>min(0.5,0.6) = 0.5</td><td>min(0.5,0.1) = 0.1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Write the matrix</h5><div class=\"math-display\"><img src=\"math/587e0aaf2cb10cc7.svg\" alt=\"R=\\begin{bmatrix}0.2&amp;0.1\\\\0.6&amp;0.1\\\\0.5&amp;0.1\\end{bmatrix}\" style=\"width:15.798ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> R is the matrix in Step 3.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Row ka degree aur column ka degree—dono ka min us cell mein.</p>"},{"id":"composition","title":"Max–min composition: three complete matrix examples","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>One result cell combines alternative two-link paths</h2><p>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.</p><table><thead><tr><th>Path</th><th>First link from R</th><th>Second link from S</th><th>Path strength</th></tr></thead><tbody><tr><td>u₁ → v₁ → w₁</td><td>.2</td><td>.5</td><td>min(.2,.5)=.2</td></tr><tr><td>u₁ → v₂ → w₁</td><td>.8</td><td>.7</td><td>min(.8,.7)=.7</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Ek path mein dono links chahiye, isliye min. Alag paths mein best chalega, isliye max.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Composition connects through a middle element</h2><p>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.</p><div class=\"math-display\"><img src=\"math/56cc213f59fd4c68.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Calculate the max–min composition using <span class=\"math-inline\"><img src=\"math/7ad9b78ea1d9260b.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:24.067ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/6a3980f8eb0faad9.svg\" alt=\"R=\\begin{bmatrix}0.2&amp;0.8\\\\0.6&amp;0.3\\end{bmatrix}\" style=\"width:15.169ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ae4133e873ae6a3f.svg\" alt=\"S=\\begin{bmatrix}0.5&amp;0.9\\\\0.7&amp;0.1\\end{bmatrix}\" style=\"width:14.911ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Every entry of T.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Cell (1,1): row 1 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/ce290d4a2b6414c6.svg\" alt=\"T_{11}=\\max\\{\\min(0.2,0.5),\\min(0.8,0.7)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5d7c26e3f57345f9.svg\" alt=\"=\\max\\{0.2,0.7\\}=0.7\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Cell (1,2): row 1 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/ce2b2b77de4033df.svg\" alt=\"T_{12}=\\max\\{\\min(0.2,0.9),\\min(0.8,0.1)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/197ec23ba477e3ac.svg\" alt=\"=\\max\\{0.2,0.1\\}=0.2\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Cell (2,1): row 2 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/07f583df1f70440b.svg\" alt=\"T_{21}=\\max\\{\\min(0.6,0.5),\\min(0.3,0.7)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5d84612aa0c3dabf.svg\" alt=\"=\\max\\{0.5,0.3\\}=0.5\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Cell (2,2): row 2 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/e2fa4ca72e9eecdf.svg\" alt=\"T_{22}=\\max\\{\\min(0.6,0.9),\\min(0.3,0.1)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b6bb46f767031fd8.svg\" alt=\"=\\max\\{0.6,0.1\\}=0.6\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/c434184a79340d55.svg\" alt=\"T=\\begin{bmatrix}0.7&amp;0.2\\\\0.5&amp;0.6\\end{bmatrix}\" style=\"width:15.044ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the max–min composition using <span class=\"math-inline\"><img src=\"math/7ad9b78ea1d9260b.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:24.067ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/5525680a26d9df18.svg\" alt=\"R=\\begin{bmatrix}1&amp;0\\\\0.4&amp;0.7\\end{bmatrix}\" style=\"width:15.169ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/377016d2bce333c2.svg\" alt=\"S=\\begin{bmatrix}0.2&amp;0.6\\\\0.8&amp;0.3\\end{bmatrix}\" style=\"width:14.911ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Every entry of T.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Cell (1,1): row 1 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/cf3e1892a786961d.svg\" alt=\"T_{11}=\\max\\{\\min(1,0.2),\\min(0,0.8)\\}\" style=\"width:34.725ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9ba8671f889808c7.svg\" alt=\"=\\max\\{0.2,0\\}=0.2\" style=\"width:19.799ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Cell (1,2): row 1 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/d6b9af12c569f647.svg\" alt=\"T_{12}=\\max\\{\\min(1,0.6),\\min(0,0.3)\\}\" style=\"width:34.725ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/234802688b1bc952.svg\" alt=\"=\\max\\{0.6,0\\}=0.6\" style=\"width:19.799ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Cell (2,1): row 2 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/145badb953d03e7a.svg\" alt=\"T_{21}=\\max\\{\\min(0.4,0.2),\\min(0.7,0.8)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5d7c26e3f57345f9.svg\" alt=\"=\\max\\{0.2,0.7\\}=0.7\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Cell (2,2): row 2 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/7580af7f56a5d58b.svg\" alt=\"T_{22}=\\max\\{\\min(0.4,0.6),\\min(0.7,0.3)\\}\" style=\"width:38.246ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fed46295bb39d225.svg\" alt=\"=\\max\\{0.4,0.3\\}=0.4\" style=\"width:21.559ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/303c2bbbbf128653.svg\" alt=\"T=\\begin{bmatrix}0.2&amp;0.6\\\\0.7&amp;0.4\\end{bmatrix}\" style=\"width:15.044ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><section class=\"example\"><p class=\"question\"><strong>Calculate the max–min composition using <span class=\"math-inline\"><img src=\"math/7ad9b78ea1d9260b.svg\" alt=\"T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:24.067ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/12f5f2edbde65b9d.svg\" alt=\"R=\\begin{bmatrix}0.3&amp;0.6&amp;0.9\\end{bmatrix}\" style=\"width:19.191ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1823a7e672a05e76.svg\" alt=\"S=\\begin{bmatrix}0.8&amp;0.1\\\\0.2&amp;0.7\\\\0.5&amp;0.4\\end{bmatrix}\" style=\"width:15.54ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Every entry of T.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Cell (1,1): row 1 of R with column 1 of S</h5><div class=\"math-display\"><img src=\"math/559127d73e85d555.svg\" alt=\"T_{11}=\\max\\{\\min(0.3,0.8),\\min(0.6,0.2),\\min(0.9,0.5)\\}\" style=\"width:51.572ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ebeaf1e5ce8f9612.svg\" alt=\"=\\max\\{0.3,0.2,0.5\\}=0.5\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Cell (1,2): row 1 of R with column 2 of S</h5><div class=\"math-display\"><img src=\"math/843b8913b1abe9b7.svg\" alt=\"T_{12}=\\max\\{\\min(0.3,0.1),\\min(0.6,0.7),\\min(0.9,0.4)\\}\" style=\"width:51.572ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8ce46b5da48e6fa8.svg\" alt=\"=\\max\\{0.1,0.6,0.4\\}=0.6\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/fc69cd14a88a24b1.svg\" alt=\"T=\\begin{bmatrix}0.5&amp;0.6\\end{bmatrix}\" style=\"width:13.913ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Har path mein min, phir saare paths mein max. Multiply-and-add nahi.</p>"}]},{"id":"ga-core","title":"3. Genetic algorithms","unit":"Unit 3 · GA","scope":"Candidate → fitness → encoding → selection → crossover → mutation → two complete generations.","sections":[{"id":"meaning","title":"GA meaning, biological idea and every basic term","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><table><thead><tr><th>Object</th><th>Concrete value</th><th>Do not confuse it with</th></tr></thead><tbody><tr><td>Individual number</td><td>Row 2</td><td>The candidate’s value x</td></tr><tr><td>Candidate value x</td><td>11</td><td>Its chromosome 1011</td></tr><tr><td>Chromosome</td><td>1011</td><td>Its fitness</td></tr><tr><td>Fitness when maximising x²</td><td>11×11=121</td><td>Its row number or bit string</td></tr></tbody></table><p>In this guide, “gene 3” counts the third bit from the <strong>left</strong> starting at 1. Binary place values were built from the <strong>right</strong> starting with weight 1. These are two labelling conventions, not contradictory place-value rules. Read the end specified in an exam.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>What a genetic algorithm does</h2><p>A <strong>genetic algorithm (GA)</strong> 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.</p><p>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.</p><table><thead><tr><th>Term</th><th>Meaning</th><th>Four-bit example</th></tr></thead><tbody><tr><td>Individual</td><td>One candidate solution</td><td>x=11</td></tr><tr><td>Chromosome</td><td>The complete encoded candidate</td><td>1011</td></tr><tr><td>Gene</td><td>One component of an encoding</td><td>The third bit</td></tr><tr><td>Allele</td><td>The value at a gene</td><td>0 or 1 for binary encoding</td></tr><tr><td>Population</td><td>The collection of current individuals</td><td>[3,5,10,12]</td></tr><tr><td>Fitness</td><td>A score used to favour useful candidates</td><td>For max x², fitness of 11 is 121</td></tr><tr><td>Generation</td><td>One cycle producing a new population</td><td>Select → cross → mutate → replace</td></tr><tr><td>Search space</td><td>All candidate solutions permitted</td><td>4-bit integers: 0–15</td></tr><tr><td>Elitism</td><td>Preserving best individuals unchanged</td><td>Copy the best into the next population</td></tr></tbody></table><p>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.</p><section class=\"example\"><p class=\"question\"><strong>For a maximisation GA with objective f(x)=x², find the fitness of x=3.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=3; fitness equals the nonnegative objective x².</p><h4>To find</h4><p>Fitness, not the encoded chromosome.</p></div><h4>Formula and why it applies</h4><p>Square x to evaluate its objective; binary encoding is a separate representation step.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute x</h5><div class=\"math-display\"><img src=\"math/7cb566d00780f2b1.svg\" alt=\"f(3)=3^2\" style=\"width:9.272ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply</h5><div class=\"math-display\"><img src=\"math/40a9936a2387e5b6.svg\" alt=\"3\\times3=9\" style=\"width:9.176ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Fitness = 9.</div></section><section class=\"example\"><p class=\"question\"><strong>For a maximisation GA with objective f(x)=x², find the fitness of x=7.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=7; fitness equals the nonnegative objective x².</p><h4>To find</h4><p>Fitness, not the encoded chromosome.</p></div><h4>Formula and why it applies</h4><p>Square x to evaluate its objective; binary encoding is a separate representation step.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute x</h5><div class=\"math-display\"><img src=\"math/a39be859ebcf3420.svg\" alt=\"f(7)=7^2\" style=\"width:9.272ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply</h5><div class=\"math-display\"><img src=\"math/67b20e8d00098635.svg\" alt=\"7\\times7=49\" style=\"width:10.308ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Fitness = 49.</div></section><section class=\"example\"><p class=\"question\"><strong>For a maximisation GA with objective f(x)=x², find the fitness of x=12.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=12; fitness equals the nonnegative objective x².</p><h4>To find</h4><p>Fitness, not the encoded chromosome.</p></div><h4>Formula and why it applies</h4><p>Square x to evaluate its objective; binary encoding is a separate representation step.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Substitute x</h5><div class=\"math-display\"><img src=\"math/40c9415d3dcdd694.svg\" alt=\"f(12)=12^2\" style=\"width:11.534ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply</h5><div class=\"math-display\"><img src=\"math/ea37e28a2a0fc9ec.svg\" alt=\"12\\times12=144\" style=\"width:13.701ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Fitness = 144.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Chromosome answer ka code; fitness us code wale answer ka score.</p>"},{"id":"encoding","title":"Encoding: binary, real values and permutations","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Expand the compact decoding formula before using it</h2><div class=\"math-display\"><img src=\"math/7a27d9903aa92206.svg\" alt=\"x=b_1 2^3+b_2 2^2+b_3 2^1+b_4 2^0\" style=\"width:28.917ex;height:2.374ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><p>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.</p><table><thead><tr><th>3-bit code</th><th>Decoded d</th><th>Fraction d/7</th><th>Mapped to [−2,5]</th></tr></thead><tbody><tr><td>000</td><td>0</td><td>0/7=0</td><td>−2+0×7=−2</td></tr><tr><td>011</td><td>3</td><td>3/7</td><td>−2+(3/7)×7=1</td></tr><tr><td>111</td><td>7</td><td>7/7=1</td><td>−2+1×7=5</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Choose an encoding that can express legal solutions</h2><p><strong>Binary encoding</strong> uses bit strings; <strong>real-valued encoding</strong> stores real numbers directly; <strong>permutation encoding</strong> 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.</p><table><thead><tr><th>Representation</th><th>Candidate</th><th>Appropriate use</th></tr></thead><tbody><tr><td>Binary</td><td>1011</td><td>An unsigned integer or a coded real value</td></tr><tr><td>Real-valued</td><td>[0.2, 1.7]</td><td>Continuous parameters</td></tr><tr><td>Permutation</td><td>[A,C,B,D]</td><td>Visit order in TSP</td></tr></tbody></table><h2>Decode an n-bit integer</h2><div class=\"math-display\"><img src=\"math/f86e986776de93a7.svg\" alt=\"x=b_1 2^{n-1}+b_2 2^{n-2}+\\cdots+b_n2^0\" style=\"width:32.06ex;height:2.357ex\" loading=\"lazy\" decoding=\"async\"></div><p>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 <span class=\"math-inline\"><img src=\"math/9dc91f3c375d809f.svg\" alt=\"2^n-1\" style=\"width:6.176ex;height:1.714ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><section class=\"example\"><p class=\"question\"><strong>Decode the 4-bit chromosome 0011.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Bits 0011; place values 8,4,2,1.</p><h4>To find</h4><p>Integer x.</p></div><h4>Formula and why it applies</h4><p>Multiply each bit by its matching place value, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. List contributions</h5><table><thead><tr><th>Bit</th><th>Place value</th><th>Contribution</th></tr></thead><tbody><tr><td>0</td><td>8</td><td>0</td></tr><tr><td>0</td><td>4</td><td>0</td></tr><tr><td>1</td><td>2</td><td>2</td></tr><tr><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/76153632459f881f.svg\" alt=\"0+0+2+1=3\" style=\"width:16.97ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=3.</div></section><section class=\"example\"><p class=\"question\"><strong>Decode the 4-bit chromosome 1010.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Bits 1010; place values 8,4,2,1.</p><h4>To find</h4><p>Integer x.</p></div><h4>Formula and why it applies</h4><p>Multiply each bit by its matching place value, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. List contributions</h5><table><thead><tr><th>Bit</th><th>Place value</th><th>Contribution</th></tr></thead><tbody><tr><td>1</td><td>8</td><td>8</td></tr><tr><td>0</td><td>4</td><td>0</td></tr><tr><td>1</td><td>2</td><td>2</td></tr><tr><td>0</td><td>1</td><td>0</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/d1e04d751dc741ed.svg\" alt=\"8+0+2+0=10\" style=\"width:18.102ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=10.</div></section><section class=\"example\"><p class=\"question\"><strong>Decode the 4-bit chromosome 1111.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Bits 1111; place values 8,4,2,1.</p><h4>To find</h4><p>Integer x.</p></div><h4>Formula and why it applies</h4><p>Multiply each bit by its matching place value, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. List contributions</h5><table><thead><tr><th>Bit</th><th>Place value</th><th>Contribution</th></tr></thead><tbody><tr><td>1</td><td>8</td><td>8</td></tr><tr><td>1</td><td>4</td><td>4</td></tr><tr><td>1</td><td>2</td><td>2</td></tr><tr><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Add</h5><div class=\"math-display\"><img src=\"math/f3965404fe997578.svg\" alt=\"8+4+2+1=15\" style=\"width:18.102ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=15.</div></section><h2>Encoding a real interval</h2><p>If the question maps an n-bit integer d to a real interval [L,U], first decode d, then use:</p><div class=\"math-display\"><img src=\"math/3013a3fc845c64e5.svg\" alt=\"x=L+\\frac{d}{2^n-1}(U-L)\" style=\"width:23.591ex;height:4.837ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"example\"><p class=\"question\"><strong>Map the 3-bit string 101 to the real interval [−2,5] using linear binary decoding.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>n=3, L=−2, U=5; string 101.</p><h4>To find</h4><p>Real x.</p></div><h4>Formula and why it applies</h4><p>The smallest bit code maps to L and the largest to U; the remaining codes are equally spaced.</p><div class=\"math-display\"><img src=\"math/d5a028f7f6ff09e2.svg\" alt=\"x=L+\\frac d{2^n-1}(U-L)\" style=\"width:23.591ex;height:4.837ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Decode integer d</h5><div class=\"math-display\"><img src=\"math/5d98008e8ca61fcc.svg\" alt=\"d=1(4)+0(2)+1(1)=5\" style=\"width:25.941ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate interval width and maximum code</h5><div class=\"math-display\"><img src=\"math/a70472c6ec58ad8d.svg\" alt=\"U-L=5-(-2)=7\\qquad2^3-1=7\" style=\"width:36.445ex;height:2.564ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Map to the interval</h5><div class=\"math-display\"><img src=\"math/2d086e3a5cf5f29f.svg\" alt=\"x=-2+(5/7)(7)=3\" style=\"width:22.162ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> x=3.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Pehle bits se integer. Real range mapping explicitly diya ho tabhi next formula lagao.</p>"},{"id":"selection","title":"Roulette selection, cumulative intervals and alternatives","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>Before the three complete sums below, read the running-total example in <a href=\"#m2/read/core-maths/probability\">Percentages, probabilities and cumulative intervals</a>. 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Selection chooses parents, usually with replacement</h2><p><strong>Roulette-wheel selection</strong> 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><div class=\"math-display\"><img src=\"math/2cf98c22ed8b8331.svg\" alt=\"P_i=F_i/\\sum_jF_j\" style=\"width:14.858ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Fitness weights of successive individuals are [1, 2, 3, 4]. Select parents using random numbers [0.05, 0.25, 0.55, 0.9].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Fitness weights [1, 2, 3, 4]; draws [0.05, 0.25, 0.55, 0.9].</p><h4>To find</h4><p>Parent row number for each draw.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum fitness</h5><div class=\"math-display\"><img src=\"math/601b2d3d469972c2.svg\" alt=\"\\sum F=1+2+3+4=10\" style=\"width:26.457ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find probabilities and cumulative bounds</h5><table><thead><tr><th>Individual</th><th>Fitness</th><th>Probability</th><th>Cumulative</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>0.1</td><td>0.1</td></tr><tr><td>2</td><td>2</td><td>0.2</td><td>0.3</td></tr><tr><td>3</td><td>3</td><td>0.3</td><td>0.6</td></tr><tr><td>4</td><td>4</td><td>0.4</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Locate each draw</h5><table><thead><tr><th>Draw</th><th>Selected individual</th></tr></thead><tbody><tr><td>0.05</td><td>1</td></tr><tr><td>0.25</td><td>2</td></tr><tr><td>0.55</td><td>3</td></tr><tr><td>0.9</td><td>4</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Selected row numbers: [1, 2, 3, 4]. Repeated selection is permitted.</div></section><section class=\"example\"><p class=\"question\"><strong>Fitness weights of successive individuals are [4, 4, 2]. Select parents using random numbers [0.2, 0.6, 0.85].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Fitness weights [4, 4, 2]; draws [0.2, 0.6, 0.85].</p><h4>To find</h4><p>Parent row number for each draw.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum fitness</h5><div class=\"math-display\"><img src=\"math/a1ef5b129218331e.svg\" alt=\"\\sum F=4+4+2=10\" style=\"width:22.56ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find probabilities and cumulative bounds</h5><table><thead><tr><th>Individual</th><th>Fitness</th><th>Probability</th><th>Cumulative</th></tr></thead><tbody><tr><td>1</td><td>4</td><td>0.4</td><td>0.4</td></tr><tr><td>2</td><td>4</td><td>0.4</td><td>0.8</td></tr><tr><td>3</td><td>2</td><td>0.2</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Locate each draw</h5><table><thead><tr><th>Draw</th><th>Selected individual</th></tr></thead><tbody><tr><td>0.2</td><td>1</td></tr><tr><td>0.6</td><td>2</td></tr><tr><td>0.85</td><td>3</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Selected row numbers: [1, 2, 3]. Repeated selection is permitted.</div></section><section class=\"example\"><p class=\"question\"><strong>Fitness weights of successive individuals are [0, 3, 1]. Select parents using random numbers [0.2, 0.8].</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Fitness weights [0, 3, 1]; draws [0.2, 0.8].</p><h4>To find</h4><p>Parent row number for each draw.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum fitness</h5><div class=\"math-display\"><img src=\"math/7f52b89af830db1b.svg\" alt=\"\\sum F=0+3+1=4\" style=\"width:21.429ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find probabilities and cumulative bounds</h5><table><thead><tr><th>Individual</th><th>Fitness</th><th>Probability</th><th>Cumulative</th></tr></thead><tbody><tr><td>1</td><td>0</td><td>0</td><td>0</td></tr><tr><td>2</td><td>3</td><td>0.75</td><td>0.75</td></tr><tr><td>3</td><td>1</td><td>0.25</td><td>1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Locate each draw</h5><table><thead><tr><th>Draw</th><th>Selected individual</th></tr></thead><tbody><tr><td>0.2</td><td>2</td></tr><tr><td>0.8</td><td>3</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Selected row numbers: [2, 3]. Repeated selection is permitted.</div></section><h2>Other selection methods</h2><table><thead><tr><th>Method</th><th>Procedure</th><th>Why it is used</th></tr></thead><tbody><tr><td>Tournament</td><td>Sample a group and take its best candidate</td><td>Only objective comparisons are needed</td></tr><tr><td>Rank</td><td>Sort candidates; assign weights based on rank</td><td>Reduces sensitivity to a single huge raw fitness</td></tr><tr><td>Elitist survival</td><td>Preserve top individuals unchanged into the next population</td><td>Protects good solutions from destructive variation</td></tr></tbody></table><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Probability nikalo → cumulative banao → random number ka interval dekho.</p>"},{"id":"operators","title":"Crossover and mutation: four complete worked variants","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Cutting means splitting the written string</h2><p>The <strong>prefix</strong> is the part before the cut; the <strong>suffix</strong> 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.</p><table><thead><tr><th>Operation</th><th>Parents / instruction</th><th>Construction</th><th>Children</th></tr></thead><tbody><tr><td>One-point crossover</td><td>10|11 and 01|00</td><td>First prefix + second tail; second prefix + first tail</td><td>1000 and 0111</td></tr><tr><td>Two-point crossover</td><td>1|01|10 and 0|10|01</td><td>Exchange only the middle blocks</td><td>11010 and 00101</td></tr><tr><td>Uniform crossover</td><td>A=1010, B=0101, mask=1100</td><td>Child 1 takes A where mask=1 and B where mask=0; child 2 reverses this</td><td>1001 and 0110</td></tr><tr><td>Mutation</td><td>1000; flip position 3 from left</td><td>The third bit is 0; replace it by 1; keep every other bit</td><td>1010</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>Crossover combines; mutation changes</h2><p>In <strong>single-point crossover</strong>, 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.</p><section class=\"example\"><p class=\"question\"><strong>Cross parents 1011 and 0100 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 1011, 0100; cut after bit 2; mutation bit 4.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">10 | 11</span> and <span class=\"bits\">01 | 00</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">10 + 00 → 1000</span><br><span class=\"bits\">01 + 11 → 0111</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>1000</td><td>0</td><td>1</td><td>1001</td></tr><tr><td>0111</td><td>1</td><td>0</td><td>0110</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>1001</td><td>8 + 0 + 0 + 1</td><td>9</td></tr><tr><td>0110</td><td>0 + 4 + 2 + 0</td><td>6</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 1001 (9) and 0110 (6).</div></section><section class=\"example\"><p class=\"question\"><strong>Cross parents 0011 and 1100 after bit 1. Then flip bit 2 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 0011, 1100; cut after bit 1; mutation bit 2.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">0 | 011</span> and <span class=\"bits\">1 | 100</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">0 + 100 → 0100</span><br><span class=\"bits\">1 + 011 → 1011</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>0100</td><td>1</td><td>0</td><td>0000</td></tr><tr><td>1011</td><td>0</td><td>1</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>0000</td><td>0 + 0 + 0 + 0</td><td>0</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1</td><td>15</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 0000 (0) and 1111 (15).</div></section><section class=\"example\"><p class=\"question\"><strong>Cross parents 1110 and 0001 after bit 3. Then flip bit 1 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 1110, 0001; cut after bit 3; mutation bit 1.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">111 | 0</span> and <span class=\"bits\">000 | 1</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">111 + 1 → 1111</span><br><span class=\"bits\">000 + 0 → 0000</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>1111</td><td>1</td><td>0</td><td>0111</td></tr><tr><td>0000</td><td>0</td><td>1</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>0111</td><td>0 + 4 + 2 + 1</td><td>7</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0</td><td>8</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 0111 (7) and 1000 (8).</div></section><section class=\"example\"><p class=\"question\"><strong>Cross parents 1010 and 1010 after bit 2. Then flip bit 4 of both children, counting from the left. Decode the final children.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Parents 1010, 1010; cut after bit 2; mutation bit 4.</p><h4>To find</h4><p>Children after crossover, after mutation and their decimal values.</p></div><h4>Formula and why it applies</h4><p>Exchange only suffixes. Mutation means 0→1 or 1→0; it does not mean set the bit to 1.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Mark the cut</h5><p><span class=\"bits\">10 | 10</span> and <span class=\"bits\">10 | 10</span></p></div><div class=\"step\"><h5>Step 2. Exchange tails</h5><p><span class=\"bits\">10 + 10 → 1010</span><br><span class=\"bits\">10 + 10 → 1010</span></p></div><div class=\"step\"><h5>Step 3. Flip the specified bit</h5><table><thead><tr><th>Crossover child</th><th>Bit before</th><th>Bit after</th><th>Mutated child</th></tr></thead><tbody><tr><td>1010</td><td>0</td><td>1</td><td>1011</td></tr><tr><td>1010</td><td>0</td><td>1</td><td>1011</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Decode</h5><table><thead><tr><th>String</th><th>Place-value sum</th><th>x</th></tr></thead><tbody><tr><td>1011</td><td>8 + 0 + 2 + 1</td><td>11</td></tr><tr><td>1011</td><td>8 + 0 + 2 + 1</td><td>11</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> Final children 1011 (11) and 1011 (11).</div></section><p><strong>Two-point crossover</strong> exchanges the segment between two cuts. <strong>Uniform crossover</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Crossover = tail exchange. Mutation = specified bit flip. Flip ka matlab 1 bhi 0 banega.</p>"},{"id":"algorithm","title":"GA architecture, two-generation flow, constraints and theory","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>Feasible</td><td>Obeys every stated constraint</td><td>x≤10: x=9 qualifies; x=12 does not</td></tr><tr><td>Penalty</td><td>A deduction for violating a constraint</td><td>For maximisation, subtract 100×excess</td></tr><tr><td>Elitism</td><td>Explicitly preserve a best old individual</td><td>Only apply if the question specifies it</td></tr><tr><td>Replacement</td><td>Choose what population the next generation uses</td><td>Our full-replacement examples use the new children</td></tr><tr><td>Stopping condition</td><td>A rule ending the repeated process</td><td>Stop after two complete generations</td></tr></tbody></table></div>\r\n<!-- depth:bridge:end -->\r\n<h2>A complete GA generation</h2><div class=\"flow\"><div class=\"node\">Encode + evaluate</div><span class=\"arrow\">→</span><div class=\"node\">Select parents</div><span class=\"arrow\">→</span><div class=\"node\">Crossover</div><span class=\"arrow\">→</span><div class=\"node\">Mutation</div><span class=\"arrow\">→</span><div class=\"node\">Evaluate children<small>replace and repeat</small></div></div>\r\n<p>A <strong>simple generational GA</strong> 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.</p>\r\n<h2>What “iteration 2” means here</h2><p>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.</p>\r\n<h2>Stopping conditions</h2><p>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.</p>\r\n<h2>Constraints</h2><p>A <strong>constraint</strong> 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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Penalty coefficient 100; bound 10; candidates 9 and 12.</p><h4>To find</h4><p>Penalised fitness of both candidates.</p></div><h4>Formula and why it applies</h4><p>Only excess above the bound receives a penalty.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Feasible candidate 9</h5><div class=\"math-display\"><img src=\"math/a12fb07643a5aaa1.svg\" alt=\"\\max(0,9-10)=0\" style=\"width:18.416ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/deb272d3158b70b9.svg\" alt=\"F(9)=81-100(0)=81\" style=\"width:24.196ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Infeasible candidate 12</h5><div class=\"math-display\"><img src=\"math/c2860199dab61091.svg\" alt=\"\\max(0,12-10)=2\" style=\"width:19.547ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/decf48b28bc4a229.svg\" alt=\"F(12)=144-100(2)=-56\" style=\"width:28.218ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Compare</h5><p>For this maximisation fitness, 81 > −56, so x=9 is preferred. Raw objective alone would misleadingly favour 12.</p></div><div class=\"answer\"><strong>Final answer.</strong> F(9)=81; F(12)=−56.</div></section><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td>Derivative-free; supports many encodings</td><td>Many objective evaluations may be costly</td></tr><tr><td>Population explores several candidates</td><td>Premature convergence is possible</td></tr><tr><td>Crossover and mutation can create new candidates</td><td>Parameter and encoding choices affect results</td></tr><tr><td>Applicable to discontinuous or combinatorial searches</td><td>No guaranteed global optimum; variation can worsen fitness</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Do generation = do baar poora cycle. Sirf children banana aur decode karna do alag iterations nahi.</p>"},{"id":"two-generations","title":"Two generations with given selection, cut and mutation","html":"<!-- depth:retained-diagram:start -->\r\n<div class=\"concept-bridge\"><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_ga_generation.fa7bf86c05.svg\" width=\"700\" height=\"490\" alt=\"This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>This diagram traces the first pair in generation 1. The full solution also processes the second pair and the entire second generation.</figcaption></figure></div>\r\n<!-- depth:retained-diagram:end -->\r\n<section class=\"example\"><p class=\"question\"><strong>Maximise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Current individual row numbers [3, 4, 4, 3]</td></tr><tr><td>2</td><td>Current individual row numbers [2, 3, 2, 3]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>0011</td><td>3 × 3 = 9</td></tr><tr><td>2</td><td>5</td><td>0101</td><td>5 × 5 = 25</td></tr><tr><td>3</td><td>10</td><td>1010</td><td>10 × 10 = 100</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>12 × 12 = 144</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: apply the supplied selection order</h5><p>The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>3</td><td>10</td><td>1010</td></tr><tr><td>2</td><td>4</td><td>12</td><td>1100</td></tr><tr><td>3</td><td>4</td><td>12</td><td>1100</td></tr><tr><td>4</td><td>3</td><td>10</td><td>1010</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>10 | 10</td><td>11 | 00</td><td>1000</td><td>1110</td></tr><tr><td>3 & 4</td><td>11 | 00</td><td>10 | 10</td><td>1110</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr><tr><td>2</td><td>1110</td><td>Flip bit 4</td><td>1111</td></tr><tr><td>3</td><td>1110</td><td>Flip bit 4</td><td>1111</td></tr><tr><td>4</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>9² = 81</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1111</td><td>8 + 4 + 2 + 1 = 15</td><td>15² = 225</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>9² = 81</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/ac14e9c27d115d0e.svg\" alt=\"\\overline f_{old}=\\frac{9+25+100+144}{4}=\\frac{278}{4}=69.5\" style=\"width:40.453ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b4cd0bde2e1de484.svg\" alt=\"\\overline f_{new}=\\frac{81+225+225+81}{4}=\\frac{612}{4}=153\" style=\"width:41.722ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 7. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>9</td><td>1001</td><td>9 × 9 = 81</td></tr><tr><td>2</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>3</td><td>15</td><td>1111</td><td>15 × 15 = 225</td></tr><tr><td>4</td><td>9</td><td>1001</td><td>9 × 9 = 81</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Generation 2: apply the supplied selection order</h5><p>The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.</p><table><thead><tr><th>Mating-pool slot</th><th>Chosen individual</th><th>x</th><th>Chromosome</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>2</td><td>3</td><td>15</td><td>1111</td></tr><tr><td>3</td><td>2</td><td>15</td><td>1111</td></tr><tr><td>4</td><td>3</td><td>15</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr><tr><td>3 & 4</td><td>11 | 11</td><td>11 | 11</td><td>1111</td><td>1111</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>2</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>3</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr><tr><td>4</td><td>1111</td><td>Flip bit 4</td><td>1110</td></tr></tbody></table></div><div class=\"step\"><h5>Step 11. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr><tr><td>1110</td><td>8 + 4 + 2 + 0 = 14</td><td>14² = 196</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/1526400ff09c5372.svg\" alt=\"\\overline f_{old}=\\frac{81+225+225+81}{4}=\\frac{612}{4}=153\" style=\"width:40.956ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/83698ff516912ccd.svg\" alt=\"\\overline f_{new}=\\frac{196+196+196+196}{4}=\\frac{784}{4}=196\" style=\"width:43.984ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [14, 14, 14, 14]. Best final objective = 196 at x = [14].</div></section>"},{"id":"roulette-generations","title":"Two generations including roulette selection","html":"<section class=\"example\"><p class=\"question\"><strong>Maximise <span class=\"math-inline\"><img src=\"math/163a21622d906b2b.svg\" alt=\"f(x)=x(15-x)+1\" style=\"width:20.589ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Random draws [0.1, 0.4, 0.65, 0.9]</td></tr><tr><td>2</td><td>Random draws [0.2, 0.4, 0.6, 0.95]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>0010</td><td>2 × (15 − 2) + 1 = 27</td></tr><tr><td>2</td><td>5</td><td>0101</td><td>5 × (15 − 5) + 1 = 51</td></tr><tr><td>3</td><td>9</td><td>1001</td><td>9 × (15 − 9) + 1 = 55</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>12 × (15 − 12) + 1 = 37</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: calculate roulette intervals</h5><p>Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.</p><div class=\"math-display\"><img src=\"math/3c9eb5a0f63c3e40.svg\" alt=\"\\sum F=27+51+55+37\\approx170\" style=\"width:32.113ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>27 ÷ 170 ≈ 0.158823529</td><td>0 + 0.158823529 ≈ 0.158823529</td></tr><tr><td>2</td><td>51 ÷ 170 ≈ 0.3</td><td>0.158823529 + 0.3 ≈ 0.458823529</td></tr><tr><td>3</td><td>55 ÷ 170 ≈ 0.323529412</td><td>0.458823529 + 0.323529412 ≈ 0.782352941</td></tr><tr><td>4</td><td>37 ÷ 170 ≈ 0.217647059</td><td>0.782352941 + 0.217647059 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.1</td><td>0 ≤ 0.1 < 0.158823529</td><td>1</td><td>2</td></tr><tr><td>0.4</td><td>0.158823529 ≤ 0.4 < 0.458823529</td><td>2</td><td>5</td></tr><tr><td>0.65</td><td>0.458823529 ≤ 0.65 < 0.782352941</td><td>3</td><td>9</td></tr><tr><td>0.9</td><td>0.782352941 ≤ 0.9 < 1</td><td>4</td><td>12</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 4. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>00 | 10</td><td>01 | 01</td><td>0001</td><td>0110</td></tr><tr><td>3 & 4</td><td>10 | 01</td><td>11 | 00</td><td>1000</td><td>1101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>0001</td><td>No mutation</td><td>0001</td></tr><tr><td>2</td><td>0110</td><td>Flip bit 4</td><td>0111</td></tr><tr><td>3</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>4</td><td>1101</td><td>Flip bit 4</td><td>1100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>0001</td><td>0 + 0 + 0 + 1 = 1</td><td>1(15−1)+1 = 15</td></tr><tr><td>0111</td><td>0 + 4 + 2 + 1 = 7</td><td>7(15−7)+1 = 57</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8(15−8)+1 = 57</td></tr><tr><td>1100</td><td>8 + 4 + 0 + 0 = 12</td><td>12(15−12)+1 = 37</td></tr></tbody></table></div><div class=\"step\"><h5>Step 7. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/22945ccb0391cac7.svg\" alt=\"\\overline f_{old}=\\frac{27+51+55+37}{4}=\\frac{170}{4}=42.5\" style=\"width:39.322ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4832c61f6dee4ab2.svg\" alt=\"\\overline f_{new}=\\frac{15+57+57+37}{4}=\\frac{166}{4}=41.5\" style=\"width:40.088ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 8. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>1</td><td>0001</td><td>1 × (15 − 1) + 1 = 15</td></tr><tr><td>2</td><td>7</td><td>0111</td><td>7 × (15 − 7) + 1 = 57</td></tr><tr><td>3</td><td>8</td><td>1000</td><td>8 × (15 − 8) + 1 = 57</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>12 × (15 − 12) + 1 = 37</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: calculate roulette intervals</h5><p>Fitness weights are nonnegative. The nonnegative objective itself is the fitness in this maximisation example.</p><div class=\"math-display\"><img src=\"math/74f6736e95b5ff63.svg\" alt=\"\\sum F=15+57+57+37\\approx166\" style=\"width:32.113ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>15 ÷ 166 ≈ 0.090361446</td><td>0 + 0.090361446 ≈ 0.090361446</td></tr><tr><td>2</td><td>57 ÷ 166 ≈ 0.343373494</td><td>0.090361446 + 0.343373494 ≈ 0.43373494</td></tr><tr><td>3</td><td>57 ÷ 166 ≈ 0.343373494</td><td>0.43373494 + 0.343373494 ≈ 0.777108434</td></tr><tr><td>4</td><td>37 ÷ 166 ≈ 0.222891566</td><td>0.777108434 + 0.222891566 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.2</td><td>0.090361446 ≤ 0.2 < 0.43373494</td><td>2</td><td>7</td></tr><tr><td>0.4</td><td>0.090361446 ≤ 0.4 < 0.43373494</td><td>2</td><td>7</td></tr><tr><td>0.6</td><td>0.43373494 ≤ 0.6 < 0.777108434</td><td>3</td><td>8</td></tr><tr><td>0.95</td><td>0.777108434 ≤ 0.95 < 1</td><td>4</td><td>12</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 11. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>01 | 11</td><td>01 | 11</td><td>0111</td><td>0111</td></tr><tr><td>3 & 4</td><td>10 | 00</td><td>11 | 00</td><td>1000</td><td>1100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>0111</td><td>No mutation</td><td>0111</td></tr><tr><td>2</td><td>0111</td><td>Flip bit 4</td><td>0110</td></tr><tr><td>3</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>4</td><td>1100</td><td>Flip bit 4</td><td>1101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 13. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>0111</td><td>0 + 4 + 2 + 1 = 7</td><td>7(15−7)+1 = 57</td></tr><tr><td>0110</td><td>0 + 4 + 2 + 0 = 6</td><td>6(15−6)+1 = 55</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>8(15−8)+1 = 57</td></tr><tr><td>1101</td><td>8 + 4 + 0 + 1 = 13</td><td>13(15−13)+1 = 27</td></tr></tbody></table></div><div class=\"step\"><h5>Step 14. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/9b9333d937330aaa.svg\" alt=\"\\overline f_{old}=\\frac{15+57+57+37}{4}=\\frac{166}{4}=41.5\" style=\"width:39.322ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5b337e1a852cf7fa.svg\" alt=\"\\overline f_{new}=\\frac{57+55+57+27}{4}=\\frac{196}{4}=49\" style=\"width:38.328ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [7, 6, 8, 13]. Best final objective = 57 at x = [7, 8].</div></section>"},{"id":"minimisation","title":"GA minimisation: transform cost before roulette selection","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/caf5baf4d59a93e5.svg\" alt=\"f(x)=(x-7)^2\" style=\"width:15.255ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness.</strong> <span class=\"marks\">[3 marks · Practice; complete two-generation solution]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><table><thead><tr><th>Generation</th><th>Selection instruction</th></tr></thead><tbody><tr><td>1</td><td>Random draws [0.1, 0.4, 0.65, 0.9]</td></tr><tr><td>2</td><td>Random draws [0.2, 0.4, 0.6, 0.95]</td></tr></tbody></table><h4>To find</h4><p>Both generations: evaluation, selection, crossover, mutation, decoding and comparison.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Generation 1: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>0010</td><td>(2 − 7)² = 25</td></tr><tr><td>2</td><td>4</td><td>0100</td><td>(4 − 7)² = 9</td></tr><tr><td>3</td><td>8</td><td>1000</td><td>(8 − 7)² = 1</td></tr><tr><td>4</td><td>12</td><td>1100</td><td>(12 − 7)² = 25</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Generation 1: calculate roulette intervals</h5><p>Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.</p><table><thead><tr><th>Individual</th><th>Cost</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>1</td><td>25</td><td>1 / (1 + 25) = 1 / 26 ≈ 0.038461538</td></tr><tr><td>2</td><td>9</td><td>1 / (1 + 9) = 1 / 10 ≈ 0.1</td></tr><tr><td>3</td><td>1</td><td>1 / (1 + 1) = 1 / 2 ≈ 0.5</td></tr><tr><td>4</td><td>25</td><td>1 / (1 + 25) = 1 / 26 ≈ 0.038461538</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/3a777f87cb72ab3e.svg\" alt=\"\\sum F=0.038461538+0.1+0.5+0.038461538\\approx0.676923077\" style=\"width:61.276ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>0.038461538 ÷ 0.676923077 ≈ 0.056818182</td><td>0 + 0.056818182 ≈ 0.056818182</td></tr><tr><td>2</td><td>0.1 ÷ 0.676923077 ≈ 0.147727273</td><td>0.056818182 + 0.147727273 ≈ 0.204545455</td></tr><tr><td>3</td><td>0.5 ÷ 0.676923077 ≈ 0.738636364</td><td>0.204545455 + 0.738636364 ≈ 0.943181818</td></tr><tr><td>4</td><td>0.038461538 ÷ 0.676923077 ≈ 0.056818182</td><td>0.943181818 + 0.056818182 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Generation 1: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.1</td><td>0.056818182 ≤ 0.1 < 0.204545455</td><td>2</td><td>4</td></tr><tr><td>0.4</td><td>0.204545455 ≤ 0.4 < 0.943181818</td><td>3</td><td>8</td></tr><tr><td>0.65</td><td>0.204545455 ≤ 0.65 < 0.943181818</td><td>3</td><td>8</td></tr><tr><td>0.9</td><td>0.204545455 ≤ 0.9 < 0.943181818</td><td>3</td><td>8</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 4. Generation 1: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>01 | 00</td><td>10 | 00</td><td>0100</td><td>1000</td></tr><tr><td>3 & 4</td><td>10 | 00</td><td>10 | 00</td><td>1000</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Generation 1: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>0100</td><td>No mutation</td><td>0100</td></tr><tr><td>2</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr><tr><td>3</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>4</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Generation 1: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>0100</td><td>0 + 4 + 0 + 0 = 4</td><td>(4−7)² = 9</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>(8−7)² = 1</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 7. Generation 1: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/a688edfd604798b3.svg\" alt=\"\\overline f_{old}=\\frac{25+9+1+25}{4}=\\frac{60}{4}=15\" style=\"width:34.168ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f966da034fd08628.svg\" alt=\"\\overline f_{new}=\\frac{9+4+1+4}{4}=\\frac{18}{4}=4.5\" style=\"width:33.301ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 8. Generation 2: evaluate and encode the current population</h5><table><thead><tr><th>Individual</th><th>x</th><th>Binary</th><th>Objective calculation</th></tr></thead><tbody><tr><td>1</td><td>4</td><td>0100</td><td>(4 − 7)² = 9</td></tr><tr><td>2</td><td>9</td><td>1001</td><td>(9 − 7)² = 4</td></tr><tr><td>3</td><td>8</td><td>1000</td><td>(8 − 7)² = 1</td></tr><tr><td>4</td><td>9</td><td>1001</td><td>(9 − 7)² = 4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Generation 2: calculate roulette intervals</h5><p>Fitness weights are nonnegative. For this minimisation example use F=1/(1+objective), so a smaller cost receives a larger weight.</p><table><thead><tr><th>Individual</th><th>Cost</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>1</td><td>9</td><td>1 / (1 + 9) = 1 / 10 ≈ 0.1</td></tr><tr><td>2</td><td>4</td><td>1 / (1 + 4) = 1 / 5 ≈ 0.2</td></tr><tr><td>3</td><td>1</td><td>1 / (1 + 1) = 1 / 2 ≈ 0.5</td></tr><tr><td>4</td><td>4</td><td>1 / (1 + 4) = 1 / 5 ≈ 0.2</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/8709c94ae272ba4a.svg\" alt=\"\\sum F=0.1+0.2+0.5+0.2\\approx1\" style=\"width:32.367ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Individual</th><th>Probability: weight ÷ total</th><th>Cumulative: old boundary + probability</th></tr></thead><tbody><tr><td>1</td><td>0.1 ÷ 1 ≈ 0.1</td><td>0 + 0.1 ≈ 0.1</td></tr><tr><td>2</td><td>0.2 ÷ 1 ≈ 0.2</td><td>0.1 + 0.2 ≈ 0.3</td></tr><tr><td>3</td><td>0.5 ÷ 1 ≈ 0.5</td><td>0.3 + 0.5 ≈ 0.8</td></tr><tr><td>4</td><td>0.2 ÷ 1 ≈ 0.2</td><td>0.8 + 0.2 ≈ 1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Generation 2: use the supplied random draws</h5><table><thead><tr><th>Random draw</th><th>Interval containing it</th><th>Selected individual</th><th>Selected x</th></tr></thead><tbody><tr><td>0.2</td><td>0.1 ≤ 0.2 < 0.3</td><td>2</td><td>9</td></tr><tr><td>0.4</td><td>0.3 ≤ 0.4 < 0.8</td><td>3</td><td>8</td></tr><tr><td>0.6</td><td>0.3 ≤ 0.6 < 0.8</td><td>3</td><td>8</td></tr><tr><td>0.95</td><td>0.8 ≤ 0.95 < 1</td><td>4</td><td>9</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 11. Generation 2: crossover after bit 2</h5><p>Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.</p><table><thead><tr><th>Pool slots paired</th><th>Parent A</th><th>Parent B</th><th>Child A</th><th>Child B</th></tr></thead><tbody><tr><td>1 & 2</td><td>10 | 01</td><td>10 | 00</td><td>1000</td><td>1001</td></tr><tr><td>3 & 4</td><td>10 | 00</td><td>10 | 01</td><td>1001</td><td>1000</td></tr></tbody></table></div><div class=\"step\"><h5>Step 12. Generation 2: mutate only the specified bits</h5><table><thead><tr><th>Child</th><th>Before mutation</th><th>Instruction</th><th>After mutation</th></tr></thead><tbody><tr><td>1</td><td>1000</td><td>No mutation</td><td>1000</td></tr><tr><td>2</td><td>1001</td><td>Flip bit 4</td><td>1000</td></tr><tr><td>3</td><td>1001</td><td>No mutation</td><td>1001</td></tr><tr><td>4</td><td>1000</td><td>Flip bit 4</td><td>1001</td></tr></tbody></table></div><div class=\"step\"><h5>Step 13. Generation 2: decode and evaluate every child</h5><table><thead><tr><th>Chromosome</th><th>Decode using place values</th><th>Objective</th></tr></thead><tbody><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>(8−7)² = 1</td></tr><tr><td>1000</td><td>8 + 0 + 0 + 0 = 8</td><td>(8−7)² = 1</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr><tr><td>1001</td><td>8 + 0 + 0 + 1 = 9</td><td>(9−7)² = 4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 14. Generation 2: compare and form the next population</h5><p>Add the objective scores in each population, then divide by its number of individuals.</p><div class=\"math-display\"><img src=\"math/b6ef25b43ff486a0.svg\" alt=\"\\overline f_{old}=\\frac{9+4+1+4}{4}=\\frac{18}{4}=4.5\" style=\"width:32.535ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/818ac9c6d2d2746f.svg\" alt=\"\\overline f_{new}=\\frac{1+1+4+4}{4}=\\frac{10}{4}=2.5\" style=\"width:33.301ex;height:4.613ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After two generations the ordered population is [8, 8, 9, 9]. Best final objective = 1 at x = [8].</div></section>"}]},{"id":"u3-ga","title":"GA for travelling salesman problem","unit":"3","scope":"Unit 3 · Evolutionary intelligence and genetic algorithms · 10-mark GA numerical in both 2025–26 papers","sections":[{"id":"ga-tsp","title":"GA approach to the travelling salesman problem","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Read the route before encoding it</h2><p>A <strong>city</strong> is a location. An <strong>edge</strong> connects two cities and has a travel distance. A <strong>tour</strong> visits each city exactly once and returns to its start. A <strong>permutation</strong> is an ordered arrangement without omissions or repetitions: [A,B,D,C] is valid for four cities; [A,B,B,C] is not.</p><p>A distance matrix uses row=departure city and column=arrival city. Entry d<sub>AB</sub>=5 means the A→B leg costs 5. In a symmetric problem d<sub>BA</sub>=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 d<sub>AB</sub>+d<sub>BD</sub>+d<sub>DC</sub>+d<sub>CA</sub>.</p><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> encode a tour as a permutation of cities, use fitness = 1/(tour length), and use crossover and mutation operators that always produce valid tours.</p>\r\n\r\n<h2>The problem</h2>\r\n<p><strong>Travelling salesman problem (TSP):</strong> 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 <span class=\"math-inline\"><img src=\"math/eab927d7255210e1.svg\" alt=\"(n-1)!/2\" style=\"width:9.906ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (12 for 5 cities, about <span class=\"math-inline\"><img src=\"math/1746ec49ffd70b58.svg\" alt=\"6\\times10^{16}\" style=\"width:7.947ex;height:2.005ex\" loading=\"lazy\" decoding=\"async\"></span> for 20 cities), so exhaustive search quickly becomes impossible.</p>\r\n\r\n<h2>How the GA is adapted</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>GA part</th><th>For TSP</th></tr></thead><tbody>\r\n<tr><td>Encoding</td><td><strong>Permutation</strong>: C A E B D means C → A → E → B → D → back to C.</td></tr>\r\n<tr><td>Fitness</td><td><span class=\"math-inline\"><img src=\"math/7887e5a1e9ffa26d.svg\" alt=\"F=1/L\" style=\"width:8.515ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, where <span class=\"math-inline\"><img src=\"math/9c269c2e6ae2c088.svg\" alt=\"L=\\sum d(c_i,c_{i+1})+d(c_n,c_1)\" style=\"width:27.553ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> includes the return edge. Shorter tour = higher fitness.</td></tr>\r\n<tr><td>Selection</td><td>Roulette wheel on F, or tournament.</td></tr>\r\n<tr><td>Crossover</td><td>Order crossover (OX), partially mapped crossover (PMX) or cycle crossover (CX).</td></tr>\r\n<tr><td>Mutation</td><td>Swap two cities, or invert a segment (inversion), with small probability.</td></tr>\r\n</tbody></table></div>\r\n\r\n<div class=\"trap\"><strong>Why ordinary crossover fails.</strong> 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.</div>\r\n\r\n<h2>Order-preserving crossover: the stated left-to-right variant</h2>\r\n<ol><li>Copy a randomly chosen segment from Parent 1 into the child, in the same positions.</li><li>Fill the remaining positions from left to right with the cities of Parent 2 in their order, skipping cities already copied.</li></ol>\r\n<p>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 = <strong>7 5 1 8 3 6 4 2</strong>. (One GA slide prints 4 2 1 8 3 7 5 6, which uses a different fill order; state your rule in the exam.)</p>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[practice · 10 marks]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Parent lengths/fitness, the crossover child, and the mutated child.</p></div><h4>Formula and why it applies</h4><p>Add all edges including the return to the start. A shorter positive length gives a larger reciprocal fitness. <div class=\"math-display\"><img src=\"math/7283c4b77917085c.svg\" alt=\"L=\\sum_{i=1}^{n-1}d(c_i,c_{i+1})+d(c_n,c_1),\\quad F=1/L\" style=\"width:40.214ex;height:6.712ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Parent lengths (include the return edge)</h5>\r\n<div class=\"math-display\"><img src=\"math/5403cdb93ef730d5.svg\" alt=\"L(ABECD)=2+3+5+8+10=28,\\quad F=1/28=0.0357\" style=\"width:59.99ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/aede143ef375acd9.svg\" alt=\"L(ADBEC)=10+4+3+5+9=31,\\quad F=1/31=0.0323\" style=\"width:59.99ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Order crossover</h5><p>Copy positions 2–3 from P1: _ B E _ _. P2's order without B, E: A, D, C → fill positions 1, 4, 5.</p>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/ga_ox.8fd21cbc51.svg\" width=\"530\" height=\"234\" alt=\"Order crossover keeps a valid tour: copy B E from P1, fill A, D, C in P2&#39;s order\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n<div class=\"math-display\"><img src=\"math/ffc7b04e07bd4328.svg\" alt=\"\\text{Child}=ABEDC,\\quad L=2+3+1+8+9=23,\\quad F=0.0435\" style=\"width:61.25ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. Swap mutation (positions 3 and 4)</h5><div class=\"math-display\"><img src=\"math/421251db4f0614de.svg\" alt=\"ABEDC\\to ABDEC,\\quad L=2+4+1+5+9=21,\\quad F=0.0476\" style=\"width:65.08ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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).</div>\r\n</section>\r\n\r\n<h2>Two more permutation crossovers (textbook, not in your slides)</h2>\r\n<p><strong>PMX</strong> (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.</p>\r\n<p><strong>Cycle crossover (CX)</strong>: 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.</p>\r\n\r\n<h2>Algorithm (from your slides)</h2>\r\n<ol><li>Initialise random tours (permutations).</li><li>Evaluate fitness = 1/L.</li><li>Select parents (roulette or tournament).</li><li>Apply OX to each pair.</li><li>Apply swap mutation with small probability.</li><li>Replace the population.</li><li>Repeat until the stopping condition; return the shortest tour.</li></ol>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> TSP mein chromosome = shehron ka order. Fitness = 1/length. Normal crossover se shehar repeat honge, isliye OX.</div>"}]},{"id":"u3-aco","title":"Unit 3 · Ant colony optimization (ACO)","unit":"3","scope":"Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers","sections":[{"id":"how-ants-work","title":"How pheromone feedback guides ant-colony search","html":"<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>Definition</h2>\r\n<p><strong>Ant colony optimization (ACO)</strong> is a population-based, probabilistic metaheuristic, introduced by <strong>Marco Dorigo in 1992</strong>, that finds good paths through a graph by imitating how ants communicate with <strong>pheromone</strong> trails. It is especially suited to routing problems such as the <strong>travelling salesman problem (TSP)</strong>.</p>\r\n\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_bridge.3fc4d22f6d.svg\" width=\"640\" height=\"270\" alt=\"Why ants find the shorter path\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<h2>How shorter paths can gain an advantage</h2>\r\n<ol>\r\n<li><strong>Random exploration.</strong> At first, ants take all paths roughly equally and drop pheromone as they walk.</li>\r\n<li><strong>Shorter path → faster round trip.</strong> Ants on the short path return sooner, so that path receives pheromone more often per minute.</li>\r\n<li><strong>Evaporation.</strong> Pheromone evaporates. On the long path it has more time to fade between visits.</li>\r\n<li><strong>Positive feedback.</strong> 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.</li>\r\n</ol>\r\n<p>This indirect communication through changes in the environment is called <strong>stigmergy</strong>: no ant tells another where to go; the trail does.</p>\r\n\r\n<h2>From real ants to artificial ants</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Real ants</th><th>Artificial ants in ACO</th></tr></thead><tbody>\r\n<tr><td>Walk from nest to food</td><td>Build a solution by moving from node to node in a graph</td></tr>\r\n<tr><td>Drop pheromone on the path used</td><td>Increase the pheromone value <span class=\"math-inline\"><img src=\"math/bdc505e26b5c671c.svg\" alt=\"\\tau_{ij}\" style=\"width:2.388ex;height:1.641ex\" loading=\"lazy\" decoding=\"async\"></span> on every edge used</td></tr>\r\n<tr><td>Pheromone evaporates</td><td>All <span class=\"math-inline\"><img src=\"math/bdc505e26b5c671c.svg\" alt=\"\\tau_{ij}\" style=\"width:2.388ex;height:1.641ex\" loading=\"lazy\" decoding=\"async\"></span> shrink by the evaporation rate <span class=\"math-inline\"><img src=\"math/210f47ee7d9c0bf6.svg\" alt=\"\\rho\" style=\"width:1.17ex;height:1.489ex\" loading=\"lazy\" decoding=\"async\"></span> each iteration</td></tr>\r\n<tr><td>Prefer stronger scent</td><td>Choose the next node with a probability based on pheromone and distance</td></tr>\r\n<tr><td>Colony reinforces frequently used paths</td><td>The algorithm searches for low-cost tours; it may stagnate on a suboptimal tour</td></tr>\r\n</tbody></table></div>\r\n\r\n<h2>TSP as a graph</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>TSP</th><th>ACO</th></tr></thead><tbody>\r\n<tr><td>City</td><td>Node</td></tr><tr><td>Distance between two cities</td><td>Edge weight <span class=\"math-inline\"><img src=\"math/bb784b3ff229be34.svg\" alt=\"d_{ij}\" style=\"width:2.575ex;height:2.236ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr><tr><td>Round trip visiting every city once</td><td>One ant's path</td></tr><tr><td>Tour length</td><td>Sum of the edges used, <strong>including the edge back to the start</strong></td></tr>\r\n</tbody></table></div>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Chhota raasta = jaldi wapas = zyada pheromone = aur cheentiyan. Lamba raasta = pheromone ud jaata hai.</div>"},{"id":"formulas","title":"ACO formulas: transition probability, city choice and pheromone update","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>P(A→B) and P(A→C).</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/d98041105cc02612.svg\" alt=\"\\eta_{ij}=1/d_{ij}\\qquad P_{ij}=\\tau_{ij}\\eta_{ij}/\\sum_{l\\in allowed}\\tau_{il}\\eta_{il}\" style=\"width:38.956ex;height:4.946ex\" loading=\"lazy\" decoding=\"async\"></div><p>Shorter distance gives a larger reciprocal. Normalise the desirability weights to probabilities.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Take reciprocal distances</h5><div class=\"math-display\"><img src=\"math/d9c5253b54fcf92e.svg\" alt=\"\\eta_{AB}=1/2=0.5\\qquad\\eta_{AC}=1/4=0.25\" style=\"width:37.749ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Multiply by pheromone</h5><div class=\"math-display\"><img src=\"math/7b0589337b7254cb.svg\" alt=\"w_B=1\\times0.5=0.5\\qquad w_C=1\\times0.25=0.25\" style=\"width:44.261ex;height:1.881ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add allowed weights</h5><div class=\"math-display\"><img src=\"math/16a735913edad702.svg\" alt=\"0.5+0.25=0.75\" style=\"width:16.719ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Divide each weight by their total</h5><div class=\"math-display\"><img src=\"math/371fe53440644f73.svg\" alt=\"P_{AB}=0.5/0.75=2/3\" style=\"width:21.527ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b90f87b145809204.svg\" alt=\"P_{AC}=0.25/0.75=1/3\" style=\"width:22.66ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> B has probability 2/3; C has probability 1/3. These are probabilities, not a rule forcing the nearest city every time.</div></section><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>1. Transition probability</h2>\r\n<p>An ant <span class=\"math-inline\"><img src=\"math/1dc6f9b1a0213681.svg\" alt=\"k\" style=\"width:1.179ex;height:1.595ex\" loading=\"lazy\" decoding=\"async\"></span> at city <span class=\"math-inline\"><img src=\"math/3c3a2b02c199adb2.svg\" alt=\"i\" style=\"width:0.781ex;height:1.52ex\" loading=\"lazy\" decoding=\"async\"></span> moves to an unvisited city <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span> with probability</p>\r\n<div class=\"math-display\"><img src=\"math/b2a12d0ebbd2c2db.svg\" alt=\"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}}\" style=\"width:34.526ex;height:9.214ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<ul>\r\n<li><span class=\"math-inline\"><img src=\"math/bdc505e26b5c671c.svg\" alt=\"\\tau_{ij}\" style=\"width:2.388ex;height:1.641ex\" loading=\"lazy\" decoding=\"async\"></span>: pheromone on edge <span class=\"math-inline\"><img src=\"math/3c3a2b02c199adb2.svg\" alt=\"i\" style=\"width:0.781ex;height:1.52ex\" loading=\"lazy\" decoding=\"async\"></span>–<span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span>; <span class=\"math-inline\"><img src=\"math/54ca51b8bfad2b71.svg\" alt=\"\\eta_{ij}\" style=\"width:2.523ex;height:1.666ex\" loading=\"lazy\" decoding=\"async\"></span>: visibility (heuristic), the inverse of distance.</li>\r\n<li><span class=\"math-inline\"><img src=\"math/ca2ff9ceb2ebf0ae.svg\" alt=\"\\alpha\" style=\"width:1.448ex;height:1.025ex\" loading=\"lazy\" decoding=\"async\"></span>: weight of pheromone; <span class=\"math-inline\"><img src=\"math/fc31c14dd22861fd.svg\" alt=\"\\beta\" style=\"width:1.281ex;height:2.034ex\" loading=\"lazy\" decoding=\"async\"></span>: weight of distance. In every class example <span class=\"math-inline\"><img src=\"math/8fe45a81f0de6694.svg\" alt=\"\\alpha=\\beta=1\" style=\"width:9.894ex;height:2.034ex\" loading=\"lazy\" decoding=\"async\"></span>.</li>\r\n<li>“allowed” = cities this ant has not visited yet.</li>\r\n</ul>\r\n<p>With all <span class=\"math-inline\"><img src=\"math/5c811732c72735df.svg\" alt=\"\\tau=1\" style=\"width:5.318ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/8fe45a81f0de6694.svg\" alt=\"\\alpha=\\beta=1\" style=\"width:9.894ex;height:2.034ex\" loading=\"lazy\" decoding=\"async\"></span>, the probabilities are simply proportional to <span class=\"math-inline\"><img src=\"math/cb175dc9c9dea9bf.svg\" alt=\"1/d\" style=\"width:3.439ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n\r\n<h2>2. Choosing the city with a random number (cumulative rule)</h2>\r\n<ol>\r\n<li>List the allowed cities <strong>in alphabetical (city) order</strong>, not sorted by probability.</li>\r\n<li>Write their cumulative probabilities.</li>\r\n<li>Pick the <strong>first</strong> city whose cumulative value is ≥ the random number <span class=\"math-inline\"><img src=\"math/b758343af751f858.svg\" alt=\"r\" style=\"width:1.02ex;height:1.025ex\" loading=\"lazy\" decoding=\"async\"></span>.</li>\r\n<li>When only one city is left, the ant goes there without using a random number, then returns to the start.</li>\r\n</ol>\r\n<div class=\"trap\"><strong>Exam trap.</strong> 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.</div>\r\n\r\n<h2>3. Pheromone update (after all ants finish)</h2>\r\n<div class=\"math-display\"><img src=\"math/7cdb88481f227e3c.svg\" alt=\"\\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&amp;\\text{if ant }k\\text{ used edge }(i,j)\\\\0&amp;\\text{otherwise}\\end{cases}\" style=\"width:70.329ex;height:6.399ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<ul>\r\n<li><span class=\"math-inline\"><img src=\"math/210f47ee7d9c0bf6.svg\" alt=\"\\rho\" style=\"width:1.17ex;height:1.489ex\" loading=\"lazy\" decoding=\"async\"></span>: evaporation rate (fraction lost). Class examples use <span class=\"math-inline\"><img src=\"math/d7320dc626d3d883.svg\" alt=\"\\rho=0.5\" style=\"width:7.078ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>. <span class=\"math-inline\"><img src=\"math/88c438d7bc523a5f.svg\" alt=\"Q\" style=\"width:1.79ex;height:2.032ex\" loading=\"lazy\" decoding=\"async\"></span>: deposit constant, usually 1.</li>\r\n<li><span class=\"math-inline\"><img src=\"math/836949dff185b3ba.svg\" alt=\"L_k\" style=\"width:2.562ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></span>: length of ant <span class=\"math-inline\"><img src=\"math/1dc6f9b1a0213681.svg\" alt=\"k\" style=\"width:1.179ex;height:1.595ex\" loading=\"lazy\" decoding=\"async\"></span>'s complete tour <strong>including the return edge</strong>. Shorter tours deposit more.</li>\r\n<li>Edges are undirected: update <span class=\"math-inline\"><img src=\"math/bdc505e26b5c671c.svg\" alt=\"\\tau_{ij}\" style=\"width:2.388ex;height:1.641ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/62cdaada6c1142ff.svg\" alt=\"\\tau_{ji}\" style=\"width:2.388ex;height:1.641ex\" loading=\"lazy\" decoding=\"async\"></span> together (the matrix stays symmetric).</li>\r\n<li>The update happens once per iteration, after every ant has finished; within an iteration all ants use the same pheromone values.</li>\r\n</ul>\r\n<div class=\"note\"><strong>When the question gives no ρ or Q</strong> (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.</div>\r\n\r\n<h2>4. Algorithm (Ant System)</h2>\r\n<ol>\r\n<li>Initialise parameters: number of ants, α, β, ρ, Q, initial pheromone <span class=\"math-inline\"><img src=\"math/10a4957527d9bc35.svg\" alt=\"\\tau_0\" style=\"width:1.976ex;height:1.35ex\" loading=\"lazy\" decoding=\"async\"></span>, maximum iterations.</li>\r\n<li>Place each ant on its start city.</li>\r\n<li>Each ant repeatedly chooses the next city with the transition probability until it has visited all cities, then returns to the start.</li>\r\n<li>Compute each tour length <span class=\"math-inline\"><img src=\"math/836949dff185b3ba.svg\" alt=\"L_k\" style=\"width:2.562ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></span> and record the best tour.</li>\r\n<li>Update pheromone: evaporation, then deposit <span class=\"math-inline\"><img src=\"math/0fe8d82420c3adda.svg\" alt=\"Q/L_k\" style=\"width:5.483ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</li>\r\n<li>Repeat steps 2–5 until the iteration limit; output the best tour.</li>\r\n</ol>\r\n\r\n<div class=\"table-wrap\"><table><thead><tr><th>Parameter</th><th>Meaning</th><th>Typical value</th></tr></thead><tbody>\r\n<tr><td>m</td><td>Number of ants</td><td>number of cities (or 20)</td></tr>\r\n<tr><td>α</td><td>Pheromone importance</td><td>1</td></tr>\r\n<tr><td>β</td><td>Distance (visibility) importance</td><td>1 (often 2–5 in practice)</td></tr>\r\n<tr><td>ρ</td><td>Evaporation rate</td><td>0.5 in class numericals (0.05–0.5 in practice)</td></tr>\r\n<tr><td>Q</td><td>Deposit constant</td><td>1 (100 in one slide example)</td></tr>\r\n<tr><td><span class=\"math-inline\"><img src=\"math/10a4957527d9bc35.svg\" alt=\"\\tau_0\" style=\"width:1.976ex;height:1.35ex\" loading=\"lazy\" decoding=\"async\"></span></td><td>Initial pheromone</td><td>1 in exam questions</td></tr>\r\n</tbody></table></div>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> 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).</div>"},{"id":"final-2025","title":"Solved PYQ: ACO for a 4-city TSP (Final 2025, 10 marks)","html":"<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Final Nov 2025 Q7b]</span></p>\r\n<div class=\"given\"><h4>Given</h4>\r\n<div class=\"math-display\"><img src=\"math/ff22cd24b937efcc.svg\" alt=\"D=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;4&amp;2&amp;4\\\\B&amp;4&amp;0&amp;3&amp;6\\\\C&amp;2&amp;3&amp;0&amp;2\\\\D&amp;4&amp;6&amp;2&amp;0\\end{array}\\qquad \\tau=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;1&amp;1&amp;1\\\\B&amp;1&amp;0&amp;1&amp;1\\\\C&amp;1&amp;1&amp;0&amp;1\\\\D&amp;1&amp;1&amp;1&amp;0\\end{array}\" style=\"width:48.522ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Assume <span class=\"math-inline\"><img src=\"math/8fe45a81f0de6694.svg\" alt=\"\\alpha=\\beta=1\" style=\"width:9.894ex;height:2.034ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/d7320dc626d3d883.svg\" alt=\"\\rho=0.5\" style=\"width:7.078ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/bd5a6aec418f8f8f.svg\" alt=\"Q=1\" style=\"width:5.938ex;height:2.032ex\" loading=\"lazy\" decoding=\"async\"></span> (class convention; not stated in the question).</p>\r\n<h4>To find</h4><p>Tour of each ant, tour lengths, updated pheromone matrix.</p></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_final_graph.ac3cd4aeac.svg\" width=\"520\" height=\"380\" alt=\"Final 2025 Q7b: distances (all pheromones start at 1)\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n<h4>Formula and why it applies</h4>\r\n<div class=\"math-display\"><img src=\"math/4a0efb39e84f4c4e.svg\" alt=\"P_{ij}=\\frac{\\tau_{ij}\\,\\eta_{ij}}{\\sum_{l\\in\\text{allowed}}\\tau_{il}\\,\\eta_{il}},\\qquad\\eta_{ij}=\\frac1{d_{ij}}\" style=\"width:36.172ex;height:5.352ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/b8a3f5425a6d79b2.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}+\\sum_{k:\\,ij\\in\\mathrm{tour}_k}\\frac{Q}{L_k}\" style=\"width:30.857ex;height:6.181ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The sum includes <strong>only ants whose completed tour contains edge ij</strong>. 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.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Probabilities from A (both ants start at A)</h5>\r\n<div class=\"math-display\"><img src=\"math/b5d4297d164fecda.svg\" alt=\"\\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\" style=\"width:89.871ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Move</th><th>P</th><th>Cumulative</th><th>Range</th></tr></thead><tbody><tr><td>A→B</td><td>0.25</td><td>0.25</td><td>0–0.25</td></tr><tr><td>A→C</td><td>0.50</td><td>0.75</td><td>0.25–0.75</td></tr><tr><td>A→D</td><td>0.25</td><td>1.00</td><td>0.75–1</td></tr></tbody></table></div>\r\n<p>Ant 1: r = 0.3 → <strong>C</strong>. Ant 2: r = 0.5 → <strong>C</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 2. Probabilities from C (B and D left)</h5>\r\n<div class=\"math-display\"><img src=\"math/52a7763a8065747e.svg\" alt=\"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\" style=\"width:83.999ex;height:2.773ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative in city order: B 0–0.4, D 0.4–1. Ant 1: r = 0.8 → <strong>D</strong>. Ant 2: r = 0.7 → <strong>D</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 3. Complete the tours</h5><p>Only B is left, then return to A.</p>\r\n<div class=\"math-display\"><img src=\"math/d48c911f3133b5dc.svg\" alt=\"\\text{Ant 1}=\\text{Ant 2}:\\;A\\to C\\to D\\to B\\to A,\\qquad L=2+2+6+4=14\" style=\"width:67.567ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_final_tour.1dbfdb8b98.svg\" width=\"520\" height=\"380\" alt=\"Both ants: A → C → D → B → A, length 14\" loading=\"lazy\" decoding=\"async\"></div></figure></div>\r\n<div class=\"step\"><h5>Step 4. Pheromone update</h5>\r\n<p>Each ant deposits <span class=\"math-inline\"><img src=\"math/799732b628eacf45.svg\" alt=\"Q/L=1/14=0.0714\" style=\"width:21.306ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> on each edge of its tour; two ants used the same four edges (AC, CD, DB, BA), so each gets <span class=\"math-inline\"><img src=\"math/2b49c5f9ee4dd7a9.svg\" alt=\"2/14=0.1429\" style=\"width:13.827ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/beecdfda1143f6eb.svg\" alt=\"\\text{used edge: }(1-0.5)(1)+0.1429=0.6429\\qquad\\text{unused edge (AD, BC): }(1-0.5)(1)+0=0.5\" style=\"width:89.4ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/25cf4d02bee20e2a.svg\" alt=\"\\tau_{\\text{new}}=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;0.6429&amp;0.6429&amp;0.5\\\\B&amp;0.6429&amp;0&amp;0.5&amp;0.6429\\\\C&amp;0.6429&amp;0.5&amp;0&amp;0.6429\\\\D&amp;0.5&amp;0.6429&amp;0.6429&amp;0\\end{array}\" style=\"width:42.542ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> 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.”</div>\r\n<p class=\"marks-split\">Official marking: path of Ant 1 (3) + path of Ant 2 (3) + pheromone matrix (4).</p>\r\n</section>"},{"id":"reexam-2026","title":"Solved PYQ: ACO for a 4-city TSP (Re-exam 2026, 10 marks)","html":"<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks · Re-exam Jan 2026 Q6a]</span></p>\r\n<div class=\"given\"><h4>Given</h4>\r\n<div class=\"math-display\"><img src=\"math/21fbc23ee8a38afa.svg\" alt=\"D=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;1&amp;2&amp;3\\\\B&amp;1&amp;0&amp;4&amp;5\\\\C&amp;2&amp;4&amp;0&amp;6\\\\D&amp;3&amp;5&amp;6&amp;0\\end{array},\\qquad\\tau_{ij}=1\\;(i\\ne j)\" style=\"width:41.536ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Assume <span class=\"math-inline\"><img src=\"math/215be7d8bc049557.svg\" alt=\"\\alpha=\\beta=1,\\;\\rho=0.5,\\;Q=1\" style=\"width:26.18ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p>Both tours, their lengths and the pheromone matrix after one iteration.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/5b888e9e5a3c73eb.svg\" alt=\"P_{ij}=\\frac{\\tau_{ij}^{\\alpha}(1/d_{ij})^\\beta}{\\sum_{k\\in allowed}\\tau_{ik}^{\\alpha}(1/d_{ik})^\\beta}\" style=\"width:27.444ex;height:6.404ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d5297204b4481c8e.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}+\\sum_{k:\\,ij\\in tour_k}\\frac{Q}{L_k}\" style=\"width:30.908ex;height:6.181ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. From A</h5>\r\n<div class=\"math-display\"><img src=\"math/d7a22769c0bad254.svg\" alt=\"\\eta:\\;B=1,\\;C=0.5,\\;D=0.3333;\\;\\text{sum}=1.8333\\Rightarrow P=0.5455,\\;0.2727,\\;0.1818\" style=\"width:76.91ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative: B 0–0.5455, C 0.5455–0.8182, D 0.8182–1. Ant 1 (0.3) → <strong>B</strong>; Ant 2 (0.5) → <strong>B</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 2. From B (C and D left)</h5>\r\n<div class=\"math-display\"><img src=\"math/9d1964928f02cbff.svg\" alt=\"\\eta:\\;C=0.25,\\;D=0.2;\\;\\text{sum}=0.45\\Rightarrow P_{BC}=0.5556,\\;P_{BD}=0.4444\" style=\"width:66.532ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative: C 0–0.5556, D 0.5556–1. Ant 1 (0.8) → <strong>D</strong>; Ant 2 (0.7) → <strong>D</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 3. Complete the tours</h5>\r\n<div class=\"math-display\"><img src=\"math/1409076465c0fee4.svg\" alt=\"A\\to B\\to D\\to C\\to A,\\qquad L=1+5+6+2=14\\;\\text{(both ants)}\" style=\"width:62.614ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_reexam_graph.02195c6ee9.svg\" width=\"520\" height=\"380\" alt=\"Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14\" loading=\"lazy\" decoding=\"async\"></div></figure></div>\r\n<div class=\"step\"><h5>Step 4. Pheromone update</h5>\r\n<p>Used edges AB, BD, DC, CA get <span class=\"math-inline\"><img src=\"math/a677db1cbc02a07c.svg\" alt=\"0.5(1)+2\\times\\frac1{14}=0.6429\" style=\"width:24.343ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></span>; unused edges AD and BC become <span class=\"math-inline\"><img src=\"math/97dede1883211cd7.svg\" alt=\"0.5\" style=\"width:2.891ex;height:1.557ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/25cf4d02bee20e2a.svg\" alt=\"\\tau_{\\text{new}}=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;0.6429&amp;0.6429&amp;0.5\\\\B&amp;0.6429&amp;0&amp;0.5&amp;0.6429\\\\C&amp;0.6429&amp;0.5&amp;0&amp;0.6429\\\\D&amp;0.5&amp;0.6429&amp;0.6429&amp;0\\end{array}\" style=\"width:42.542ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> Both ants: A → B → D → C → A, length 14. Pheromone 0.6429 on AB, BD, CD, AC; 0.5 on AD, BC.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> This key applies <em>no evaporation</em> (<span class=\"math-inline\"><img src=\"math/7856892795a9fcf9.svg\" alt=\"1+0.1428=1.1428\" style=\"width:19.484ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></span>) 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.</div>\r\n</section>"},{"id":"lecture-example","title":"Practice: the lecture's Ant System example (two different tours)","html":"<p class=\"cue\"><strong>Why do this:</strong> 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.</p>\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. Distances: AB = 5, AC = 6, AD = 7, BC = 2, BD = 9, CD = 3; all pheromones 1; <span class=\"math-inline\"><img src=\"math/215be7d8bc049557.svg\" alt=\"\\alpha=\\beta=1,\\;\\rho=0.5,\\;Q=1\" style=\"width:26.18ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>. 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.</strong> <span class=\"marks\">[lecture example · 10 marks]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>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].</p><h4>To find</h4><p>Two complete tours and every updated edge pheromone.</p></div><h4>Formula and why it applies</h4><p>Prefer high pheromone and small distance, normalise over unvisited cities, then evaporate and deposit once per iteration. <div class=\"math-display\"><img src=\"math/c9ac4c197173e498.svg\" alt=\"P_{ij}=\\frac{\\tau_{ij}^{\\alpha}(1/d_{ij})^{\\beta}}{\\sum_{k\\in allowed}\\tau_{ik}^{\\alpha}(1/d_{ik})^{\\beta}}\" style=\"width:27.444ex;height:6.404ex\" loading=\"lazy\" decoding=\"async\"></div> <div class=\"math-display\"><img src=\"math/97bee3443d137b73.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}^{old}+\\sum_{ants\\ using\\ ij}Q/L\" style=\"width:34.428ex;height:5.157ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_lecture_graph.629672bf56.svg\" width=\"520\" height=\"380\" alt=\"Lecture example (Ant System): distances\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. From A</h5>\r\n<div class=\"math-display\"><img src=\"math/e47560808b5cfa0e.svg\" alt=\"\\eta=\\tfrac15,\\tfrac16,\\tfrac17=0.2,\\;0.1667,\\;0.1429;\\;\\text{sum}=0.5095\\Rightarrow P=0.3925,\\;0.3271,\\;0.2804\" style=\"width:78.62ex;height:2.773ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative: B 0–0.3925, C 0.3925–0.7196, D 0.7196–1. Ant 1 (0.45) → C. Ant 2 (0.83) → D.</p></div>\r\n<div class=\"step\"><h5>Step 2. Ant 1 from C (B, D left)</h5>\r\n<div class=\"math-display\"><img src=\"math/1b6803f7bb0eede8.svg\" alt=\"\\eta=\\tfrac12,\\tfrac13\\Rightarrow P_{CB}=0.6,\\;P_{CD}=0.4\" style=\"width:33.961ex;height:2.773ex\" loading=\"lazy\" decoding=\"async\"></div><p>r = 0.5 ≤ 0.6 → B; then D; then back to A.</p>\r\n<div class=\"math-display\"><img src=\"math/f2d71691d61a5d31.svg\" alt=\"\\text{Ant 1: }A\\to C\\to B\\to D\\to A,\\quad L_1=6+2+9+7=24\" style=\"width:56.423ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. Ant 2 from D (B, C left)</h5>\r\n<div class=\"math-display\"><img src=\"math/b66f5122ccaaac24.svg\" alt=\"\\eta=\\tfrac19,\\tfrac13\\Rightarrow P_{DB}=0.25,\\;P_{DC}=0.75\" style=\"width:36.332ex;height:2.773ex\" loading=\"lazy\" decoding=\"async\"></div><p>Cumulative B 0–0.25, C 0.25–1; r = 0.5 → C; then B; then A.</p>\r\n<div class=\"math-display\"><img src=\"math/161908e94cfc42c7.svg\" alt=\"\\text{Ant 2: }A\\to D\\to C\\to B\\to A,\\quad L_2=7+3+2+5=17\" style=\"width:56.423ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Deposits</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Edge</th><th>Used by</th><th>New τ</th></tr></thead><tbody>\r\n<tr><td>AD, BC</td><td>both ants</td><td>0.5 + 1/24 + 1/17 = 0.6005</td></tr>\r\n<tr><td>AC, BD</td><td>Ant 1 only</td><td>0.5 + 1/24 = 0.5417</td></tr>\r\n<tr><td>AB, CD</td><td>Ant 2 only</td><td>0.5 + 1/17 = 0.5588</td></tr>\r\n</tbody></table></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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 &gt; 1/24), so its edges grow faster. AD and BC, used by both, end highest at 0.6005.</div>\r\n<div class=\"keyfix\"><strong>Slide corrections.</strong> 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.</div>\r\n</section>\r\n\r\n<!-- depth:full-matrix:start -->\r\n<div class=\"concept-bridge\"><h2>Write the requested final matrix</h2><p>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.</p><div class=\"math-display\"><img src=\"math/9cb40cf52889b49c.svg\" alt=\"\\tau^{new}\\approx\\begin{bmatrix}0&amp;.558823529&amp;.541666667&amp;.600490196\\\\.558823529&amp;0&amp;.600490196&amp;.541666667\\\\.541666667&amp;.600490196&amp;0&amp;.558823529\\\\.600490196&amp;.541666667&amp;.558823529&amp;0\\end{bmatrix}\" style=\"width:60.393ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div>\r\n<!-- depth:full-matrix:end -->"},{"id":"applications","title":"5/10-mark answer: applications of ACO (explain one)","html":"<p class=\"cue\"><strong>Asked as:</strong> “List the applications of Ant Colony Optimization and explain any one application in detail.” <span class=\"marks\">[5 marks · Final 2025 Q1b; key: listing 3 + explanation 2]</span></p>\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Travelling salesman problem</strong>: shortest tour visiting every city once.</li>\r\n<li><strong>Vehicle routing</strong>: delivery routes for a fleet with capacity and time windows (minimising distance, time, fuel).</li>\r\n<li><strong>Network routing</strong>: adaptive routing of data packets in communication and sensor networks (AntNet).</li>\r\n<li><strong>Job-shop and project scheduling</strong>: assigning jobs to machines to minimise completion time.</li>\r\n<li><strong>Image processing</strong>: edge detection, with ants moving over pixel-intensity graphs.</li>\r\n<li><strong>Assignment problems</strong>: quadratic assignment, timetabling, graph colouring.</li>\r\n<li><strong>Feature selection and data mining</strong>: Ant-Miner for classification rules.</li>\r\n<li><strong>Load balancing</strong> in distributed systems and cloud task allocation.</li>\r\n</ol>\r\n<h3>One application in detail: vehicle routing (or TSP)</h3>\r\n<ol>\r\n<li><strong>Graph.</strong> Depot and customers are nodes; travel times or distances are edge weights.</li>\r\n<li><strong>Ants.</strong> Each ant builds a complete set of routes. From its current customer it chooses the next with probability <span class=\"math-inline\"><img src=\"math/7d200da3be6a78d4.svg\" alt=\"\\propto\\tau_{ij}\\,(1/d_{ij})\" style=\"width:11.752ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>, skipping customers already served or that would exceed the vehicle capacity; when the vehicle is full it returns to the depot.</li>\r\n<li><strong>Evaluation.</strong> Total distance (plus penalties for late deliveries).</li>\r\n<li><strong>Learning.</strong> Pheromone evaporates everywhere and is added in proportion to <span class=\"math-inline\"><img src=\"math/afe42919eb73e68a.svg\" alt=\"Q/L\" style=\"width:4.462ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> on the routes of good solutions, so short connections are reinforced.</li>\r\n<li><strong>Result.</strong> 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.</li>\r\n</ol>\r\n<h3>Advantages and limitations</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody>\r\n<tr><td>Naturally suited to graph and routing problems</td><td>Several parameters to tune (α, β, ρ, number of ants)</td></tr>\r\n<tr><td>Can share useful route information and adapt search to changing graphs</td><td>Convergence time is uncertain; may stagnate on a sub-optimal path</td></tr>\r\n<tr><td>Positive feedback + parallel ants</td><td>Theoretical analysis is difficult</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> ACO = “raaste wale problems” (TSP, routing, scheduling). PSO = “numbers wale problems” (continuous function, weights).</div>"}]},{"id":"pso-core","title":"4. Particle swarm optimization","unit":"Unit 3 · PSO","scope":"First understand position, velocity and memory; then solve complete two-iteration minimisation examples.","sections":[{"id":"meaning","title":"Swarm intelligence, particles, velocity, pbest and gbest","html":"<h2>Swarm intelligence</h2><p><strong>Swarm intelligence</strong> 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.</p>\r\n<p><strong>Particle swarm optimization (PSO)</strong> 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.</p>\r\n<h2>Translate every PSO word into a concrete object</h2><table><thead><tr><th>Term</th><th>Meaning</th><th>Example</th></tr></thead><tbody><tr><td>Particle</td><td>One candidate solution</td><td>Particle A</td></tr><tr><td>Position x</td><td>The candidate’s coordinates</td><td>xA = 3</td></tr><tr><td>Objective f(x)</td><td>The problem’s score for that candidate</td><td>f(3) = 3² = 9</td></tr><tr><td>Velocity v</td><td>Proposed change of position</td><td>vA = −1 means move left by 1</td></tr><tr><td>pbest</td><td>Best position that this particle has visited</td><td>A once visited x=1 with score 1</td></tr><tr><td>gbest</td><td>Best position found by any particle</td><td>Among all personal bests, x=0.5 scores 0.25</td></tr></tbody></table>\r\n<!-- depth:retained-diagram:start -->\r\n<div class=\"concept-bridge\"><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_pso_memory.fcc9783a95.svg\" width=\"700\" height=\"335\" alt=\"A best memory changes only when the new score improves.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>A best memory changes only when the new score improves.</figcaption></figure></div>\r\n<!-- depth:retained-diagram:end -->\r\n<h2>Current position is not necessarily personal best</h2><p>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.</p><section class=\"example\"><p class=\"question\"><strong>A particle visits x=3, x=1, x=2 in that order while minimising f(x)=x². Find pbest after each visit.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>Positions in chronological order: 3 → 1 → 2.</p><h4>To find</h4><p>The best-so-far position and score.</p></div><h4>Formula and why it applies</h4><p>Keep the location with the lowest objective encountered so far.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First visit</h5><div class=\"math-display\"><img src=\"math/7f1b6387a96fa5e5.svg\" alt=\"f(3)=9\" style=\"width:8.284ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>No history: pbest=3, best score=9.</p></div><div class=\"step\"><h5>Step 2. Second visit</h5><div class=\"math-display\"><img src=\"math/c0e5424c98d7c06b.svg\" alt=\"f(1)=1&lt;9\" style=\"width:12.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Replace pbest by 1.</p></div><div class=\"step\"><h5>Step 3. Third visit</h5><div class=\"math-display\"><img src=\"math/e8b8ef3456701e2b.svg\" alt=\"f(2)=4&gt;1\" style=\"width:12.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Keep pbest=1 even though the current position is 2.</p></div><div class=\"answer\"><strong>Final answer.</strong> Final current position=2; pbest=1; personal-best score=1.</div></section><section class=\"example\"><p class=\"question\"><strong>Define swarm intelligence and briefly explain one nature-inspired algorithm.</strong> <span class=\"marks\">[2 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><p class=\"memory\"><strong>Yaad rakho:</strong> Position abhi kahan ho; pbest apna best past; gbest sabka best past.</p>"},{"id":"equation","title":"Read the PSO equation and work three individual updates","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>First read the update in words</h2><p><strong>New velocity = retained old velocity + pull toward personal best + pull toward the group best.</strong> After finding that velocity, add it to the old position. You are calculating a movement, then applying it.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/depth_pso.88e9c2a672.svg\" width=\"720\" height=\"230\" alt=\"A negative difference pulls toward a best position on the left.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>A negative difference pulls toward a best position on the left.</figcaption></figure><p>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.</p><p>In v<sub>i,j</sub><sup>t</sup>, 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<h2>The velocity equation is three contributions added together</h2><div class=\"math-display\"><img src=\"math/dac83013fb52dd1c.svg\" alt=\"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})\" style=\"width:53.007ex;height:2.988ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/60fe3c0d98c51b4c.svg\" alt=\"x_{i,j}^{t+1}=x_{i,j}^{t}+v_{i,j}^{t+1}\" style=\"width:16.932ex;height:2.988ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>i</td><td>Which particle</td></tr><tr><td>j</td><td>Which coordinate of that particle</td></tr><tr><td>t / t+1</td><td>Before / after this iteration; these are labels, not powers</td></tr><tr><td>w</td><td>Inertia weight: how much old velocity is kept</td></tr><tr><td>c₁r₁</td><td>Combined strength of the pull to personal best</td></tr><tr><td>c₂r₂</td><td>Combined strength of the pull to global best</td></tr><tr><td>r₁,r₂</td><td>Random factors, normally in [0,1]; use the values supplied in an exam</td></tr></tbody></table><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=4, v=0, pbest=4, gbest=2; w=.5; c₁r₁=.5; c₂r₂=.5.</p><h4>To find</h4><p>New velocity followed by new position.</p></div><h4>Formula and why it applies</h4><p>Use the three-term velocity equation, then add the new velocity to x.</p><div class=\"math-display\"><img src=\"math/a86502ce620dafcc.svg\" alt=\"v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)\" style=\"width:44.119ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inertia</h5><div class=\"math-display\"><img src=\"math/e71e2d0a61e9d301.svg\" alt=\"0.5\\times0=0\" style=\"width:10.937ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Personal pull</h5><div class=\"math-display\"><img src=\"math/a6908257a641f5f9.svg\" alt=\"0.5(4-(4))=0\" style=\"width:15.588ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Social pull</h5><div class=\"math-display\"><img src=\"math/572c7c6589c1b745.svg\" alt=\"0.5(2-(4))=-1\" style=\"width:17.348ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. New velocity</h5><div class=\"math-display\"><img src=\"math/96abcf8e044d8408.svg\" alt=\"v_{new}=0+0+(-1)=-1\" style=\"width:25.507ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. New position</h5><div class=\"math-display\"><img src=\"math/7ce7c2323916220b.svg\" alt=\"x_{new}=4+(-1)=3\" style=\"width:20.047ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> vnew=-1; xnew=3.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=4, v=-2, pbest=3, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.</p><h4>To find</h4><p>New velocity followed by new position.</p></div><h4>Formula and why it applies</h4><p>Use the three-term velocity equation, then add the new velocity to x.</p><div class=\"math-display\"><img src=\"math/a86502ce620dafcc.svg\" alt=\"v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)\" style=\"width:44.119ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inertia</h5><div class=\"math-display\"><img src=\"math/493f21e1dcf9ae65.svg\" alt=\"0.5\\times(-2)=-1\" style=\"width:16.217ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Personal pull</h5><div class=\"math-display\"><img src=\"math/4914c1155f2d3a69.svg\" alt=\"0.5(3-(4))=-0.5\" style=\"width:19.109ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Social pull</h5><div class=\"math-display\"><img src=\"math/b774cba7be997b80.svg\" alt=\"0.5(1-(4))=-1.5\" style=\"width:19.109ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. New velocity</h5><div class=\"math-display\"><img src=\"math/fb1a87666bd393ac.svg\" alt=\"v_{new}=(-1)+(-0.5)+(-1.5)=-3\" style=\"width:36.068ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. New position</h5><div class=\"math-display\"><img src=\"math/87db5516b0eef4a5.svg\" alt=\"x_{new}=4+(-3)=1\" style=\"width:20.047ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> vnew=-3; xnew=1.</div></section><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><div class=\"given\"><h4>Given</h4><p>x=-2, v=1, pbest=-1, gbest=1; w=.5; c₁r₁=.5; c₂r₂=.5.</p><h4>To find</h4><p>New velocity followed by new position.</p></div><h4>Formula and why it applies</h4><p>Use the three-term velocity equation, then add the new velocity to x.</p><div class=\"math-display\"><img src=\"math/a86502ce620dafcc.svg\" alt=\"v_{new}=0.5v+0.5(pbest-x)+0.5(gbest-x)\" style=\"width:44.119ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Inertia</h5><div class=\"math-display\"><img src=\"math/12ea92d29476784c.svg\" alt=\"0.5\\times1=0.5\" style=\"width:12.697ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Personal pull</h5><div class=\"math-display\"><img src=\"math/61d7bcc89fa9fd8a.svg\" alt=\"0.5(-1-(-2))=0.5\" style=\"width:20.869ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Social pull</h5><div class=\"math-display\"><img src=\"math/85cc697d8abbcf2c.svg\" alt=\"0.5(1-(-2))=1.5\" style=\"width:19.109ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. New velocity</h5><div class=\"math-display\"><img src=\"math/bc8dd34ee10c4d4d.svg\" alt=\"v_{new}=0.5+0.5+1.5=2.5\" style=\"width:27.267ex;height:1.864ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. New position</h5><div class=\"math-display\"><img src=\"math/264c82a55bf4620a.svg\" alt=\"x_{new}=(-2)+2.5=0.5\" style=\"width:23.567ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> vnew=2.5; xnew=0.5.</div></section><p><strong>First-iteration shortcut:</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Old speed ka hissa + apne best ki pull + group best ki pull; phir new speed ko position mein add.</p>"},{"id":"two-particles","title":"Two particles, two iterations: start with the simplest minimisation","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(-2)</td><td>(0)</td></tr><tr><td>B</td><td>(4)</td><td>(0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/73d4f3be5484ad52.svg\" alt=\"f(-2)=(-2)^2=4=4\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/312433d364d9cfab.svg\" alt=\"f(4)=4^2=16=16\" style=\"width:19.831ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/130e21267aeccc61.svg\" alt=\"gbest^0=(-2)\" style=\"width:13.638ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 4. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (-2). pbest values are A: (-2), B: (4).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/1d782a69e1d0fcb8.svg\" alt=\"d_p=-2-(-2)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6f82367c11e33631.svg\" alt=\"d_g=-2-(-2)=0\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/4e58cfc2f623e47e.svg\" alt=\"x^{(1)}=(-2)+0=-2\" style=\"width:21.001ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/ad073051db57b851.svg\" alt=\"d_p=4-(4)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/eb7d3c2c066600f2.svg\" alt=\"d_g=-2-(4)=-6\" style=\"width:19.601ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4dd7f304ffa4f233.svg\" alt=\"S=0.5\\times(-6)=-3\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/c239eeeeeca7f890.svg\" alt=\"v^{(1)}=0+0+(-3)=-3\" style=\"width:24.701ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/d71458dcf56b7a77.svg\" alt=\"x^{(1)}=4+(-3)=1\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/73d4f3be5484ad52.svg\" alt=\"f(-2)=(-2)^2=4=4\" style=\"width:22.849ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/872b6624767f4385.svg\" alt=\"f(1)=1^2=1=1\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>4</td><td>4</td><td>Keep old: tie</td><td>(-2)</td></tr><tr><td>B</td><td>16</td><td>1</td><td>Replace: new score is lower</td><td>(1)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1)</strong>, with objective <strong>1</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(-2)</td><td>(0)</td><td>(-2)</td></tr><tr><td>B</td><td>(1)</td><td>(-3)</td><td>(1)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (-2), B: (1).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/1d782a69e1d0fcb8.svg\" alt=\"d_p=-2-(-2)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/9102a4aae4f9ab55.svg\" alt=\"d_g=1-(-2)=3\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9efd684a8627ac87.svg\" alt=\"S=0.5\\times(3)=1.5\" style=\"width:18.933ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/25e29c2b2380aded.svg\" alt=\"v^{(2)}=0+0+1.5=1.5\" style=\"width:22.94ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/0af67fb865c5f5c7.svg\" alt=\"x^{(2)}=(-2)+1.5=-0.5\" style=\"width:24.521ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/02f316319733ea90.svg\" alt=\"I=0.5\\times(-3)=-1.5\" style=\"width:22.135ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/4e2008e440fe556c.svg\" alt=\"v^{(2)}=(-1.5)+0+0=-1.5\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/700c5bb73aa33b26.svg\" alt=\"x^{(2)}=1+(-1.5)=-0.5\" style=\"width:24.521ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/6c453bb065df6e4a.svg\" alt=\"f(-0.5)=(-0.5)^2=0.25=0.25\" style=\"width:32.152ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/6c453bb065df6e4a.svg\" alt=\"f(-0.5)=(-0.5)^2=0.25=0.25\" style=\"width:32.152ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>4</td><td>0.25</td><td>Replace: new score is lower</td><td>(-0.5)</td></tr><tr><td>B</td><td>1</td><td>0.25</td><td>Replace: new score is lower</td><td>(-0.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(-0.5)</strong>, with objective <strong>0.25</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(-0.5)</td><td>(1.5)</td><td>(-0.5)</td></tr><tr><td>B</td><td>(-0.5)</td><td>(-1.5)</td><td>(-0.5)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"memory-matters","title":"A worse move: pbest stays in the past","html":"<p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/e23769019c76d37b.svg\" alt=\"f(x)=x^2\" style=\"width:9.598ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(1)</td><td>(4)</td></tr><tr><td>B</td><td>(3)</td><td>(-1)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/872b6624767f4385.svg\" alt=\"f(1)=1^2=1=1\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/519522f49346438a.svg\" alt=\"f(3)=3^2=9=9\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/d6d8eee6e10c4922.svg\" alt=\"gbest^0=(1)\" style=\"width:11.878ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 1. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (1), B: (3).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/e009c778bab94586.svg\" alt=\"I=0.5\\times4=2\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/25c7782eb44a678a.svg\" alt=\"v^{(1)}=2+0+0=2\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/8e886f0f9174fead.svg\" alt=\"x^{(1)}=1+2=3\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/dc7ed342b0db88bc.svg\" alt=\"I=0.5\\times(-1)=-0.5\" style=\"width:22.135ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/114e8d23bb26d062.svg\" alt=\"d_p=3-(3)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/57f4bea8a1c6b79f.svg\" alt=\"d_g=1-(3)=-2\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/96dd8f64f9d9a341.svg\" alt=\"S=0.5\\times(-2)=-1\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/e15db2dfd9b255cf.svg\" alt=\"v^{(1)}=(-0.5)+0+(-1)=-1.5\" style=\"width:31.741ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/76c197431121b5e1.svg\" alt=\"x^{(1)}=3+(-1.5)=1.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/519522f49346438a.svg\" alt=\"f(3)=3^2=9=9\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/b61e97d213b18164.svg\" alt=\"f(1.5)=1.5^2=2.25=2.25\" style=\"width:26.872ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>9</td><td>Keep old: new score is worse</td><td>(1)</td></tr><tr><td>B</td><td>9</td><td>2.25</td><td>Replace: new score is lower</td><td>(1.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1)</strong>, with objective <strong>1</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(3)</td><td>(2)</td><td>(1)</td></tr><tr><td>B</td><td>(1.5)</td><td>(-1.5)</td><td>(1.5)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1). pbest values are A: (1), B: (1.5).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/4d6486404a7509ba.svg\" alt=\"I=0.5\\times2=1\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e56ef95c25fb8bde.svg\" alt=\"d_p=1-(3)=-2\" style=\"width:17.883ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a08a6d09414479ce.svg\" alt=\"C=0.5\\times(-2)=-1\" style=\"width:20.954ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/57f4bea8a1c6b79f.svg\" alt=\"d_g=1-(3)=-2\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/96dd8f64f9d9a341.svg\" alt=\"S=0.5\\times(-2)=-1\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/a51eec1438d949c1.svg\" alt=\"v^{(2)}=1+(-1)+(-1)=-1\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/60104aa04f06aad8.svg\" alt=\"x^{(2)}=3+(-1)=2\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Only coordinate</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/16e3f0369a50c03f.svg\" alt=\"I=0.5\\times(-1.5)=-0.75\" style=\"width:25.026ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/dcb7c97c6295715d.svg\" alt=\"d_p=1.5-(1.5)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2e6ff91ff778f21f.svg\" alt=\"d_g=1-(1.5)=-0.5\" style=\"width:21.362ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/418a15cd3fa3bbcc.svg\" alt=\"S=0.5\\times(-0.5)=-0.25\" style=\"width:25.345ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/c528696fa4ba4081.svg\" alt=\"v^{(2)}=(-0.75)+0+(-0.25)=-1\" style=\"width:34.004ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/905c77866baf10ae.svg\" alt=\"x^{(2)}=1.5+(-1)=0.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/00c58d851ae8132e.svg\" alt=\"f(2)=2^2=4=4\" style=\"width:17.568ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/4c640081b99e1be6.svg\" alt=\"f(0.5)=0.5^2=0.25=0.25\" style=\"width:26.872ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>1</td><td>4</td><td>Keep old: new score is worse</td><td>(1)</td></tr><tr><td>B</td><td>2.25</td><td>0.25</td><td>Replace: new score is lower</td><td>(0.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(0.5)</strong>, with objective <strong>0.25</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(2)</td><td>(-1)</td><td>(1)</td></tr><tr><td>B</td><td>(0.5)</td><td>(-1)</td><td>(0.5)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p class=\"memory\"><strong>Yaad rakho:</strong> Naya result kharab ho toh position toh badlegi, pbest nahi.</p>"},{"id":"two-coordinates","title":"Two-dimensional PSO: keep the coordinates separate","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/a02144dad2ff9c8a.svg\" alt=\"f(x)=x_1^2+x_2^2\" style=\"width:14.645ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using 2 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[3 marks · Practice; expanded teaching solution]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(1, 1)</td><td>(0, 0)</td></tr><tr><td>B</td><td>(3, 2)</td><td>(0, 0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/952bb71a534d7b48.svg\" alt=\"f(3, 2)=3^2+2^2=9+4=13\" style=\"width:29.618ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/bae2559b2265b2a0.svg\" alt=\"gbest^0=(1, 1)\" style=\"width:14.015ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 2. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (3, 2).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/bc4c5112ff057d33.svg\" alt=\"x^{(1)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/dec9907b2180e0af.svg\" alt=\"v^{(1)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/bc4c5112ff057d33.svg\" alt=\"x^{(1)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/114e8d23bb26d062.svg\" alt=\"d_p=3-(3)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/57f4bea8a1c6b79f.svg\" alt=\"d_g=1-(3)=-2\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/96dd8f64f9d9a341.svg\" alt=\"S=0.5\\times(-2)=-1\" style=\"width:20.694ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/000e26bf52e8a50e.svg\" alt=\"v^{(1)}=0+0+(-1)=-1\" style=\"width:24.701ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/a890dd5de2855674.svg\" alt=\"x^{(1)}=3+(-1)=2\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e7f9deeb68816f5a.svg\" alt=\"d_p=2-(2)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fe1a995f4b4afef.svg\" alt=\"d_g=1-(2)=-1\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38f7adbc6f0de36b.svg\" alt=\"S=0.5\\times(-1)=-0.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/a489ee8326d49a33.svg\" alt=\"v^{(1)}=0+0+(-0.5)=-0.5\" style=\"width:28.221ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/51c2ec0b6a29b186.svg\" alt=\"x^{(1)}=2+(-0.5)=1.5\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/d342f4df799385a1.svg\" alt=\"f(2, 1.5)=2^2+1.5^2=4+2.25=6.25\" style=\"width:37.79ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>2</td><td>2</td><td>Keep old: tie</td><td>(1, 1)</td></tr><tr><td>B</td><td>13</td><td>6.25</td><td>Replace: new score is lower</td><td>(2, 1.5)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1, 1)</strong>, with objective <strong>2</strong>.</p></div><div class=\"step\"><h5>Step 8. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(1, 1)</td><td>(0, 0)</td><td>(1, 1)</td></tr><tr><td>B</td><td>(2, 1.5)</td><td>(-1, -0.5)</td><td>(2, 1.5)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 9. Iteration 2: freeze the previous memories</h5><p>All particles in this iteration use gbest = (1, 1). pbest values are A: (1, 1), B: (2, 1.5).</p></div><div class=\"step\"><h5>Step 10. Iteration 2: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8ba6a1d6c9203afb.svg\" alt=\"v^{(2)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/a7841f9dac4f92c7.svg\" alt=\"x^{(2)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a352ebe71945e68e.svg\" alt=\"d_p=1-(1)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/d4af3bfbae14d68f.svg\" alt=\"d_g=1-(1)=0\" style=\"width:16.081ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d00ab76bdfccf855.svg\" alt=\"S=0.5\\times(0)=0\" style=\"width:17.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8ba6a1d6c9203afb.svg\" alt=\"v^{(2)}=0+0+0=0\" style=\"width:19.42ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/a7841f9dac4f92c7.svg\" alt=\"x^{(2)}=1+0=1\" style=\"width:15.72ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/dc7ed342b0db88bc.svg\" alt=\"I=0.5\\times(-1)=-0.5\" style=\"width:22.135ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/e7f9deeb68816f5a.svg\" alt=\"d_p=2-(2)=0\" style=\"width:16.123ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fe1a995f4b4afef.svg\" alt=\"d_g=1-(2)=-1\" style=\"width:17.841ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38f7adbc6f0de36b.svg\" alt=\"S=0.5\\times(-1)=-0.5\" style=\"width:22.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/31b640bb301f8dce.svg\" alt=\"v^{(2)}=(-0.5)+0+(-0.5)=-1\" style=\"width:31.741ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/144d4f69ce96cfe2.svg\" alt=\"x^{(2)}=2+(-1)=1\" style=\"width:19.24ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/84dfd42953d2811a.svg\" alt=\"I=0.5\\times(-0.5)=-0.25\" style=\"width:25.026ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/dcb7c97c6295715d.svg\" alt=\"d_p=1.5-(1.5)=0\" style=\"width:19.643ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/19e8c86525a0eadb.svg\" alt=\"c_1r_1=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/660e9363a712569b.svg\" alt=\"C=0.5\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2e6ff91ff778f21f.svg\" alt=\"d_g=1-(1.5)=-0.5\" style=\"width:21.362ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/1cc595b44ce899fa.svg\" alt=\"c_2r_2=1\\times0.5=0.5\" style=\"width:19.689ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/418a15cd3fa3bbcc.svg\" alt=\"S=0.5\\times(-0.5)=-0.25\" style=\"width:25.345ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/8789b37bca837a83.svg\" alt=\"v^{(2)}=(-0.25)+0+(-0.25)=-0.5\" style=\"width:35.764ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/b71d05464709fcf3.svg\" alt=\"x^{(2)}=1.5+(-0.5)=1\" style=\"width:22.761ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/e7fb8b8ea59ba406.svg\" alt=\"f(1, 1)=1^2+1^2=1+1=2\" style=\"width:28.487ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>2</td><td>2</td><td>Keep old: tie</td><td>(1, 1)</td></tr><tr><td>B</td><td>6.25</td><td>2</td><td>Replace: new score is lower</td><td>(1, 1)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(1, 1)</strong>, with objective <strong>2</strong>.</p></div><div class=\"step\"><h5>Step 14. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(1, 1)</td><td>(0, 0)</td><td>(1, 1)</td></tr><tr><td>B</td><td>(1, 1)</td><td>(-1, -0.5)</td><td>(1, 1)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"class-three-particles","title":"Class PSO photograph: all three particles through iteration 2","html":"<p>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.</p><p>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.</p><section class=\"example\"><p class=\"question\"><strong>Minimise <span class=\"math-inline\"><img src=\"math/ef9d55cf7c043920.svg\" alt=\"f(x)=x_1^2+x_2^2-x_1x_2\" style=\"width:21.974ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using 3 particles. Use the initial data below and perform exactly two PSO iterations, reporting position, velocity, pbest and gbest after each iteration.</strong> <span class=\"marks\">[10 marks · Class data; two-iteration minimisation extension]</span></p><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Particle</th><th>Initial position x⁰</th><th>Initial velocity v⁰</th></tr></thead><tbody><tr><td>A</td><td>(3.14, 7.21)</td><td>(0.1, 0.3)</td></tr><tr><td>B</td><td>(4.15, 7.31)</td><td>(0.5, 0.1)</td></tr><tr><td>C</td><td>(6.17, 8.27)</td><td>(0.2, 0)</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>The complete swarm state after iterations 1 and 2, and the best location found.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate every initial position</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/bf321f61ed66837c.svg\" alt=\"f(3.14, 7.21)=3.14^2+7.21^2-(3.14)(7.21)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d54138730c346bbf.svg\" alt=\"=9.8596+51.9841-22.6394=39.2043\" style=\"width:39.471ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/1980ac03eb9e462c.svg\" alt=\"f(4.15, 7.31)=4.15^2+7.31^2-(4.15)(7.31)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ba408f391fd916c4.svg\" alt=\"=17.2225+53.4361-30.3365=40.3221\" style=\"width:40.602ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle C</strong></p><div class=\"math-display\"><img src=\"math/ac0fc4a2897f8794.svg\" alt=\"f(6.17, 8.27)=6.17^2+8.27^2-(6.17)(8.27)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/558e7a3b9a40d34e.svg\" alt=\"=38.0689+68.3929-51.0259=55.4359\" style=\"width:40.602ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Initialise the memories</h5><p>pbest is each initial position because there is no earlier history. The smallest objective decides gbest.</p><div class=\"math-display\"><img src=\"math/567a650862d29da5.svg\" alt=\"gbest^0=(3.14, 7.21)\" style=\"width:19.798ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Its score is 39.2043. Store the position, not only the score.</p></div><div class=\"step\"><h5>Step 3. Iteration 1: freeze the previous memories</h5><p>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).</p></div><div class=\"step\"><h5>Step 4. Iteration 1: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/4f87680527f659f2.svg\" alt=\"I=0.5\\times0.1=0.05\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/d3ab4c94a5f284d2.svg\" alt=\"d_p=3.14-(3.14)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6212c336dbecc343.svg\" alt=\"d_g=3.14-(3.14)=0\" style=\"width:21.864ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/16804d70bddc0ccc.svg\" alt=\"S=0.12\\times(0)=0\" style=\"width:18.304ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/6950d20a25859fe4.svg\" alt=\"v^{(1)}=0.05+0+0=0.05\" style=\"width:25.203ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/de8ab0140b454ff9.svg\" alt=\"x^{(1)}=3.14+0.05=3.19\" style=\"width:24.394ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/eb88185c1e62a59c.svg\" alt=\"I=0.5\\times0.3=0.15\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/d7b5c8d3808f4c73.svg\" alt=\"d_p=7.21-(7.21)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/ca02c52199da4f04.svg\" alt=\"d_g=7.21-(7.21)=0\" style=\"width:21.864ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/16804d70bddc0ccc.svg\" alt=\"S=0.12\\times(0)=0\" style=\"width:18.304ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/c7ca03a89be4beea.svg\" alt=\"v^{(1)}=0.15+0+0=0.15\" style=\"width:25.203ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/f693927b5eebad50.svg\" alt=\"x^{(1)}=7.21+0.15=7.36\" style=\"width:24.394ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Iteration 1: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/db302571bbe707b4.svg\" alt=\"I=0.5\\times0.5=0.25\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/2ddd2b101f36cd26.svg\" alt=\"d_p=4.15-(4.15)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/1978fefc1be6f223.svg\" alt=\"d_g=3.14-(4.15)=-1.01\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/060e9302bdac4457.svg\" alt=\"S=0.12\\times(-1.01)=-0.1212\" style=\"width:29.87ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/08fa8ab93dce4fd3.svg\" alt=\"v^{(1)}=0.25+0+(-0.1212)=0.1288\" style=\"width:36.14ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/bb72c3734ea8a809.svg\" alt=\"x^{(1)}=4.15+0.1288=4.2788\" style=\"width:28.919ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/4f87680527f659f2.svg\" alt=\"I=0.5\\times0.1=0.05\" style=\"width:19.746ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/bceb9619d4320629.svg\" alt=\"d_p=7.31-(7.31)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/2fc0a8e88db078cd.svg\" alt=\"d_g=7.21-(7.31)=-0.1\" style=\"width:25.384ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f8e69de5d9161da2.svg\" alt=\"S=0.12\\times(-0.1)=-0.012\" style=\"width:27.608ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/3dca081cd95c2dd0.svg\" alt=\"v^{(1)}=0.05+0+(-0.012)=0.038\" style=\"width:33.877ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/644604a12b5bcc31.svg\" alt=\"x^{(1)}=7.31+0.038=7.348\" style=\"width:26.657ex;height:2.32ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Iteration 1: update particle C</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/3c5f4d0f2cda8136.svg\" alt=\"I=0.5\\times0.2=0.1\" style=\"width:18.614ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/13f27d08182e6e02.svg\" alt=\"d_p=6.17-(6.17)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/93416da8e366b396.svg\" alt=\"d_g=3.14-(6.17)=-3.03\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a59d670bba6f5dac.svg\" alt=\"S=0.12\\times(-3.03)=-0.3636\" style=\"width:29.87ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/3fdb1b4bffd3874d.svg\" alt=\"v^{(1)}=0.1+0+(-0.3636)=-0.2636\" style=\"width:36.769ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/40f8a4a790d7094f.svg\" alt=\"x^{(1)}=6.17+(-0.2636)=5.9064\" style=\"width:32.439ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/6f4daee36ea96185.svg\" alt=\"I=0.5\\times0=0\" style=\"width:15.094ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/d343c09e8978bf19.svg\" alt=\"d_p=8.27-(8.27)=0\" style=\"width:21.905ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/ea093f799c7411f8.svg\" alt=\"d_g=7.21-(8.27)=-1.06\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b9fa5298c9c7cb16.svg\" alt=\"S=0.12\\times(-1.06)=-0.1272\" style=\"width:29.87ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/28af9633e743719d.svg\" alt=\"v^{(1)}=0+0+(-0.1272)=-0.1272\" style=\"width:35.008ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/dba6d056546c8535.svg\" alt=\"x^{(1)}=8.27+(-0.1272)=8.1428\" style=\"width:32.439ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Iteration 1: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/3ae29bc527e20248.svg\" alt=\"f(3.19, 7.36)=3.19^2+7.36^2-(3.19)(7.36)\" style=\"width:42.191ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b9b0c1a8c0f513a8.svg\" alt=\"=10.1761+54.1696-23.4784=40.8673\" style=\"width:40.602ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/c476266715700a96.svg\" alt=\"f(4.2788, 7.348)=4.2788^2+7.348^2-(4.2788)(7.348)\" style=\"width:52.372ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1baa4a09739c8180.svg\" alt=\"=18.30812944+53.993104-31.4406224=40.86061104\" style=\"width:55.308ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle C</strong></p><div class=\"math-display\"><img src=\"math/3a9fac3b191a1ffa.svg\" alt=\"f(5.9064, 8.1428)=5.9064^2+8.1428^2-(5.9064)(8.1428)\" style=\"width:55.765ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/273655b1059b7aef.svg\" alt=\"=34.88556096+66.30519184-48.09463392=53.09611888\" style=\"width:58.702ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Iteration 1: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>39.2043</td><td>40.8673</td><td>Keep old: new score is worse</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>40.3221</td><td>40.86061104</td><td>Keep old: new score is worse</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>55.4359</td><td>53.09611888</td><td>Replace: new score is lower</td><td>(5.9064, 8.1428)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(3.14, 7.21)</strong>, with objective <strong>39.2043</strong>.</p></div><div class=\"step\"><h5>Step 9. Iteration 1: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(3.19, 7.36)</td><td>(0.05, 0.15)</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>(4.2788, 7.348)</td><td>(0.1288, 0.038)</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>(5.9064, 8.1428)</td><td>(-0.2636, -0.1272)</td><td>(5.9064, 8.1428)</td></tr></tbody></table></div><div class=\"step\"><h5>Step 10. Iteration 2: freeze the previous memories</h5><p>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).</p></div><div class=\"step\"><h5>Step 11. Iteration 2: update particle A</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/e4bd35a53c831c76.svg\" alt=\"I=0.5\\times0.05=0.025\" style=\"width:22.008ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/cc2af53bc1a4a60e.svg\" alt=\"d_p=3.14-(3.19)=-0.05\" style=\"width:26.557ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/db60d8d854aa5ee6.svg\" alt=\"C=0.6\\times(-0.05)=-0.03\" style=\"width:26.737ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/1dbfd156a9aafbb3.svg\" alt=\"d_g=3.14-(3.19)=-0.05\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e7739769871dabe8.svg\" alt=\"S=0.12\\times(-0.05)=-0.006\" style=\"width:28.739ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/4e6287c93cb39658.svg\" alt=\"v^{(2)}=0.025+(-0.03)+(-0.006)=-0.011\" style=\"width:43.18ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/04d374313aaab72d.svg\" alt=\"x^{(2)}=3.19+(-0.011)=3.179\" style=\"width:30.177ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/e9c97812dc9ecc86.svg\" alt=\"I=0.5\\times0.15=0.075\" style=\"width:22.008ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/08869d3b9cefb65b.svg\" alt=\"d_p=7.21-(7.36)=-0.15\" style=\"width:26.557ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b80cfa7b094e421e.svg\" alt=\"C=0.6\\times(-0.15)=-0.09\" style=\"width:26.737ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/8346d41c793ff815.svg\" alt=\"d_g=7.21-(7.36)=-0.15\" style=\"width:26.515ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bb6864a422495c83.svg\" alt=\"S=0.12\\times(-0.15)=-0.018\" style=\"width:28.739ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/df1003fde626354c.svg\" alt=\"v^{(2)}=0.075+(-0.09)+(-0.018)=-0.033\" style=\"width:43.18ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/04ced9552ec0a2fc.svg\" alt=\"x^{(2)}=7.36+(-0.033)=7.327\" style=\"width:30.177ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 12. Iteration 2: update particle B</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/c7a3d7f19f863ddf.svg\" alt=\"I=0.5\\times0.1288=0.0644\" style=\"width:25.402ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/a86b46d750156354.svg\" alt=\"d_p=4.15-(4.2788)=-0.1288\" style=\"width:31.082ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9088271ed20d40af.svg\" alt=\"C=0.6\\times(-0.1288)=-0.07728\" style=\"width:32.393ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/ad7db7d0feab17e6.svg\" alt=\"d_g=3.14-(4.2788)=-1.1388\" style=\"width:31.04ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/115797e01c1867dd.svg\" alt=\"S=0.12\\times(-1.1388)=-0.136656\" style=\"width:34.395ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/ebf74e4d56d1b7b9.svg\" alt=\"v^{(2)}=0.0644+(-0.07728)+(-0.136656)=-0.149536\" style=\"width:54.492ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/eae7d898d5a551e1.svg\" alt=\"x^{(2)}=4.2788+(-0.149536)=4.129264\" style=\"width:39.227ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/45baaa3ae928b8b4.svg\" alt=\"I=0.5\\times0.038=0.019\" style=\"width:23.139ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/c86909b46639b9bb.svg\" alt=\"d_p=7.31-(7.348)=-0.038\" style=\"width:28.82ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/241c822838613f93.svg\" alt=\"C=0.6\\times(-0.038)=-0.0228\" style=\"width:30.13ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/fe0c41420480a542.svg\" alt=\"d_g=7.21-(7.348)=-0.138\" style=\"width:28.778ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e9a578685c025bc9.svg\" alt=\"S=0.12\\times(-0.138)=-0.01656\" style=\"width:32.132ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/9363048bb26f273e.svg\" alt=\"v^{(2)}=0.019+(-0.0228)+(-0.01656)=-0.02036\" style=\"width:49.968ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/d30e07ac98dd2bba.svg\" alt=\"x^{(2)}=7.348+(-0.02036)=7.32764\" style=\"width:35.833ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 13. Iteration 2: update particle C</h5><p><strong>Coordinate 1</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/cfc400d9e06f7358.svg\" alt=\"I=0.5\\times(-0.2636)=-0.1318\" style=\"width:30.682ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/786ba18b3b62c512.svg\" alt=\"d_p=5.9064-(5.9064)=0\" style=\"width:26.43ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/6b3316f35248ffdf.svg\" alt=\"d_g=3.14-(5.9064)=-2.7664\" style=\"width:31.04ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b32a5de2e3b2cefc.svg\" alt=\"S=0.12\\times(-2.7664)=-0.331968\" style=\"width:34.395ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/de7212cc169aa2f9.svg\" alt=\"v^{(2)}=(-0.1318)+0+(-0.331968)=-0.463768\" style=\"width:48.207ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/ab68ef2fa1b527a9.svg\" alt=\"x^{(2)}=5.9064+(-0.463768)=5.442632\" style=\"width:39.227ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Coordinate 2</strong></p><p>Inertia = keep a fraction of the old velocity.</p><div class=\"math-display\"><img src=\"math/d56f94fb044781a6.svg\" alt=\"I=0.5\\times(-0.1272)=-0.0636\" style=\"width:30.682ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Personal pull: first subtract the current coordinate from the personal-best coordinate.</p><div class=\"math-display\"><img src=\"math/9923de46bc28d517.svg\" alt=\"d_p=8.1428-(8.1428)=0\" style=\"width:26.43ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the two personal coefficients, then multiply by the difference.</p><div class=\"math-display\"><img src=\"math/16c273adcc74f25a.svg\" alt=\"c_1r_1=1.2\\times0.5=0.6\" style=\"width:21.449ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/89df484c365b908d.svg\" alt=\"C=0.6\\times(0)=0\" style=\"width:17.433ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Social pull: subtract the current coordinate from the frozen global-best coordinate.</p><div class=\"math-display\"><img src=\"math/024d71da7fe2cc3c.svg\" alt=\"d_g=7.21-(8.1428)=-0.9328\" style=\"width:31.04ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply the social coefficients, then multiply by that difference.</p><div class=\"math-display\"><img src=\"math/e19d636861b5bba6.svg\" alt=\"c_2r_2=1.2\\times0.1=0.12\" style=\"width:22.581ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/71d9611ef2b3e668.svg\" alt=\"S=0.12\\times(-0.9328)=-0.111936\" style=\"width:34.395ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the three velocity contributions.</p><div class=\"math-display\"><img src=\"math/1a832b53cf0e106d.svg\" alt=\"v^{(2)}=(-0.0636)+0+(-0.111936)=-0.175536\" style=\"width:48.207ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div><p>Add the new velocity to the old position. The parenthesised upper label is the iteration number.</p><div class=\"math-display\"><img src=\"math/17e63ccf7082af52.svg\" alt=\"x^{(2)}=8.1428+(-0.175536)=7.967264\" style=\"width:39.227ex;height:2.7ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 14. Iteration 2: evaluate the new positions</h5><p><strong>Particle A</strong></p><div class=\"math-display\"><img src=\"math/76bb4ad3f6895999.svg\" alt=\"f(3.179, 7.327)=3.179^2+7.327^2-(3.179)(7.327)\" style=\"width:48.978ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e1463199434aa355.svg\" alt=\"=10.106041+53.684929-23.292533=40.498437\" style=\"width:49.652ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle B</strong></p><div class=\"math-display\"><img src=\"math/0ac428234bdb63ad.svg\" alt=\"f(4.129264, 7.32764)=4.129264^2+7.32764^2-(4.129264)(7.32764)\" style=\"width:65.946ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a32da9cd0f25ac36.svg\" alt=\"=17.050821182+53.69430797-30.257760057=40.487369094\" style=\"width:62.096ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Particle C</strong></p><div class=\"math-display\"><img src=\"math/515e8ddbaa301792.svg\" alt=\"f(5.442632, 7.967264)=5.442632^2+7.967264^2-(5.442632)(7.967264)\" style=\"width:69.34ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a9051d35de42b6a1.svg\" alt=\"=29.622243087+63.477295646-43.362885999=49.736652734\" style=\"width:63.227ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 15. Iteration 2: update pbest, then gbest</h5><table><thead><tr><th>Particle</th><th>Old pbest score</th><th>New score</th><th>Decision</th><th>pbest position</th></tr></thead><tbody><tr><td>A</td><td>39.2043</td><td>40.498437</td><td>Keep old: new score is worse</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>40.3221</td><td>40.487369094</td><td>Keep old: new score is worse</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>53.09611888</td><td>49.736652734</td><td>Replace: new score is lower</td><td>(5.442632, 7.967264)</td></tr></tbody></table><p>Compare the retained pbest scores. gbest = <strong>(3.14, 7.21)</strong>, with objective <strong>39.2043</strong>.</p></div><div class=\"step\"><h5>Step 16. Iteration 2: record the complete state</h5><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>pbest</th></tr></thead><tbody><tr><td>A</td><td>(3.179, 7.327)</td><td>(-0.011, -0.033)</td><td>(3.14, 7.21)</td></tr><tr><td>B</td><td>(4.129264, 7.32764)</td><td>(-0.149536, -0.02036)</td><td>(4.15, 7.31)</td></tr><tr><td>C</td><td>(5.442632, 7.967264)</td><td>(-0.463768, -0.175536)</td><td>(5.442632, 7.967264)</td></tr></tbody></table></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>\r\n\r\n<!-- depth:retained-diagram:start -->\r\n<div class=\"concept-bridge\"><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_pso_class_paths.961831cda1.svg\" width=\"700\" height=\"440\" alt=\"Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Motion alone does not imply improvement. Evaluate the objective at the new location before updating a best memory.</figcaption></figure></div>\r\n<!-- depth:retained-diagram:end -->"},{"id":"theory","title":"PSO algorithm, architecture, advantages and limitations","html":"<h2>Algorithm you can write in an exam</h2><ol><li>Define the objective and whether to minimise or maximise it. Initialise particle positions and velocities.</li><li>Evaluate every particle. Set each pbest to its initial position and gbest to the best among them.</li><li>Use the previous state to calculate each new velocity.</li><li>Update each position using that new velocity. Apply bounds or a velocity limit only according to the stated policy.</li><li>Evaluate the new positions. Update a pbest only when the new objective is better; choose gbest from the personal bests.</li><li>Repeat until the iteration budget or another stopping criterion is reached.</li></ol>\r\n<div class=\"flow\"><div class=\"node\">Initialise</div><span class=\"arrow\">→</span><div class=\"node\">Evaluate + memories</div><span class=\"arrow\">→</span><div class=\"node\">Velocity</div><span class=\"arrow\">→</span><div class=\"node\">Position</div><span class=\"arrow\">→</span><div class=\"node\">Evaluate + update memories<small>repeat until stopping</small></div></div><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody><tr><td>Simple position/velocity updates; does not require objective derivatives</td><td>Can converge prematurely to a local region</td></tr><tr><td>Uses both individual and shared experience</td><td>Results depend on coefficients, initialisation and random factors</td></tr><tr><td>Useful for many continuous optimisation problems</td><td>Constraints and discrete encodings need suitable handling</td></tr><tr><td>Keeps best-so-far memories</td><td>Does not guarantee the global optimum in a finite run</td></tr></tbody></table><section class=\"example\"><p class=\"question\"><strong>Explain one application of PSO.</strong> <span class=\"marks\">[3 marks · Practice]</span></p><h4>Answer</h4><p>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.</p></section><table><thead><tr><th>Exam situation</th><th>Action</th></tr></thead><tbody><tr><td>Minimisation</td><td>Lower f is better</td></tr><tr><td>Maximisation</td><td>Higher f is better; do not reverse velocity differences</td></tr><tr><td>Tie in best score</td><td>Keep the previous best unless a tie rule is supplied</td></tr><tr><td>Different random factors each iteration</td><td>Read the relevant row; do not reuse old factors</td></tr><tr><td>Synchronous update</td><td>Freeze gbest for all particles within one iteration</td></tr><tr><td>Position/velocity outside a limit</td><td>Use the limit-handling rule explicitly supplied; state an assumption if absent</td></tr></tbody></table><p class=\"memory\"><strong>Yaad rakho:</strong> Velocity → position → score → pbest → gbest. Ye order har iteration mein same.</p>"}]},{"id":"u4-rl","title":"Unit 4 · What reinforcement learning is","unit":"4","scope":"Unit 4 · Introduction to reinforcement learning · TEE","sections":[{"id":"what-is-rl","title":"Reinforcement learning: learning from rewards","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>One interaction, with every word attached to a value</h2><table><thead><tr><th>Time</th><th>Current state</th><th>Chosen action</th><th>Observed reward</th><th>Next state</th></tr></thead><tbody><tr><td>0</td><td>Robot in room A</td><td>Move right</td><td>−1 for the move</td><td>Room B</td></tr><tr><td>1</td><td>Room B</td><td>Pick up parcel</td><td>+5 for pickup</td><td>Carrying parcel</td></tr><tr><td>2</td><td>Carrying parcel</td><td>Finish</td><td>+2 for delivery</td><td>Terminal</td></tr></tbody></table><p>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.</p><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>Definition (write this in the exam)</h2>\r\n<p><strong>Reinforcement learning (RL)</strong> is a type of machine learning in which an <strong>agent</strong> learns a <strong>policy</strong>, a rule that maps situations (<strong>states</strong>) to <strong>actions</strong>, by interacting with an <strong>environment</strong>. After every action the environment returns a numerical <strong>reward</strong> and a new state. The agent's goal is to maximise the <strong>expected cumulative (discounted) reward</strong>, called the <strong>return</strong>. No labelled “correct action” is given; the agent discovers good actions by trial and error.</p>\r\n\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/rl_loop_full.a9937cb961.svg\" width=\"600\" height=\"300\" alt=\"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 .\" loading=\"lazy\" decoding=\"async\"></div><figcaption>At time t the agent sees state S<sub>t</sub>, chooses action A<sub>t</sub>; the environment replies with reward R<sub>t+1</sub> and next state S<sub>t+1</sub>.</figcaption></figure>\r\n\r\n<h2>The vocabulary you must know</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Term</th><th>Meaning</th><th>Example: a robot vacuum</th></tr></thead><tbody>\r\n<tr><td><strong>Agent</strong></td><td>The learner and decision maker.</td><td>The vacuum's controller.</td></tr>\r\n<tr><td><strong>Environment</strong></td><td>Everything outside the agent that responds to its actions.</td><td>The room, furniture, dust.</td></tr>\r\n<tr><td><strong>State <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span></strong></td><td>A description of the current situation.</td><td>Position + battery level.</td></tr>\r\n<tr><td><strong>Action <span class=\"math-inline\"><img src=\"math/2d4a1257492be872.svg\" alt=\"a\" style=\"width:1.197ex;height:1.02ex\" loading=\"lazy\" decoding=\"async\"></span></strong></td><td>A choice the agent can make in a state.</td><td>Forward, turn left, return to dock.</td></tr>\r\n<tr><td><strong>Reward <span class=\"math-inline\"><img src=\"math/b758343af751f858.svg\" alt=\"r\" style=\"width:1.02ex;height:1.025ex\" loading=\"lazy\" decoding=\"async\"></span></strong></td><td>Immediate scalar feedback after an action.</td><td>+1 per dust patch, −10 for hitting a wall.</td></tr>\r\n<tr><td><strong>Policy <span class=\"math-inline\"><img src=\"math/7e7e8c545536f6a2.svg\" alt=\"\\pi\" style=\"width:1.29ex;height:1ex\" loading=\"lazy\" decoding=\"async\"></span></strong></td><td>The agent's behaviour: <span class=\"math-inline\"><img src=\"math/f155e46af3f71ce4.svg\" alt=\"\\pi(a\\mid s)\" style=\"width:7.194ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> = probability of action <span class=\"math-inline\"><img src=\"math/2d4a1257492be872.svg\" alt=\"a\" style=\"width:1.197ex;height:1.02ex\" loading=\"lazy\" decoding=\"async\"></span> in state <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span>.</td><td>“If battery &lt; 15%, go to dock.”</td></tr>\r\n<tr><td><strong>Return <span class=\"math-inline\"><img src=\"math/418bfe298764c6bc.svg\" alt=\"G_t\" style=\"width:2.544ex;height:1.952ex\" loading=\"lazy\" decoding=\"async\"></span></strong></td><td>Total discounted reward from time <span class=\"math-inline\"><img src=\"math/b84a36f811c3dd68.svg\" alt=\"t\" style=\"width:0.817ex;height:1.441ex\" loading=\"lazy\" decoding=\"async\"></span> onward.</td><td>All future dust collected, minus penalties.</td></tr>\r\n<tr><td><strong>Value <span class=\"math-inline\"><img src=\"math/214f0238bdf479cc.svg\" alt=\"v(s)\" style=\"width:3.919ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></strong></td><td>Expected return starting from state <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span>.</td><td>How good it is to be at the centre with a full battery.</td></tr>\r\n<tr><td><strong>Model</strong></td><td>The agent's knowledge of <span class=\"math-inline\"><img src=\"math/8818d06a66002156.svg\" alt=\"P(s&#39;\\mid s,a)\" style=\"width:10.298ex;height:2.283ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/486a3031e7ac622b.svg\" alt=\"R\" style=\"width:1.717ex;height:1.593ex\" loading=\"lazy\" decoding=\"async\"></span> (optional).</td><td>A map of the room.</td></tr>\r\n</tbody></table></div>\r\n\r\n<h2>Four elements of an RL system (Sutton and Barto)</h2>\r\n<ol>\r\n<li><strong>Policy</strong>: defines behaviour (state → action).</li>\r\n<li><strong>Reward signal</strong>: defines the goal; the immediate desirability of a step.</li>\r\n<li><strong>Value function</strong>: long-term desirability of a state (what reward is expected later).</li>\r\n<li><strong>Model of the environment</strong> (optional): predicts the next state and reward, used for planning. Methods with a model are <em>model-based</em>; without one, <em>model-free</em> (for example, Q-learning).</li>\r\n</ol>\r\n\r\n<h2>How RL differs from other learning</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>Supervised</th><th>Unsupervised</th><th>Reinforcement</th></tr></thead><tbody>\r\n<tr><td>Feedback</td><td>Correct label for every input</td><td>None</td><td>A reward, often delayed</td></tr>\r\n<tr><td>Goal</td><td>Predict labels</td><td>Find structure (clusters)</td><td>Maximise long-term return</td></tr>\r\n<tr><td>Data</td><td>Fixed dataset (i.i.d.)</td><td>Fixed dataset</td><td>Generated by the agent's own actions (sequential)</td></tr>\r\n<tr><td>Example</td><td>Spam classifier</td><td>Customer segments (GMM)</td><td>Game-playing agent</td></tr>\r\n</tbody></table></div>\r\n\r\n<h2>Two ideas that make RL special</h2>\r\n<p><strong>Delayed reward.</strong> A move in chess earns nothing now but may win the game 30 moves later. RL must assign credit to earlier actions.</p>\r\n<p><strong>Exploration versus exploitation.</strong> To earn reward the agent should <em>exploit</em> the best action it knows, but to find better actions it must <em>explore</em> untried ones. A common rule is <strong>ε-greedy</strong>: with probability <span class=\"math-inline\"><img src=\"math/bad648db5f9b2803.svg\" alt=\"1-\\varepsilon\" style=\"width:4.951ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span> take the best-known action; with probability <span class=\"math-inline\"><img src=\"math/e34d6bfa22904706.svg\" alt=\"\\varepsilon\" style=\"width:1.054ex;height:1.072ex\" loading=\"lazy\" decoding=\"async\"></span> take a random one.</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Agent karta hai, environment batata hai (reward + next state), policy decide karti hai, value future ka hisaab rakhti hai.</div>"}]},{"id":"u4-markov","title":"Unit 4 · Markov processes (transition matrices)","unit":"4","scope":"Unit 4 · Markov processes · asked in every recent paper (5 and 10 marks)","sections":[{"id":"markov-chain","title":"Markov property, transition matrix and state diagram","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>Definitions</h2>\r\n<p><strong>Markov property.</strong> A sequence of states <span class=\"math-inline\"><img src=\"math/a4c47d7eb261ab94.svg\" alt=\"S_1, S_2, \\dots\" style=\"width:9.413ex;height:2.034ex\" loading=\"lazy\" decoding=\"async\"></span> has the Markov property if the future is independent of the past given the present:</p>\r\n<div class=\"math-display\"><img src=\"math/8b44c46b24e14f80.svg\" alt=\"P(S_{t+1}\\mid S_t, S_{t-1},\\dots,S_1)=P(S_{t+1}\\mid S_t)\" style=\"width:39.023ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Markov process (Markov chain).</strong> A memoryless random process given by a pair <span class=\"math-inline\"><img src=\"math/bd68aa54ee45e3af.svg\" alt=\"\\langle \\mathcal S, P\\rangle\" style=\"width:5.918ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: a finite set of states <span class=\"math-inline\"><img src=\"math/54f9d81745f0a6da.svg\" alt=\"\\mathcal S\" style=\"width:1.452ex;height:1.645ex\" loading=\"lazy\" decoding=\"async\"></span> and a <strong>transition probability matrix</strong> <span class=\"math-inline\"><img src=\"math/43eba13e48b4ac63.svg\" alt=\"P\" style=\"width:1.699ex;height:1.545ex\" loading=\"lazy\" decoding=\"async\"></span> with entries</p>\r\n<div class=\"math-display\"><img src=\"math/8f271383e8f91295.svg\" alt=\"P_{ij}=P(S_{t+1}=j\\mid S_t=i)\" style=\"width:25.309ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Row <span class=\"math-inline\"><img src=\"math/3c3a2b02c199adb2.svg\" alt=\"i\" style=\"width:0.781ex;height:1.52ex\" loading=\"lazy\" decoding=\"async\"></span> is the state you are <strong>in now</strong> (“from”); column <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span> is the state you go <strong>to next</strong>. Two rules always hold:</p>\r\n<ol><li>Every entry is between 0 and 1: <span class=\"math-inline\"><img src=\"math/e864eb4c19313d10.svg\" alt=\"0\\le P_{ij}\\le 1\" style=\"width:11.148ex;height:2.211ex\" loading=\"lazy\" decoding=\"async\"></span>.</li><li>Every row sums to 1: <span class=\"math-inline\"><img src=\"math/4864b97aaf5ebb33.svg\" alt=\"\\sum_j P_{ij}=1\" style=\"width:10.613ex;height:2.669ex\" loading=\"lazy\" decoding=\"async\"></span> (from any state you must go somewhere, possibly staying).</li></ol>\r\n<p>A <strong>state transition diagram</strong> draws each state as a circle and each non-zero <span class=\"math-inline\"><img src=\"math/fe1d46e7593684d1.svg\" alt=\"P_{ij}\" style=\"width:2.851ex;height:2.211ex\" loading=\"lazy\" decoding=\"async\"></span> as an arrow from <span class=\"math-inline\"><img src=\"math/3c3a2b02c199adb2.svg\" alt=\"i\" style=\"width:0.781ex;height:1.52ex\" loading=\"lazy\" decoding=\"async\"></span> to <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span> labelled with the probability. Staying in the same state is a self-loop.</p>\r\n\r\n<div class=\"trap\"><strong>Exam trap.</strong> 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.</div>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks · Final Nov 2025 Q1d]</span></p>\r\n<div class=\"given\"><h4>Given</h4><p>Two states: X, Y. From X: stay 0.75, to Y 0.25. From Y: to X 0.40, stay 0.60.</p><h4>To find</h4><p>Matrix <span class=\"math-inline\"><img src=\"math/43eba13e48b4ac63.svg\" alt=\"P\" style=\"width:1.699ex;height:1.545ex\" loading=\"lazy\" decoding=\"async\"></span> and its diagram.</p></div>\r\n<h4>Formula and why it applies</h4>\r\n<p><span class=\"math-inline\"><img src=\"math/7f4c1d9519ac27a9.svg\" alt=\"P_{ij}=P(\\text{next}=j\\mid\\text{now}=i)\" style=\"width:27.32ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>. Each yearly switch depends only on the brand used this year, so the process is Markov.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Order the states and fill row by row</h5>\r\n<div class=\"math-display\"><img src=\"math/550d8027e65ec3eb.svg\" alt=\"P=\\begin{array}{c|cc} &amp; X &amp; Y\\\\\\hline X &amp; 0.75 &amp; 0.25\\\\ Y &amp; 0.40 &amp; 0.60\\end{array}\\qquad\\text{i.e. } P=\\begin{bmatrix}0.75&amp;0.25\\\\0.40&amp;0.60\\end{bmatrix}\" style=\"width:44.139ex;height:8.756ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Check the rows</h5><p>Row X: 0.75 + 0.25 = 1. Row Y: 0.40 + 0.60 = 1. Valid.</p></div>\r\n<div class=\"step\"><h5>Step 3. Draw the diagram</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_brand.c2c4be3e6a.svg\" width=\"520\" height=\"280\" alt=\"Self-loops carry the retention probabilities (0.75, 0.6); the arrows between states carry the switching probabilities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Self-loops carry the retention probabilities (0.75, 0.6); the arrows between states carry the switching probabilities.</figcaption></figure></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/1028784b72801945.svg\" alt=\"P=\\begin{bmatrix}0.75&amp;0.25\\\\0.40&amp;0.60\\end{bmatrix}\" style=\"width:17.413ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span> with the diagram above.</div>\r\n<p class=\"marks-split\">Marking in the official key: matrix 3 marks, diagram 2 marks.</p>\r\n</section>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks · Re-exam Jan 2026 Q1d]</span></p><div class=\"given\"><h4>Given</h4><p>For Savings: stay 80%, switch 20%. For Current: switch to Savings 10%, stay 90%. State order: Savings, Current.</p><h4>To find</h4><p>The transition matrix and labelled state diagram.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/8f271383e8f91295.svg\" alt=\"P_{ij}=P(S_{t+1}=j\\mid S_t=i)\" style=\"width:25.309ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><p>Convert percentages to fractions of 100. A row fixes the present state, while columns list possible destinations.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Matrix (rows = this year, columns = next year)</h5><div class=\"math-display\"><img src=\"math/ad78149edee2ba2b.svg\" alt=\"P=\\begin{array}{c|cc} &amp; S &amp; C\\\\\\hline S &amp; 0.80 &amp; 0.20\\\\ C &amp; 0.10 &amp; 0.90\\end{array}\" style=\"width:18.536ex;height:8.756ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Diagram</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_bank.879499f6eb.svg\" width=\"520\" height=\"280\" alt=\"Savings (S) and Current (C) accounts per year\" loading=\"lazy\" decoding=\"async\"></div></figure></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/e333fb4ce294957a.svg\" alt=\"P=\\begin{bmatrix}0.8&amp;0.2\\\\0.1&amp;0.9\\end{bmatrix}\" style=\"width:15.151ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>; diagram as shown. Each part carries 2.5 marks in the key.</div>\r\n</section>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Row = “abhi kahan ho”, column = “kal kahan jaoge”. Har row ka total 1.</div>"},{"id":"next-step","title":"Next-step and n-step distributions","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/a352d238bb02bc14.svg\" alt=\"P=\\begin{bmatrix}0.8&amp;0.2\\\\0.1&amp;0.9\\end{bmatrix}\" style=\"width:15.151ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><p>Row/column order is Savings, Current; initial counts [60,40].</p><h4>To find</h4><p>Two successive count vectors.</p></div><h4>Formula and why it applies</h4><p>Each destination receives incoming contributions from every origin. Multiply origin count by the corresponding transition probability, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Period 1: contributions to Savings</h5><div class=\"math-display\"><img src=\"math/fb4be71da02b8086.svg\" alt=\"60\\times0.8=48\\qquad40\\times0.1=4\" style=\"width:29.792ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/637f4b18747624bc.svg\" alt=\"S_1=48+4=52\" style=\"width:16.831ex;height:1.934ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Period 1: contributions to Current</h5><div class=\"math-display\"><img src=\"math/365204994bb40e62.svg\" alt=\"60\\times0.2=12\\qquad40\\times0.9=36\" style=\"width:30.923ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ea2f674cf5833607.svg\" alt=\"C_1=12+36=48\" style=\"width:18.193ex;height:1.934ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Period 2: use the new counts [52,48]</h5><div class=\"math-display\"><img src=\"math/413733c9cae5c40e.svg\" alt=\"S_2=52\\times0.8+48\\times0.1=41.6+4.8=46.4\" style=\"width:43.733ex;height:1.934ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Period 2: second destination</h5><div class=\"math-display\"><img src=\"math/61e8c23afa57bd0c.svg\" alt=\"C_2=52\\times0.2+48\\times0.9=10.4+43.2=53.6\" style=\"width:45.095ex;height:1.934ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> After one period [52,48]; after two [46.4,53.6]. Each total is 100. Fractional counts are expectations, not split people.</div></section><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> write today's numbers as a row, multiply by the matrix, and you get tomorrow's numbers.</p>\r\n\r\n<h2>The rule</h2>\r\n<p>Let <span class=\"math-inline\"><img src=\"math/c5e02241cdaf66e6.svg\" alt=\"x_t\" style=\"width:2.059ex;height:1.357ex\" loading=\"lazy\" decoding=\"async\"></span> be a <strong>row vector</strong> of today's shares (or counts) in each state, in the same order as the matrix rows. Then</p>\r\n<div class=\"math-display\"><img src=\"math/efd1264e0038146b.svg\" alt=\"x_{t+1}=x_t\\,P,\\qquad x_{t+n}=x_t\\,P^{\\,n}\" style=\"width:29.857ex;height:2.112ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Entry <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span> of <span class=\"math-inline\"><img src=\"math/de9a8c96e0ee7db9.svg\" alt=\"x_{t+1}\" style=\"width:4.104ex;height:1.471ex\" loading=\"lazy\" decoding=\"async\"></span> is the <strong>column <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span></strong> calculation: everyone who arrives in <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span>, from every state.</p>\r\n<div class=\"math-display\"><img src=\"math/030f0c9b46caf90b.svg\" alt=\"x_{t+1}(j)=\\sum_i x_t(i)\\,P_{ij}\" style=\"width:21.287ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><span class=\"math-inline\"><img src=\"math/9ef45de9aca6f359.svg\" alt=\"P^{\\,n}\" style=\"width:3.35ex;height:1.545ex\" loading=\"lazy\" decoding=\"async\"></span> is the <strong>n-step transition matrix</strong>: <span class=\"math-inline\"><img src=\"math/270ba67bd7a265ef.svg\" alt=\"(P^{\\,n})_{ij}\" style=\"width:6.509ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span> is the probability of being in <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span> after <span class=\"math-inline\"><img src=\"math/0a03c1424e475329.svg\" alt=\"n\" style=\"width:1.357ex;height:1.025ex\" loading=\"lazy\" decoding=\"async\"></span> steps when starting in <span class=\"math-inline\"><img src=\"math/3c3a2b02c199adb2.svg\" alt=\"i\" style=\"width:0.781ex;height:1.52ex\" loading=\"lazy\" decoding=\"async\"></span> (the Chapman–Kolmogorov result). Counts stay counts (the total is preserved); shares stay shares (they still add to 1).</p>\r\n\r\n<div class=\"trap\"><strong>Exam trap.</strong> Multiply the row vector by the <em>columns</em> of <span class=\"math-inline\"><img src=\"math/43eba13e48b4ac63.svg\" alt=\"P\" style=\"width:1.699ex;height:1.545ex\" loading=\"lazy\" decoding=\"async\"></span>, not its rows. A quick check: the answer's total must equal the starting total (100 guests stay 100 guests).</div>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[part of 10 marks · Final Nov 2025 Q5a]</span></p>\r\n<div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/a2936167c6c14fec.svg\" alt=\"P=\\begin{bmatrix}0.60&amp;0.25&amp;0.15\\\\0.30&amp;0.50&amp;0.20\\\\0.20&amp;0.30&amp;0.50\\end{bmatrix},\\qquad x_0=[50,\\;30,\\;20]\" style=\"width:46.472ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p><span class=\"math-inline\"><img src=\"math/fe018f0ddfd05790.svg\" alt=\"x_1=x_0P\" style=\"width:9.28ex;height:1.92ex\" loading=\"lazy\" decoding=\"async\"></span>.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/8b9618ddde204a22.svg\" alt=\"x_{t+1}=x_tP,\\qquad x_{t+2}=(x_tP)P\" style=\"width:30.749ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>For each destination, multiply each present-state share by its probability of arriving there, then add all arrivals.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Paris tomorrow (column 1)</h5><div class=\"math-display\"><img src=\"math/396ed931211b6fc9.svg\" alt=\"50(0.60)+30(0.30)+20(0.20)=30+9+4=43\" style=\"width:48.02ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. London tomorrow (column 2)</h5><div class=\"math-display\"><img src=\"math/66d48e5543eb7f89.svg\" alt=\"50(0.25)+30(0.50)+20(0.30)=12.5+15+6=33.5\" style=\"width:52.672ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. Rome tomorrow (column 3)</h5><div class=\"math-display\"><img src=\"math/1005a6b946cdda94.svg\" alt=\"50(0.15)+30(0.20)+20(0.50)=7.5+6+10=23.5\" style=\"width:51.54ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Check the total</h5><p>43 + 33.5 + 23.5 = 100 = 50 + 30 + 20. Correct.</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> Expected guests tomorrow: Paris 43, London 33.5, Rome 23.5.</div>\r\n</section>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. Using the brand-switching matrix <span class=\"math-inline\"><img src=\"math/1028784b72801945.svg\" alt=\"P=\\begin{bmatrix}0.75&amp;0.25\\\\0.40&amp;0.60\\end{bmatrix}\" style=\"width:17.413ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>, a customer uses Brand X this year. Find the probability that the customer uses each brand after two years.</strong> <span class=\"marks\">[practice · 3 marks]</span></p><div class=\"given\"><h4>Given</h4><p>Transition matrix P is printed in the question. For the two-year brand example the initial state is certainly X, so x₀=[1,0].</p><h4>To find</h4><p>The requested next-step or two-step distribution.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/8b9618ddde204a22.svg\" alt=\"x_{t+1}=x_tP,\\qquad x_{t+2}=(x_tP)P\" style=\"width:30.749ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>For each destination, multiply each present-state share by its probability of arriving there, then add all arrivals.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Start vector</h5><p><span class=\"math-inline\"><img src=\"math/b6383902c21eeee0.svg\" alt=\"x_0=[1,\\;0]\" style=\"width:10.454ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (certainly X now).</p></div>\r\n<div class=\"step\"><h5>Step 2. One year</h5><div class=\"math-display\"><img src=\"math/05a31cec6643ce3f.svg\" alt=\"x_1=[1,0]P=[0.75,\\;0.25]\" style=\"width:25.48ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. Two years</h5><div class=\"math-display\"><img src=\"math/c991023e560f0430.svg\" alt=\"x_2=x_1P=[0.75(0.75)+0.25(0.40),\\;0.75(0.25)+0.25(0.60)]=[0.6625,\\;0.3375]\" style=\"width:78.423ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> After two years: X with probability 0.6625, Y with probability 0.3375. (Equivalently, row X of <span class=\"math-inline\"><img src=\"math/6708ca668a7d9dcd.svg\" alt=\"P^2=\\begin{bmatrix}0.6625&amp;0.3375\\\\0.54&amp;0.46\\end{bmatrix}\" style=\"width:23.051ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>.)</div>\r\n</section>\r\n\r\n<h2>Other next-step results, with full working in Solved papers</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Paper question</th><th>Start</th><th>Next step</th></tr></thead><tbody>\r\n<tr><td>Learning levels B, I, A (Final Q6b)</td><td>[50, 30, 20]</td><td>[36, 32, 32]</td></tr>\r\n<tr><td>Booking channels W, A, C (Re-exam Q5b)</td><td>[0.40, 0.35, 0.25]</td><td>[0.39, 0.335, 0.275]</td></tr>\r\n<tr><td>Aircraft at hubs A, B, C (Re-exam Q6b)</td><td>[30, 40, 30]</td><td>[38.5, 32.5, 29]</td></tr>\r\n</tbody></table></div>\r\n<p>The complete working for each is in <a href=\"#tee/papers/paper-final-2025/q6b\">Solved papers</a>.</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Kal ka number = har jagah se aane wale log jodo (column ke saath multiply).</div>"},{"id":"steady-state","title":"Steady state and long-run gain or loss","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>For transitions Savings→Current=0.2 and Current→Savings=0.1, derive the stationary shares.</strong> <span class=\"marks\">[3 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>s and c that remain unchanged after a step.</p></div><h4>Formula and why it applies</h4><p>At stationarity total incoming share equals current share.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write Savings balance</h5><div class=\"math-display\"><img src=\"math/193b341ebcb587b5.svg\" alt=\"s=0.8s+0.1c\" style=\"width:14.667ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Subtract 0.8s from both sides</h5><div class=\"math-display\"><img src=\"math/3dfa7c84f62b2e86.svg\" alt=\"s-0.8s=0.1c\\quad\\Rightarrow\\quad0.2s=0.1c\" style=\"width:33.552ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Divide both sides by 0.1</h5><div class=\"math-display\"><img src=\"math/63aa27a487626a55.svg\" alt=\"2s=c\" style=\"width:6.189ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Use the total share</h5><div class=\"math-display\"><img src=\"math/191d2d48b18264ce.svg\" alt=\"s+c=1\\quad\\Rightarrow\\quad s+2s=1\\quad\\Rightarrow\\quad3s=1\" style=\"width:41.551ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Divide and recover the other share</h5><div class=\"math-display\"><img src=\"math/2788e62b0b2007f8.svg\" alt=\"s=1/3\\qquad c=2s=2/3\" style=\"width:24.597ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Stationary shares [1/3,2/3].</div></section></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> a stationary distribution is unchanged by one transition; that fixed row <span class=\"math-inline\"><img src=\"math/7e7e8c545536f6a2.svg\" alt=\"\\pi\" style=\"width:1.29ex;height:1ex\" loading=\"lazy\" decoding=\"async\"></span> satisfies <span class=\"math-inline\"><img src=\"math/e595caf895fa199c.svg\" alt=\"\\pi=\\pi P\" style=\"width:7.295ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></span>, and comparing it with today's shares tells you who gains and who loses in the long run.</p>\r\n\r\n<h2>Definition</h2>\r\n<p>A <strong>steady-state (stationary) distribution</strong> is a row vector <span class=\"math-inline\"><img src=\"math/118db8b67dc77bc6.svg\" alt=\"\\pi=[\\pi_1,\\dots,\\pi_n]\" style=\"width:15.32ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> such that</p>\r\n<div class=\"math-display\"><img src=\"math/e3293de0e0ea04b1.svg\" alt=\"\\pi=\\pi P,\\qquad \\sum_i \\pi_i=1,\\qquad \\pi_i\\ge 0\" style=\"width:34.356ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>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), <span class=\"math-inline\"><img src=\"math/45f2d2d1b7d524a8.svg\" alt=\"x_t\\to\\pi\" style=\"width:6.868ex;height:1.513ex\" loading=\"lazy\" decoding=\"async\"></span> from <em>any</em> starting distribution.</p>\r\n\r\n<h2>Method for any number of states</h2>\r\n<ol>\r\n<li>Write one balance equation per column: <span class=\"math-inline\"><img src=\"math/ea9b496718656056.svg\" alt=\"\\pi_j=\\sum_i\\pi_iP_{ij}\" style=\"width:13.54ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>.</li>\r\n<li>For the irreducible examples here, keep n−1 independent balance equations and add <span class=\"math-inline\"><img src=\"math/b39286a8c89942c9.svg\" alt=\"\\sum\\pi_i=1\" style=\"width:8.944ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</li>\r\n<li>Express every <span class=\"math-inline\"><img src=\"math/7e7e8c545536f6a2.svg\" alt=\"\\pi\" style=\"width:1.29ex;height:1ex\" loading=\"lazy\" decoding=\"async\"></span> in terms of one of them, then use the sum to find it.</li>\r\n</ol>\r\n<p><strong>Two-state shortcut.</strong> When a+b&gt;0, if <span class=\"math-inline\"><img src=\"math/3eacaa69615e9607.svg\" alt=\"P=\\begin{bmatrix}1-a&amp;a\\\\b&amp;1-b\\end{bmatrix}\" style=\"width:19.329ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span> then</p>\r\n<div class=\"math-display\"><img src=\"math/2511ae4b7c84ed79.svg\" alt=\"\\pi=\\left[\\frac{b}{a+b},\\;\\frac{a}{a+b}\\right]\" style=\"width:20.188ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Brand switching: <span class=\"math-inline\"><img src=\"math/6003dba221d13feb.svg\" alt=\"a=0.25,\\;b=0.40\\Rightarrow\\pi=[0.40/0.65,\\;0.25/0.65]=[0.6154,\\;0.3846]\" style=\"width:65.434ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. Bank: <span class=\"math-inline\"><img src=\"math/119a700d02c295a5.svg\" alt=\"a=0.2,\\;b=0.1\\Rightarrow\\pi=[1/3,\\;2/3]\" style=\"width:33.126ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n\r\n<h2>How to interpret a transition matrix (asked as a 2–3 mark part)</h2>\r\n<ul>\r\n<li><strong>Diagonal entries <span class=\"math-inline\"><img src=\"math/d21fe82fdd25b21f.svg\" alt=\"P_{ii}\" style=\"width:2.744ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></span></strong> = <strong>retention</strong>: the fraction that stays.</li>\r\n<li><strong>Off-diagonal entries <span class=\"math-inline\"><img src=\"math/fe1d46e7593684d1.svg\" alt=\"P_{ij}\" style=\"width:2.851ex;height:2.211ex\" loading=\"lazy\" decoding=\"async\"></span></strong> = <strong>transfer/loss</strong> from <span class=\"math-inline\"><img src=\"math/3c3a2b02c199adb2.svg\" alt=\"i\" style=\"width:0.781ex;height:1.52ex\" loading=\"lazy\" decoding=\"async\"></span> to <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span>; looking down column <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span> shows <strong>inflow (gain)</strong> into <span class=\"math-inline\"><img src=\"math/7a5268d94266eaaf.svg\" alt=\"j\" style=\"width:0.932ex;height:1.957ex\" loading=\"lazy\" decoding=\"async\"></span>.</li>\r\n<li><strong>Long-run gainer/loser</strong>: compare <span class=\"math-inline\"><img src=\"math/e0c070505a488343.svg\" alt=\"\\pi_j\" style=\"width:2.136ex;height:1.641ex\" loading=\"lazy\" decoding=\"async\"></span> with the current share. Larger → gains; smaller → loses.</li>\r\n<li>An <strong>absorbing state</strong> has <span class=\"math-inline\"><img src=\"math/698cf8e871a3b571.svg\" alt=\"P_{ii}=1\" style=\"width:6.892ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></span>: once entered it is never left.</li>\r\n</ul>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[part of 10 marks · Final Nov 2025 Q6b]</span></p>\r\n<div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/ad531c204822e0b1.svg\" alt=\"P=\\begin{bmatrix}0.6&amp;0.3&amp;0.1\\\\0.2&amp;0.5&amp;0.3\\\\0&amp;0.1&amp;0.9\\end{bmatrix}\" style=\"width:20.933ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><p>Row A is 0 + 0.1 + (0.8 + 0.1) = 1.</p><h4>To find</h4><p><span class=\"math-inline\"><img src=\"math/031664350e5c144f.svg\" alt=\"\\pi=[\\pi_B,\\pi_I,\\pi_A]\" style=\"width:15.229ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/690921434c640510.svg\" alt=\"\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:20.386ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><p>At stationarity each destination receives exactly its current share. Solve the balance equations together with the total-probability equation.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Column B balance</h5><div class=\"math-display\"><img src=\"math/445f3c8d74cadf82.svg\" alt=\"\\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\" style=\"width:59.894ex;height:1.877ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Column A balance</h5><div class=\"math-display\"><img src=\"math/15df96f89f27c195.svg\" alt=\"\\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\" style=\"width:80.633ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. Use the sum</h5><div class=\"math-display\"><img src=\"math/0d4ea6d007ce74ae.svg\" alt=\"\\pi_B+2\\pi_B+7\\pi_B=1\\;\\Rightarrow\\;\\pi_B=0.1,\\quad\\pi_I=0.2,\\quad\\pi_A=0.7\" style=\"width:56.709ex;height:1.968ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Check with column I</h5><div class=\"math-display\"><img src=\"math/6fea0316b61a8fc1.svg\" alt=\"0.3(0.1)+0.5(0.2)+0.1(0.7)=0.03+0.10+0.07=0.20=\\pi_I\\;\\checkmark\" style=\"width:63.631ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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.</div>\r\n<div class=\"keyfix\"><strong>Official key correction.</strong> The key prints 16.3%, 25.5%, 58.2%. Those numbers do not satisfy <span class=\"math-inline\"><img src=\"math/e595caf895fa199c.svg\" alt=\"\\pi=\\pi P\" style=\"width:7.295ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></span> (column B gives <span class=\"math-inline\"><img src=\"math/c4d46c0025cc2225.svg\" alt=\"0.6(0.163)+0.2(0.255)=0.149\\ne0.163\" style=\"width:38.718ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>). The correct steady state is 0.1, 0.2, 0.7.</div>\r\n</section>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[part of 10 marks · Final Nov 2025 Q5a]</span></p>\r\n<div class=\"given\"><h4>Given</h4><div class=\"math-display\"><img src=\"math/a6093f9acfe22fe1.svg\" alt=\"P=\\begin{bmatrix}0.60&amp;0.25&amp;0.15\\\\0.30&amp;0.50&amp;0.20\\\\0.20&amp;0.30&amp;0.50\\end{bmatrix}\" style=\"width:24.327ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><h4>To find</h4><p>Stationary shares and the requested comparison with the initial distribution.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/690921434c640510.svg\" alt=\"\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:20.386ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><p>At stationarity each destination receives exactly its current share. Solve the balance equations together with the total-probability equation.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Column P balance</h5><div class=\"math-display\"><img src=\"math/1708781ef111507a.svg\" alt=\"\\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\" style=\"width:53.25ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Column L balance</h5><div class=\"math-display\"><img src=\"math/5f029acce8c76d6c.svg\" alt=\"\\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\" style=\"width:57.161ex;height:1.88ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Substitute Step 1: <span class=\"math-inline\"><img src=\"math/bb6389f4842051c2.svg\" alt=\"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\" style=\"width:75.716ex;height:1.905ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<p>Then <span class=\"math-inline\"><img src=\"math/ea975cda05879034.svg\" alt=\"\\pi_P=0.75(1.36\\pi_R)+0.5\\pi_R=1.52\\,\\pi_R\" style=\"width:36.651ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p></div>\r\n<div class=\"step\"><h5>Step 3. Use the sum</h5><div class=\"math-display\"><img src=\"math/40a070a0bf109760.svg\" alt=\"(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\" style=\"width:76.05ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Exactly: <span class=\"math-inline\"><img src=\"math/3b7300b6febd286b.svg\" alt=\"\\pi=[38/97,\\;34/97,\\;25/97]\" style=\"width:25.803ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p></div>\r\n<div class=\"step\"><h5>Step 4. Compare with today's shares [0.50, 0.30, 0.20]</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>City</th><th>Today</th><th>Long run</th><th>Verdict</th></tr></thead><tbody><tr><td>Paris</td><td>0.50</td><td>0.392</td><td>Loses guests</td></tr><tr><td>London</td><td>0.30</td><td>0.351</td><td>Gains</td></tr><tr><td>Rome</td><td>0.20</td><td>0.258</td><td>Gains</td></tr></tbody></table></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/a2ee97608735415b.svg\" alt=\"\\pi\\approx[0.392,\\;0.351,\\;0.258]\" style=\"width:24.296ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: 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.)</div>\r\n</section>\r\n\r\n<h2>Other steady states from the papers</h2>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Question</th><th>Steady state</th><th>Compared with now</th></tr></thead><tbody>\r\n<tr><td>Brand X/Y (Final Q1d)</td><td>[8/13, 5/13] = [0.615, 0.385]</td><td>—</td></tr>\r\n<tr><td>Savings/Current (Re-exam Q1d)</td><td>[1/3, 2/3]</td><td>Current dominates</td></tr>\r\n<tr><td>Booking W, A, C (Re-exam Q5b)</td><td>[8/21, 1/3, 2/7] = [0.381, 0.333, 0.286]</td><td>Now [0.40, 0.35, 0.25]: Website and App shrink slightly; Counter grows.</td></tr>\r\n<tr><td>Aircraft A, B, C (Re-exam Q6b)</td><td>[25/63, 20/63, 2/7] = [0.397, 0.317, 0.286]</td><td>Now [0.3, 0.4, 0.3]: A gains; B loses; C loses slightly.</td></tr>\r\n</tbody></table></div>\r\n<div class=\"keyfix\"><strong>Official key correction (Re-exam Q5b).</strong> 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.</div>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Steady state = “ab kuch nahi badlega”: <span class=\"math-inline\"><img src=\"math/3ac2346fee4256a7.svg\" alt=\"\\pi = \\pi P\" style=\"width:7.295ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></span> aur total 1. Gain/loss = steady share vs aaj ka share.</div>"}]},{"id":"u4-bellman","title":"Unit 4 · MRP, MDP, policies and Bellman equations","unit":"4","scope":"Unit 4 · Markov reward process, Markov decision process, value functions, Bellman equations, applications","sections":[{"id":"mrp-return","title":"Markov reward process, return and discount","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Discounting changes the weight of later rewards</h2><p>γ (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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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 γ.</p>\r\n\r\n<h2>Definition</h2>\r\n<p>A <strong>Markov reward process (MRP)</strong> is a tuple <span class=\"math-inline\"><img src=\"math/1cf28b140fd79e47.svg\" alt=\"\\langle\\mathcal S,P,R,\\gamma\\rangle\" style=\"width:10.876ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>:</p>\r\n<ul>\r\n<li><span class=\"math-inline\"><img src=\"math/54f9d81745f0a6da.svg\" alt=\"\\mathcal S\" style=\"width:1.452ex;height:1.645ex\" loading=\"lazy\" decoding=\"async\"></span>: finite set of states; <span class=\"math-inline\"><img src=\"math/43eba13e48b4ac63.svg\" alt=\"P\" style=\"width:1.699ex;height:1.545ex\" loading=\"lazy\" decoding=\"async\"></span>: transition matrix, <span class=\"math-inline\"><img src=\"math/0ebf21d8b931d2d0.svg\" alt=\"P_{ss&#39;}=P(S_{t+1}=s&#39;\\mid S_t=s)\" style=\"width:27.08ex;height:2.283ex\" loading=\"lazy\" decoding=\"async\"></span>;</li>\r\n<li><span class=\"math-inline\"><img src=\"math/486a3031e7ac622b.svg\" alt=\"R\" style=\"width:1.717ex;height:1.593ex\" loading=\"lazy\" decoding=\"async\"></span>: reward function, <span class=\"math-inline\"><img src=\"math/bcb8b1797c06bfd8.svg\" alt=\"R(s)=\\mathbb E[R_{t+1}\\mid S_t=s]\" style=\"width:22.966ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (the expected reward for leaving <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span>);</li>\r\n<li><span class=\"math-inline\"><img src=\"math/389866bfd285136c.svg\" alt=\"\\gamma\\in[0,1]\" style=\"width:8.521ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: the <strong>discount factor</strong>.</li>\r\n</ul>\r\n<p>There are no actions yet; the process simply drifts and collects rewards. (Add actions and you get an MDP.)</p>\r\n\r\n<h2>Return</h2>\r\n<p>The <strong>return</strong> <span class=\"math-inline\"><img src=\"math/418bfe298764c6bc.svg\" alt=\"G_t\" style=\"width:2.544ex;height:1.952ex\" loading=\"lazy\" decoding=\"async\"></span> is the total discounted reward from time <span class=\"math-inline\"><img src=\"math/b84a36f811c3dd68.svg\" alt=\"t\" style=\"width:0.817ex;height:1.441ex\" loading=\"lazy\" decoding=\"async\"></span>:</p>\r\n<div class=\"math-display\"><img src=\"math/61d2488b0a270706.svg\" alt=\"G_t=R_{t+1}+\\gamma R_{t+2}+\\gamma^2R_{t+3}+\\dots=\\sum_{k=0}^{\\infty}\\gamma^kR_{t+k+1}\" style=\"width:49.283ex;height:6.399ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Why discount?</strong> (1) With bounded rewards, it keeps the infinite discounted sum finite when <span class=\"math-inline\"><img src=\"math/4ec13e93147870ec.svg\" alt=\"\\gamma&lt;1\" style=\"width:5.377ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>. (2) Future rewards are uncertain. (3) Immediate rewards are usually preferred (like interest on money). <span class=\"math-inline\"><img src=\"math/d06cb90e005f54d4.svg\" alt=\"\\gamma=0\" style=\"width:5.377ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span> makes the agent short-sighted (only the next reward counts); <span class=\"math-inline\"><img src=\"math/cd9ca536b7f46490.svg\" alt=\"\\gamma\\to1\" style=\"width:5.879ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span> makes it far-sighted.</p>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. An episode gives rewards <span class=\"math-inline\"><img src=\"math/49e74a4d062c7fe7.svg\" alt=\"R_1=-2,\\;R_2=-1,\\;R_3=-2,\\;R_4=0\" style=\"width:37.598ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></span> and then ends. Find <span class=\"math-inline\"><img src=\"math/5322d8ff87ec1002.svg\" alt=\"G_0\" style=\"width:2.766ex;height:1.97ex\" loading=\"lazy\" decoding=\"async\"></span> with <span class=\"math-inline\"><img src=\"math/c491a3a52610e919.svg\" alt=\"\\gamma=0.9\" style=\"width:7.137ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[practice · 2 marks]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>Rewards [−2,−1,−2,0]; discount γ=0.9; episode ends after the fourth reward.</p><h4>To find</h4><p>Return G₀.</p></div><h4>Formula and why it applies</h4><p>The first reward is undiscounted. Each later reward receives one extra factor of γ. <div class=\"math-display\"><img src=\"math/92c2d569c2ff0264.svg\" alt=\"G_0=R_1+\\gamma R_2+\\gamma^2R_3+\\gamma^3R_4\" style=\"width:30.792ex;height:2.489ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Write the discounted sum</h5><div class=\"math-display\"><img src=\"math/92c2d569c2ff0264.svg\" alt=\"G_0=R_1+\\gamma R_2+\\gamma^2R_3+\\gamma^3R_4\" style=\"width:30.792ex;height:2.489ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Substitute</h5><div class=\"math-display\"><img src=\"math/9a77a967b32f363f.svg\" alt=\"G_0=-2+0.9(-1)+0.81(-2)+0.729(0)=-2-0.9-1.62=-4.52\" style=\"width:68.388ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/54ecfef1a5e374f5.svg\" alt=\"G_0=-4.52\" style=\"width:11.566ex;height:1.97ex\" loading=\"lazy\" decoding=\"async\"></span>.</div>\r\n</section>\r\n\r\n<h2>State-value function of an MRP</h2>\r\n<p>The <strong>value</strong> of a state is the expected return when starting there:</p>\r\n<div class=\"math-display\"><img src=\"math/3a1a21a071450128.svg\" alt=\"v(s)=\\mathbb E\\,[\\,G_t\\mid S_t=s\\,]\" style=\"width:21.496ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The return of one episode is random; the value is its average over all possible futures.</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Return = aaj ka reward + γ × kal ka + γ² × parson ka… γ chhota = jaldi chahiye, γ bada = lambi soch.</div>\r\n\r\n<!-- depth:discount-0.5:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>An episode gives rewards [2, 4, 8] and then ends. Find the return from the start with γ=0.5.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Rewards in order: R₁=2, R₂=4, R₃=8. Discount factor γ=0.5. The episode then ends, so there are no later rewards.</p><h4>To find</h4><p>G₀: the discounted sum of all three rewards, measured from the start.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/7e7a8fe5c95dbdc8.svg\" alt=\"G_0=R_1+\\gamma R_2+\\gamma^2R_3\" style=\"width:22.99ex;height:2.489ex\" loading=\"lazy\" decoding=\"async\"></div><p>Keep the first reward undiscounted; multiply each later reward by the appropriate power.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First reward contribution</h5><div class=\"math-display\"><img src=\"math/c1fb0fa1e275d956.svg\" alt=\"1\\times(2)=2\" style=\"width:10.937ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second reward contribution</h5><div class=\"math-display\"><img src=\"math/8f4e70094d023847.svg\" alt=\"0.5\\times(4)=2\" style=\"width:12.697ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Third reward contribution</h5><div class=\"math-display\"><img src=\"math/d314ab19535cf0b6.svg\" alt=\"0.5^2\\times(8)=2\" style=\"width:13.685ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add contributions</h5><div class=\"math-display\"><img src=\"math/f58d97b5beb6cfcc.svg\" alt=\"G_0=(2)+(2)+(2)=6\" style=\"width:24.137ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 6.</div></section></div>\r\n<!-- depth:discount-0.5:end -->\r\n<!-- depth:discount-0.9:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>An episode gives rewards [-1, 5, 2] and then ends. Find the return from the start with γ=0.9.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Rewards in order: R₁=-1, R₂=5, R₃=2. Discount factor γ=0.9. The episode then ends, so there are no later rewards.</p><h4>To find</h4><p>G₀: the discounted sum of all three rewards, measured from the start.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/7e7a8fe5c95dbdc8.svg\" alt=\"G_0=R_1+\\gamma R_2+\\gamma^2R_3\" style=\"width:22.99ex;height:2.489ex\" loading=\"lazy\" decoding=\"async\"></div><p>Keep the first reward undiscounted; multiply each later reward by the appropriate power.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First reward contribution</h5><div class=\"math-display\"><img src=\"math/01d91edc60cbc82c.svg\" alt=\"1\\times(-1)=-1\" style=\"width:14.457ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second reward contribution</h5><div class=\"math-display\"><img src=\"math/307a4fc23f4ba8e0.svg\" alt=\"0.9\\times(5)=4.5\" style=\"width:14.457ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Third reward contribution</h5><div class=\"math-display\"><img src=\"math/b276421b6d8cf042.svg\" alt=\"0.9^2\\times(2)=1.62\" style=\"width:16.576ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add contributions</h5><div class=\"math-display\"><img src=\"math/dc498059f2b74dca.svg\" alt=\"G_0=(-1)+(4.5)+(1.62)=5.12\" style=\"width:33.44ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 5.12.</div></section></div>\r\n<!-- depth:discount-0.9:end -->\r\n<!-- depth:discount-0:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>An episode gives rewards [2, 4, 8] and then ends. Find the return from the start with γ=0.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Rewards in order: R₁=2, R₂=4, R₃=8. Discount factor γ=0. The episode then ends, so there are no later rewards.</p><h4>To find</h4><p>G₀: the discounted sum of all three rewards, measured from the start.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/7e7a8fe5c95dbdc8.svg\" alt=\"G_0=R_1+\\gamma R_2+\\gamma^2R_3\" style=\"width:22.99ex;height:2.489ex\" loading=\"lazy\" decoding=\"async\"></div><p>Keep the first reward undiscounted; multiply each later reward by the appropriate power.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First reward contribution</h5><div class=\"math-display\"><img src=\"math/c1fb0fa1e275d956.svg\" alt=\"1\\times(2)=2\" style=\"width:10.937ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second reward contribution</h5><div class=\"math-display\"><img src=\"math/2e86b7550d7cec9c.svg\" alt=\"0\\times(4)=0\" style=\"width:10.937ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Third reward contribution</h5><div class=\"math-display\"><img src=\"math/3f0045412e0c9af2.svg\" alt=\"0^2\\times(8)=0\" style=\"width:11.924ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add contributions</h5><div class=\"math-display\"><img src=\"math/6433acabcea5b54f.svg\" alt=\"G_0=(2)+(0)+(0)=2\" style=\"width:24.137ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 2.</div></section></div>\r\n<!-- depth:discount-0:end -->"},{"id":"bellman-mrp","title":"Bellman equation for an MRP (with a solved example)","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Immediate reward plus discounted expected next value.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/811e452127929f3e.svg\" alt=\"v(s)=R(s)+\\gamma\\sum_{s&#39;}P(s&#39;\\mid s)v(s&#39;)\" style=\"width:32.131ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div><p>s′ is read “next state”; the prime is not a derivative. The sum is a weighted average of next-state values.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. First branch contribution</h5><div class=\"math-display\"><img src=\"math/6862aff895141018.svg\" alt=\"0.6\\times10=6\" style=\"width:12.068ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Second branch contribution</h5><div class=\"math-display\"><img src=\"math/2711ae2397112a4c.svg\" alt=\"0.4\\times0=0\" style=\"width:10.937ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Average, then discount</h5><div class=\"math-display\"><img src=\"math/386c4e1d4519186c.svg\" alt=\"6+0=6\\qquad0.5\\times6=3\" style=\"width:24.638ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Add immediate reward</h5><div class=\"math-display\"><img src=\"math/aed5ac659044d3f1.svg\" alt=\"v(s)=2+3=5\" style=\"width:16.112ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> v(s)=5.</div></section><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> the value of a state = the reward you get now + γ × the average value of where you land next.</p>\r\n\r\n<h2>Derivation (short and examinable)</h2>\r\n<div class=\"math-display\"><img src=\"math/b890be2892d436ac.svg\" alt=\"\\begin{aligned}v(s)&amp;=\\mathbb E[G_t\\mid S_t=s]\\\\&amp;=\\mathbb E[R_{t+1}+\\gamma(R_{t+2}+\\gamma R_{t+3}+\\dots)\\mid S_t=s]\\\\&amp;=\\mathbb E[R_{t+1}+\\gamma G_{t+1}\\mid S_t=s]\\\\&amp;=R(s)+\\gamma\\sum_{s&#39;\\in\\mathcal S}P_{ss&#39;}\\,v(s&#39;)\\end{aligned}\" style=\"width:46.566ex;height:13.787ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The key step is <span class=\"math-inline\"><img src=\"math/837aecc6afff8d86.svg\" alt=\"G_t=R_{t+1}+\\gamma G_{t+1}\" style=\"width:18.67ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>: 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.</p>\r\n<p><strong>Matrix form.</strong> Stack the values in a column <span class=\"math-inline\"><img src=\"math/fe332ce60af0f3c3.svg\" alt=\"v\" style=\"width:1.097ex;height:1.027ex\" loading=\"lazy\" decoding=\"async\"></span>: <span class=\"math-inline\"><img src=\"math/8248280819c17d38.svg\" alt=\"v=R+\\gamma Pv\\Rightarrow (I-\\gamma P)v=R\\Rightarrow v=(I-\\gamma P)^{-1}R\" style=\"width:50.744ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span>. For small problems just solve the linear equations.</p>\r\n\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mrp_student.be69eb4eb6.svg\" width=\"600\" height=\"300\" alt=\"Done is terminal (it loops to itself with reward 0), so v(Done) = 0.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Done is terminal (it loops to itself with reward 0), so v(Done) = 0.</figcaption></figure>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>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 <span class=\"math-inline\"><img src=\"math/c491a3a52610e919.svg\" alt=\"\\gamma=0.9\" style=\"width:7.137ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, find v(Class) and v(Lab).</strong> <span class=\"marks\">[practice · 5 marks]</span></p>\r\n<div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/b06d57b864effc2d.svg\" alt=\"R(C)=-2,\\;R(L)=-1,\\;v(D)=0,\\;\\gamma=0.9\" style=\"width:42.953ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p><span class=\"math-inline\"><img src=\"math/3d1e99a2714e55b1.svg\" alt=\"v(C),\\;v(L)\" style=\"width:10.61ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p></div>\r\n<h4>Formula and why it applies</h4>\r\n<div class=\"math-display\"><img src=\"math/eb908cf2d66f9fa5.svg\" alt=\"v(s)=R(s)+\\gamma\\sum_{s&#39;}P_{ss&#39;}v(s&#39;)\" style=\"width:27.62ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>It holds for every state, so we get one equation per non-terminal state.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Equation for Class</h5><div class=\"math-display\"><img src=\"math/c27d02b92c11fd77.svg\" alt=\"v(C)=-2+0.9\\,[\\,0.5\\,v(L)+0.5\\,(0)\\,]=-2+0.45\\,v(L)\" style=\"width:52.601ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Equation for Lab</h5><div class=\"math-display\"><img src=\"math/7b9d5ae6e490a014.svg\" alt=\"v(L)=-1+0.9\\,[\\,0.4\\,v(C)+0.6\\,(0)\\,]=-1+0.36\\,v(C)\" style=\"width:52.779ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. Substitute Step 2 into Step 1</h5><div class=\"math-display\"><img src=\"math/ebb39216a5765bf5.svg\" alt=\"v(C)=-2+0.45(-1+0.36\\,v(C))=-2.45+0.162\\,v(C)\\Rightarrow0.838\\,v(C)=-2.45\" style=\"width:77.77ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Solve</h5><div class=\"math-display\"><img src=\"math/2b295ea148a86b91.svg\" alt=\"v(C)=\\frac{-2.45}{0.838}=-2.9236,\\qquad v(L)=-1+0.36(-2.9236)=-2.0525\" style=\"width:68.928ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 5. Check Class</h5><div class=\"math-display\"><img src=\"math/6e971d442b2340c9.svg\" alt=\"-2+0.45(-2.0525)=-2-0.9236=-2.9236\\;\\checkmark\" style=\"width:48.02ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/c86b63e5ffd55eb7.svg\" alt=\"v(\\text{Class})\\approx-2.924,\\;v(\\text{Lab})\\approx-2.053,\\;v(\\text{Done})=0\" style=\"width:49.955ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. Lab is “less bad” because it is more likely to finish quickly.</div>\r\n</section>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Bellman = “abhi ka reward + γ × aage ka average value”. Har state ki ek equation, phir solve.</div>\r\n\r\n<!-- depth:algebra:start -->\r\n<div class=\"concept-bridge\"><h2>The substitution algebra in slow motion</h2><div class=\"math-display\"><img src=\"math/637ce97b6476a63f.svg\" alt=\"v_C=-2+0.45(-1+0.36v_C)\" style=\"width:29.139ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Multiply .45 into both bracket terms: .45×(−1)=−.45 and .45×.36=.162.</p><div class=\"math-display\"><img src=\"math/bd1b2a47575bc95d.svg\" alt=\"v_C=-2-0.45+0.162v_C=-2.45+0.162v_C\" style=\"width:44.839ex;height:1.906ex\" loading=\"lazy\" decoding=\"async\"></div><p>Subtract .162vC from both sides; the coefficient on the left is 1−.162=.838.</p><div class=\"math-display\"><img src=\"math/591d6eadcfd21cd8.svg\" alt=\"0.838v_C=-2.45\\quad\\Rightarrow\\quad v_C=-2.45/0.838\\approx-2.923627685\" style=\"width:58.803ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Now use the Lab equation: .36×(−2.923627685)≈−1.052505967; adding −1 gives vL≈−2.052505967.</p></div>\r\n<!-- depth:algebra:end -->"},{"id":"mdp-policy","title":"Markov decision process, policies and value functions","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><table><thead><tr><th>Read this</th><th>Meaning</th><th>Concrete example</th></tr></thead><tbody><tr><td>π(a|s)</td><td>Probability the policy chooses action a in state s</td><td>In room A: left .3, right .7</td></tr><tr><td>P(s′|s,a)</td><td>Probability of the environment’s next state after that action</td><td>Right action reaches room B with probability .8</td></tr><tr><td>vπ(s)</td><td>Expected return starting in state s and following policy π</td><td>A number scoring the state</td></tr><tr><td>qπ(s,a)</td><td>Expected return if action a is taken first, then policy π is followed</td><td>One score for each possible first action</td></tr><tr><td>π in this chapter</td><td>A policy</td><td>Unlike π in a Markov-chain stationary distribution; context distinguishes them</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>Markov decision process</h2>\r\n<p>A <strong>Markov decision process (MDP)</strong> is a tuple <span class=\"math-inline\"><img src=\"math/2a8c7332f3030a47.svg\" alt=\"\\langle\\mathcal S,\\mathcal A,P,R,\\gamma\\rangle\" style=\"width:13.735ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>:</p>\r\n<ul>\r\n<li><span class=\"math-inline\"><img src=\"math/54f9d81745f0a6da.svg\" alt=\"\\mathcal S\" style=\"width:1.452ex;height:1.645ex\" loading=\"lazy\" decoding=\"async\"></span>: states; <span class=\"math-inline\"><img src=\"math/ce88a93ac568728b.svg\" alt=\"\\mathcal A\" style=\"width:1.853ex;height:1.76ex\" loading=\"lazy\" decoding=\"async\"></span>: actions;</li>\r\n<li><span class=\"math-inline\"><img src=\"math/9a04b612a1d5ca7f.svg\" alt=\"P^{a}_{ss&#39;}=P(S_{t+1}=s&#39;\\mid S_t=s,A_t=a)\" style=\"width:34.762ex;height:2.431ex\" loading=\"lazy\" decoding=\"async\"></span>: transition probabilities, now depending on the action;</li>\r\n<li><span class=\"math-inline\"><img src=\"math/5d475467732358d0.svg\" alt=\"R^{a}_{s}=\\mathbb E[R_{t+1}\\mid S_t=s,A_t=a]\" style=\"width:28.861ex;height:2.272ex\" loading=\"lazy\" decoding=\"async\"></span>: expected reward for taking <span class=\"math-inline\"><img src=\"math/2d4a1257492be872.svg\" alt=\"a\" style=\"width:1.197ex;height:1.02ex\" loading=\"lazy\" decoding=\"async\"></span> in <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span>;</li>\r\n<li><span class=\"math-inline\"><img src=\"math/8a226d1a655f7384.svg\" alt=\"\\gamma\" style=\"width:1.229ex;height:1.486ex\" loading=\"lazy\" decoding=\"async\"></span>: discount factor.</li>\r\n</ul>\r\n<p>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.</p>\r\n\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mdp_two.331bc03880.svg\" width=\"620\" height=\"300\" alt=\"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).\" loading=\"lazy\" decoding=\"async\"></div><figcaption>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).</figcaption></figure>\r\n\r\n<h2>Policy</h2>\r\n<p>A <strong>policy</strong> <span class=\"math-inline\"><img src=\"math/7e7e8c545536f6a2.svg\" alt=\"\\pi\" style=\"width:1.29ex;height:1ex\" loading=\"lazy\" decoding=\"async\"></span> is a distribution over actions given states:</p>\r\n<div class=\"math-display\"><img src=\"math/3bcff52e9ca32562.svg\" alt=\"\\pi(a\\mid s)=P(A_t=a\\mid S_t=s)\" style=\"width:28.462ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<ul><li><strong>Deterministic</strong> policy: one fixed action per state, <span class=\"math-inline\"><img src=\"math/c6437d9ecddc37a5.svg\" alt=\"a=\\pi(s)\" style=\"width:8.325ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</li><li><strong>Stochastic</strong> policy: probabilities, e.g. <span class=\"math-inline\"><img src=\"math/6b25a58130fefd91.svg\" alt=\"\\pi(\\text{stay}\\mid s_1)=0.5,\\;\\pi(\\text{go}\\mid s_1)=0.5\" style=\"width:33.781ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</li></ul>\r\n<p>The policies used in these examples are stationary Markov policies. The term policy more generally also permits time-dependent or history-dependent decision rules.</p>\r\n\r\n<h2>Value functions</h2>\r\n<p><strong>State-value function</strong>: expected return from state <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span> when following <span class=\"math-inline\"><img src=\"math/7e7e8c545536f6a2.svg\" alt=\"\\pi\" style=\"width:1.29ex;height:1ex\" loading=\"lazy\" decoding=\"async\"></span>:</p>\r\n<div class=\"math-display\"><img src=\"math/ca7b3acce010f57a.svg\" alt=\"v_\\pi(s)=\\mathbb E_\\pi[G_t\\mid S_t=s]\" style=\"width:22.562ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Action-value function (Q-function)</strong>: expected return when taking action <span class=\"math-inline\"><img src=\"math/2d4a1257492be872.svg\" alt=\"a\" style=\"width:1.197ex;height:1.02ex\" loading=\"lazy\" decoding=\"async\"></span> in <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span> and following <span class=\"math-inline\"><img src=\"math/7e7e8c545536f6a2.svg\" alt=\"\\pi\" style=\"width:1.29ex;height:1ex\" loading=\"lazy\" decoding=\"async\"></span> afterwards:</p>\r\n<div class=\"math-display\"><img src=\"math/830f0f5268ecd933.svg\" alt=\"q_\\pi(s,a)=\\mathbb E_\\pi[G_t\\mid S_t=s,A_t=a]\" style=\"width:32.358ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>They are linked by averaging over the policy's choices:</p>\r\n<div class=\"math-display\"><img src=\"math/9ede9bf563f2c6c9.svg\" alt=\"v_\\pi(s)=\\sum_{a\\in\\mathcal A}\\pi(a\\mid s)\\,q_\\pi(s,a)\" style=\"width:26.384ex;height:5.016ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Optimal</strong> value functions take the best policy: <span class=\"math-inline\"><img src=\"math/ed035ab67f88529a.svg\" alt=\"v_*(s)=\\max_\\pi v_\\pi(s)\" style=\"width:18.629ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/c4640b6ec47433ce.svg\" alt=\"q_*(s,a)=\\max_\\pi q_\\pi(s,a)\" style=\"width:22.858ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. An optimal policy acts greedily on <span class=\"math-inline\"><img src=\"math/3ccaa9f377c85da8.svg\" alt=\"q_*\" style=\"width:1.997ex;height:1.439ex\" loading=\"lazy\" decoding=\"async\"></span>: <span class=\"math-inline\"><img src=\"math/f3cf791d9745c384.svg\" alt=\"\\pi_*(s)=\\arg\\max_a q_*(s,a)\" style=\"width:24.284ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>Markov process</th><th>MRP</th><th>MDP</th></tr></thead><tbody>\r\n<tr><td>Tuple</td><td><span class=\"math-inline\"><img src=\"math/f25474192d3bf3f0.svg\" alt=\"\\langle\\mathcal S,P\\rangle\" style=\"width:5.918ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td><td><span class=\"math-inline\"><img src=\"math/1cf28b140fd79e47.svg\" alt=\"\\langle\\mathcal S,P,R,\\gamma\\rangle\" style=\"width:10.876ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td><td><span class=\"math-inline\"><img src=\"math/2a8c7332f3030a47.svg\" alt=\"\\langle\\mathcal S,\\mathcal A,P,R,\\gamma\\rangle\" style=\"width:13.735ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Rewards</td><td>No</td><td>Yes</td><td>Yes</td></tr>\r\n<tr><td>Decisions</td><td>No</td><td>No</td><td>Yes (actions)</td></tr>\r\n<tr><td>Value</td><td>—</td><td><span class=\"math-inline\"><img src=\"math/214f0238bdf479cc.svg\" alt=\"v(s)\" style=\"width:3.919ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td><td><span class=\"math-inline\"><img src=\"math/16476f59173bd3a8.svg\" alt=\"v_\\pi(s),\\;q_\\pi(s,a)\" style=\"width:13.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n</tbody></table></div>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> MP → +reward = MRP → +action = MDP. v = “state kitni achhi”, q = “is state mein yeh action kitna achha”.</div>"},{"id":"bellman-equations","title":"Bellman expectation and optimality equations (worked)","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[2 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>Action values: Left=3 and Right=7. Policy probabilities: Left=0.25 and Right=0.75. The supplied action values already include subsequent returns.</p><h4>To find</h4><p>A weighted average, a maximum and the label attaining that maximum.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/46eb24952a8c1ab7.svg\" alt=\"v_\\pi(s)=\\sum_a\\pi(a\\mid s)q_\\pi(s,a)\" style=\"width:26.006ex;height:4.767ex\" loading=\"lazy\" decoding=\"async\"></div><p>The expectation averages according to policy; maximisation selects a largest action score.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Weight Left</h5><div class=\"math-display\"><img src=\"math/653f73dba2be3445.svg\" alt=\"0.25\\times3=0.75\" style=\"width:14.959ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Weight Right</h5><div class=\"math-display\"><img src=\"math/5c142a10f628b6eb.svg\" alt=\"0.75\\times7=5.25\" style=\"width:14.959ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Add for the policy value</h5><div class=\"math-display\"><img src=\"math/c56792e7802f455e.svg\" alt=\"v_\\pi=0.75+5.25=6\" style=\"width:20.173ex;height:1.886ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Read max and argmax</h5><p>max(3,7)=7 is a number. argmax is Right, the action with that number.</p></div><div class=\"answer\"><strong>Final answer.</strong> Policy value 6; maximum action value 7; greedy action Right.</div></section></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> the expectation equations score a given policy; the optimality equations replace the policy's average by a max and describe the best possible behaviour.</p>\r\n\r\n<h2>Bellman expectation equations</h2>\r\n<p>Split the return into “reward now + discounted value later”, and average over the policy and the environment:</p>\r\n<div class=\"math-display\"><img src=\"math/7b8a3aea9af35f5f.svg\" alt=\"v_\\pi(s)=\\sum_{a}\\pi(a\\mid s)\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,\\big[\\,R(s,a,s&#39;)+\\gamma\\,v_\\pi(s&#39;)\\,\\big]\" style=\"width:55.666ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/4789f0f7def0f243.svg\" alt=\"q_\\pi(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,\\Big[\\,R(s,a,s&#39;)+\\gamma\\sum_{a&#39;}\\pi(a&#39;\\mid s&#39;)\\,q_\\pi(s&#39;,a&#39;)\\,\\Big]\" style=\"width:62.028ex;height:5.335ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Read the first one aloud: <em>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.</em></p>\r\n\r\n<h2>Bellman optimality equations</h2>\r\n<div class=\"math-display\"><img src=\"math/9a59f92e2e358c6a.svg\" alt=\"v_*(s)=\\max_{a}\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,\\big[\\,R(s,a,s&#39;)+\\gamma\\,v_*(s&#39;)\\,\\big]\" style=\"width:48.815ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/6f856204425ff6bb.svg\" alt=\"q_*(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,\\big[\\,R(s,a,s&#39;)+\\gamma\\max_{a&#39;}q_*(s&#39;,a&#39;)\\,\\big]\" style=\"width:53.672ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The only change is <span class=\"math-inline\"><img src=\"math/935b09896577bd3b.svg\" alt=\"\\sum_a\\pi(a\\mid s)\\to\\max_a\" style=\"width:19.758ex;height:2.358ex\" loading=\"lazy\" decoding=\"async\"></span>: 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).</p>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. In the two-state MDP (figure in the previous lesson), s₂ is terminal with <span class=\"math-inline\"><img src=\"math/14eba4db728727d6.svg\" alt=\"v(s_2)=0\" style=\"width:9.055ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/c491a3a52610e919.svg\" alt=\"\\gamma=0.9\" style=\"width:7.137ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>. 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 <span class=\"math-inline\"><img src=\"math/05a49a1a1019f0f7.svg\" alt=\"v_\\pi(s_1)\" style=\"width:6.006ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> for the random policy <span class=\"math-inline\"><img src=\"math/8c95286b27a764a3.svg\" alt=\"\\pi(\\text{stay})=\\pi(\\text{go})=0.5\" style=\"width:21.385ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. (b) Find <span class=\"math-inline\"><img src=\"math/ba05a03037bd4feb.svg\" alt=\"v_*(s_1)\" style=\"width:5.894ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and the optimal action.</strong> <span class=\"marks\">[practice · 6 marks]</span></p>\r\n<div class=\"given\"><h4>Given</h4><p><span class=\"math-inline\"><img src=\"math/bebd3888f239dad7.svg\" alt=\"q(s_1,\\text{stay})=1+0.9\\,v(s_1)\" style=\"width:25.042ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>; <span class=\"math-inline\"><img src=\"math/3b7159339f0c3987.svg\" alt=\"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)\" style=\"width:61.051ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p>The value under the random policy, the optimal value and the optimal action.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/a5e70ba1f7aaa949.svg\" alt=\"v_\\pi(s)=\\sum_a\\pi(a\\mid s)q_\\pi(s,a),\\qquad v_*(s)=\\max_a q_*(s,a)\" style=\"width:51.068ex;height:4.767ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. (a) Expectation equation for the random policy</h5><div class=\"math-display\"><img src=\"math/0b711572c2407738.svg\" alt=\"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\" style=\"width:80.255ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. (b) Try “go” always</h5><div class=\"math-display\"><img src=\"math/c5eca38ec463b77a.svg\" alt=\"v=4+0.18v\\Rightarrow v=4/0.82=4.878\" style=\"width:35.221ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Check whether switching helps: <span class=\"math-inline\"><img src=\"math/0eff67e823e28a45.svg\" alt=\"q(\\text{stay})=1+0.9(4.878)=5.390&gt;4.878\" style=\"width:39.96ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. So “go” is not optimal.</p></div>\r\n<div class=\"step\"><h5>Step 3. Try “stay” always</h5><div class=\"math-display\"><img src=\"math/1f1b525d33de57d2.svg\" alt=\"v=1+0.9v\\Rightarrow v=10\" style=\"width:21.896ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><p>Check: <span class=\"math-inline\"><img src=\"math/15cfa2584493bce2.svg\" alt=\"q(\\text{go})=4+0.18(10)=5.8&lt;10=q(\\text{stay})\" style=\"width:41.126ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. No improvement possible.</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> (a) <span class=\"math-inline\"><img src=\"math/80d83715ae3f22a7.svg\" alt=\"v_\\pi(s_1)\\approx5.43\" style=\"width:13.046ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. (b) <span class=\"math-inline\"><img src=\"math/379f03e15709665d.svg\" alt=\"v_*(s_1)=10\" style=\"width:11.173ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> with <span class=\"math-inline\"><img src=\"math/26abf1418e7a596a.svg\" alt=\"q_*(s_1,\\text{stay})=10\" style=\"width:16.189ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/defe0522e073671d.svg\" alt=\"q_*(s_1,\\text{go})=5.8\" style=\"width:14.983ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: the optimal action is <strong>stay</strong>. A steady +1 forever is worth <span class=\"math-inline\"><img src=\"math/ad897de8c397fc5d.svg\" alt=\"1/(1-0.9)=10\" style=\"width:16.09ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, more than a one-time +5.</div>\r\n</section>\r\n\r\n<h2>Seeing the max at work: value iteration</h2>\r\n<p>Start with <span class=\"math-inline\"><img src=\"math/392369c0ba50f924.svg\" alt=\"v_0(s_1)=0\" style=\"width:10.042ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and apply the optimality equation repeatedly: <span class=\"math-inline\"><img src=\"math/db13b37224954848.svg\" alt=\"v_{k+1}=\\max(1+0.9v_k,\\;4+0.18v_k)\" style=\"width:33.731ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"table-wrap\"><table><thead><tr><th>k</th><th>stay = 1 + 0.9vₖ</th><th>go = 4 + 0.18vₖ</th><th>vₖ₊₁</th><th>best</th></tr></thead><tbody>\r\n<tr><td>0</td><td>1.000</td><td>4.000</td><td>4.000</td><td>go</td></tr>\r\n<tr><td>1</td><td>4.600</td><td>4.720</td><td>4.720</td><td>go</td></tr>\r\n<tr><td>2</td><td>5.248</td><td>4.850</td><td>5.248</td><td>stay</td></tr>\r\n<tr><td>3</td><td>5.723</td><td>4.945</td><td>5.723</td><td>stay</td></tr>\r\n<tr><td>…</td><td colspan=\"2\">converges</td><td>10</td><td>stay</td></tr>\r\n</tbody></table></div>\r\n<p>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.</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Expectation = policy ka average (Σπ). Optimality = best action (max). Baaki sab same: reward + γ × next value.</div>\r\n\r\n<!-- depth:policy-algebra:start -->\r\n<div class=\"concept-bridge\"><h2>Expand the random-policy equation</h2><p>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.</p><div class=\"math-display\"><img src=\"math/886e804c14fdc761.svg\" alt=\"v=0.5(1+0.9v)+0.5(4+0.18v)\" style=\"width:33.086ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6e4eca135d9eae35.svg\" alt=\"v=0.5+0.45v+2+0.09v=2.5+0.54v\" style=\"width:40.468ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><p>Subtract .54v from both sides, then divide by .46.</p><div class=\"math-display\"><img src=\"math/294b5e0b255011dd.svg\" alt=\"(1-0.54)v=2.5\\quad0.46v=2.5\\quad v=2.5/0.46\\approx5.434782609\" style=\"width:59.357ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:policy-algebra:end -->"},{"id":"solving","title":"Using Bellman equations: policy and value iteration","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>A <strong>backup</strong> 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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<p class=\"cue\"><strong>In one line:</strong> 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.</p>\r\n\r\n<h2>1. Policy evaluation</h2>\r\n<p>Given <span class=\"math-inline\"><img src=\"math/7e7e8c545536f6a2.svg\" alt=\"\\pi\" style=\"width:1.29ex;height:1ex\" loading=\"lazy\" decoding=\"async\"></span>, compute <span class=\"math-inline\"><img src=\"math/59ce33a75ce0983e.svg\" alt=\"v_\\pi\" style=\"width:2.197ex;height:1.359ex\" loading=\"lazy\" decoding=\"async\"></span> by repeatedly applying the expectation equation until values stop changing:</p>\r\n<div class=\"math-display\"><img src=\"math/3bbeb8acbcb4f4f5.svg\" alt=\"v_{k+1}(s)\\leftarrow\\sum_a\\pi(a\\mid s)\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma v_k(s&#39;)]\" style=\"width:48.575ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h2>2. Policy iteration</h2>\r\n<div class=\"flow\"><div class=\"node\">Start with any policy π</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Evaluate: find <span class=\"math-inline\"><img src=\"math/59ce33a75ce0983e.svg\" alt=\"v_\\pi\" style=\"width:2.197ex;height:1.359ex\" loading=\"lazy\" decoding=\"async\"></span></div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Improve: <span class=\"math-inline\"><img src=\"math/d82f4ea4f553e1e7.svg\" alt=\"\\pi&#39;(s)=\\arg\\max_a q_\\pi(s,a)\" style=\"width:24.036ex;height:2.283ex\" loading=\"lazy\" decoding=\"async\"></span></div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Repeat until the policy stops changing</div></div>\r\n<p>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.</p>\r\n\r\n<h2>3. Value iteration</h2>\r\n<p>Skip full evaluation; apply the optimality equation directly:</p>\r\n<div class=\"math-display\"><img src=\"math/b41a10ce7769c4dd.svg\" alt=\"v_{k+1}(s)\\leftarrow\\max_a\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma v_k(s&#39;)]\" style=\"width:41.948ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Stop when the change is tiny, then act greedily. The table in the previous lesson is value iteration on one state.</p>\r\n\r\n<details class=\"optional-extension\"><summary>Optional extension: Q-learning (not an observed PYQ)</summary><p>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.</p><h2>Q-learning</h2><p>Q-learning is included to illustrate a Bellman target; it is not separately named in the supplied introductory RL syllabus.</p>\r\n<p>When <span class=\"math-inline\"><img src=\"math/43eba13e48b4ac63.svg\" alt=\"P\" style=\"width:1.699ex;height:1.545ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/486a3031e7ac622b.svg\" alt=\"R\" style=\"width:1.717ex;height:1.593ex\" loading=\"lazy\" decoding=\"async\"></span> are unknown, the agent learns <span class=\"math-inline\"><img src=\"math/3ccaa9f377c85da8.svg\" alt=\"q_*\" style=\"width:1.997ex;height:1.439ex\" loading=\"lazy\" decoding=\"async\"></span> from its own experience <span class=\"math-inline\"><img src=\"math/fc6fae0a339bc5e8.svg\" alt=\"(s,a,r,s&#39;)\" style=\"width:9.745ex;height:2.283ex\" loading=\"lazy\" decoding=\"async\"></span>:</p>\r\n<div class=\"math-display\"><img src=\"math/d6e7feae89b08cf3.svg\" alt=\"Q(s,a)\\leftarrow Q(s,a)+\\alpha\\,\\big[\\,r+\\gamma\\max_{a&#39;}Q(s&#39;,a&#39;)-Q(s,a)\\,\\big]\" style=\"width:52.009ex;height:3.663ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><span class=\"math-inline\"><img src=\"math/ca2ff9ceb2ebf0ae.svg\" alt=\"\\alpha\" style=\"width:1.448ex;height:1.025ex\" loading=\"lazy\" decoding=\"async\"></span> is the learning rate. The bracket is the <strong>temporal-difference error</strong>: (Bellman target) − (current guess). The agent usually explores with ε-greedy actions while learning.</p>\r\n\r\n<section class=\"example\">\r\n<p class=\"question\"><strong>Question. A Q-table has <span class=\"math-inline\"><img src=\"math/efb25431f54f8edc.svg\" alt=\"Q(s,a)=2\" style=\"width:10.962ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The agent takes <span class=\"math-inline\"><img src=\"math/2d4a1257492be872.svg\" alt=\"a\" style=\"width:1.197ex;height:1.02ex\" loading=\"lazy\" decoding=\"async\"></span> in <span class=\"math-inline\"><img src=\"math/92329599456283d6.svg\" alt=\"s\" style=\"width:1.061ex;height:1.023ex\" loading=\"lazy\" decoding=\"async\"></span>, receives <span class=\"math-inline\"><img src=\"math/e61c4165fe299ce3.svg\" alt=\"r=3\" style=\"width:5.169ex;height:1.69ex\" loading=\"lazy\" decoding=\"async\"></span> and lands in <span class=\"math-inline\"><img src=\"math/45840389386c62f8.svg\" alt=\"s&#39;\" style=\"width:1.689ex;height:1.74ex\" loading=\"lazy\" decoding=\"async\"></span> where <span class=\"math-inline\"><img src=\"math/3f677ab805df68d2.svg\" alt=\"\\max_{a&#39;}Q(s&#39;,a&#39;)=5\" style=\"width:18.283ex;height:2.283ex\" loading=\"lazy\" decoding=\"async\"></span>. With <span class=\"math-inline\"><img src=\"math/32cf597702a3bb21.svg\" alt=\"\\alpha=0.5,\\;\\gamma=0.9\" style=\"width:16.128ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, find the updated <span class=\"math-inline\"><img src=\"math/0caba73ef360f772.svg\" alt=\"Q(s,a)\" style=\"width:6.814ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</strong> <span class=\"marks\">[Optional authored example]</span></p><div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>Old Q=2, reward=3, best next-state Q=5, α=0.5, γ=0.9; the next state is nonterminal.</p><h4>To find</h4><p>The updated Q estimate.</p></div><h4>Formula and why it applies</h4><p>Move partway from the old estimate toward the one-step Bellman target. <div class=\"math-display\"><img src=\"math/bf626aee4ce371f4.svg\" alt=\"Q_{new}=Q_{old}+\\alpha[r+\\gamma\\max Q_{next}-Q_{old}]\" style=\"width:39.361ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Target</h5><div class=\"math-display\"><img src=\"math/9f91a54deb2a51d6.svg\" alt=\"r+\\gamma\\max_{a&#39;}Q(s&#39;,a&#39;)=3+0.9(5)=7.5\" style=\"width:36.654ex;height:3.571ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Update</h5><div class=\"math-display\"><img src=\"math/fb6236e8c0963234.svg\" alt=\"Q\\leftarrow2+0.5(7.5-2)=2+2.75=4.75\" style=\"width:38.622ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/12b09999f026b089.svg\" alt=\"Q(s,a)=4.75\" style=\"width:13.853ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</div>\r\n</section>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Model pata hai → policy/value iteration. Model nahi pata → Q-learning (experience se seekho).</div></details>"},{"id":"ten-mark-answer","title":"10-mark answer: Bellman equation and applications of RL","html":"<p class=\"cue\"><strong>Asked as:</strong> “Explain Bellman equation in reinforcement learning. Also give applications of reinforcement learning.” <span class=\"marks\">[10 marks · Re-exam Jan 2026 Q7b; marking: Bellman explanation 5, applications 5]</span></p>\n\n<p>Write the answer below in this order. It fits in about two pages.</p>\n\n<div class=\"answer-box\">\n<h3>Part A · Bellman equation (5 marks)</h3>\n<p><strong>1. Setting.</strong> Reinforcement learning problems are modelled as a Markov decision process <span class=\"math-inline\"><img src=\"math/2a8c7332f3030a47.svg\" alt=\"\\langle\\mathcal S,\\mathcal A,P,R,\\gamma\\rangle\" style=\"width:13.735ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The agent follows a policy <span class=\"math-inline\"><img src=\"math/f155e46af3f71ce4.svg\" alt=\"\\pi(a\\mid s)\" style=\"width:7.194ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and wants to maximise the return <span class=\"math-inline\"><img src=\"math/3f482d8ea694678d.svg\" alt=\"G_t=\\sum_{k\\ge0}\\gamma^kR_{t+k+1}\" style=\"width:20.364ex;height:2.798ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>2. Value functions.</strong> <span class=\"math-inline\"><img src=\"math/a27ddca95f461e82.svg\" alt=\"v_\\pi(s)=\\mathbb E_\\pi[G_t\\mid S_t=s]\" style=\"width:22.562ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/0885e6b22d6c67c2.svg\" alt=\"q_\\pi(s,a)=\\mathbb E_\\pi[G_t\\mid S_t=s,A_t=a]\" style=\"width:32.358ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>3. Key idea.</strong> The return is recursive: <span class=\"math-inline\"><img src=\"math/837aecc6afff8d86.svg\" alt=\"G_t=R_{t+1}+\\gamma G_{t+1}\" style=\"width:18.67ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>. Taking expectations gives the <strong>Bellman expectation equation</strong>:</p>\n<div class=\"math-display\"><img src=\"math/cd7f793810f9ae1e.svg\" alt=\"v_\\pi(s)=\\sum_a\\pi(a\\mid s)\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R(s,a,s&#39;)+\\gamma v_\\pi(s&#39;)]\" style=\"width:53.904ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\n<div class=\"math-display\"><img src=\"math/0aaca96cab3cf147.svg\" alt=\"q_\\pi(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,\\Big[R(s,a,s&#39;)+\\gamma\\sum_{a&#39;}\\pi(a&#39;\\mid s&#39;)q_\\pi(s&#39;,a&#39;)\\Big]\" style=\"width:60.894ex;height:5.335ex\" loading=\"lazy\" decoding=\"async\"></div>\n<p><strong>4. Optimality.</strong> For the optimal policy the average over actions becomes a maximum (<strong>Bellman optimality equation</strong>):</p>\n<div class=\"math-display\"><img src=\"math/cc767eadfe69fc8c.svg\" alt=\"v_*(s)=\\max_a\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma v_*(s&#39;)],\\qquad q_*(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma\\max_{a&#39;}q_*(s&#39;,a&#39;)]\" style=\"width:89.433ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\n<p><strong>5. Meaning and use.</strong> 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 <span class=\"math-inline\"><img src=\"math/f3cf791d9745c384.svg\" alt=\"\\pi_*(s)=\\arg\\max_a q_*(s,a)\" style=\"width:24.284ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>6. Small illustration</strong> (adds clarity): if staying in a state gives +1 each step with <span class=\"math-inline\"><img src=\"math/c491a3a52610e919.svg\" alt=\"\\gamma=0.9\" style=\"width:7.137ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, then <span class=\"math-inline\"><img src=\"math/64606eb39a2dfd24.svg\" alt=\"v=1+0.9v\\Rightarrow v=10\" style=\"width:21.896ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n\n<h3>Part B · Applications of reinforcement learning (5 marks)</h3>\n<ol>\n<li><strong>Game playing</strong>: AlphaGo (defeated Lee Sedol, 2016), Atari agents (DQN), and the Mario agent built in this course's lab.</li>\n<li><strong>Robotics</strong>: walking, grasping and balancing learned by trial and error in simulation.</li>\n<li><strong>Autonomous driving</strong>: lane changing, merging and parking decisions.</li>\n<li><strong>Recommendation systems</strong>: choosing content to maximise long-term engagement rather than single clicks.</li>\n<li><strong>Finance</strong>: trading and portfolio rebalancing as sequential decisions.</li>\n<li><strong>Healthcare</strong>: dynamic treatment regimes (dose adjustment over time).</li>\n<li><strong>Resource and energy management</strong>: data-centre cooling control, traffic-signal timing, inventory control.</li>\n<li><strong>Language models</strong>: reinforcement learning from human feedback (RLHF) for chatbots.</li>\n</ol>\n<h4>One application in detail: traffic-signal control</h4>\n<div class=\"table-wrap\"><table><tbody>\n<tr><th>Agent</th><td>Controller at an intersection.</td></tr>\n<tr><th>State</th><td>Queue length and waiting time on each approach, current signal phase.</td></tr>\n<tr><th>Actions</th><td>Keep the current phase or switch to the next green phase.</td></tr>\n<tr><th>Reward</th><td>Negative of total waiting time (or vehicles cleared per cycle).</td></tr>\n<tr><th>Learning</th><td>Q-learning updates <span class=\"math-inline\"><img src=\"math/0caba73ef360f772.svg\" alt=\"Q(s,a)\" style=\"width:6.814ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> from observed traffic; ε-greedy exploration tries alternative timings.</td></tr>\n<tr><th>Benefit</th><td>Adapts to rush hours and incidents; fixed timers cannot.</td></tr>\n<tr><th>Challenge</th><td>Safety during exploration, so agents are trained in simulation first.</td></tr>\n</tbody></table></div>\n</div>\n\n<div class=\"memory\"><strong>Yaad rakho:</strong> Bellman ka sar: “value = reward abhi + γ × value aage”. Application likho to S, A, R batao: examiner ko yahi chahiye.</div>"}]}],"formulas":[{"id":"m2-formulas-v2","title":"All M2 formulas","unit":"M2 revision","scope":"One place for the formulas, meanings, conditions and links to full worked examples.","sections":[{"id":"fuzzy","title":"Fuzzy formulas, with meanings and worked-example links","html":"<h2>Fuzzy formulas</h2><h3>Triangular membership</h3><div class=\"math-display\"><img src=\"math/f0ca7a326bd064e8.svg\" alt=\"\\mu(x)=\\max\\left(0,\\min\\left(\\frac{x-a}{b-a},\\frac{c-x}{c-b}\\right)\\right)\" style=\"width:38.263ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><p>a=left zero, b=peak, c=right zero, with a&lt;b&lt;c. Locate x before choosing the rising/falling branch.</p><p><a href=\"#m2/read/fuzzy-core/triangle\">Read the explanation and worked sums →</a></p><h3>Union and intersection</h3><div class=\"math-display\"><img src=\"math/eaf940ee2fdf1f17.svg\" alt=\"\\mu_{A\\cup B}=\\max(\\mu_A,\\mu_B)\\quad\\mu_{A\\cap B}=\\min(\\mu_A,\\mu_B)\" style=\"width:42.914ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Compare memberships at the same element. These formulas use standard max–min operations.</p><p><a href=\"#m2/read/fuzzy-core/set-operations\">Read the explanation and worked sums →</a></p><h3>Complement and difference</h3><div class=\"math-display\"><img src=\"math/ac545c5022ffd6a1.svg\" alt=\"\\mu_{A^c}=1-\\mu_A\\quad\\mu_{A\\setminus B}=\\min(\\mu_A,1-\\mu_B)\" style=\"width:39.039ex;height:2.497ex\" loading=\"lazy\" decoding=\"async\"></div><p>A difference means A AND NOT B; it is not ordinary subtraction.</p><p><a href=\"#m2/read/fuzzy-core/set-operations\">Read the explanation and worked sums →</a></p><h3>Rule strength, clipping and aggregation</h3><div class=\"math-display\"><img src=\"math/043f511911bca932.svg\" alt=\"\\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)\" style=\"width:62.895ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><p>a,b are input degrees; α is the strength; z is a candidate output value. OR conditions use max instead.</p><p><a href=\"#m2/read/fuzzy-core/rules-clipping\">Read the explanation and worked sums →</a></p><h3>Mean of maxima</h3><div class=\"math-display\"><img src=\"math/9ed17a341041965a.svg\" alt=\"z^*=\\frac{\\sum_{z_i\\in M}z_i}{|M|}\\quad\\text{one plateau }[a,b]:\\ z^*=(a+b)/2\" style=\"width:49.788ex;height:5.805ex\" loading=\"lazy\" decoding=\"async\"></div><p>M is the set of discrete output locations attaining maximum membership. The plateau shortcut is for one continuous maximum interval.</p><p><a href=\"#m2/read/fuzzy-core/mom\">Read the explanation and worked sums →</a></p><h3>Discrete / continuous centroid</h3><div class=\"math-display\"><img src=\"math/79ddc9ad485491a0.svg\" alt=\"z^*=\\frac{\\sum_i z_i\\mu_i}{\\sum_i\\mu_i}\\qquad z^*=\\frac{\\int z\\mu(z)\\,dz}{\\int\\mu(z)\\,dz}\" style=\"width:33.623ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><p>Use actual discrete memberships or the full continuous aggregate. Denominator must be positive.</p><p><a href=\"#m2/read/fuzzy-core/centroid\">Read the explanation and worked sums →</a></p><h3>Specified representative-weighted output</h3><div class=\"math-display\"><img src=\"math/0fb4cda8fcd0e1d8.svg\" alt=\"z^*=\\frac{\\sum_r\\alpha_r c_r}{\\sum_r\\alpha_r}\" style=\"width:13.974ex;height:5.67ex\" loading=\"lazy\" decoding=\"async\"></div><p>c is a supplied representative such as a peak. Do not call this the exact area centroid of a clipped Mamdani aggregate without justification.</p><p><a href=\"#m2/read/fuzzy-core/weighted-average\">Read the explanation and worked sums →</a></p><h3>Cartesian product and max–min composition</h3><div class=\"math-display\"><img src=\"math/dfabdb4f1a2b77c3.svg\" alt=\"R_{ij}=\\min(A_i,B_j)\\quad T_{ik}=\\max_j\\min(R_{ij},S_{jk})\" style=\"width:43.154ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div><p>Relations must have a common middle domain in the same order. Min along a path, max across paths.</p><p><a href=\"#m2/read/fuzzy-relations/composition\">Read the explanation and worked sums →</a></p>\r\n\r\n<!-- depth:remaining-memberships:start -->\r\n<div class=\"concept-bridge\"><h2>Other membership formulas from the reading lessons</h2><h3>Trapezoid with distinct breakpoints</h3><div class=\"math-display\"><img src=\"math/61dfda51f019f3c9.svg\" alt=\"\\mu(x)=\\max\\left(0,\\min\\left(\\frac{x-a}{b-a},1,\\frac{d-x}{d-c}\\right)\\right)\" style=\"width:40.597ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><p>For a&lt;b≤c&lt;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. <a href=\"#m2/read/fuzzy-core/trapezoid-intuition\">Branch examples →</a></p><h3>Gaussian membership</h3><div class=\"math-display\"><img src=\"math/3a8ce5565c9dd1ff.svg\" alt=\"\\mu(x)=e^{-(x-c)^2/(2\\sigma^2)}\" style=\"width:19.174ex;height:2.834ex\" loading=\"lazy\" decoding=\"async\"></div><p>c is the centre and σ&gt;0 sets the width. At x=c the exponent is zero and membership is 1. <a href=\"#m2/read/fuzzy-core/smooth-memberships\">Worked exponential calculations →</a></p><h3>Generalised bell membership</h3><div class=\"math-display\"><img src=\"math/37da3dd6f213b8e7.svg\" alt=\"\\mu(x)=\\frac{1}{1+|(x-c)/a|^{2b}}\" style=\"width:24.388ex;height:5.275ex\" loading=\"lazy\" decoding=\"async\"></div><p>a&gt;0 controls width; b&gt;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.</p><h3>Alpha-cut</h3><div class=\"math-display\"><img src=\"math/34e8388304c6f4b2.svg\" alt=\"A_\\alpha=\\{x:\\mu_A(x)\\ge\\alpha\\}\" style=\"width:21.639ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>α is the chosen membership threshold. For 0&lt;α≤1 keep inputs meeting or exceeding it, including threshold-equality endpoints. <a href=\"#m2/read/fuzzy-core/properties\">Discrete and triangular examples →</a></p></div>\r\n<!-- depth:remaining-memberships:end -->"},{"id":"ga-pso","title":"GA and PSO formulas, symbols and memory rules","html":"<h3>Binary decoding</h3><div class=\"math-display\"><img src=\"math/4fb94e1436769fba.svg\" alt=\"x=\\sum_{i=1}^{n}b_i2^{n-i}\" style=\"width:13.741ex;height:6.354ex\" loading=\"lazy\" decoding=\"async\"></div><p>bᵢ is a bit; the maximum n-bit unsigned integer is 2ⁿ−1.</p><p><a href=\"#m2/read/ga-core/encoding\">Full explanation and worked solutions →</a></p><h3>Roulette selection</h3><div class=\"math-display\"><img src=\"math/a3d3e670e29c240d.svg\" alt=\"P_i=F_i/\\sum_jF_j\\quad C_i=\\sum_{j=1}^iP_j\" style=\"width:28.438ex;height:6.9ex\" loading=\"lazy\" decoding=\"async\"></div><p>Fitness weights must be nonnegative with a positive total. For minimisation use the specified transformation or selection method. C is cumulative probability.</p><p><a href=\"#m2/read/ga-core/selection\">Full explanation and worked solutions →</a></p><h3>Population average</h3><div class=\"math-display\"><img src=\"math/5a16aa84fc40bbd3.svg\" alt=\"\\bar f=\\frac{f_1+\\cdots+f_N}{N}\" style=\"width:18.253ex;height:4.676ex\" loading=\"lazy\" decoding=\"async\"></div><p>N is the number of individuals. Compare both best and average; mutation need not improve either.</p><p><a href=\"#m2/read/ga-core/two-generations\">Full explanation and worked solutions →</a></p><h3>PSO velocity</h3><div class=\"math-display\"><img src=\"math/8a9f3b6c402bae75.svg\" alt=\"v^{t+1}=wv^t+c_1r_1(pbest^t-x^t)+c_2r_2(gbest^t-x^t)\" style=\"width:48.613ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>w weights inertia; c₁r₁ weights personal pull; c₂r₂ weights social pull. Apply the same equation separately to each coordinate.</p><p><a href=\"#m2/read/pso-core/equation\">Full explanation and worked solutions →</a></p><h3>PSO position</h3><div class=\"math-display\"><img src=\"math/3a35d97963567317.svg\" alt=\"x^{t+1}=x^t+v^{t+1}\" style=\"width:15.853ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><p>Use the new velocity, not the old one. Then reevaluate the objective.</p><p><a href=\"#m2/read/pso-core/two-particles\">Full explanation and worked solutions →</a></p><p><strong>Memory updates:</strong> 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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Formula ke pehle objective direction aur old state likho. Iteration 2 mein fresh positions aur retained memories use karo.</p>\r\n\r\n<!-- depth:encoding-conventions:start -->\r\n<div class=\"concept-bridge\"><h2>Encoding and minimisation conventions</h2><div class=\"math-display\"><img src=\"math/3013a3fc845c64e5.svg\" alt=\"x=L+\\frac{d}{2^n-1}(U-L)\" style=\"width:23.591ex;height:4.837ex\" loading=\"lazy\" decoding=\"async\"></div><p>For the specified uniform real-range encoding: decode n bits into unsigned integer d first. L and U are the physical limits. <a href=\"#m2/read/ga-core/encoding\">Endpoint examples →</a></p><div class=\"math-display\"><img src=\"math/361a654c14fe241e.svg\" alt=\"F=\\frac{1}{1+f(x)}\" style=\"width:13.903ex;height:5.208ex\" loading=\"lazy\" decoding=\"async\"></div><p>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. <a href=\"#m2/read/ga-core/minimisation\">Complete minimisation example →</a></p></div>\r\n<!-- depth:encoding-conventions:end -->"}]},{"id":"tee-formulas","title":"TEE formula sheet · Units 1 and 4","unit":"0","scope":"Probability, Bayes, GMM/EM, Markov chains and Bellman equations (Units 2–3 are in the M2 sheet)","sections":[{"id":"unit1","title":"Unit 1 formulas: probability, Bayes, naive Bayes, Bayesian networks, GMM","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Conditions and notation for this revision sheet</h2><p>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, N<sub>c</sub> is the class count and k is the number of possible values of the particular feature.</p><p>For the Jensen expression below, λ weights are nonnegative, sum to 1, and the logged arguments are positive. For a Gaussian, σ&gt;0. GMM weights π<sub>k</sub> are nonnegative and sum to 1; γ<sub>ik</sub> or λ<sub>k</sub><sup>i</sup> are responsibilities, not the mixing weights themselves.</p><p>Worked explanations: <a href=\"#tee/read/u1-nb/model\">Naive Bayes</a> · <a href=\"#tee/read/u1-bn/semantics\">CPTs and Bayesian networks</a> · <a href=\"#tee/read/u1-gmm/centre-spread\">Mean, variance and likelihood</a> · <a href=\"#tee/read/u1-gmm/em\">EM update</a>.</p></div>\r\n<!-- depth:bridge:end -->\r\n<div class=\"table-wrap\"><table><tbody>\r\n<tr><th>Conditional</th><td><span class=\"math-inline\"><img src=\"math/b69a34e61294d724.svg\" alt=\"P(a\\mid b)=P(a\\land b)/P(b)\" style=\"width:24.232ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Product rule</th><td><span class=\"math-inline\"><img src=\"math/68a6596a80d9767b.svg\" alt=\"P(a\\land b)=P(a\\mid b)P(b)\" style=\"width:23.101ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Marginalisation</th><td><span class=\"math-inline\"><img src=\"math/b6dbba8c2c4c1da9.svg\" alt=\"P(Y)=\\sum_zP(Y,z)\" style=\"width:19.144ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Normalisation</th><td><span class=\"math-inline\"><img src=\"math/6a7c981fbbb8b9db.svg\" alt=\"\\mathbf P(X\\mid e)=\\alpha\\,\\mathbf P(X,e),\\;\\alpha=1/\\sum_xP(x,e)\" style=\"width:40.198ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Bayes' rule</th><td><span class=\"math-inline\"><img src=\"math/21c4330d83c41c29.svg\" alt=\"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)}\" style=\"width:46.386ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Naive Bayes</th><td><span class=\"math-inline\"><img src=\"math/2c5a9cfc42c5e274.svg\" alt=\"v_{NB}=\\arg\\max_cP(c)\\prod_iP(a_i\\mid c)\" style=\"width:32.261ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span>; Laplace: <span class=\"math-inline\"><img src=\"math/c521050ae7174687.svg\" alt=\"\\frac{n_{ic}+1}{N_c+k}\" style=\"width:5.013ex;height:3.12ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>BN chain rule</th><td><span class=\"math-inline\"><img src=\"math/44d1eaaf40faab74.svg\" alt=\"P(x_1..x_n)=\\prod_iP(x_i\\mid parents(X_i))\" style=\"width:35.862ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>BN query</th><td><span class=\"math-inline\"><img src=\"math/49b2c852ff5f290f.svg\" alt=\"P(X\\mid e)=\\alpha\\sum_{\\text{hidden}}\\prod P(\\cdot\\mid parents)\" style=\"width:36.968ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>CPT size</th><td>Boolean node with k Boolean parents: independent probability parameters = <span class=\"math-inline\"><img src=\"math/1e088370ad90412f.svg\" alt=\"2^k\" style=\"width:2.152ex;height:1.932ex\" loading=\"lazy\" decoding=\"async\"></span> numbers</td></tr>\r\n<tr><th>GMM density</th><td><span class=\"math-inline\"><img src=\"math/68bcea7fd026bedf.svg\" alt=\"p(x)=\\sum_k\\pi_k\\mathcal N(x\\mid\\mu_k,\\sigma_k^2)\" style=\"width:26.168ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Gaussian</th><td><span class=\"math-inline\"><img src=\"math/0a27dae1a77ea038.svg\" alt=\"\\mathcal N(x\\mid\\mu,\\sigma^2)=\\frac1{\\sqrt{2\\pi}\\sigma}e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}\" style=\"width:26.747ex;height:4.411ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Log-likelihood</th><td><span class=\"math-inline\"><img src=\"math/7852bd4ef8cbe433.svg\" alt=\"\\log L=\\sum_i\\log\\sum_k\\pi_k\\mathcal N(x_i\\mid\\mu_k,\\sigma_k^2)\" style=\"width:34.299ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Jensen (log concave)</th><td><span class=\"math-inline\"><img src=\"math/e188562c73c0cd46.svg\" alt=\"\\log\\sum_k\\lambda_ka_k\\ge\\sum_k\\lambda_k\\log a_k\" style=\"width:26.623ex;height:2.36ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>E-step</th><td><span class=\"math-inline\"><img src=\"math/662cdc674fe7b2c5.svg\" alt=\"\\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)\" style=\"width:41.37ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>M-step</th><td><span class=\"math-inline\"><img src=\"math/94b0dd17291e3c1a.svg\" alt=\"\\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}\" style=\"width:41.424ex;height:4.104ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>GMM parameters</th><td>1-D: <span class=\"math-inline\"><img src=\"math/eec5afc3e1c07c8c.svg\" alt=\"3K-1\" style=\"width:7.039ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></span> (K = 5 → 14)</td></tr>\r\n</tbody></table></div>"},{"id":"unit4","title":"Unit 4 formulas: Markov chains, MRP, MDP, Bellman","html":"<!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Read these symbols in context</h2><p>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.</p><p>The two-state stationary shortcut needs a+b&gt;0. The inverse (I−γP)⁻¹ exists for a finite stochastic P with 0≤γ&lt;1; at γ=1, check the problem’s terminal structure instead of assuming the full matrix is invertible. The continuing discounted-return examples use γ&lt;1. A finite episode can also use γ=1.</p><p>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.</p><p>Worked explanations: <a href=\"#tee/read/u4-markov/next-step\">Matrix multiplication</a> · <a href=\"#tee/read/u4-markov/steady-state\">Stationary algebra</a> · <a href=\"#tee/read/u4-bellman/mrp-return\">Discounted return</a> · <a href=\"#tee/read/u4-bellman/bellman-equations\">Bellman equations</a>.</p></div>\r\n<!-- depth:bridge:end -->\r\n<div class=\"table-wrap\"><table><tbody>\r\n<tr><th>Markov property</th><td><span class=\"math-inline\"><img src=\"math/e99a6e85c6b029e3.svg\" alt=\"P(S_{t+1}\\mid S_t,\\dots,S_1)=P(S_{t+1}\\mid S_t)\" style=\"width:33.82ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Transition matrix</th><td><span class=\"math-inline\"><img src=\"math/7f4c1d9519ac27a9.svg\" alt=\"P_{ij}=P(\\text{next}=j\\mid\\text{now}=i)\" style=\"width:27.32ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>; rows sum to 1</td></tr>\r\n<tr><th>Next step</th><td><span class=\"math-inline\"><img src=\"math/8b6e8d7e9dedda16.svg\" alt=\"x_{t+1}=x_tP\" style=\"width:10.88ex;height:2.016ex\" loading=\"lazy\" decoding=\"async\"></span> (row vector); <span class=\"math-inline\"><img src=\"math/3229af8e13e5a4dd.svg\" alt=\"x_{t+n}=x_tP^n\" style=\"width:12.313ex;height:2.016ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Steady state</th><td><span class=\"math-inline\"><img src=\"math/fa1b266acbaaacb0.svg\" alt=\"\\pi=\\pi P,\\;\\sum\\pi_i=1\" style=\"width:17.874ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>; two states <span class=\"math-inline\"><img src=\"math/b54df1e7f5634ea5.svg\" alt=\"\\begin{bmatrix}1-a&amp;a\\\\b&amp;1-b\\end{bmatrix}\\Rightarrow\\pi=\\left[\\frac b{a+b},\\frac a{a+b}\\right]\" style=\"width:32.877ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Return</th><td><span class=\"math-inline\"><img src=\"math/3f482d8ea694678d.svg\" alt=\"G_t=\\sum_{k\\ge0}\\gamma^kR_{t+k+1}\" style=\"width:20.364ex;height:2.798ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>MRP Bellman</th><td><span class=\"math-inline\"><img src=\"math/7c2858b3388b1fca.svg\" alt=\"v(s)=R(s)+\\gamma\\sum_{s&#39;}P_{ss&#39;}v(s&#39;)\" style=\"width:28.125ex;height:2.379ex\" loading=\"lazy\" decoding=\"async\"></span>; <span class=\"math-inline\"><img src=\"math/d7e46a6497b0a4a6.svg\" alt=\"v=(I-\\gamma P)^{-1}R\" style=\"width:16.658ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Policy</th><td><span class=\"math-inline\"><img src=\"math/556c05bd826349e2.svg\" alt=\"\\pi(a\\mid s)=P(A_t=a\\mid S_t=s)\" style=\"width:28.462ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Value functions</th><td><span class=\"math-inline\"><img src=\"math/b08e042bdd23bc61.svg\" alt=\"v_\\pi(s)=\\mathbb E_\\pi[G_t\\mid s]\" style=\"width:17.392ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>; <span class=\"math-inline\"><img src=\"math/99133acdbfaa7afa.svg\" alt=\"q_\\pi(s,a)=\\mathbb E_\\pi[G_t\\mid s,a]\" style=\"width:21.71ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>; <span class=\"math-inline\"><img src=\"math/3ce6dda6fd8fe296.svg\" alt=\"v_\\pi=\\sum_a\\pi(a\\mid s)q_\\pi(s,a)\" style=\"width:23.341ex;height:2.358ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Bellman expectation</th><td><span class=\"math-inline\"><img src=\"math/e0207f466cf8054f.svg\" alt=\"v_\\pi(s)=\\sum_a\\pi(a\\mid s)\\sum_{s&#39;}P(s&#39;\\mid s,a)[R+\\gamma v_\\pi(s&#39;)]\" style=\"width:46.468ex;height:2.379ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Bellman optimality</th><td><span class=\"math-inline\"><img src=\"math/7e6827fd1d3ef854.svg\" alt=\"v_*(s)=\\max_a\\sum_{s&#39;}P(s&#39;\\mid s,a)[R+\\gamma v_*(s&#39;)]\" style=\"width:40.494ex;height:2.379ex\" loading=\"lazy\" decoding=\"async\"></span>; <span class=\"math-inline\"><img src=\"math/d84f2e508180aed8.svg\" alt=\"q_*(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)[R+\\gamma\\max_{a&#39;}q_*(s&#39;,a&#39;)]\" style=\"width:46.172ex;height:2.379ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n\r\n</tbody></table></div><p>Optional further reading: the <a href=\"#tee/read/u4-bellman/solving\">Q-learning extension</a> is kept with the Bellman lesson, outside this core formula list.</p>"},{"id":"aco-tsp","title":"TEE-only formulas: ACO and GA for TSP","html":"<h2>Ant colony optimisation</h2>\r\n<div class=\"table-wrap\"><table><tbody>\r\n<tr><th>Transition probability</th><td><span class=\"math-inline\"><img src=\"math/8df8f5c198d8cd6b.svg\" alt=\"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}\" style=\"width:33.463ex;height:7.153ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><th>Choice rule</th><td>cumulative probabilities in <strong>city order</strong>; first city with cumulative ≥ r</td></tr>\r\n<tr><th>Pheromone update</th><td><span class=\"math-inline\"><img src=\"math/0cc34ae2992158a9.svg\" alt=\"\\tau_{ij}\\leftarrow(1-\\rho)\\tau_{ij}+\\sum_{k:\\,ij\\in tour_k} Q/L_k\" style=\"width:33.97ex;height:2.669ex\" loading=\"lazy\" decoding=\"async\"></span> on every edge ant k used (return edge included); symmetric only for an undirected symmetric TSP</td></tr>\r\n<tr><th>Values assumed in the worked PYQs</th><td><span class=\"math-inline\"><img src=\"math/0a0a3aed7677e436.svg\" alt=\"\\alpha=\\beta=1,\\;\\rho=0.5,\\;Q=1,\\;\\tau_0=1\" style=\"width:33.94ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n</tbody></table></div>\r\n<p>α 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.</p><div class=\"math-display\"><img src=\"math/316d88916534af37.svg\" alt=\"L=\\sum_{i=1}^{n-1}d(c_i,c_{i+1})+d(c_n,c_1)\" style=\"width:28.431ex;height:6.712ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/85040bacae1471d9.svg\" alt=\"F_{TSP}=1/L\" style=\"width:11.822ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p>"}]}],"papers":[{"id":"paper-final-2025","title":"Final examination · 24 Nov 2025","unit":"paper","scope":"Actual TEE paper · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)","sections":[{"id":"q1a","title":"Q1(a) Joint probability table [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>The printed eight entries are reproduced below. Their total is 1.002, not 1. Therefore the table is inconsistent as a probability distribution.</p><div class=\"table-wrap\"><table><thead><tr><th></th><th>Credit, female</th><th>Credit, male</th><th>Debit, female</th><th>Debit, male</th></tr></thead><tbody>\r\n<tr><td><strong>Premium (Y=1)</strong></td><td>0.08</td><td>0.10</td><td>0.072</td><td>0.05</td></tr>\r\n<tr><td><strong>Regular (Y=0)</strong></td><td>0.10</td><td>0.15</td><td>0.25</td><td>0.20</td></tr></tbody></table></div><h4>To find</h4><p>The five requested probabilities, stating how the inconsistent data are interpreted.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/e29a33f81d36c3d3.svg\" alt=\"P(E)=\\frac{\\text{sum of weights for }E}{\\text{sum of all weights}}\" style=\"width:29.187ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/656f97e9f0aa20fc.svg\" alt=\"P(A\\mid E)=\\frac{\\text{sum of weights for }A\\cap E}{\\text{sum of weights for }E}\" style=\"width:36.981ex;height:5.167ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Validate the full table</h5><div class=\"math-display\"><img src=\"math/96cf20835aaf1e81.svg\" alt=\"0.08+0.10+0.072+0.05+0.10+0.15+0.25+0.20=1.002\" style=\"width:60.843ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><p>Use total weight 1.002 consistently for unconditional probabilities.</p></div><div class=\"step\"><h5>Step 2. Premium row total</h5><div class=\"math-display\"><img src=\"math/455884f740d33473.svg\" alt=\"w(premium)=0.08+0.10+0.072+0.05=0.302\" style=\"width:49.347ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Female given premium</h5><div class=\"math-display\"><img src=\"math/61d38ae71dd8a06e.svg\" alt=\"P(female\\mid premium)=\\frac{0.08+0.072}{0.302}=\\frac{0.152}{0.302}\\approx0.503311\" style=\"width:58.502ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Credit given premium</h5><div class=\"math-display\"><img src=\"math/f1511f5b6ec07db0.svg\" alt=\"P(credit\\mid premium)=\\frac{0.08+0.10}{0.302}=\\frac{0.18}{0.302}\\approx0.596026\" style=\"width:55.988ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Normalised premium marginal</h5><div class=\"math-display\"><img src=\"math/3465c1e9a29a79c1.svg\" alt=\"P(premium)=\\frac{0.302}{1.002}\\approx0.301397\" style=\"width:33.45ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Normalised credit marginal</h5><div class=\"math-display\"><img src=\"math/594c62fd5c571144.svg\" alt=\"P(credit)=\\frac{0.08+0.10+0.10+0.15}{1.002}=\\frac{0.43}{1.002}\\approx0.429142\" style=\"width:58.419ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Regular given male and debit</h5><div class=\"math-display\"><img src=\"math/7f500d88c2aab86f.svg\" alt=\"P(regular\\mid male,debit)=\\frac{0.20}{0.05+0.20}=0.8\" style=\"width:44.133ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Under common normalisation: (a) 0.503311 and 0.596026; (b) 0.301397 and 0.429142; (c) 0.8.</div><p><strong>Alternative correction:</strong> 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.</p></section>"},{"id":"q1b","title":"Q1(b) Applications of ACO [5]","html":"<p class=\"question\"><strong>List the applications of Ant Colony Optimization and explain any one application in detail.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Travelling salesman problem</strong>: shortest tour visiting every city once.</li>\r\n<li><strong>Vehicle routing</strong>: delivery routes for a fleet with capacity and time windows (minimising distance, time, fuel).</li>\r\n<li><strong>Network routing</strong>: adaptive routing of data packets in communication and sensor networks (AntNet).</li>\r\n<li><strong>Job-shop and project scheduling</strong>: assigning jobs to machines to minimise completion time.</li>\r\n<li><strong>Image processing</strong>: edge detection, with ants moving over pixel-intensity graphs.</li>\r\n<li><strong>Assignment problems</strong>: quadratic assignment, timetabling, graph colouring.</li>\r\n<li><strong>Feature selection and data mining</strong>: Ant-Miner for classification rules.</li>\r\n<li><strong>Load balancing</strong> in distributed systems and cloud task allocation.</li>\r\n</ol>\r\n<h3>One application in detail: vehicle routing (or TSP)</h3>\r\n<ol>\r\n<li><strong>Graph.</strong> Depot and customers are nodes; travel times or distances are edge weights.</li>\r\n<li><strong>Ants.</strong> Each ant builds a complete set of routes. From its current customer it chooses the next with probability <span class=\"math-inline\"><img src=\"math/7d200da3be6a78d4.svg\" alt=\"\\propto\\tau_{ij}\\,(1/d_{ij})\" style=\"width:11.752ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>, skipping customers already served or that would exceed the vehicle capacity; when the vehicle is full it returns to the depot.</li>\r\n<li><strong>Evaluation.</strong> Total distance (plus penalties for late deliveries).</li>\r\n<li><strong>Learning.</strong> Pheromone evaporates everywhere and is added in proportion to <span class=\"math-inline\"><img src=\"math/afe42919eb73e68a.svg\" alt=\"Q/L\" style=\"width:4.462ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> on the routes of good solutions, so short connections are reinforced.</li>\r\n<li><strong>Result.</strong> 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.</li>\r\n</ol>\r\n<h3>Advantages and limitations</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody>\r\n<tr><td>Naturally suited to graph and routing problems</td><td>Several parameters to tune (α, β, ρ, number of ants)</td></tr>\r\n<tr><td>Can share useful route information and adapt search to changing graphs</td><td>Convergence time is uncertain; may stagnate on a sub-optimal path</td></tr>\r\n<tr><td>Positive feedback + parallel ants</td><td>Theoretical analysis is difficult</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> ACO = “raaste wale problems” (TSP, routing, scheduling). PSO = “numbers wale problems” (continuous function, weights).</div>\r\n"},{"id":"q1c","title":"Q1(c) Fuzzy set operations [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The aligned X and Y memberships printed in this question.</p><h4>To find</h4><p>The four requested membership lists in the original element order.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1−μ for NOT. <div class=\"math-display\"><img src=\"math/e32ad02c5ba3dae5.svg\" alt=\"\\mu_{X\\cup Y}=\\max(\\mu_X,\\mu_Y),\\quad\\mu_{X\\cap Y}=\\min(\\mu_X,\\mu_Y)\" style=\"width:44.598ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div> Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Complements</h5><p>¬X = {0.4, 0.2, 0.7, 0.5, 0.3}; ¬Y = {0.6, 0.5, 0.1, 0.4, 0.8}.</p></div>\r\n<div class=\"step\"><h5>Step 2. Table</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th></tr></thead><tbody>\r\n<tr><td>X</td><td>0.6</td><td>0.8</td><td>0.3</td><td>0.5</td><td>0.7</td></tr>\r\n<tr><td>Y</td><td>0.4</td><td>0.5</td><td>0.9</td><td>0.6</td><td>0.2</td></tr>\r\n<tr><td><strong>X ∪ Y = max</strong></td><td>0.6</td><td>0.8</td><td>0.9</td><td>0.6</td><td>0.7</td></tr>\r\n<tr><td><strong>X ∩ Y = min</strong></td><td>0.4</td><td>0.5</td><td>0.3</td><td>0.5</td><td>0.2</td></tr>\r\n<tr><td><strong>¬X ∪ ¬Y</strong></td><td>0.6</td><td>0.5</td><td>0.7</td><td>0.5</td><td>0.8</td></tr>\r\n<tr><td><strong>¬X ∩ ¬Y</strong></td><td>0.4</td><td>0.2</td><td>0.1</td><td>0.4</td><td>0.3</td></tr>\r\n</tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Check with De Morgan's law</h5><p>¬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} ✓.</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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)}.</div>\r\n<p class=\"marks-split\">Official marking: 1 + 1 + 1.5 + 1.5.</p>\r\n</section>\r\n\r\n<!-- depth:element-working:start -->\r\n<div class=\"concept-bridge\"><h2>Calculate every element separately</h2><h3>Element c1</h3><div class=\"math-display\"><img src=\"math/ab521a108b232136.svg\" alt=\"\\neg X:1-0.6=0.4\\qquad\\neg Y:1-0.4=0.6\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9fba815e535802c7.svg\" alt=\"X\\cup Y:\\max(0.6,0.4)=0.6\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/580180c90f774b30.svg\" alt=\"X\\cap Y:\\min(0.6,0.4)=0.4\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ac5d994d1c80e0dd.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.4,0.6)=0.6\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f8ad2bf1c74a8449.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.4,0.6)=0.4\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c2</h3><div class=\"math-display\"><img src=\"math/994b18481ef2566a.svg\" alt=\"\\neg X:1-0.8=0.2\\qquad\\neg Y:1-0.5=0.5\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/34ae0707b407acaa.svg\" alt=\"X\\cup Y:\\max(0.8,0.5)=0.8\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/276fcc7ea7945a48.svg\" alt=\"X\\cap Y:\\min(0.8,0.5)=0.5\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e450f31b46fa1e42.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.2,0.5)=0.5\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/503c7cc18cb10c65.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.2,0.5)=0.2\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c3</h3><div class=\"math-display\"><img src=\"math/abbf5f7c84a2a614.svg\" alt=\"\\neg X:1-0.3=0.7\\qquad\\neg Y:1-0.9=0.1\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b75d7a85a782c820.svg\" alt=\"X\\cup Y:\\max(0.3,0.9)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/33c018c6e76860e7.svg\" alt=\"X\\cap Y:\\min(0.3,0.9)=0.3\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b158ec14569973da.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.7,0.1)=0.7\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7b8935d4bd0523c1.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.7,0.1)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c4</h3><div class=\"math-display\"><img src=\"math/9b11f9a14b9e240f.svg\" alt=\"\\neg X:1-0.5=0.5\\qquad\\neg Y:1-0.6=0.4\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/30d486e82175d463.svg\" alt=\"X\\cup Y:\\max(0.5,0.6)=0.6\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd263e46a0f4e96c.svg\" alt=\"X\\cap Y:\\min(0.5,0.6)=0.5\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bc8abd6badb711b9.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.5,0.4)=0.5\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2acca2b0b18cfada.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.5,0.4)=0.4\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c5</h3><div class=\"math-display\"><img src=\"math/b115216f7121911a.svg\" alt=\"\\neg X:1-0.7=0.3\\qquad\\neg Y:1-0.2=0.8\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ca6e5562fab61517.svg\" alt=\"X\\cup Y:\\max(0.7,0.2)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3de60cd86ef1a257.svg\" alt=\"X\\cap Y:\\min(0.7,0.2)=0.2\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0712a083103a814e.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.3,0.8)=0.8\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6274e157a87eaf7b.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.3,0.8)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:element-working:end -->"},{"id":"q1d","title":"Q1(d) Brand-switching Markov chain [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: X, Y.</p><h4>To find</h4><p>The transition matrix and state diagram.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>X</th><th>Y</th></tr></thead><tbody><tr><td>X</td><td>0.75</td><td>0.25</td></tr><tr><td>Y</td><td>0.4</td><td>0.6</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_brand.c2c4be3e6a.svg\" width=\"520\" height=\"280\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"answer\"><strong>Final answer.</strong> The transition matrix and state diagram are given above.</div></section>"},{"id":"q2a","title":"Q2(a) PSO, one iteration [10]","html":"<p class=\"question\"><strong>Question. Maximize <span class=\"math-inline\"><img src=\"math/51d7b4f8ba214898.svg\" alt=\"F(x_1,x_2)=2x_1^2-3x_1x_2+x_2^2+5x_1+2x_2+7\" style=\"width:45.217ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using Particle Swarm Optimization. <span class=\"math-inline\"><img src=\"math/cf25c61c163c59c7.svg\" alt=\"X=\\begin{bmatrix}2.5&amp;-3.0\\\\3.5&amp;-1.5\\end{bmatrix},\\;V=\\begin{bmatrix}0.2&amp;0.3\\\\0.1&amp;0.25\\end{bmatrix}\" style=\"width:35.097ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Take <span class=\"math-inline\"><img src=\"math/d99737a5fc79423b.svg\" alt=\"W=0.9,\\;c_1=c_2=1.5,\\;r_1=0.5949,\\;r_2=0.0855\" style=\"width:48.665ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></span>. Optimize and give the solution after 1 iteration showing the step-by-step process.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4><p>Particle 1: <span class=\"math-inline\"><img src=\"math/85ac77f48027edb2.svg\" alt=\"x=(2.5,\\,-3.0)\" style=\"width:14.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/438166430b0200d4.svg\" alt=\"v=(0.2,\\,0.3)\" style=\"width:13.041ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. Particle 2: <span class=\"math-inline\"><img src=\"math/a92c6e5b7c6f437f.svg\" alt=\"x=(3.5,\\,-1.5)\" style=\"width:14.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/3bf1b4b0830b2535.svg\" alt=\"v=(0.1,\\,0.25)\" style=\"width:14.172ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/24c25a9332d3129e.svg\" alt=\"c_1r_1=1.5\\times0.5949=0.89235,\\qquad c_2r_2=1.5\\times0.0855=0.12825\" style=\"width:64.267ex;height:1.971ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<h4>To find</h4><p>Fitness, pbest, gbest; new velocities and positions; updated pbest and gbest.</p></div>\r\n<h4>Formula and why it applies</h4>\r\n<div class=\"math-display\"><img src=\"math/15c9c9495dc886c9.svg\" alt=\"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}\" style=\"width:62.375ex;height:3.036ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Each particle is pulled by its own memory and by the swarm's best; we maximise, so the larger <span class=\"math-inline\"><img src=\"math/277a47abb82a8255.svg\" alt=\"F\" style=\"width:1.695ex;height:1.538ex\" loading=\"lazy\" decoding=\"async\"></span> is better.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Fitness of particle 1</h5><div class=\"math-display\"><img src=\"math/3938546a658fac5b.svg\" alt=\"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\" style=\"width:97.613ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Fitness of particle 2</h5><div class=\"math-display\"><img src=\"math/4d48c40dfb866c17.svg\" alt=\"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\" style=\"width:101.006ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. pbest and gbest</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>Position</th><th>F</th><th>pbest</th></tr></thead><tbody><tr><td>1</td><td>(2.5, −3.0)</td><td>57.5</td><td>(2.5, −3.0)</td></tr><tr><td>2</td><td>(3.5, −1.5)</td><td>64</td><td>(3.5, −1.5)</td></tr></tbody></table></div>\r\n<p>No previous iteration, so pbest = current position. Largest fitness is 64, so <strong>gbest = (3.5, −1.5)</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 4. Velocity and position of particle 1</h5>\r\n<div class=\"math-display\"><img src=\"math/c5345abf4a118373.svg\" alt=\"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\" style=\"width:85.978ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/aa0bacfeb906b753.svg\" alt=\"x_{11}=2.5+0.30825=2.80825\" style=\"width:29.606ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/a3af7b24f214c46d.svg\" alt=\"v_{12}=0.9(0.3)+0.89235(0)+0.12825(-1.5-(-3.0))=0.27+0.192375=0.462375\" style=\"width:82.207ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c09ac9a314e4985c.svg\" alt=\"x_{12}=-3.0+0.462375=-2.537625\" style=\"width:35.388ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 5. Velocity and position of particle 2 (it is gbest, so both pull terms are 0)</h5>\r\n<div class=\"math-display\"><img src=\"math/d5ef6ea1fa183f88.svg\" alt=\"v_{21}=0.9(0.1)+0+0=0.09,\\qquad x_{21}=3.5+0.09=3.59\" style=\"width:56.628ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/cdc998e6ae01e141.svg\" alt=\"v_{22}=0.9(0.25)+0+0=0.225,\\qquad x_{22}=-1.5+0.225=-1.275\" style=\"width:64.673ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 6. New fitness</h5>\r\n<div class=\"math-display\"><img src=\"math/d85fb6275e35f72d.svg\" alt=\"F(2.80825,-2.537625)=15.772536+21.378856+6.439541+14.04125-5.07525+7=59.5569\" style=\"width:94.464ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/df29fd84a6cdf039.svg\" alt=\"F(3.59,-1.275)=25.7762+13.73175+1.625625+17.95-2.55+7=63.5336\" style=\"width:77.495ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 7. Update pbest and gbest</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>New position</th><th>New F</th><th>Old pbest F</th><th>pbest after iteration</th></tr></thead><tbody>\r\n<tr><td>1</td><td>(2.80825, −2.537625)</td><td>59.5569</td><td>57.5</td><td>(2.80825, −2.537625) — improved</td></tr>\r\n<tr><td>2</td><td>(3.59, −1.275)</td><td>63.5336</td><td>64</td><td>(3.5, −1.5) — kept</td></tr></tbody></table></div>\r\n<p>The best pbest fitness is still 64, so gbest stays (3.5, −1.5).</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/4cf56ad79b60f4ff.svg\" alt=\"V=\\begin{bmatrix}0.30825&amp;0.462375\\\\0.09&amp;0.225\\end{bmatrix}\" style=\"width:25.372ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/befb5808089844a6.svg\" alt=\"X=\\begin{bmatrix}2.80825&amp;-2.537625\\\\3.59&amp;-1.275\\end{bmatrix}\" style=\"width:27.32ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. After one iteration particle 1 improved to F = 59.5569; the best solution so far is gbest = (3.5, −1.5) with F = 64.</div>\r\n<p class=\"marks-split\">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 <span class=\"math-inline\"><img src=\"math/e82facc124656ec6.svg\" alt=\"x_{11}\" style=\"width:3.082ex;height:1.339ex\" loading=\"lazy\" decoding=\"async\"></span>; that is a copying slip.</p>\r\n</section>\r\n"},{"id":"q2b","title":"Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Read the derivation’s symbols first</h2><p>“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. λ<sub>k</sub><sup>i</sup> in some notes is the same responsibility that other sections call γ<sub>ik</sub>. A superscript i here labels the observation, not an exponent.</p><p>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.</p><table><thead><tr><th>Parameter</th><th>Number in a 1D K-component GMM</th><th>Why</th></tr></thead><tbody><tr><td>Means</td><td>K</td><td>One centre for each component</td></tr><tr><td>Variances</td><td>K</td><td>One spread for each component</td></tr><tr><td>Independent mixing weights</td><td>K−1</td><td>The last weight is 1 minus the others</td></tr><tr><td>Total</td><td>3K−1</td><td>K+K+(K−1)</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n\r\n\r\n<div class=\"answer-box\">\r\n<h3>1. GMM versus k-means</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Aspect</th><th>k-means</th><th>GMM</th></tr></thead><tbody>\r\n<tr><td>Assignment</td><td>Hard: each point in exactly one cluster</td><td>Soft: probability <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> of belonging to each cluster</td></tr>\r\n<tr><td>Model</td><td>Geometric: nearest centroid</td><td>Probabilistic generative model <span class=\"math-inline\"><img src=\"math/04ce4e1e89065414.svg\" alt=\"\\sum_k\\pi_k\\mathcal N(\\mu_k,\\Sigma_k)\" style=\"width:16.12ex;height:2.448ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Cluster shape</td><td>Spherical, similar size</td><td>Elliptical, any size/orientation; overlapping clusters</td></tr>\r\n<tr><td>Parameters</td><td>K centroids</td><td>Weights, means, covariances (1-D: 3K − 1)</td></tr>\r\n<tr><td>Algorithm / objective</td><td>Assign–update; minimise squared distances</td><td>EM; maximise log-likelihood</td></tr>\r\n<tr><td>Output</td><td>Hard labels and fitted centroids</td><td>Labels, membership probabilities and a density (useful for anomaly detection)</td></tr>\r\n<tr><td>Relation</td><td colspan=\"2\">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.</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>2. Derivation of the log-likelihood</h3>\r\n<p><strong>Step 1. Model.</strong> Each point is generated by choosing component k with probability <span class=\"math-inline\"><img src=\"math/e60970d7047375ff.svg\" alt=\"\\pi_k\" style=\"width:2.311ex;height:1.332ex\" loading=\"lazy\" decoding=\"async\"></span> and drawing <span class=\"math-inline\"><img src=\"math/f66cfb5e517110e8.svg\" alt=\"x_i\\sim\\mathcal N(\\mu_k,\\sigma_k^2)\" style=\"width:14.731ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>, so its density is <span class=\"math-inline\"><img src=\"math/6550a4aaf9e87286.svg\" alt=\"f_{mix}(x_i)=\\sum_k\\pi_k\\mathcal N(x_i\\mid\\mu_k,\\sigma_k^2)\" style=\"width:30.677ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<p><strong>Step 2. Likelihood.</strong> Points are i.i.d., so the likelihood is a product (θ = all parameters):</p>\r\n<div class=\"math-display\"><img src=\"math/41dc390b2652cd78.svg\" alt=\"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]\" style=\"width:35.259ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 3. Log-likelihood.</strong> Logs turn the product into a sum:</p>\r\n<div class=\"math-display\"><img src=\"math/9a0bb26e3ef13adb.svg\" alt=\"\\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)\" style=\"width:42.737ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 4. Why it cannot be solved directly.</strong> The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.</p>\r\n<p><strong>Step 5. Jensen's inequality.</strong> log is concave, so for weights <span class=\"math-inline\"><img src=\"math/5006fcb64f6c3cf6.svg\" alt=\"\\lambda_k\\ge0,\\;\\sum\\lambda_k=1\" style=\"width:17.378ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: <span class=\"math-inline\"><img src=\"math/742b7c09a1ce32a4.svg\" alt=\"\\log\\big(\\sum_k\\lambda_ka_k\\big)\\ge\\sum_k\\lambda_k\\log a_k\" style=\"width:29.072ex;height:2.713ex\" loading=\"lazy\" decoding=\"async\"></span>. Introduce <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> for every point (<span class=\"math-inline\"><img src=\"math/fbe0441b97e0b9c1.svg\" alt=\"\\sum_k\\lambda_k^i=1\" style=\"width:10.276ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span>), multiply and divide inside the log:</p>\r\n<div class=\"math-display\"><img src=\"math/06dff5bae3d2cfe1.svg\" alt=\"\\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}\" style=\"width:78.361ex;height:6.391ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 6. Estimation (EM).</strong> Maximise the lower bound alternately. Fixing θ gives the E-step <span class=\"math-inline\"><img src=\"math/662cdc674fe7b2c5.svg\" alt=\"\\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)\" style=\"width:41.37ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></span>. Fixing λ and differentiating (with a Lagrange multiplier for <span class=\"math-inline\"><img src=\"math/131aa1c87311a5f9.svg\" alt=\"\\sum\\pi_k=1\" style=\"width:9.225ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>) gives the M-step:</p>\r\n<div class=\"math-display\"><img src=\"math/ffbe3f9b626d2a86.svg\" alt=\"\\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}\" style=\"width:59.614ex;height:6.179ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h3>3. Number of parameters for K = 5</h3><p>The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:</p>\r\n<div class=\"math-display\"><img src=\"math/5d57bdfd8f83239c.svg\" alt=\"2K+(K-1)=3K-1=3(5)-1=\\mathbf{14}\" style=\"width:40.189ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>(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.</p>\r\n</div>\r\n<div class=\"keyfix\"><strong>Slide note.</strong> One slide puts the convex inequality under the “concave” heading. Correct: log is <em>concave</em>, so <span class=\"math-inline\"><img src=\"math/2ddf537dc44d74a6.svg\" alt=\"f(\\sum\\lambda a)\\ge\\sum\\lambda f(a)\" style=\"width:19.59ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (≥, not &gt;).</div>\r\n"},{"id":"q3a","title":"Q3(a) Bayesian network: wet grass given no rain [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>C→S, C→R, (S,R)→W. Root and conditional probabilities are listed in the question. Evidence R=false.</p><h4>To find</h4><p>P(W=true | R=false). Hidden variables C and S must be summed out.</p></div><h4>Formula and why it applies</h4><p>Use the network joint and divide by the evidence probability. <div class=\"math-display\"><img src=\"math/ec8db3b28ef749de.svg\" alt=\"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)}\" style=\"width:54.182ex;height:5.963ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/bn_sprinkler.a251583272.svg\" width=\"600\" height=\"360\" alt=\"Final 2025 Q3a: sprinkler network\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<div class=\"step\"><h5>Step 1. Joint by the chain rule</h5><div class=\"math-display\"><img src=\"math/62a8884ca57ac2e6.svg\" alt=\"P(C,S,R,W)=P(C)\\,P(S\\mid C)\\,P(R\\mid C)\\,P(W\\mid S,R)\" style=\"width:52.278ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Sum over C and S with R = false, W = true</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>C</th><th>S</th><th>P(C)</th><th>P(S|C)</th><th>P(¬R|C)</th><th>P(W|S,¬R)</th><th>Product</th></tr></thead><tbody>\r\n<tr><td>T</td><td>T</td><td>0.5</td><td>0.1</td><td>0.2</td><td>0.90</td><td>0.0090</td></tr>\r\n<tr><td>T</td><td>F</td><td>0.5</td><td>0.9</td><td>0.2</td><td>0.01</td><td>0.0009</td></tr>\r\n<tr><td>F</td><td>T</td><td>0.5</td><td>0.5</td><td>0.8</td><td>0.90</td><td>0.1800</td></tr>\r\n<tr><td>F</td><td>F</td><td>0.5</td><td>0.5</td><td>0.8</td><td>0.01</td><td>0.0020</td></tr>\r\n<tr><td colspan=\"6\"><strong>P(W, ¬R)</strong></td><td><strong>0.1919</strong></td></tr></tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Evidence</h5><div class=\"math-display\"><img src=\"math/97de213766352c7b.svg\" alt=\"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\" style=\"width:73.203ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/c18c31810569b62d.svg\" alt=\"P(W\\mid\\lnot R)=\\frac{0.1919}{0.5}=0.3838\" style=\"width:30.542ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> P(grass wet | no rain) ≈ <strong>0.384</strong>. Without rain, the grass is wet mainly when the sprinkler runs (more likely on non-cloudy days).</div>\r\n<div class=\"keyfix\"><strong>Keep the requested conditional probability separate.</strong> 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.</div>\r\n<h4>Optional comparison: calculate P(Wet) from the same network</h4>\r\n<p>The four no-rain cases already total 0.1919. Now add the four rain cases, keeping the same Cloudy/Sprinkler order.</p>\r\n<div class=\"math-display\"><img src=\"math/fa867c388246e93b.svg\" alt=\"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)\" style=\"width:91.777ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/43750abdd00f3218.svg\" alt=\"P(W,R)=0.0396+0.324+0.0495+0.045=0.4581\" style=\"width:52.048ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/9357fadf4faa85ed.svg\" alt=\"P(W)=P(W,R)+P(W,\\neg R)=0.4581+0.1919=0.6500\" style=\"width:57.884ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/a03cc788f3ded23d.svg\" alt=\"P(R\\mid W)=\\frac{0.4581}{0.6500}\\approx0.704769231\" style=\"width:34.689ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Meaning:</strong> 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.</p>\r\n<div class=\"trap\"><strong>Trap.</strong> 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).</div>\r\n</section>\r\n"},{"id":"q3b","title":"Q3(b) Fuzzy loan-approval system [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Crisp value</th></tr></thead><tbody><tr><td>Credit Score</td><td>55</td></tr><tr><td>Income Stability</td><td>35</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>A complete stated design and its continuous Mamdani centroid.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/5aa4acd6aab4215a.svg\" alt=\"z^*=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:18.101ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Specify the membership functions</h5><table><thead><tr><th>Input / output position</th><th>Triangle</th><th>Peak</th></tr></thead><tbody><tr><td>Low / Reject</td><td>(1,25,50)</td><td>25</td></tr><tr><td>Medium / Consider</td><td>(25,50,75)</td><td>50</td></tr><tr><td>High / Approve</td><td>(50,75,100)</td><td>75</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 2. Write all nine rules</h5><table><thead><tr><th>Credit Score / Income Stability</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Reject</td><td>Reject</td><td>Consider</td></tr><tr><td>Medium</td><td>Reject</td><td>Consider</td><td>Approve</td></tr><tr><td>High</td><td>Consider</td><td>Approve</td><td>Approve</td></tr></tbody></table><p>Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.</p></div><div class=\"step\"><h5>Step 3. Fuzzify Credit Score = 55</h5><div class=\"math-display\"><img src=\"math/b1adf4cfc2121094.svg\" alt=\"\\mu_{Low}(55)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0625f25570fc580f.svg\" alt=\"\\mu_{Medium}(55)=\\frac{75-55}{75-50}=0.8\" style=\"width:28.917ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6f64cb8c41f3eca0.svg\" alt=\"\\mu_{High}(55)=\\frac{55-50}{75-50}=0.2\" style=\"width:26.443ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Fuzzify Income Stability = 35</h5><div class=\"math-display\"><img src=\"math/c3eeae587085fbae.svg\" alt=\"\\mu_{Low}(35)=\\frac{50-35}{50-25}=0.6\" style=\"width:25.797ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d607a558d66f8791.svg\" alt=\"\\mu_{Medium}(35)=\\frac{35-25}{50-25}=0.4\" style=\"width:28.917ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1509e75effd66d75.svg\" alt=\"\\mu_{High}(35)=0\" style=\"width:13.38ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Evaluate all rules and aggregate matching consequents</h5><table><thead><tr><th>Credit Score</th><th>Income Stability</th><th>Firing strength</th><th>Consequent</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>min(0,0.6) = 0</td><td>Reject</td></tr><tr><td>Low</td><td>Medium</td><td>min(0,0.4) = 0</td><td>Reject</td></tr><tr><td>Low</td><td>High</td><td>min(0,0) = 0</td><td>Consider</td></tr><tr><td>Medium</td><td>Low</td><td>min(0.8,0.6) = 0.6</td><td>Reject</td></tr><tr><td>Medium</td><td>Medium</td><td>min(0.8,0.4) = 0.4</td><td>Consider</td></tr><tr><td>Medium</td><td>High</td><td>min(0.8,0) = 0</td><td>Approve</td></tr><tr><td>High</td><td>Low</td><td>min(0.2,0.6) = 0.2</td><td>Consider</td></tr><tr><td>High</td><td>Medium</td><td>min(0.2,0.4) = 0.2</td><td>Approve</td></tr><tr><td>High</td><td>High</td><td>min(0.2,0) = 0</td><td>Approve</td></tr></tbody></table><p>Aggregated label strengths: Reject = 0.6, Consider = 0.4, Approve = 0.2.</p><div class=\"math-display\"><img src=\"math/d1c2a08444481d0c.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:29.283ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Draw the aggregated output</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_loan_aggregate.2c5ffa32a7.svg\" width=\"680\" height=\"300\" alt=\"The shaded upper envelope counts any overlap only once.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The shaded upper envelope counts any overlap only once.</figcaption></figure></div><div class=\"step\"><h5>Step 7. Calculate area and moment of each straight-line strip</h5><p>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.</p><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d68335c9ce0df62c.svg\" alt=\"M=\\frac{b-a}{6}\\big[(2a+b)u+(a+2b)v\\big]\" style=\"width:34.017ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>1</td><td>15.4</td><td>0</td><td>0.6</td><td>4.32</td><td>45.792</td></tr><tr><td>15.4</td><td>25</td><td>0.6</td><td>0.6</td><td>5.76</td><td>116.352</td></tr><tr><td>25</td><td>35</td><td>0.6</td><td>0.6</td><td>6</td><td>180</td></tr><tr><td>35</td><td>40</td><td>0.6</td><td>0.4</td><td>2.5</td><td>93.333333333</td></tr><tr><td>40</td><td>50</td><td>0.4</td><td>0.4</td><td>4</td><td>180</td></tr><tr><td>50</td><td>55</td><td>0.4</td><td>0.4</td><td>2</td><td>105</td></tr><tr><td>55</td><td>65</td><td>0.4</td><td>0.4</td><td>4</td><td>240</td></tr><tr><td>65</td><td>70</td><td>0.4</td><td>0.2</td><td>1.5</td><td>100.833333333</td></tr><tr><td>70</td><td>75</td><td>0.2</td><td>0.2</td><td>1</td><td>72.5</td></tr><tr><td>75</td><td>95</td><td>0.2</td><td>0.2</td><td>4</td><td>340</td></tr><tr><td>95</td><td>100</td><td>0.2</td><td>0</td><td>0.5</td><td>48.333333333</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Divide total moment by total area</h5><div class=\"math-display\"><img src=\"math/04fe6e4450abbfe1.svg\" alt=\"\\sum A=35.58\" style=\"width:13.512ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/db33614c63a7fe19.svg\" alt=\"\\sum M=1522.144\" style=\"width:17.586ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd239737d0e6ec58.svg\" alt=\"z^*=\\frac{1522.144}{35.58}\\approx42.780888139\" style=\"width:30.689ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:centroid-working:start -->\r\n<div class=\"concept-bridge\"><h2>How the centroid table’s breakpoints are obtained</h2><p>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.</p><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>A and M for one table row.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ee3fb707739e8b69.svg\" alt=\"M=\\frac{b-a}{6}[(2a+b)u+(a+2b)v]\" style=\"width:33.388ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><p>A is trapezoid area. M weights every small area by its horizontal position; this formula integrates a straight line.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Width and height sum</h5><div class=\"math-display\"><img src=\"math/49c4a9b06649aac9.svg\" alt=\"b-a=15.4-1=14.4\\qquad u+v=0.6\" style=\"width:38.5ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Area</h5><div class=\"math-display\"><img src=\"math/344db3e57e5c18d1.svg\" alt=\"A=14.4\\times0.6/2=8.64/2=4.32\" style=\"width:32.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. First bracket term</h5><div class=\"math-display\"><img src=\"math/f077b4473411d432.svg\" alt=\"(2a+b)u=(2+15.4)\\times0=0\" style=\"width:29.861ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Second bracket term</h5><div class=\"math-display\"><img src=\"math/79c1733b7155a919.svg\" alt=\"(a+2b)v=(1+30.8)\\times0.6=31.8\\times0.6=19.08\" style=\"width:48.144ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Moment</h5><div class=\"math-display\"><img src=\"math/26cef63984606712.svg\" alt=\"M=(14.4/6)(0+19.08)=2.4\\times19.08=45.792\" style=\"width:47.381ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Area=4.32; moment=45.792. Repeat the same arithmetic for each row, then sum the areas and moments separately.</div></section></div>\r\n<!-- depth:centroid-working:end --><h3>Interpret the loan result using an explicit decision rule</h3><p>Choose the output label having the greatest membership at the centroid; this is an additional stated interpretation rule. At z=42.780888139:</p><div class=\"math-display\"><img src=\"math/388fb9433b0d08db.svg\" alt=\"\\mu_{Reject}=(50-z)/25\\approx0.288764474,\\quad\\mu_{Consider}=(z-25)/25\\approx0.711235526,\\quad\\mu_{Approve}=0\" style=\"width:90.776ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><p>The resulting recommendation is <strong>Consider / manual review</strong>; 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.</p>"},{"id":"q4a","title":"Q4(a) Cartesian product and max–min composition [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The fuzzy sets or relation matrices and their listed row/column order.</p><h4>To find</h4><p>The relation matrix/matrices and the composition specified in the question.</p></div><h4>Formula and why it applies</h4><p>For Cartesian products take min of row and column membership. For the ordered matrix composition shown here: <div class=\"math-display\"><img src=\"math/1a39e95150df91b7.svg\" alt=\"T_{ik}=\\max_j\\min(S_{ij},R_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div> If max–product is asked instead, replace the inner min by multiplication.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. R = A × B (rows small, medium, large; columns slow, moderate, fast)</h5>\r\n<div class=\"math-display\"><img src=\"math/9db67d15872888f6.svg\" alt=\"R=\\begin{bmatrix}\\min(.4,.2)&amp;\\min(.4,.7)&amp;\\min(.4,.3)\\\\\\min(.3,.2)&amp;\\min(.3,.7)&amp;\\min(.3,.3)\\\\\\min(.1,.2)&amp;\\min(.1,.7)&amp;\\min(.1,.3)\\end{bmatrix}=\\begin{bmatrix}0.2&amp;0.4&amp;0.3\\\\0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\end{bmatrix}\" style=\"width:61.686ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. S = C × B</h5>\r\n<div class=\"math-display\"><img src=\"math/03c1b332a4b4facf.svg\" alt=\"S=\\begin{bmatrix}0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\\\0.2&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:20.694ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. S ∘ R by max–min (row of S with column of R)</h5>\r\n<p>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.</p>\r\n<div class=\"math-display\"><img src=\"math/2134a14de60dd459.svg\" alt=\"(1,1)=\\max[\\min(.2,.2),\\min(.3,.2),\\min(.3,.1)]=\\max(.2,.2,.1)=0.2\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/b81568f26ae092d4.svg\" alt=\"(1,2)=\\max[\\min(.2,.4),\\min(.3,.3),\\min(.3,.1)]=\\max(.2,.3,.1)=0.3\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/0857c1f332a31d0c.svg\" alt=\"(1,3)=\\max[\\min(.2,.3),\\min(.3,.3),\\min(.3,.1)]=0.3\" style=\"width:51.609ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Row 2 of S is all 0.1, so every entry of row 2 is 0.1.</p>\r\n<div class=\"math-display\"><img src=\"math/7cbca4576287a20a.svg\" alt=\"(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\" style=\"width:108.309ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/564480fc64ab9d52.svg\" alt=\"S\\circ R=\\begin{bmatrix}0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\\\0.2&amp;0.3&amp;0.3\\end{bmatrix}\" style=\"width:24.548ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> 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.</div>\r\n<div class=\"note\"><strong>A careful remark you can add.</strong> 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.</div>\r\n</section>\r\n\r\n<!-- depth:all-cells:start -->\r\n<div class=\"concept-bridge\"><h2>Every cell without the row shortcuts</h2><p>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.</p><h3>R: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>R11</td><td>0.4</td><td>0.2</td><td>0.2</td></tr><tr><td>R12</td><td>0.4</td><td>0.7</td><td>0.4</td></tr><tr><td>R13</td><td>0.4</td><td>0.3</td><td>0.3</td></tr><tr><td>R21</td><td>0.3</td><td>0.2</td><td>0.2</td></tr><tr><td>R22</td><td>0.3</td><td>0.7</td><td>0.3</td></tr><tr><td>R23</td><td>0.3</td><td>0.3</td><td>0.3</td></tr><tr><td>R31</td><td>0.1</td><td>0.2</td><td>0.1</td></tr><tr><td>R32</td><td>0.1</td><td>0.7</td><td>0.1</td></tr><tr><td>R33</td><td>0.1</td><td>0.3</td><td>0.1</td></tr></tbody></table><h3>S: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>S11</td><td>0.3</td><td>0.2</td><td>0.2</td></tr><tr><td>S12</td><td>0.3</td><td>0.7</td><td>0.3</td></tr><tr><td>S13</td><td>0.3</td><td>0.3</td><td>0.3</td></tr><tr><td>S21</td><td>0.1</td><td>0.2</td><td>0.1</td></tr><tr><td>S22</td><td>0.1</td><td>0.7</td><td>0.1</td></tr><tr><td>S23</td><td>0.1</td><td>0.3</td><td>0.1</td></tr><tr><td>S31</td><td>0.4</td><td>0.2</td><td>0.2</td></tr><tr><td>S32</td><td>0.4</td><td>0.7</td><td>0.4</td></tr><tr><td>S33</td><td>0.4</td><td>0.3</td><td>0.3</td></tr></tbody></table><p><strong>Result cell (1,1)</strong></p><div class=\"math-display\"><img src=\"math/04a79caa9a98c1c4.svg\" alt=\"\\max\\{\\min(0.2,0.2),\\min(0.3,0.2),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,2)</strong></p><div class=\"math-display\"><img src=\"math/fb42face9e153c77.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.3,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,3)</strong></p><div class=\"math-display\"><img src=\"math/4535d46543709132.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.3,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,1)</strong></p><div class=\"math-display\"><img src=\"math/b8bd41528e9d1a36.svg\" alt=\"\\max\\{\\min(0.1,0.2),\\min(0.1,0.2),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,2)</strong></p><div class=\"math-display\"><img src=\"math/9eda900daa88d0f0.svg\" alt=\"\\max\\{\\min(0.1,0.4),\\min(0.1,0.3),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,3)</strong></p><div class=\"math-display\"><img src=\"math/a0554ac89675d583.svg\" alt=\"\\max\\{\\min(0.1,0.3),\\min(0.1,0.3),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,1)</strong></p><div class=\"math-display\"><img src=\"math/7738d5099a9e3ab1.svg\" alt=\"\\max\\{\\min(0.2,0.2),\\min(0.4,0.2),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,2)</strong></p><div class=\"math-display\"><img src=\"math/952b0167063f5e45.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,3)</strong></p><div class=\"math-display\"><img src=\"math/859d029599adbb59.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:all-cells:end -->"},{"id":"q4b","title":"Q4(b) Naive Bayes: flu [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>The full training data are in Step 1. Query: Fever=Yes, Cough=Yes, Temperature=Normal. The main calculation uses unsmoothed counts.</p><h4>To find</h4><p>Both class scores and the predicted class.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/e0195b1e4ddb0473.svg\" alt=\"score(C)=P(C)\\prod_jP(a_j\\mid C)\" style=\"width:29.642ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the training rows as a table</h5><table><thead><tr><th>Row</th><th>Fever</th><th>Cough</th><th>Temperature</th><th>Class</th></tr></thead><tbody><tr><td>1</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>2</td><td>No</td><td>No</td><td>Normal</td><td>No</td></tr><tr><td>3</td><td>Yes</td><td>No</td><td>Low</td><td>No</td></tr><tr><td>4</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>5</td><td>No</td><td>Yes</td><td>Normal</td><td>No</td></tr><tr><td>6</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>7</td><td>No</td><td>No</td><td>Low</td><td>No</td></tr><tr><td>8</td><td>Yes</td><td>No</td><td>Normal</td><td>No</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Separate the two class groups</h5><table><thead><tr><th>Class</th><th>Rows in this group</th><th>Class count</th><th>Prior</th></tr></thead><tbody><tr><td>Yes</td><td>1, 4, 6</td><td>3</td><td>3/8 = 0.375</td></tr><tr><td>No</td><td>2, 3, 5, 7, 8</td><td>5</td><td>5/8 = 0.625</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. For class Yes, count Fever=Yes</h5><p>Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.</p><div class=\"math-display\"><img src=\"math/bf71c2b5401bc336.svg\" alt=\"P(\\text{Fever}=\\text{Yes}\\mid C=\\text{Yes})=\\frac{3}{3}=1\" style=\"width:35.144ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. For class Yes, count Cough=Yes</h5><p>Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.</p><div class=\"math-display\"><img src=\"math/a6ffcdb19b7e5a36.svg\" alt=\"P(\\text{Cough}=\\text{Yes}\\mid C=\\text{Yes})=\\frac{3}{3}=1\" style=\"width:35.988ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. For class Yes, count Temperature=Normal</h5><p>Look only at class Yes rows 1, 4, 6. No row in this class has that feature value.</p><div class=\"math-display\"><img src=\"math/2bcd33037561157b.svg\" alt=\"P(\\text{Temperature}=\\text{Normal}\\mid C=\\text{Yes})=\\frac{0}{3}=0\" style=\"width:46.176ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the Yes score one factor at a time</h5><div class=\"math-display\"><img src=\"math/c3f053c53b40a9b7.svg\" alt=\"P(Yes)=3/8=0.375\" style=\"width:21.883ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f8249f6f69de64a.svg\" alt=\"0.375\\times1=0.375\" style=\"width:17.222ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f8249f6f69de64a.svg\" alt=\"0.375\\times1=0.375\" style=\"width:17.222ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e5245fc04fe5be62.svg\" alt=\"0.375\\times0=0\" style=\"width:13.199ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. For class No, count Fever=Yes</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 3, 8.</p><div class=\"math-display\"><img src=\"math/2feb71df5b426bfc.svg\" alt=\"P(\\text{Fever}=\\text{Yes}\\mid C=\\text{No})=\\frac{2}{5}=0.4\" style=\"width:36.14ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. For class No, count Cough=Yes</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/d406a69469adaf9b.svg\" alt=\"P(\\text{Cough}=\\text{Yes}\\mid C=\\text{No})=\\frac{1}{5}=0.2\" style=\"width:36.984ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. For class No, count Temperature=Normal</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 2, 5, 8.</p><div class=\"math-display\"><img src=\"math/738acde5b7f3afea.svg\" alt=\"P(\\text{Temperature}=\\text{Normal}\\mid C=\\text{No})=\\frac{3}{5}=0.6\" style=\"width:47.171ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Multiply the No score one factor at a time</h5><div class=\"math-display\"><img src=\"math/b83bf0fcbd8f3bee.svg\" alt=\"P(No)=5/8=0.625\" style=\"width:21.147ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ccabec7597d2610a.svg\" alt=\"0.625\\times0.4=0.25\" style=\"width:17.851ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4b7931095eb1884c.svg\" alt=\"0.25\\times0.2=0.05\" style=\"width:16.719ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fcec3b47d13c61a4.svg\" alt=\"0.05\\times0.6=0.03\" style=\"width:16.719ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Compare the scores</h5><div class=\"math-display\"><img src=\"math/9f7a6514218ef651.svg\" alt=\"score(Yes)=0\\qquad score(No)=0.03\" style=\"width:36.607ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The larger score belongs to No. Normalise only if a posterior probability is requested: divide each score by their total 0.03.</p></div><div class=\"answer\"><strong>Final answer.</strong> Predict No. Yes score=0; No score=0.03.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.</p>"},{"id":"q5a","title":"Q5(a) Hotel guest movement (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: P, L, R. Initial vector [50, 30, 20].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>P</th><th>L</th><th>R</th></tr></thead><tbody><tr><td>P</td><td>0.6</td><td>0.25</td><td>0.15</td></tr><tr><td>L</td><td>0.3</td><td>0.5</td><td>0.2</td></tr><tr><td>R</td><td>0.2</td><td>0.3</td><td>0.5</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_hotel.55f5204329.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to P</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to P</th><th>Contribution</th></tr></thead><tbody><tr><td>P</td><td>50</td><td>0.6</td><td>50 × 0.6 = 30</td></tr><tr><td>L</td><td>30</td><td>0.3</td><td>30 × 0.3 = 9</td></tr><tr><td>R</td><td>20</td><td>0.2</td><td>20 × 0.2 = 4</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/26b7dba609bb77e3.svg\" alt=\"P_{new}=30+9+4=43\" style=\"width:22.844ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to L</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to L</th><th>Contribution</th></tr></thead><tbody><tr><td>P</td><td>50</td><td>0.25</td><td>50 × 0.25 = 12.5</td></tr><tr><td>L</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr><tr><td>R</td><td>20</td><td>0.3</td><td>20 × 0.3 = 6</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/141ce72082fe6ed8.svg\" alt=\"L_{new}=12.5+15+6=33.5\" style=\"width:27.584ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to R</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to R</th><th>Contribution</th></tr></thead><tbody><tr><td>P</td><td>50</td><td>0.15</td><td>50 × 0.15 = 7.5</td></tr><tr><td>L</td><td>30</td><td>0.2</td><td>30 × 0.2 = 6</td></tr><tr><td>R</td><td>20</td><td>0.5</td><td>20 × 0.5 = 10</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/1cfa32a9ab8dc27f.svg\" alt=\"R_{new}=7.5+6+10=23.5\" style=\"width:26.629ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: write the Paris equation</h5><div class=\"math-display\"><img src=\"math/a8c5e214edbb94e4.svg\" alt=\"p=0.6p+0.3l+0.2r\" style=\"width:21.193ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bf5256a21829e5b4.svg\" alt=\"0.4p=0.3l+0.2r\" style=\"width:17.29ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><p>Divide every term by .4.</p><div class=\"math-display\"><img src=\"math/e7f829189002f918.svg\" alt=\"p=0.75l+0.5r\" style=\"width:15.529ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Write the London equation and substitute p</h5><div class=\"math-display\"><img src=\"math/809047184e208e3d.svg\" alt=\"l=0.25p+0.5l+0.3r\" style=\"width:21.861ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f791f1205fe97449.svg\" alt=\"0.5l=0.25(0.75l+0.5r)+0.3r\" style=\"width:30.417ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bc67c26ec7fc1e90.svg\" alt=\"0.5l=0.1875l+0.125r+0.3r\" style=\"width:29.159ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Collect like terms</h5><div class=\"math-display\"><img src=\"math/ac05d4785e692e11.svg\" alt=\"(0.5-0.1875)l=(0.125+0.3)r\" style=\"width:30.985ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d21c86c6a141bc54.svg\" alt=\"0.3125l=0.425r\\quad\\Rightarrow\\quad l=1.36r\" style=\"width:32.929ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af26ae261b198416.svg\" alt=\"p=0.75(1.36r)+0.5r=1.52r\" style=\"width:29.718ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. Use total probability to get all three shares</h5><div class=\"math-display\"><img src=\"math/936703629ebeff23.svg\" alt=\"p+l+r=1\\quad\\Rightarrow\\quad1.52r+1.36r+r=1\" style=\"width:41.343ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/76317a80ed92e6f4.svg\" alt=\"3.88r=1\\quad r=1/3.88=25/97\" style=\"width:30.449ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/442f9f9b9a48c0ce.svg\" alt=\"l=1.36(25/97)=34/97\\quad p=1.52(25/97)=38/97\" style=\"width:50.333ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>P</td><td>0.5</td><td>0.391752577</td><td>-0.108247423</td><td>Loses</td></tr><tr><td>L</td><td>0.3</td><td>0.350515464</td><td>0.050515464</td><td>Gains</td></tr><tr><td>R</td><td>0.2</td><td>0.257731959</td><td>0.057731959</td><td>Gains</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [43.0, 33.5, 23.5]. Stationary shares ≈ [0.391752577, 0.350515464, 0.257731959]. P loses, L gains, R gains.</div></section>"},{"id":"q5b","title":"Q5(b) Genetic algorithm [10]","html":"<p class=\"question\"><strong>Implement a GA to maximise <span class=\"math-inline\"><img src=\"math/aacd674038ffd6be.svg\" alt=\"f(x)=2x^3-5x^2+7x\" style=\"width:22.099ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> 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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><p><strong>The printed data are inconsistent.</strong> 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.</p><p>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.</p><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Two valid children under the declared assumptions and their fitness.</p></div><h4>Formula and why it applies</h4><p>Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.</p><div class=\"math-display\"><img src=\"math/fb065d212fc56261.svg\" alt=\"f(x)=2x^3-5x^2+7x\" style=\"width:22.099ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Encode and evaluate the declared parent population</h5><table><thead><tr><th>x</th><th>Binary</th><th>Fitness substitution</th></tr></thead><tbody><tr><td>13</td><td>1101</td><td>2(13³) − 5(13²) + 7(13) = 3640</td></tr><tr><td>6</td><td>0110</td><td>2(6³) − 5(6²) + 7(6) = 294</td></tr><tr><td>2</td><td>0010</td><td>2(2³) − 5(2²) + 7(2) = 10</td></tr><tr><td>7</td><td>0111</td><td>2(7³) − 5(7²) + 7(7) = 490</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Select the two fittest under the stated assumption</h5><p>[13, 7] with fitness [3640, 490].</p></div><div class=\"step\"><h5>Step 3. Cut after bit 2 and exchange tails</h5><table><thead><tr><th>Parent 1</th><th>Parent 2</th><th>Child 1</th><th>Child 2</th></tr></thead><tbody><tr><td>11 | 01</td><td>01 | 11</td><td>1111</td><td>0101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Flip the last bit of each child</h5><table><thead><tr><th>Before</th><th>After</th><th>Decoded x</th></tr></thead><tbody><tr><td>1111</td><td>1110</td><td>14</td></tr><tr><td>0101</td><td>0100</td><td>4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Evaluate both children</h5><table><thead><tr><th>x</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>14</td><td>2(2744) − 5(196) + 7(14) = 4606</td></tr><tr><td>4</td><td>2(64) − 5(16) + 7(4) = 76</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Compare with the selected parents</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:polynomial-working:start -->\r\n<div class=\"concept-bridge\"><h2>Evaluate the polynomial without skipping the powers</h2><p>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.</p><h3>x=13</h3><div class=\"math-display\"><img src=\"math/3b2d51c91ac2cf33.svg\" alt=\"x^2=13\\times13=169\\qquad x^3=169\\times13=2197\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b223b59b645fb4b2.svg\" alt=\"2x^3=4394\\quad 5x^2=845\\quad 7x=91\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/729d7b573feaaf95.svg\" alt=\"f(13)=4394-845+91=3640\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=6</h3><div class=\"math-display\"><img src=\"math/4a05c63ed6e04319.svg\" alt=\"x^2=6\\times6=36\\qquad x^3=36\\times6=216\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/402fc08edced6189.svg\" alt=\"2x^3=432\\quad 5x^2=180\\quad 7x=42\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a5f219480ddd154a.svg\" alt=\"f(6)=432-180+42=294\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=2</h3><div class=\"math-display\"><img src=\"math/3a35f3beb07d2871.svg\" alt=\"x^2=2\\times2=4\\qquad x^3=4\\times2=8\" style=\"width:33.476ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/42f55d86ed2302e7.svg\" alt=\"2x^3=16\\quad 5x^2=20\\quad 7x=14\" style=\"width:29.615ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/235889b9921ff9b5.svg\" alt=\"f(2)=16-20+14=10\" style=\"width:24.751ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=7</h3><div class=\"math-display\"><img src=\"math/eac1f56ad09d694c.svg\" alt=\"x^2=7\\times7=49\\qquad x^3=49\\times7=343\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e9a8667a88c96f77.svg\" alt=\"2x^3=686\\quad 5x^2=245\\quad 7x=49\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8c54966ea16cb628.svg\" alt=\"f(7)=686-245+49=490\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=15</h3><div class=\"math-display\"><img src=\"math/8c2aaf117e33ac77.svg\" alt=\"x^2=15\\times15=225\\qquad x^3=225\\times15=3375\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9652ff9e90959bb5.svg\" alt=\"2x^3=6750\\quad 5x^2=1125\\quad 7x=105\" style=\"width:35.271ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1609c9dac811fd7a.svg\" alt=\"f(15)=6750-1125+105=5730\" style=\"width:33.801ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=5</h3><div class=\"math-display\"><img src=\"math/63703f64d73bd95d.svg\" alt=\"x^2=5\\times5=25\\qquad x^3=25\\times5=125\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c7ab1b91c2eced73.svg\" alt=\"2x^3=250\\quad 5x^2=125\\quad 7x=35\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b80fc8e2e02f0c86.svg\" alt=\"f(5)=250-125+35=160\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=14</h3><div class=\"math-display\"><img src=\"math/13e67d57f1606f3f.svg\" alt=\"x^2=14\\times14=196\\qquad x^3=196\\times14=2744\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7a11853924c667dd.svg\" alt=\"2x^3=5488\\quad 5x^2=980\\quad 7x=98\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4be8ca3a4ac49622.svg\" alt=\"f(14)=5488-980+98=4606\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=4</h3><div class=\"math-display\"><img src=\"math/9c1546066fc40eda.svg\" alt=\"x^2=4\\times4=16\\qquad x^3=16\\times4=64\" style=\"width:36.869ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a4dd7bf5365d3c7e.svg\" alt=\"2x^3=128\\quad 5x^2=80\\quad 7x=28\" style=\"width:30.746ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/818af979753c0a98.svg\" alt=\"f(4)=128-80+28=76\" style=\"width:25.882ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>“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.</p></div>\r\n<!-- depth:polynomial-working:end -->"},{"id":"q6a","title":"Q6(a) Applications of fuzzy logic [10]","html":"<p class=\"question\"><strong>List the applications of fuzzy logic. Explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition</h3>\r\n<p>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”.</p>\r\n<h3>Applications</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Area</th><th>Examples</th></tr></thead><tbody>\r\n<tr><td>Home appliances</td><td>Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners</td></tr>\r\n<tr><td>Automotive</td><td>Automatic transmission, anti-lock braking (ABS), cruise control, engine control</td></tr>\r\n<tr><td>Transportation</td><td>Traffic-signal control, Sendai subway train control (smooth braking and acceleration)</td></tr>\r\n<tr><td>Consumer electronics</td><td>Camera autofocus and auto-exposure, image stabilisation</td></tr>\r\n<tr><td>Industrial control</td><td>Cement kilns, pH, temperature and distillation control in chemical plants</td></tr>\r\n<tr><td>Aerospace</td><td>Satellite and spacecraft attitude control</td></tr>\r\n<tr><td>Medicine</td><td>Diagnosis support, anaesthesia dosage control</td></tr>\r\n<tr><td>Finance and decisions</td><td>Loan approval, credit and fire-risk scoring, stock trading rules</td></tr>\r\n<tr><td>AI and robotics</td><td>Robot navigation, natural-language interfaces, expert systems</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>One application in detail: fuzzy washing machine</h3>\r\n<ol>\r\n<li><strong>Problem.</strong> 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.</li>\r\n<li><strong>Inputs and outputs.</strong> 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.</li>\r\n<li><strong>Fuzzification.</strong> Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.</li>\r\n<li><strong>Rule base.</strong> 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.</li>\r\n<li><strong>Inference.</strong> Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.</li>\r\n<li><strong>Defuzzification.</strong> 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.</li>\r\n<li><strong>Benefits.</strong> Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.</li>\r\n</ol>\r\n<h3>Advantages and disadvantages (bonus)</h3>\r\n<p><strong>Advantages:</strong> handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. <strong>Disadvantages:</strong> 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.</p>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.</div>\r\n"},{"id":"q6b","title":"Q6(b) Learner progression (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: B, I, A. Initial vector [50, 30, 20].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>B</th><th>I</th><th>A</th></tr></thead><tbody><tr><td>B</td><td>0.6</td><td>0.3</td><td>0.1</td></tr><tr><td>I</td><td>0.2</td><td>0.5</td><td>0.3</td></tr><tr><td>A</td><td>0</td><td>0.1</td><td>0.9</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_learning.61a789edc7.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to B</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to B</th><th>Contribution</th></tr></thead><tbody><tr><td>B</td><td>50</td><td>0.6</td><td>50 × 0.6 = 30</td></tr><tr><td>I</td><td>30</td><td>0.2</td><td>30 × 0.2 = 6</td></tr><tr><td>A</td><td>20</td><td>0</td><td>20 × 0 = 0</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/60af91b5a47e34d2.svg\" alt=\"B_{new}=30+6+0=36\" style=\"width:23.109ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to I</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to I</th><th>Contribution</th></tr></thead><tbody><tr><td>B</td><td>50</td><td>0.3</td><td>50 × 0.3 = 15</td></tr><tr><td>I</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr><tr><td>A</td><td>20</td><td>0.1</td><td>20 × 0.1 = 2</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/d10fe140b0e969ab.svg\" alt=\"I_{new}=15+15+2=32\" style=\"width:23.518ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to A</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to A</th><th>Contribution</th></tr></thead><tbody><tr><td>B</td><td>50</td><td>0.1</td><td>50 × 0.1 = 5</td></tr><tr><td>I</td><td>30</td><td>0.3</td><td>30 × 0.3 = 9</td></tr><tr><td>A</td><td>20</td><td>0.9</td><td>20 × 0.9 = 18</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/e07af325efaf974e.svg\" alt=\"A_{new}=5+9+18=32\" style=\"width:23.088ex;height:1.977ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: balance the Beginner column</h5><div class=\"math-display\"><img src=\"math/e6252d668732cace.svg\" alt=\"b=0.6b+0.2i\" style=\"width:14.287ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a1b2778c1d42930.svg\" alt=\"0.4b=0.2i\\quad\\Rightarrow\\quad i=2b\" style=\"width:24.495ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Balance the Advanced column</h5><div class=\"math-display\"><img src=\"math/6e1d2349f082467b.svg\" alt=\"a=0.1b+0.3i+0.9a\" style=\"width:21.368ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e730f86d7c6fb366.svg\" alt=\"0.1a=0.1b+0.3(2b)=0.7b\" style=\"width:27.366ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4e3c76ca7c5b3101.svg\" alt=\"a=0.7b/0.1=7b\" style=\"width:17.217ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Use the sum of shares</h5><div class=\"math-display\"><img src=\"math/8e00c1c8e9302c7a.svg\" alt=\"b+i+a=1\\quad b+2b+7b=1\" style=\"width:29.744ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/401c3cb4b3606dfc.svg\" alt=\"10b=1\\quad b=0.1\\quad i=0.2\\quad a=0.7\" style=\"width:34.842ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><p>Advanced is not an absorbing state: its self-transition is .9, not 1.</p></div><div class=\"step\"><h5>Step 9. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>B</td><td>0.5</td><td>0.1</td><td>-0.4</td><td>Loses</td></tr><tr><td>I</td><td>0.3</td><td>0.2</td><td>-0.1</td><td>Loses</td></tr><tr><td>A</td><td>0.2</td><td>0.7</td><td>0.5</td><td>Gains</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [36.0, 32.0, 32.0]. Stationary shares ≈ [0.1, 0.2, 0.7]. B loses, I loses, A gains.</div></section>"},{"id":"q7a","title":"Q7(a) Applications of PSO [10]","html":"<p class=\"question\"><strong>List the applications of Particle Swarm Optimization and explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Function optimisation</strong>: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.</li>\r\n<li><strong>Neural-network training</strong>: optimising weights and biases (your Lab 8 uses the pyswarms library for this).</li>\r\n<li><strong>Hyper-parameter tuning</strong> of ML models (learning rate, number of hidden units, SVM C and γ).</li>\r\n<li><strong>Feature selection</strong>: choosing the most useful subset of features (binary PSO).</li>\r\n<li><strong>Image processing</strong>: threshold selection for segmentation, edge detection, image enhancement.</li>\r\n<li><strong>Path planning</strong> for robots and drones: shortest collision-free path.</li>\r\n<li><strong>Power systems</strong>: economic load dispatch, optimal placement of capacitors.</li>\r\n<li><strong>Control engineering</strong>: tuning PID controller gains.</li>\r\n<li><strong>Scheduling and wireless sensor networks</strong>: job scheduling, sensor node placement and clustering.</li>\r\n</ol>\r\n\r\n<h3>One application in detail: training a neural network with PSO</h3>\r\n<div class=\"flow\"><div class=\"node\">Training data</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Neural network with weights = particle position</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Error (fitness)</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">PSO moves the weights</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Best weights = gbest</div></div>\r\n<ol>\r\n<li><strong>Encoding.</strong> 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.</li>\r\n<li><strong>Fitness.</strong> 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).</li>\r\n<li><strong>Search.</strong> 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).</li>\r\n<li><strong>Stop</strong> after a fixed number of iterations or when the error stops improving; gbest is the trained network.</li>\r\n<li><strong>Why PSO here:</strong> 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. <strong>Limitation:</strong> 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.</li>\r\n</ol>\r\n\r\n<h3>Advantages and disadvantages (add for 10 marks)</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Disadvantages</th></tr></thead><tbody>\r\n<tr><td>Simple to implement; few parameters (w, c₁, c₂)</td><td>Can converge prematurely to a local optimum</td></tr>\r\n<tr><td>No derivatives needed</td><td>Sensitive to parameter choice</td></tr>\r\n<tr><td>Fast convergence in early iterations; memory (pbest, gbest)</td><td>No guarantee of the global optimum</td></tr>\r\n<tr><td>Objective evaluations can be parallel; particles share information through gbest</td><td>Less suited to discrete problems without modification</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<p class=\"marks-split\">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).</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.</div>\r\n"},{"id":"q7b","title":"Q7(b) ACO for TSP [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4>\r\n<div class=\"math-display\"><img src=\"math/ff22cd24b937efcc.svg\" alt=\"D=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;4&amp;2&amp;4\\\\B&amp;4&amp;0&amp;3&amp;6\\\\C&amp;2&amp;3&amp;0&amp;2\\\\D&amp;4&amp;6&amp;2&amp;0\\end{array}\\qquad \\tau=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;1&amp;1&amp;1\\\\B&amp;1&amp;0&amp;1&amp;1\\\\C&amp;1&amp;1&amp;0&amp;1\\\\D&amp;1&amp;1&amp;1&amp;0\\end{array}\" style=\"width:48.522ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Assume <span class=\"math-inline\"><img src=\"math/8fe45a81f0de6694.svg\" alt=\"\\alpha=\\beta=1\" style=\"width:9.894ex;height:2.034ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/d7320dc626d3d883.svg\" alt=\"\\rho=0.5\" style=\"width:7.078ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/bd5a6aec418f8f8f.svg\" alt=\"Q=1\" style=\"width:5.938ex;height:2.032ex\" loading=\"lazy\" decoding=\"async\"></span> (class convention; not stated in the question).</p>\r\n<h4>To find</h4><p>Tour of each ant, tour lengths, updated pheromone matrix.</p></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_final_graph.ac3cd4aeac.svg\" width=\"520\" height=\"380\" alt=\"Final 2025 Q7b: distances (all pheromones start at 1)\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n<h4>Formula and why it applies</h4>\r\n<div class=\"math-display\"><img src=\"math/4a0efb39e84f4c4e.svg\" alt=\"P_{ij}=\\frac{\\tau_{ij}\\,\\eta_{ij}}{\\sum_{l\\in\\text{allowed}}\\tau_{il}\\,\\eta_{il}},\\qquad\\eta_{ij}=\\frac1{d_{ij}}\" style=\"width:36.172ex;height:5.352ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/b8a3f5425a6d79b2.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}+\\sum_{k:\\,ij\\in\\mathrm{tour}_k}\\frac{Q}{L_k}\" style=\"width:30.857ex;height:6.181ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The sum includes <strong>only ants whose completed tour contains edge ij</strong>. 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.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Probabilities from A (both ants start at A)</h5>\r\n<div class=\"math-display\"><img src=\"math/b5d4297d164fecda.svg\" alt=\"\\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\" style=\"width:89.871ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Move</th><th>P</th><th>Cumulative</th><th>Range</th></tr></thead><tbody><tr><td>A→B</td><td>0.25</td><td>0.25</td><td>0–0.25</td></tr><tr><td>A→C</td><td>0.50</td><td>0.75</td><td>0.25–0.75</td></tr><tr><td>A→D</td><td>0.25</td><td>1.00</td><td>0.75–1</td></tr></tbody></table></div>\r\n<p>Ant 1: r = 0.3 → <strong>C</strong>. Ant 2: r = 0.5 → <strong>C</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 2. Probabilities from C (B and D left)</h5>\r\n<div class=\"math-display\"><img src=\"math/52a7763a8065747e.svg\" alt=\"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\" style=\"width:83.999ex;height:2.773ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative in city order: B 0–0.4, D 0.4–1. Ant 1: r = 0.8 → <strong>D</strong>. Ant 2: r = 0.7 → <strong>D</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 3. Complete the tours</h5><p>Only B is left, then return to A.</p>\r\n<div class=\"math-display\"><img src=\"math/d48c911f3133b5dc.svg\" alt=\"\\text{Ant 1}=\\text{Ant 2}:\\;A\\to C\\to D\\to B\\to A,\\qquad L=2+2+6+4=14\" style=\"width:67.567ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_final_tour.1dbfdb8b98.svg\" width=\"520\" height=\"380\" alt=\"Both ants: A → C → D → B → A, length 14\" loading=\"lazy\" decoding=\"async\"></div></figure></div>\r\n<div class=\"step\"><h5>Step 4. Pheromone update</h5>\r\n<p>Each ant deposits <span class=\"math-inline\"><img src=\"math/799732b628eacf45.svg\" alt=\"Q/L=1/14=0.0714\" style=\"width:21.306ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> on each edge of its tour; two ants used the same four edges (AC, CD, DB, BA), so each gets <span class=\"math-inline\"><img src=\"math/2b49c5f9ee4dd7a9.svg\" alt=\"2/14=0.1429\" style=\"width:13.827ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/beecdfda1143f6eb.svg\" alt=\"\\text{used edge: }(1-0.5)(1)+0.1429=0.6429\\qquad\\text{unused edge (AD, BC): }(1-0.5)(1)+0=0.5\" style=\"width:89.4ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/25cf4d02bee20e2a.svg\" alt=\"\\tau_{\\text{new}}=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;0.6429&amp;0.6429&amp;0.5\\\\B&amp;0.6429&amp;0&amp;0.5&amp;0.6429\\\\C&amp;0.6429&amp;0.5&amp;0&amp;0.6429\\\\D&amp;0.5&amp;0.6429&amp;0.6429&amp;0\\end{array}\" style=\"width:42.542ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> 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.”</div>\r\n<p class=\"marks-split\">Official marking: path of Ant 1 (3) + path of Ant 2 (3) + pheromone matrix (4).</p>\r\n</section>\r\n"}]},{"id":"paper-reexam-2026","title":"Re-examination · 31 Jan 2026","unit":"paper","scope":"Actual TEE re-exam · 100 marks · 3 hours · Q1 compulsory + any 4 of Q2–Q7 · every answer verified (key errors flagged)","sections":[{"id":"q1a","title":"Q1(a) Disease, fever and test joint table [5]","html":"<p class=\"question\"><strong>Question. For a disease Y with fever X as a symptom, a test Z is conducted. Joint probabilities: Disease (Y=1): fever &amp; test+ 0.576, fever &amp; test− 0.144, no fever &amp; test+ 0.072, no fever &amp; 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?</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.</p><h4>To find</h4><p>All requested marginal and conditional probabilities.</p></div><h4>Formula and why it applies</h4><p>Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum. <div class=\"math-display\"><img src=\"math/3b42af132ac8057a.svg\" alt=\"P(A\\mid E)=\\frac{P(A\\cap E)}{P(E)},\\quad P(E)&gt;0\" style=\"width:34.787ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. (1)</h5><div class=\"math-display\"><img src=\"math/e2428bb7484a2222.svg\" alt=\"P(Y{=}1\\mid X{=}1,Z{=}1)=\\frac{0.576}{0.576+0.008}=\\frac{0.576}{0.584}=0.986\" style=\"width:54.738ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. (2) Add every test-positive cell</h5><div class=\"math-display\"><img src=\"math/4ae537c83ce53b71.svg\" alt=\"P(Z{=}1)=0.576+0.072+0.008+0.012=0.668\" style=\"width:48.087ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. (3)</h5><div class=\"math-display\"><img src=\"math/ab59aa2401b72e20.svg\" alt=\"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\" style=\"width:103.115ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> (1) 0.986; (2) 0.668; (3) 0.423.</div>\r\n<div class=\"keyfix\"><strong>Key correction.</strong> 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.</div>\r\n</section>"},{"id":"q1b","title":"Q1(b) Applications of PSO [5]","html":"<p class=\"question\"><strong>List the applications of Particle Swarm Optimization and explain any one application in detail.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3>\r\n\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Function optimisation</strong>: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.</li>\r\n<li><strong>Neural-network training</strong>: optimising weights and biases (your Lab 8 uses the pyswarms library for this).</li>\r\n<li><strong>Hyper-parameter tuning</strong> of ML models (learning rate, number of hidden units, SVM C and γ).</li>\r\n<li><strong>Feature selection</strong>: choosing the most useful subset of features (binary PSO).</li>\r\n<li><strong>Image processing</strong>: threshold selection for segmentation, edge detection, image enhancement.</li>\r\n<li><strong>Path planning</strong> for robots and drones: shortest collision-free path.</li>\r\n<li><strong>Power systems</strong>: economic load dispatch, optimal placement of capacitors.</li>\r\n<li><strong>Control engineering</strong>: tuning PID controller gains.</li>\r\n<li><strong>Scheduling and wireless sensor networks</strong>: job scheduling, sensor node placement and clustering.</li>\r\n</ol>\r\n\r\n<h3>One application in detail: training a neural network with PSO</h3>\r\n<div class=\"flow\"><div class=\"node\">Training data</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Neural network with weights = particle position</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Error (fitness)</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">PSO moves the weights</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Best weights = gbest</div></div>\r\n<ol>\r\n<li><strong>Encoding.</strong> 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.</li>\r\n<li><strong>Fitness.</strong> 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).</li>\r\n<li><strong>Search.</strong> 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).</li>\r\n<li><strong>Stop</strong> after a fixed number of iterations or when the error stops improving; gbest is the trained network.</li>\r\n<li><strong>Why PSO here:</strong> 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. <strong>Limitation:</strong> 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.</li>\r\n</ol>\r\n\r\n<h3>Advantages and disadvantages (add for 10 marks)</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Disadvantages</th></tr></thead><tbody>\r\n<tr><td>Simple to implement; few parameters (w, c₁, c₂)</td><td>Can converge prematurely to a local optimum</td></tr>\r\n<tr><td>No derivatives needed</td><td>Sensitive to parameter choice</td></tr>\r\n<tr><td>Fast convergence in early iterations; memory (pbest, gbest)</td><td>No guarantee of the global optimum</td></tr>\r\n<tr><td>Objective evaluations can be parallel; particles share information through gbest</td><td>Less suited to discrete problems without modification</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<p class=\"marks-split\">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).</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.</div>\r\n"},{"id":"q1c","title":"Q1(c) Fuzzy set operations [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The aligned X and Y memberships printed in this question.</p><h4>To find</h4><p>The four requested membership lists in the original element order.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1−μ for NOT. <div class=\"math-display\"><img src=\"math/e32ad02c5ba3dae5.svg\" alt=\"\\mu_{X\\cup Y}=\\max(\\mu_X,\\mu_Y),\\quad\\mu_{X\\cap Y}=\\min(\\mu_X,\\mu_Y)\" style=\"width:44.598ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div> Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.</p><h4>Solution</h4>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th></tr></thead><tbody>\r\n<tr><td>¬X</td><td>0.3</td><td>0.1</td><td>0.8</td><td>0.6</td><td>0.1</td></tr>\r\n<tr><td>¬Y</td><td>0.4</td><td>0.7</td><td>0.2</td><td>0.3</td><td>0.9</td></tr>\r\n<tr><td><strong>X ∪ Y</strong></td><td>0.7</td><td>0.9</td><td>0.8</td><td>0.7</td><td>0.9</td></tr>\r\n<tr><td><strong>X ∩ Y</strong></td><td>0.6</td><td>0.3</td><td>0.2</td><td>0.4</td><td>0.1</td></tr>\r\n<tr><td><strong>¬X ∪ ¬Y</strong></td><td>0.4</td><td>0.7</td><td>0.8</td><td>0.6</td><td>0.9</td></tr>\r\n<tr><td><strong>¬X ∩ ¬Y</strong></td><td>0.3</td><td>0.1</td><td>0.2</td><td>0.3</td><td>0.1</td></tr>\r\n</tbody></table></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> As in the last four rows. De Morgan check: ¬X ∪ ¬Y = 1 − (X ∩ Y) and ¬X ∩ ¬Y = 1 − (X ∪ Y) ✓.</div>\r\n</section>\r\n\r\n<!-- depth:element-working:start -->\r\n<div class=\"concept-bridge\"><h2>Calculate every element separately</h2><h3>Element c1</h3><div class=\"math-display\"><img src=\"math/c590062072bce4a3.svg\" alt=\"\\neg X:1-0.7=0.3\\qquad\\neg Y:1-0.6=0.4\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a2eea0fe6bbb6b87.svg\" alt=\"X\\cup Y:\\max(0.7,0.6)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ecd4a7a60c39fa85.svg\" alt=\"X\\cap Y:\\min(0.7,0.6)=0.6\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1aca856a2f38fa09.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.3,0.4)=0.4\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4ef33b6f553800c5.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.3,0.4)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c2</h3><div class=\"math-display\"><img src=\"math/ce24f9cbda57e56d.svg\" alt=\"\\neg X:1-0.9=0.1\\qquad\\neg Y:1-0.3=0.7\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/05dee517321dfca3.svg\" alt=\"X\\cup Y:\\max(0.9,0.3)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4a2bc31233f313e7.svg\" alt=\"X\\cap Y:\\min(0.9,0.3)=0.3\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b188e2e037566b1e.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.1,0.7)=0.7\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/82b3199ed4befd72.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.1,0.7)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c3</h3><div class=\"math-display\"><img src=\"math/24c8a43adb44c324.svg\" alt=\"\\neg X:1-0.2=0.8\\qquad\\neg Y:1-0.8=0.2\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ddba21d8acd6b044.svg\" alt=\"X\\cup Y:\\max(0.2,0.8)=0.8\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/247907e255730431.svg\" alt=\"X\\cap Y:\\min(0.2,0.8)=0.2\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/41e12e8e143ca16d.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.8,0.2)=0.8\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ea5cfbc43203761d.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.8,0.2)=0.2\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c4</h3><div class=\"math-display\"><img src=\"math/0b5f5f89785edd94.svg\" alt=\"\\neg X:1-0.4=0.6\\qquad\\neg Y:1-0.7=0.3\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/05b7177b2b3fbf81.svg\" alt=\"X\\cup Y:\\max(0.4,0.7)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1cfa1c76382cbe6b.svg\" alt=\"X\\cap Y:\\min(0.4,0.7)=0.4\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1568254a4bf6e796.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.6,0.3)=0.6\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/edebdcb00abb9544.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.6,0.3)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c5</h3><div class=\"math-display\"><img src=\"math/f594ae61dd359b85.svg\" alt=\"\\neg X:1-0.9=0.1\\qquad\\neg Y:1-0.1=0.9\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/da89b631e703aa27.svg\" alt=\"X\\cup Y:\\max(0.9,0.1)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5461384d5ad733c2.svg\" alt=\"X\\cap Y:\\min(0.9,0.1)=0.1\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2a8b87917a1340f9.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.1,0.9)=0.9\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/601ec64fa8926431.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.1,0.9)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:element-working:end -->"},{"id":"q1d","title":"Q1(d) Savings and current accounts (Markov chain) [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: S, C.</p><h4>To find</h4><p>The transition matrix and state diagram.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>S</th><th>C</th></tr></thead><tbody><tr><td>S</td><td>0.8</td><td>0.2</td></tr><tr><td>C</td><td>0.1</td><td>0.9</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_bank.879499f6eb.svg\" width=\"520\" height=\"280\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"answer\"><strong>Final answer.</strong> The transition matrix and state diagram are given above.</div></section>"},{"id":"q2a","title":"Q2(a) Fuzzy fire-hazard system [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Crisp value</th></tr></thead><tbody><tr><td>Temperature</td><td>65</td></tr><tr><td>Smoke Level</td><td>80</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>A complete stated design and its continuous Mamdani centroid.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/5aa4acd6aab4215a.svg\" alt=\"z^*=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:18.101ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Specify the membership functions</h5><table><thead><tr><th>Input / output position</th><th>Triangle</th><th>Peak</th></tr></thead><tbody><tr><td>Low / Low</td><td>(1,25,50)</td><td>25</td></tr><tr><td>Medium / Moderate</td><td>(25,50,75)</td><td>50</td></tr><tr><td>High / High</td><td>(50,75,100)</td><td>75</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 2. Write all nine rules</h5><table><thead><tr><th>Temperature / Smoke Level</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>Low</td><td>Moderate</td></tr><tr><td>Medium</td><td>Low</td><td>Moderate</td><td>High</td></tr><tr><td>High</td><td>Moderate</td><td>High</td><td>High</td></tr></tbody></table><p>Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.</p></div><div class=\"step\"><h5>Step 3. Fuzzify Temperature = 65</h5><div class=\"math-display\"><img src=\"math/9e3859fafc31a24f.svg\" alt=\"\\mu_{Low}(65)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f35f654b9795c088.svg\" alt=\"\\mu_{Medium}(65)=\\frac{75-65}{75-50}=0.4\" style=\"width:28.917ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/de5666dfbbcb02fc.svg\" alt=\"\\mu_{High}(65)=\\frac{65-50}{75-50}=0.6\" style=\"width:26.443ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Fuzzify Smoke Level = 80</h5><div class=\"math-display\"><img src=\"math/0a1689e705282396.svg\" alt=\"\\mu_{Low}(80)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af4f190a786e2c05.svg\" alt=\"\\mu_{Medium}(80)=0\" style=\"width:15.853ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ec0cdd51e84c6204.svg\" alt=\"\\mu_{High}(80)=\\frac{100-80}{100-75}=0.8\" style=\"width:27.575ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Evaluate all rules and aggregate matching consequents</h5><table><thead><tr><th>Temperature</th><th>Smoke Level</th><th>Firing strength</th><th>Consequent</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>min(0,0) = 0</td><td>Low</td></tr><tr><td>Low</td><td>Medium</td><td>min(0,0) = 0</td><td>Low</td></tr><tr><td>Low</td><td>High</td><td>min(0,0.8) = 0</td><td>Moderate</td></tr><tr><td>Medium</td><td>Low</td><td>min(0.4,0) = 0</td><td>Low</td></tr><tr><td>Medium</td><td>Medium</td><td>min(0.4,0) = 0</td><td>Moderate</td></tr><tr><td>Medium</td><td>High</td><td>min(0.4,0.8) = 0.4</td><td>High</td></tr><tr><td>High</td><td>Low</td><td>min(0.6,0) = 0</td><td>Moderate</td></tr><tr><td>High</td><td>Medium</td><td>min(0.6,0) = 0</td><td>High</td></tr><tr><td>High</td><td>High</td><td>min(0.6,0.8) = 0.6</td><td>High</td></tr></tbody></table><p>Aggregated label strengths: Low = 0, Moderate = 0, High = 0.6.</p><div class=\"math-display\"><img src=\"math/d1c2a08444481d0c.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:29.283ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Draw the aggregated output</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fire_aggregate.e0cab4ad42.svg\" width=\"680\" height=\"300\" alt=\"The shaded upper envelope counts any overlap only once.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The shaded upper envelope counts any overlap only once.</figcaption></figure></div><div class=\"step\"><h5>Step 7. Calculate area and moment of each straight-line strip</h5><p>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.</p><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d68335c9ce0df62c.svg\" alt=\"M=\\frac{b-a}{6}\\big[(2a+b)u+(a+2b)v\\big]\" style=\"width:34.017ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>50</td><td>65</td><td>0</td><td>0.6</td><td>4.5</td><td>270</td></tr><tr><td>65</td><td>85</td><td>0.6</td><td>0.6</td><td>12</td><td>900</td></tr><tr><td>85</td><td>100</td><td>0.6</td><td>0</td><td>4.5</td><td>405</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Divide total moment by total area</h5><div class=\"math-display\"><img src=\"math/2ffb3645f0d4cc76.svg\" alt=\"\\sum A=21\" style=\"width:10.62ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0a14da79e18490bb.svg\" alt=\"\\sum M=1575\" style=\"width:13.564ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/647a203082aabc5c.svg\" alt=\"z^*=\\frac{1575}{21}\\approx75\" style=\"width:15.857ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> For these stated triangles and rules, the centroid is 75. This is in the high-risk region of this illustrative fuzzy design.</div></section><p>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.</p>\r\n\r\n<!-- depth:centroid-working:start -->\r\n<div class=\"concept-bridge\"><h2>Why the clipped High shape is symmetric about 75</h2><p>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.</p><table><thead><tr><th>Piece</th><th>Area calculation</th><th>Centre</th><th>Moment</th></tr></thead><tbody><tr><td>Left triangle [50,65]</td><td>½×15×.6=4.5</td><td>(50+65+65)/3=60</td><td>4.5×60=270</td></tr><tr><td>Rectangle [65,85]</td><td>20×.6=12</td><td>(65+85)/2=75</td><td>12×75=900</td></tr><tr><td>Right triangle [85,100]</td><td>½×15×.6=4.5</td><td>(85+85+100)/3=90</td><td>4.5×90=405</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:centroid-working:end -->"},{"id":"q2b","title":"Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Read the derivation’s symbols first</h2><p>“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. λ<sub>k</sub><sup>i</sup> in some notes is the same responsibility that other sections call γ<sub>ik</sub>. A superscript i here labels the observation, not an exponent.</p><p>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.</p><table><thead><tr><th>Parameter</th><th>Number in a 1D K-component GMM</th><th>Why</th></tr></thead><tbody><tr><td>Means</td><td>K</td><td>One centre for each component</td></tr><tr><td>Variances</td><td>K</td><td>One spread for each component</td></tr><tr><td>Independent mixing weights</td><td>K−1</td><td>The last weight is 1 minus the others</td></tr><tr><td>Total</td><td>3K−1</td><td>K+K+(K−1)</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n\r\n\r\n<div class=\"answer-box\">\r\n<h3>1. GMM versus k-means</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Aspect</th><th>k-means</th><th>GMM</th></tr></thead><tbody>\r\n<tr><td>Assignment</td><td>Hard: each point in exactly one cluster</td><td>Soft: probability <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> of belonging to each cluster</td></tr>\r\n<tr><td>Model</td><td>Geometric: nearest centroid</td><td>Probabilistic generative model <span class=\"math-inline\"><img src=\"math/04ce4e1e89065414.svg\" alt=\"\\sum_k\\pi_k\\mathcal N(\\mu_k,\\Sigma_k)\" style=\"width:16.12ex;height:2.448ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Cluster shape</td><td>Spherical, similar size</td><td>Elliptical, any size/orientation; overlapping clusters</td></tr>\r\n<tr><td>Parameters</td><td>K centroids</td><td>Weights, means, covariances (1-D: 3K − 1)</td></tr>\r\n<tr><td>Algorithm / objective</td><td>Assign–update; minimise squared distances</td><td>EM; maximise log-likelihood</td></tr>\r\n<tr><td>Output</td><td>Hard labels and fitted centroids</td><td>Labels, membership probabilities and a density (useful for anomaly detection)</td></tr>\r\n<tr><td>Relation</td><td colspan=\"2\">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.</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>2. Derivation of the log-likelihood</h3>\r\n<p><strong>Step 1. Model.</strong> Each point is generated by choosing component k with probability <span class=\"math-inline\"><img src=\"math/e60970d7047375ff.svg\" alt=\"\\pi_k\" style=\"width:2.311ex;height:1.332ex\" loading=\"lazy\" decoding=\"async\"></span> and drawing <span class=\"math-inline\"><img src=\"math/f66cfb5e517110e8.svg\" alt=\"x_i\\sim\\mathcal N(\\mu_k,\\sigma_k^2)\" style=\"width:14.731ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>, so its density is <span class=\"math-inline\"><img src=\"math/6550a4aaf9e87286.svg\" alt=\"f_{mix}(x_i)=\\sum_k\\pi_k\\mathcal N(x_i\\mid\\mu_k,\\sigma_k^2)\" style=\"width:30.677ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<p><strong>Step 2. Likelihood.</strong> Points are i.i.d., so the likelihood is a product (θ = all parameters):</p>\r\n<div class=\"math-display\"><img src=\"math/41dc390b2652cd78.svg\" alt=\"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]\" style=\"width:35.259ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 3. Log-likelihood.</strong> Logs turn the product into a sum:</p>\r\n<div class=\"math-display\"><img src=\"math/9a0bb26e3ef13adb.svg\" alt=\"\\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)\" style=\"width:42.737ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 4. Why it cannot be solved directly.</strong> The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.</p>\r\n<p><strong>Step 5. Jensen's inequality.</strong> log is concave, so for weights <span class=\"math-inline\"><img src=\"math/5006fcb64f6c3cf6.svg\" alt=\"\\lambda_k\\ge0,\\;\\sum\\lambda_k=1\" style=\"width:17.378ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: <span class=\"math-inline\"><img src=\"math/742b7c09a1ce32a4.svg\" alt=\"\\log\\big(\\sum_k\\lambda_ka_k\\big)\\ge\\sum_k\\lambda_k\\log a_k\" style=\"width:29.072ex;height:2.713ex\" loading=\"lazy\" decoding=\"async\"></span>. Introduce <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> for every point (<span class=\"math-inline\"><img src=\"math/fbe0441b97e0b9c1.svg\" alt=\"\\sum_k\\lambda_k^i=1\" style=\"width:10.276ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span>), multiply and divide inside the log:</p>\r\n<div class=\"math-display\"><img src=\"math/06dff5bae3d2cfe1.svg\" alt=\"\\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}\" style=\"width:78.361ex;height:6.391ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 6. Estimation (EM).</strong> Maximise the lower bound alternately. Fixing θ gives the E-step <span class=\"math-inline\"><img src=\"math/662cdc674fe7b2c5.svg\" alt=\"\\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)\" style=\"width:41.37ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></span>. Fixing λ and differentiating (with a Lagrange multiplier for <span class=\"math-inline\"><img src=\"math/131aa1c87311a5f9.svg\" alt=\"\\sum\\pi_k=1\" style=\"width:9.225ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>) gives the M-step:</p>\r\n<div class=\"math-display\"><img src=\"math/ffbe3f9b626d2a86.svg\" alt=\"\\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}\" style=\"width:59.614ex;height:6.179ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h3>3. Number of parameters for K = 5</h3><p>The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:</p>\r\n<div class=\"math-display\"><img src=\"math/5d57bdfd8f83239c.svg\" alt=\"2K+(K-1)=3K-1=3(5)-1=\\mathbf{14}\" style=\"width:40.189ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>(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.</p>\r\n</div>\r\n<div class=\"keyfix\"><strong>Slide note.</strong> One slide puts the convex inequality under the “concave” heading. Correct: log is <em>concave</em>, so <span class=\"math-inline\"><img src=\"math/2ddf537dc44d74a6.svg\" alt=\"f(\\sum\\lambda a)\\ge\\sum\\lambda f(a)\" style=\"width:19.59ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (≥, not &gt;).</div>\r\n"},{"id":"q3a","title":"Q3(a) Bayesian network: fever given no flu [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>W→F, W→C, (F,C)→V. The complete probabilities are in the question. Evidence F=false.</p><h4>To find</h4><p>P(V=true | F=false), summing hidden W and C.</p></div><h4>Formula and why it applies</h4><p>Use the network joint and normalise by the no-Flu evidence. <div class=\"math-display\"><img src=\"math/e2104f63677bf585.svg\" alt=\"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)}\" style=\"width:55.005ex;height:5.963ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/bn_flu.1d732f0fb6.svg\" width=\"600\" height=\"360\" alt=\"Re-exam 2026 Q3a: weather–flu–cough–fever network\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<div class=\"step\"><h5>Step 1. Chain rule</h5><div class=\"math-display\"><img src=\"math/73135e72ac19cca4.svg\" alt=\"P(W,F,C,V)=P(W)\\,P(F\\mid W)\\,P(C\\mid W)\\,P(V\\mid F,C)\" style=\"width:54.335ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Sum over W and C with F = false, V = true</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>W</th><th>C</th><th>P(W)</th><th>P(¬F|W)</th><th>P(C|W)</th><th>P(V|¬F,C)</th><th>Product</th></tr></thead><tbody>\r\n<tr><td>T</td><td>T</td><td>0.75</td><td>0.8</td><td>0.70</td><td>0.60</td><td>0.252</td></tr>\r\n<tr><td>T</td><td>F</td><td>0.75</td><td>0.8</td><td>0.30</td><td>0.01</td><td>0.0018</td></tr>\r\n<tr><td>F</td><td>T</td><td>0.25</td><td>0.5</td><td>0.25</td><td>0.60</td><td>0.01875</td></tr>\r\n<tr><td>F</td><td>F</td><td>0.25</td><td>0.5</td><td>0.75</td><td>0.01</td><td>0.0009375</td></tr>\r\n<tr><td colspan=\"6\"><strong>P(V, ¬F)</strong></td><td><strong>0.2734875</strong></td></tr></tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Evidence</h5><div class=\"math-display\"><img src=\"math/a396371c860e59b0.svg\" alt=\"P(\\lnot F)=0.75(0.8)+0.25(0.5)=0.6+0.125=0.725\" style=\"width:51.793ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/a27699b35a63a308.svg\" alt=\"P(V\\mid\\lnot F)=\\frac{0.2734875}{0.725}=0.3772\" style=\"width:33.282ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> P(fever | no flu) ≈ <strong>0.377</strong> (fever without flu comes mostly from cough).</div>\r\n<div class=\"keyfix\"><strong>Key correction.</strong> 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).</div>\r\n</section>\r\n"},{"id":"q3b","title":"Q3(b) Fuzzy relations and composition [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The fuzzy sets or relation matrices and their listed row/column order.</p><h4>To find</h4><p>The relation matrix/matrices and the composition specified in the question.</p></div><h4>Formula and why it applies</h4><p>For Cartesian products take min of row and column membership. For the ordered matrix composition shown here: <div class=\"math-display\"><img src=\"math/1a39e95150df91b7.svg\" alt=\"T_{ik}=\\max_j\\min(S_{ij},R_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div> If max–product is asked instead, replace the inner min by multiplication.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. R and S</h5>\r\n<div class=\"math-display\"><img src=\"math/463247054a5e2b55.svg\" alt=\"R=\\begin{bmatrix}0.4&amp;0.6&amp;0.3\\\\0.4&amp;0.4&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\end{bmatrix},\\qquad S=\\begin{bmatrix}0.4&amp;0.5&amp;0.3\\\\0.2&amp;0.2&amp;0.2\\\\0.4&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:47.176ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. S ∘ R</h5>\r\n<div class=\"math-display\"><img src=\"math/07a16abae3efd072.svg\" alt=\"(1,1)=\\max[\\min(.4,.4),\\min(.5,.4),\\min(.3,.1)]=\\max(.4,.4,.1)=0.4\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/8e54167083aa61b1.svg\" alt=\"(1,2)=\\max[\\min(.4,.6),\\min(.5,.4),\\min(.3,.1)]=\\max(.4,.4,.1)=0.4\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/6ce0ff88a64ad0ef.svg\" alt=\"(1,3)=\\max[\\min(.4,.3),\\min(.5,.3),\\min(.3,.1)]=0.3\" style=\"width:51.609ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c87a743bfa211789.svg\" alt=\"\\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\" style=\"width:100.894ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/f54af3b992bbd86c.svg\" alt=\"R=\\begin{bmatrix}.4&amp;.6&amp;.3\\\\.4&amp;.4&amp;.3\\\\.1&amp;.1&amp;.1\\end{bmatrix}\" style=\"width:17.558ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/acc98fbd37745e57.svg\" alt=\"S=\\begin{bmatrix}.4&amp;.5&amp;.3\\\\.2&amp;.2&amp;.2\\\\.4&amp;.4&amp;.3\\end{bmatrix}\" style=\"width:17.3ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/291bb354e326dcfa.svg\" alt=\"S\\circ R=\\begin{bmatrix}0.4&amp;0.4&amp;0.3\\\\0.2&amp;0.2&amp;0.2\\\\0.4&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:24.548ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>. (The key gives R and S only.)</div>\r\n</section>\r\n\r\n<!-- depth:all-cells:start -->\r\n<div class=\"concept-bridge\"><h2>Every cell without the row shortcuts</h2><p>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.</p><h3>R: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>R11</td><td>0.6</td><td>0.4</td><td>0.4</td></tr><tr><td>R12</td><td>0.6</td><td>0.8</td><td>0.6</td></tr><tr><td>R13</td><td>0.6</td><td>0.3</td><td>0.3</td></tr><tr><td>R21</td><td>0.4</td><td>0.4</td><td>0.4</td></tr><tr><td>R22</td><td>0.4</td><td>0.8</td><td>0.4</td></tr><tr><td>R23</td><td>0.4</td><td>0.3</td><td>0.3</td></tr><tr><td>R31</td><td>0.1</td><td>0.4</td><td>0.1</td></tr><tr><td>R32</td><td>0.1</td><td>0.8</td><td>0.1</td></tr><tr><td>R33</td><td>0.1</td><td>0.3</td><td>0.1</td></tr></tbody></table><h3>S: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>S11</td><td>0.5</td><td>0.4</td><td>0.4</td></tr><tr><td>S12</td><td>0.5</td><td>0.8</td><td>0.5</td></tr><tr><td>S13</td><td>0.5</td><td>0.3</td><td>0.3</td></tr><tr><td>S21</td><td>0.2</td><td>0.4</td><td>0.2</td></tr><tr><td>S22</td><td>0.2</td><td>0.8</td><td>0.2</td></tr><tr><td>S23</td><td>0.2</td><td>0.3</td><td>0.2</td></tr><tr><td>S31</td><td>0.4</td><td>0.4</td><td>0.4</td></tr><tr><td>S32</td><td>0.4</td><td>0.8</td><td>0.4</td></tr><tr><td>S33</td><td>0.4</td><td>0.3</td><td>0.3</td></tr></tbody></table><p><strong>Result cell (1,1)</strong></p><div class=\"math-display\"><img src=\"math/21233f6c94b2b173.svg\" alt=\"\\max\\{\\min(0.4,0.4),\\min(0.5,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,2)</strong></p><div class=\"math-display\"><img src=\"math/999b4f88f5256b56.svg\" alt=\"\\max\\{\\min(0.4,0.6),\\min(0.5,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,3)</strong></p><div class=\"math-display\"><img src=\"math/d50a44d1852d902c.svg\" alt=\"\\max\\{\\min(0.4,0.3),\\min(0.5,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f11631b96248ce3d.svg\" alt=\"=\\max\\{0.3,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,1)</strong></p><div class=\"math-display\"><img src=\"math/c683e55ca4bccac0.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.2,0.4),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,2)</strong></p><div class=\"math-display\"><img src=\"math/5eeb6f5598722d4c.svg\" alt=\"\\max\\{\\min(0.2,0.6),\\min(0.2,0.4),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,3)</strong></p><div class=\"math-display\"><img src=\"math/524a01bd31cd2a0e.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.2,0.3),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,1)</strong></p><div class=\"math-display\"><img src=\"math/4c61c54bcac1075e.svg\" alt=\"\\max\\{\\min(0.4,0.4),\\min(0.4,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,2)</strong></p><div class=\"math-display\"><img src=\"math/cedfe000344abbe9.svg\" alt=\"\\max\\{\\min(0.4,0.6),\\min(0.4,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,3)</strong></p><div class=\"math-display\"><img src=\"math/98186c591a86ee1c.svg\" alt=\"\\max\\{\\min(0.4,0.3),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f11631b96248ce3d.svg\" alt=\"=\\max\\{0.3,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:all-cells:end -->"},{"id":"q4a","title":"Q4(a) PSO, one iteration [10]","html":"<p class=\"question\"><strong>Question. Maximize <span class=\"math-inline\"><img src=\"math/523616224185a5ce.svg\" alt=\"F(x)=x_1^2-x_1x_2+x_2^2+3x_1+4x_2+5\" style=\"width:38.679ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using Particle Swarm Optimization. <span class=\"math-inline\"><img src=\"math/0ba0d9983a41cf83.svg\" alt=\"X=\\begin{bmatrix}3.1472&amp;-4.0246\\\\4.0579&amp;-2.2150\\end{bmatrix},\\;V=\\begin{bmatrix}0.2194&amp;0.2449\\\\0.1908&amp;0.2228\\end{bmatrix}\" style=\"width:47.54ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Take <span class=\"math-inline\"><img src=\"math/d99737a5fc79423b.svg\" alt=\"W=0.9,\\;c_1=c_2=1.5,\\;r_1=0.5949,\\;r_2=0.0855\" style=\"width:48.665ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></span>. Optimize and give the solution after 1 iteration showing the step-by-step process.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4><p>P1: <span class=\"math-inline\"><img src=\"math/f58367ac748ee874.svg\" alt=\"x=(3.1472,\\,-4.0246)\" style=\"width:21.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/582ec15d8b22479d.svg\" alt=\"v=(0.2194,\\,0.2449)\" style=\"width:19.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. P2: <span class=\"math-inline\"><img src=\"math/1588eb472c257b22.svg\" alt=\"x=(4.0579,\\,-2.2150)\" style=\"width:21.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/ea7da7e3a3880e01.svg\" alt=\"v=(0.1908,\\,0.2228)\" style=\"width:19.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. <span class=\"math-inline\"><img src=\"math/37a512f090105dd3.svg\" alt=\"c_1r_1=0.89235\" style=\"width:14.409ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/c760fda5e7728aea.svg\" alt=\"c_2r_2=0.12825\" style=\"width:14.409ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p>Updated velocities, positions, pbest and gbest after one iteration.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/d17ec7429fc5876d.svg\" alt=\"v^{new}=wv+c_1r_1(pbest-x)+c_2r_2(gbest-x),\\quad x^{new}=x+v^{new}\" style=\"width:63.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Fitness of P1 (term by term)</h5>\r\n<div class=\"math-display\"><img src=\"math/3c47a0a1f1465e31.svg\" alt=\"x_1^2=9.904868,\\;-x_1x_2=+12.666221,\\;x_2^2=16.197405,\\;3x_1=9.4416,\\;4x_2=-16.0984\" style=\"width:84.466ex;height:2.559ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/10f900e5ecd1d222.svg\" alt=\"F_1=9.904868+12.666221+16.197405+9.4416-16.0984+5=37.1117\" style=\"width:72.459ex;height:1.878ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Fitness of P2</h5>\r\n<div class=\"math-display\"><img src=\"math/323572bf8ccf630b.svg\" alt=\"F_2=16.466552+8.988249+4.906225+12.1737-8.86+5=38.6747\" style=\"width:69.065ex;height:1.878ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. pbest and gbest</h5><p>pbest = current positions. <span class=\"math-inline\"><img src=\"math/0858b2bce4269ef8.svg\" alt=\"38.6747&gt;37.1117\" style=\"width:17.85ex;height:1.622ex\" loading=\"lazy\" decoding=\"async\"></span>, so <strong>gbest = P2 = (4.0579, −2.2150)</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 4. Particle 1 updates</h5>\r\n<div class=\"math-display\"><img src=\"math/0c6669f7602148c0.svg\" alt=\"v_{11}=0.9(0.2194)+0+0.12825(4.0579-3.1472)=0.19746+0.116797=0.314257\" style=\"width:81.325ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c789efe14e1349c9.svg\" alt=\"x_{11}=3.1472+0.314257=3.461457\" style=\"width:35.262ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/82dc2ed77545eeb8.svg\" alt=\"v_{12}=0.9(0.2449)+0+0.12825(-2.2150+4.0246)=0.22041+0.232081=0.452491\" style=\"width:83.085ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/daa1f4fff8808c55.svg\" alt=\"x_{12}=-4.0246+0.452491=-3.572109\" style=\"width:38.782ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 5. Particle 2 updates (gbest particle: only inertia acts)</h5>\r\n<div class=\"math-display\"><img src=\"math/42d42b7358982c8c.svg\" alt=\"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\" style=\"width:95.402ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 6. New fitness and bests</h5><div data-v2-fitness=\"true\"><p>Use the same objective at each new position. Keep full precision internally; displayed coordinates are rounded.</p><div class=\"math-display\"><img src=\"math/b030a3c1723e90f0.svg\" alt=\"F(3.461457275,-3.5721088)=(3.461457275)^2-(3.461457275)(-3.5721088)+(-3.5721088)^2+3(3.461457275)+4(-3.5721088)+5\" style=\"width:130.757ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/246cb1e4add2ab6e.svg\" alt=\"=11.981686467+12.364701993+12.759961279+10.384371825+(-14.2884352)+5\\approx38.202286364\" style=\"width:100.058ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3fe27d20d1a3f2c2.svg\" alt=\"F(4.22962,-2.01448)=(4.22962)^2-(4.22962)(-2.01448)+(-2.01448)^2+3(4.22962)+4(-2.01448)+5\" style=\"width:103.608ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a64c8baf9521e960.svg\" alt=\"=17.889685344+8.520484898+4.05812967+12.68886+(-8.05792)+5\\approx40.099239912\" style=\"width:88.746ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>New position</th><th>New F</th><th>Old F</th><th>pbest</th></tr></thead><tbody>\r\n<tr><td>1</td><td>(3.461457, −3.572109)</td><td>38.2023</td><td>37.1117</td><td>updated</td></tr>\r\n<tr><td>2</td><td>(4.22962, −2.01448)</td><td>40.0992</td><td>38.6747</td><td>updated</td></tr></tbody></table></div>\r\n<p>The best pbest is now P2's with F = 40.0992, so gbest moves to (4.22962, −2.01448).</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/181c38752c9bafe9.svg\" alt=\"V=\\begin{bmatrix}0.314257&amp;0.452491\\\\0.17172&amp;0.20052\\end{bmatrix}\" style=\"width:26.504ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/751b3a44f8f94dbc.svg\" alt=\"X=\\begin{bmatrix}3.461457&amp;-3.572109\\\\4.22962&amp;-2.01448\\end{bmatrix}\" style=\"width:28.451ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Both particles improved; new gbest = (4.22962, −2.01448) with F = 40.0992.</div>\r\n<div class=\"keyfix\"><strong>Official key warning.</strong> The re-exam answer key solves a <em>different</em> 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.</div>\r\n<p class=\"marks-split\">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).</p>\r\n</section>\r\n"},{"id":"q4b","title":"Q4(b) Naive Bayes: job offer [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>The full training data are in Step 1. Query: Experience=Mid, Salary=Low, Reputation=Good. The main calculation uses unsmoothed counts.</p><h4>To find</h4><p>Both class scores and the predicted class.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/e0195b1e4ddb0473.svg\" alt=\"score(C)=P(C)\\prod_jP(a_j\\mid C)\" style=\"width:29.642ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the training rows as a table</h5><table><thead><tr><th>Row</th><th>Experience</th><th>Salary</th><th>Reputation</th><th>Class</th></tr></thead><tbody><tr><td>1</td><td>Fresher</td><td>Low</td><td>Good</td><td>Yes</td></tr><tr><td>2</td><td>Mid</td><td>High</td><td>Good</td><td>Yes</td></tr><tr><td>3</td><td>Senior</td><td>High</td><td>Average</td><td>No</td></tr><tr><td>4</td><td>Fresher</td><td>Medium</td><td>Average</td><td>Yes</td></tr><tr><td>5</td><td>Senior</td><td>Low</td><td>Good</td><td>No</td></tr><tr><td>6</td><td>Mid</td><td>Medium</td><td>Good</td><td>Yes</td></tr><tr><td>7</td><td>Fresher</td><td>High</td><td>Average</td><td>No</td></tr><tr><td>8</td><td>Senior</td><td>Medium</td><td>Average</td><td>No</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Separate the two class groups</h5><table><thead><tr><th>Class</th><th>Rows in this group</th><th>Class count</th><th>Prior</th></tr></thead><tbody><tr><td>Yes</td><td>1, 2, 4, 6</td><td>4</td><td>4/8 = 0.5</td></tr><tr><td>No</td><td>3, 5, 7, 8</td><td>4</td><td>4/8 = 0.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. For class Yes, count Experience=Mid</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 2, 6.</p><div class=\"math-display\"><img src=\"math/d14d2e65e85aa98c.svg\" alt=\"P(\\text{Experience}=\\text{Mid}\\mid C=\\text{Yes})=\\frac{2}{4}=0.5\" style=\"width:42.49ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. For class Yes, count Salary=Low</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1.</p><div class=\"math-display\"><img src=\"math/b6e871091f36d8f9.svg\" alt=\"P(\\text{Salary}=\\text{Low}\\mid C=\\text{Yes})=\\frac{1}{4}=0.25\" style=\"width:39.285ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. For class Yes, count Reputation=Good</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1, 2, 6.</p><div class=\"math-display\"><img src=\"math/00e0bac1e035a9f7.svg\" alt=\"P(\\text{Reputation}=\\text{Good}\\mid C=\\text{Yes})=\\frac{3}{4}=0.75\" style=\"width:45.266ex;height:4.586ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the Yes score one factor at a time</h5><div class=\"math-display\"><img src=\"math/fa6d94e12c8c8a44.svg\" alt=\"P(Yes)=4/8=0.5\" style=\"width:19.62ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cd8320ff28f21681.svg\" alt=\"0.5\\times0.5=0.25\" style=\"width:15.588ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/646a455657cc6928.svg\" alt=\"0.25\\times0.25=0.0625\" style=\"width:20.113ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9df28e0200ccc17b.svg\" alt=\"0.0625\\times0.75=0.046875\" style=\"width:24.638ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. For class No, count Experience=Mid</h5><p>Look only at class No rows 3, 5, 7, 8. No row in this class has that feature value.</p><div class=\"math-display\"><img src=\"math/210f557f91613842.svg\" alt=\"P(\\text{Experience}=\\text{Mid}\\mid C=\\text{No})=\\frac{0}{4}=0\" style=\"width:39.966ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. For class No, count Salary=Low</h5><p>Look only at class No rows 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/e95fc4843fd44476.svg\" alt=\"P(\\text{Salary}=\\text{Low}\\mid C=\\text{No})=\\frac{1}{4}=0.25\" style=\"width:38.52ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. For class No, count Reputation=Good</h5><p>Look only at class No rows 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/6f502d0eec66aa0e.svg\" alt=\"P(\\text{Reputation}=\\text{Good}\\mid C=\\text{No})=\\frac{1}{4}=0.25\" style=\"width:44.502ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Multiply the No score one factor at a time</h5><div class=\"math-display\"><img src=\"math/7ee037eb525f597a.svg\" alt=\"P(No)=4/8=0.5\" style=\"width:18.885ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e71e2d0a61e9d301.svg\" alt=\"0.5\\times0=0\" style=\"width:10.937ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cf25ab85b70dd28a.svg\" alt=\"0\\times0.25=0\" style=\"width:12.068ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cf25ab85b70dd28a.svg\" alt=\"0\\times0.25=0\" style=\"width:12.068ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Compare the scores</h5><div class=\"math-display\"><img src=\"math/14926697646660d6.svg\" alt=\"score(Yes)=0.046875\\qquad score(No)=0\" style=\"width:41.131ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The larger score belongs to Yes. Normalise only if a posterior probability is requested: divide each score by their total 0.046875.</p></div><div class=\"answer\"><strong>Final answer.</strong> Predict Yes. Yes score=0.046875; No score=0.</div></section><div class=\"keyfix\"><strong>Official key note.</strong> 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.</div><p class=\"memory\"><strong>Yaad rakho:</strong> Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.</p>"},{"id":"q5a","title":"Q5(a) Genetic algorithm [10]","html":"<p class=\"question\"><strong>Implement a GA to maximise <span class=\"math-inline\"><img src=\"math/d678d50d2d5c4ae4.svg\" alt=\"f(x)=2x^3-3x^2+8x\" style=\"width:22.099ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> 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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><p><strong>The printed data are inconsistent.</strong> 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.</p><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Two valid children under the declared assumptions and their fitness.</p></div><h4>Formula and why it applies</h4><p>Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.</p><div class=\"math-display\"><img src=\"math/68385220447af94f.svg\" alt=\"f(x)=2x^3-3x^2+8x\" style=\"width:22.099ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Encode and evaluate the declared parent population</h5><table><thead><tr><th>x</th><th>Binary</th><th>Fitness substitution</th></tr></thead><tbody><tr><td>12</td><td>001100</td><td>2(12³) − 3(12²) + 8(12) = 3120</td></tr><tr><td>20</td><td>010100</td><td>2(20³) − 3(20²) + 8(20) = 14960</td></tr><tr><td>17</td><td>010001</td><td>2(17³) − 3(17²) + 8(17) = 9095</td></tr><tr><td>13</td><td>001101</td><td>2(13³) − 3(13²) + 8(13) = 3991</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Select the two fittest under the stated assumption</h5><p>[20, 17] with fitness [14960, 9095].</p></div><div class=\"step\"><h5>Step 3. Cut after bit 2 and exchange tails</h5><table><thead><tr><th>Parent 1</th><th>Parent 2</th><th>Child 1</th><th>Child 2</th></tr></thead><tbody><tr><td>01 | 0100</td><td>01 | 0001</td><td>010001</td><td>010100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Flip the last bit of each child</h5><table><thead><tr><th>Before</th><th>After</th><th>Decoded x</th></tr></thead><tbody><tr><td>010001</td><td>010000</td><td>16</td></tr><tr><td>010100</td><td>010101</td><td>21</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Evaluate both children</h5><table><thead><tr><th>x</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>16</td><td>2(4096) − 3(256) + 8(16) = 7552</td></tr><tr><td>21</td><td>2(9261) − 3(441) + 8(21) = 17367</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Compare with the selected parents</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:polynomial-working:start -->\r\n<div class=\"concept-bridge\"><h2>Evaluate the polynomial without skipping the powers</h2><p>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.</p><h3>x=12</h3><div class=\"math-display\"><img src=\"math/68dcfd678cb95894.svg\" alt=\"x^2=12\\times12=144\\qquad x^3=144\\times12=1728\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f6a8611548b73ce.svg\" alt=\"2x^3=3456\\quad 3x^2=432\\quad 8x=96\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ece74f225f6dc343.svg\" alt=\"f(12)=3456-432+96=3120\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=20</h3><div class=\"math-display\"><img src=\"math/b143d22c2e5129d2.svg\" alt=\"x^2=20\\times20=400\\qquad x^3=400\\times20=8000\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/581d9ac708a9edf4.svg\" alt=\"2x^3=16000\\quad 3x^2=1200\\quad 8x=160\" style=\"width:36.402ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af62ea37a6cc0979.svg\" alt=\"f(20)=16000-1200+160=14960\" style=\"width:36.063ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=17</h3><div class=\"math-display\"><img src=\"math/8106fc4d3ea404bb.svg\" alt=\"x^2=17\\times17=289\\qquad x^3=289\\times17=4913\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3f446d5c18f6525b.svg\" alt=\"2x^3=9826\\quad 3x^2=867\\quad 8x=136\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/33f7934e87e644ca.svg\" alt=\"f(17)=9826-867+136=9095\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=13</h3><div class=\"math-display\"><img src=\"math/3b2d51c91ac2cf33.svg\" alt=\"x^2=13\\times13=169\\qquad x^3=169\\times13=2197\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/963b6763e9667406.svg\" alt=\"2x^3=4394\\quad 3x^2=507\\quad 8x=104\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fb78bd652840ab88.svg\" alt=\"f(13)=4394-507+104=3991\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=16</h3><div class=\"math-display\"><img src=\"math/1a7d6636e629e211.svg\" alt=\"x^2=16\\times16=256\\qquad x^3=256\\times16=4096\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/116d99ec87e1c7e9.svg\" alt=\"2x^3=8192\\quad 3x^2=768\\quad 8x=128\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f0bfce15122fad53.svg\" alt=\"f(16)=8192-768+128=7552\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=21</h3><div class=\"math-display\"><img src=\"math/db60547636676c53.svg\" alt=\"x^2=21\\times21=441\\qquad x^3=441\\times21=9261\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7a74ad5911e6f0d8.svg\" alt=\"2x^3=18522\\quad 3x^2=1323\\quad 8x=168\" style=\"width:36.402ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/da828d5642e53dc9.svg\" alt=\"f(21)=18522-1323+168=17367\" style=\"width:36.063ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:polynomial-working:end -->"},{"id":"q5b","title":"Q5(b) Hotel booking channels (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: W, A, C. Initial vector [0.4, 0.35, 0.25].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>W</th><th>A</th><th>C</th></tr></thead><tbody><tr><td>W</td><td>0.5</td><td>0.3</td><td>0.2</td></tr><tr><td>A</td><td>0.4</td><td>0.4</td><td>0.2</td></tr><tr><td>C</td><td>0.2</td><td>0.3</td><td>0.5</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_booking.a7176dff51.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to W</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to W</th><th>Contribution</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.5</td><td>0.4 × 0.5 = 0.2</td></tr><tr><td>A</td><td>0.35</td><td>0.4</td><td>0.35 × 0.4 = 0.14</td></tr><tr><td>C</td><td>0.25</td><td>0.2</td><td>0.25 × 0.2 = 0.05</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/0367611df103826d.svg\" alt=\"W_{new}=0.2+0.14+0.05=0.39\" style=\"width:31.699ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to A</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to A</th><th>Contribution</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.3</td><td>0.4 × 0.3 = 0.12</td></tr><tr><td>A</td><td>0.35</td><td>0.4</td><td>0.35 × 0.4 = 0.14</td></tr><tr><td>C</td><td>0.25</td><td>0.3</td><td>0.25 × 0.3 = 0.075</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/5f59f5d8bf197b8d.svg\" alt=\"A_{new}=0.12+0.14+0.075=0.335\" style=\"width:34.654ex;height:1.977ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to C</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to C</th><th>Contribution</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.2</td><td>0.4 × 0.2 = 0.08</td></tr><tr><td>A</td><td>0.35</td><td>0.2</td><td>0.35 × 0.2 = 0.07</td></tr><tr><td>C</td><td>0.25</td><td>0.5</td><td>0.25 × 0.5 = 0.125</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/7892e8414e63bbd0.svg\" alt=\"C_{new}=0.08+0.07+0.125=0.275\" style=\"width:34.575ex;height:1.952ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: find Counter first</h5><div class=\"math-display\"><img src=\"math/39cb7355944fbe4a.svg\" alt=\"c=0.2w+0.2a+0.5c\" style=\"width:21.999ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><p>Since w+a+c=1, replace w+a with 1−c.</p><div class=\"math-display\"><img src=\"math/49f2613d4b58dc75.svg\" alt=\"c=0.2(1-c)+0.5c=0.2+0.3c\" style=\"width:32.707ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/eaaea4df9a4e16b6.svg\" alt=\"0.7c=0.2\\quad c=2/7\" style=\"width:19.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Find App in terms of Website</h5><div class=\"math-display\"><img src=\"math/ac7bb8ac13980636.svg\" alt=\"a=0.3w+0.4a+0.3c\" style=\"width:22.216ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5e60a8a8d562c8fe.svg\" alt=\"0.6a=0.3w+0.3c\\quad a=0.5w+0.5c\" style=\"width:35.878ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Use the sum to isolate Website</h5><div class=\"math-display\"><img src=\"math/748747a4be5b6069.svg\" alt=\"w+(0.5w+0.5c)+c=1\" style=\"width:25.188ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9499078f217c4146.svg\" alt=\"1.5w=1-1.5c=1-3/7=4/7\" style=\"width:32.015ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38376c6530974a73.svg\" alt=\"w=(4/7)/1.5=8/21\" style=\"width:21.355ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/afad15a4af697ec7.svg\" alt=\"a=1-w-c=1-8/21-6/21=7/21=1/3\" style=\"width:46.158ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.380952381</td><td>-0.019047619</td><td>Loses</td></tr><tr><td>A</td><td>0.35</td><td>0.333333333</td><td>-0.016666667</td><td>Loses</td></tr><tr><td>C</td><td>0.25</td><td>0.285714286</td><td>0.035714286</td><td>Gains</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [0.39, 0.335, 0.275]. Stationary shares ≈ [0.380952381, 0.333333333, 0.285714286]. W loses, A loses, C gains.</div></section>"},{"id":"q6a","title":"Q6(a) ACO for TSP [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4>\r\n<div class=\"math-display\"><img src=\"math/21fbc23ee8a38afa.svg\" alt=\"D=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;1&amp;2&amp;3\\\\B&amp;1&amp;0&amp;4&amp;5\\\\C&amp;2&amp;4&amp;0&amp;6\\\\D&amp;3&amp;5&amp;6&amp;0\\end{array},\\qquad\\tau_{ij}=1\\;(i\\ne j)\" style=\"width:41.536ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Assume <span class=\"math-inline\"><img src=\"math/215be7d8bc049557.svg\" alt=\"\\alpha=\\beta=1,\\;\\rho=0.5,\\;Q=1\" style=\"width:26.18ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p>Both tours, their lengths and the pheromone matrix after one iteration.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/5b888e9e5a3c73eb.svg\" alt=\"P_{ij}=\\frac{\\tau_{ij}^{\\alpha}(1/d_{ij})^\\beta}{\\sum_{k\\in allowed}\\tau_{ik}^{\\alpha}(1/d_{ik})^\\beta}\" style=\"width:27.444ex;height:6.404ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d5297204b4481c8e.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}+\\sum_{k:\\,ij\\in tour_k}\\frac{Q}{L_k}\" style=\"width:30.908ex;height:6.181ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. From A</h5>\r\n<div class=\"math-display\"><img src=\"math/d7a22769c0bad254.svg\" alt=\"\\eta:\\;B=1,\\;C=0.5,\\;D=0.3333;\\;\\text{sum}=1.8333\\Rightarrow P=0.5455,\\;0.2727,\\;0.1818\" style=\"width:76.91ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative: B 0–0.5455, C 0.5455–0.8182, D 0.8182–1. Ant 1 (0.3) → <strong>B</strong>; Ant 2 (0.5) → <strong>B</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 2. From B (C and D left)</h5>\r\n<div class=\"math-display\"><img src=\"math/9d1964928f02cbff.svg\" alt=\"\\eta:\\;C=0.25,\\;D=0.2;\\;\\text{sum}=0.45\\Rightarrow P_{BC}=0.5556,\\;P_{BD}=0.4444\" style=\"width:66.532ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative: C 0–0.5556, D 0.5556–1. Ant 1 (0.8) → <strong>D</strong>; Ant 2 (0.7) → <strong>D</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 3. Complete the tours</h5>\r\n<div class=\"math-display\"><img src=\"math/1409076465c0fee4.svg\" alt=\"A\\to B\\to D\\to C\\to A,\\qquad L=1+5+6+2=14\\;\\text{(both ants)}\" style=\"width:62.614ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_reexam_graph.02195c6ee9.svg\" width=\"520\" height=\"380\" alt=\"Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14\" loading=\"lazy\" decoding=\"async\"></div></figure></div>\r\n<div class=\"step\"><h5>Step 4. Pheromone update</h5>\r\n<p>Used edges AB, BD, DC, CA get <span class=\"math-inline\"><img src=\"math/a677db1cbc02a07c.svg\" alt=\"0.5(1)+2\\times\\frac1{14}=0.6429\" style=\"width:24.343ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></span>; unused edges AD and BC become <span class=\"math-inline\"><img src=\"math/97dede1883211cd7.svg\" alt=\"0.5\" style=\"width:2.891ex;height:1.557ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/25cf4d02bee20e2a.svg\" alt=\"\\tau_{\\text{new}}=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;0.6429&amp;0.6429&amp;0.5\\\\B&amp;0.6429&amp;0&amp;0.5&amp;0.6429\\\\C&amp;0.6429&amp;0.5&amp;0&amp;0.6429\\\\D&amp;0.5&amp;0.6429&amp;0.6429&amp;0\\end{array}\" style=\"width:42.542ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> Both ants: A → B → D → C → A, length 14. Pheromone 0.6429 on AB, BD, CD, AC; 0.5 on AD, BC.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> This key applies <em>no evaporation</em> (<span class=\"math-inline\"><img src=\"math/7856892795a9fcf9.svg\" alt=\"1+0.1428=1.1428\" style=\"width:19.484ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></span>) 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.</div>\r\n</section>\r\n"},{"id":"q6b","title":"Q6(b) Aircraft movement between hubs (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: A, B, C. Initial vector [30, 40, 30].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr><td>A</td><td>0.5</td><td>0.3</td><td>0.2</td></tr><tr><td>B</td><td>0.4</td><td>0.4</td><td>0.2</td></tr><tr><td>C</td><td>0.25</td><td>0.25</td><td>0.5</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_airline.779a8c5fd6.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to A</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to A</th><th>Contribution</th></tr></thead><tbody><tr><td>A</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr><tr><td>B</td><td>40</td><td>0.4</td><td>40 × 0.4 = 16</td></tr><tr><td>C</td><td>30</td><td>0.25</td><td>30 × 0.25 = 7.5</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/67abb9b77cf134f6.svg\" alt=\"A_{new}=15+16+7.5=38.5\" style=\"width:27.74ex;height:1.977ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to B</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to B</th><th>Contribution</th></tr></thead><tbody><tr><td>A</td><td>30</td><td>0.3</td><td>30 × 0.3 = 9</td></tr><tr><td>B</td><td>40</td><td>0.4</td><td>40 × 0.4 = 16</td></tr><tr><td>C</td><td>30</td><td>0.25</td><td>30 × 0.25 = 7.5</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/c43c2e3add5e9f7a.svg\" alt=\"B_{new}=9+16+7.5=32.5\" style=\"width:26.629ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to C</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to C</th><th>Contribution</th></tr></thead><tbody><tr><td>A</td><td>30</td><td>0.2</td><td>30 × 0.2 = 6</td></tr><tr><td>B</td><td>40</td><td>0.2</td><td>40 × 0.2 = 8</td></tr><tr><td>C</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/e1d10b6213a4f6c2.svg\" alt=\"C_{new}=6+8+15=29\" style=\"width:23.009ex;height:1.952ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: find C first</h5><div class=\"math-display\"><img src=\"math/063ad466582b38bf.svg\" alt=\"c=0.2(a+b)+0.5c\" style=\"width:20.218ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/49f2613d4b58dc75.svg\" alt=\"c=0.2(1-c)+0.5c=0.2+0.3c\" style=\"width:32.707ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/eaaea4df9a4e16b6.svg\" alt=\"0.7c=0.2\\quad c=2/7\" style=\"width:19.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Find B in terms of A</h5><div class=\"math-display\"><img src=\"math/8b2ff5dead1627ab.svg\" alt=\"b=0.3a+0.4b+0.25c\" style=\"width:22.472ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/463b4822655ff527.svg\" alt=\"0.6b=0.3a+0.25c\" style=\"width:18.735ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c6b1f0d1f25d8a7c.svg\" alt=\"b=0.5a+\\frac5{12}c\" style=\"width:15.079ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Use a+b=1−c</h5><div class=\"math-display\"><img src=\"math/2e4dfec7416e59d8.svg\" alt=\"a+0.5a+\\frac5{12}\\frac27=1-\\frac27=\\frac57\" style=\"width:30.386ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dbf72a6e6a9bedfd.svg\" alt=\"1.5a=\\frac57-\\frac5{42}=\\frac{25}{42}\" style=\"width:21.531ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8653487298ec14a0.svg\" alt=\"a=\\frac{25}{42}\\div\\frac32=\\frac{25}{63}\" style=\"width:18.639ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/369b239ecbe26cbf.svg\" alt=\"b=1-\\frac{25}{63}-\\frac{18}{63}=\\frac{20}{63}\" style=\"width:23.441ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>A</td><td>0.3</td><td>0.396825397</td><td>0.096825397</td><td>Gains</td></tr><tr><td>B</td><td>0.4</td><td>0.317460317</td><td>-0.082539683</td><td>Loses</td></tr><tr><td>C</td><td>0.3</td><td>0.285714286</td><td>-0.014285714</td><td>Loses</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [38.5, 32.5, 29.0]. Stationary shares ≈ [0.396825397, 0.317460317, 0.285714286]. A gains, B loses, C loses.</div></section>"},{"id":"q7a","title":"Q7(a) Applications of fuzzy logic [10]","html":"<p class=\"question\"><strong>List the applications of fuzzy logic. Explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition</h3>\r\n<p>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”.</p>\r\n<h3>Applications</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Area</th><th>Examples</th></tr></thead><tbody>\r\n<tr><td>Home appliances</td><td>Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners</td></tr>\r\n<tr><td>Automotive</td><td>Automatic transmission, anti-lock braking (ABS), cruise control, engine control</td></tr>\r\n<tr><td>Transportation</td><td>Traffic-signal control, Sendai subway train control (smooth braking and acceleration)</td></tr>\r\n<tr><td>Consumer electronics</td><td>Camera autofocus and auto-exposure, image stabilisation</td></tr>\r\n<tr><td>Industrial control</td><td>Cement kilns, pH, temperature and distillation control in chemical plants</td></tr>\r\n<tr><td>Aerospace</td><td>Satellite and spacecraft attitude control</td></tr>\r\n<tr><td>Medicine</td><td>Diagnosis support, anaesthesia dosage control</td></tr>\r\n<tr><td>Finance and decisions</td><td>Loan approval, credit and fire-risk scoring, stock trading rules</td></tr>\r\n<tr><td>AI and robotics</td><td>Robot navigation, natural-language interfaces, expert systems</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>One application in detail: fuzzy washing machine</h3>\r\n<ol>\r\n<li><strong>Problem.</strong> 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.</li>\r\n<li><strong>Inputs and outputs.</strong> 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.</li>\r\n<li><strong>Fuzzification.</strong> Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.</li>\r\n<li><strong>Rule base.</strong> 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.</li>\r\n<li><strong>Inference.</strong> Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.</li>\r\n<li><strong>Defuzzification.</strong> 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.</li>\r\n<li><strong>Benefits.</strong> Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.</li>\r\n</ol>\r\n<h3>Advantages and disadvantages (bonus)</h3>\r\n<p><strong>Advantages:</strong> handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. <strong>Disadvantages:</strong> 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.</p>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.</div>\r\n"},{"id":"q7b","title":"Q7(b) Bellman equation and applications of RL [10]","html":"<p class=\"question\"><strong>Explain the Bellman equation in reinforcement learning. Also give applications of reinforcement learning.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\n\n<p>Write the answer below in this order. It fits in about two pages.</p>\n\n<div class=\"answer-box\">\n<h3>Part A · Bellman equation (5 marks)</h3>\n<p><strong>1. Setting.</strong> Reinforcement learning problems are modelled as a Markov decision process <span class=\"math-inline\"><img src=\"math/2a8c7332f3030a47.svg\" alt=\"\\langle\\mathcal S,\\mathcal A,P,R,\\gamma\\rangle\" style=\"width:13.735ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The agent follows a policy <span class=\"math-inline\"><img src=\"math/f155e46af3f71ce4.svg\" alt=\"\\pi(a\\mid s)\" style=\"width:7.194ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and wants to maximise the return <span class=\"math-inline\"><img src=\"math/3f482d8ea694678d.svg\" alt=\"G_t=\\sum_{k\\ge0}\\gamma^kR_{t+k+1}\" style=\"width:20.364ex;height:2.798ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>2. Value functions.</strong> <span class=\"math-inline\"><img src=\"math/a27ddca95f461e82.svg\" alt=\"v_\\pi(s)=\\mathbb E_\\pi[G_t\\mid S_t=s]\" style=\"width:22.562ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/0885e6b22d6c67c2.svg\" alt=\"q_\\pi(s,a)=\\mathbb E_\\pi[G_t\\mid S_t=s,A_t=a]\" style=\"width:32.358ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>3. Key idea.</strong> The return is recursive: <span class=\"math-inline\"><img src=\"math/837aecc6afff8d86.svg\" alt=\"G_t=R_{t+1}+\\gamma G_{t+1}\" style=\"width:18.67ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>. Taking expectations gives the <strong>Bellman expectation equation</strong>:</p>\n<div class=\"math-display\"><img src=\"math/cd7f793810f9ae1e.svg\" alt=\"v_\\pi(s)=\\sum_a\\pi(a\\mid s)\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R(s,a,s&#39;)+\\gamma v_\\pi(s&#39;)]\" style=\"width:53.904ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\n<div class=\"math-display\"><img src=\"math/0aaca96cab3cf147.svg\" alt=\"q_\\pi(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,\\Big[R(s,a,s&#39;)+\\gamma\\sum_{a&#39;}\\pi(a&#39;\\mid s&#39;)q_\\pi(s&#39;,a&#39;)\\Big]\" style=\"width:60.894ex;height:5.335ex\" loading=\"lazy\" decoding=\"async\"></div>\n<p><strong>4. Optimality.</strong> For the optimal policy the average over actions becomes a maximum (<strong>Bellman optimality equation</strong>):</p>\n<div class=\"math-display\"><img src=\"math/cc767eadfe69fc8c.svg\" alt=\"v_*(s)=\\max_a\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma v_*(s&#39;)],\\qquad q_*(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma\\max_{a&#39;}q_*(s&#39;,a&#39;)]\" style=\"width:89.433ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\n<p><strong>5. Meaning and use.</strong> 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 <span class=\"math-inline\"><img src=\"math/f3cf791d9745c384.svg\" alt=\"\\pi_*(s)=\\arg\\max_a q_*(s,a)\" style=\"width:24.284ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>6. Small illustration</strong> (adds clarity): if staying in a state gives +1 each step with <span class=\"math-inline\"><img src=\"math/c491a3a52610e919.svg\" alt=\"\\gamma=0.9\" style=\"width:7.137ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, then <span class=\"math-inline\"><img src=\"math/64606eb39a2dfd24.svg\" alt=\"v=1+0.9v\\Rightarrow v=10\" style=\"width:21.896ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n\n<h3>Part B · Applications of reinforcement learning (5 marks)</h3>\n<ol>\n<li><strong>Game playing</strong>: AlphaGo (defeated Lee Sedol, 2016), Atari agents (DQN), and the Mario agent built in this course's lab.</li>\n<li><strong>Robotics</strong>: walking, grasping and balancing learned by trial and error in simulation.</li>\n<li><strong>Autonomous driving</strong>: lane changing, merging and parking decisions.</li>\n<li><strong>Recommendation systems</strong>: choosing content to maximise long-term engagement rather than single clicks.</li>\n<li><strong>Finance</strong>: trading and portfolio rebalancing as sequential decisions.</li>\n<li><strong>Healthcare</strong>: dynamic treatment regimes (dose adjustment over time).</li>\n<li><strong>Resource and energy management</strong>: data-centre cooling control, traffic-signal timing, inventory control.</li>\n<li><strong>Language models</strong>: reinforcement learning from human feedback (RLHF) for chatbots.</li>\n</ol>\n<h4>One application in detail: traffic-signal control</h4>\n<div class=\"table-wrap\"><table><tbody>\n<tr><th>Agent</th><td>Controller at an intersection.</td></tr>\n<tr><th>State</th><td>Queue length and waiting time on each approach, current signal phase.</td></tr>\n<tr><th>Actions</th><td>Keep the current phase or switch to the next green phase.</td></tr>\n<tr><th>Reward</th><td>Negative of total waiting time (or vehicles cleared per cycle).</td></tr>\n<tr><th>Learning</th><td>Q-learning updates <span class=\"math-inline\"><img src=\"math/0caba73ef360f772.svg\" alt=\"Q(s,a)\" style=\"width:6.814ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> from observed traffic; ε-greedy exploration tries alternative timings.</td></tr>\n<tr><th>Benefit</th><td>Adapts to rush hours and incidents; fixed timers cannot.</td></tr>\n<tr><th>Challenge</th><td>Safety during exploration, so agents are trained in simulation first.</td></tr>\n</tbody></table></div>\n</div>\n\n<div class=\"memory\"><strong>Yaad rakho:</strong> Bellman ka sar: “value = reward abhi + γ × value aage”. Application likho to S, A, R batao: examiner ko yahi chahiye.</div>\n"}]},{"id":"paper-2025-april","title":"Final / re-examination · 28 Apr 2025","unit":"paper","scope":"Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.","sections":[{"id":"q1a","title":"Q1(a) Joint masses, normalization and conditional probability [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(a)</strong> <span class=\"marks\">[5 marks · 2025-04-28]</span><div class=\"table-wrap\"><table><thead><tr><th>Machine</th><th>No Fault (X = 0)</th><th>Fault (X = 1)</th></tr></thead><tbody><tr><td>Machine A</td><td>0.40</td><td>0.05</td></tr><tr><td>Machine B</td><td>0.25</td><td>0.10</td></tr><tr><td>Machine C</td><td>0.20</td><td>0.08</td></tr><tr><td>Machine D</td><td>0.05</td><td>0.07</td></tr></tbody></table></div><p>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).</p><ul><li>If a fault occurs, what is the probability that it came from Machine C?</li><li>What is the probability that a randomly selected product has a fault?</li><li>Given the product is from Machine B, what is the probability that it has a fault?</li></ul></div><h3>Answer</h3><h3>Given</h3><p>The eight printed entries are used exactly as shown. X=1 means fault; Y identifies the machine.</p><h3>To find</h3><p>P(C | fault), P(fault), and P(fault | B).</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/b482646983d755cb.svg\" alt=\"P(A\\mid B)=\\frac{P(A\\cap B)}{P(B)}\" style=\"width:22.16ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><p>Conditioning restricts the denominator to the given group. Before treating a whole table as a joint probability distribution, its entries must sum to 1.</p><section class=\"step\"><h3>Step 1. Check the printed total</h3><div class=\"math-display\"><img src=\"math/6388bf0e029e7de3.svg\" alt=\"\\text{No-fault total}=0.40+0.25+0.20+0.05=0.90\" style=\"width:47.834ex;height:1.781ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3c42285ce038d0e3.svg\" alt=\"\\text{Fault total}=0.05+0.10+0.08+0.07=0.30\" style=\"width:45.037ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/017ee19616d63679.svg\" alt=\"\\text{Grand total}=0.90+0.30=1.20\\ne1\" style=\"width:36.543ex;height:2.106ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Source inconsistency:</strong> 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.</p></section><section class=\"step\"><h3>Step 2. Machine C, given a fault</h3><div class=\"math-display\"><img src=\"math/ec2f2af190c229ec.svg\" alt=\"P(C\\mid X=1)=\\frac{0.08/1.20}{0.30/1.20}=\\frac{0.08}{0.30}=\\frac4{15}\\approx0.266667\" style=\"width:52.204ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><p>Among all fault mass, 0.08 belongs to C. The common normalization factor cancels.</p></section><section class=\"step\"><h3>Step 3. Overall fault probability under the stated repair</h3><div class=\"math-display\"><img src=\"math/2d7f62f0b50223d0.svg\" alt=\"P(X=1)=\\frac{0.30}{1.20}=0.25\" style=\"width:24.61ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Answer under mass normalization: 25%.</strong> 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.</p></section><section class=\"step\"><h3>Step 4. Fault, given Machine B</h3><div class=\"math-display\"><img src=\"math/a88bec71b29e2cf3.svg\" alt=\"P(X=1\\mid B)=\\frac{0.10}{0.25+0.10}=\\frac{0.10}{0.35}=\\frac27\\approx0.285714\" style=\"width:52.705ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><p>Machine B is the denominator because the product is known to come from B. <strong>Final conditional answers: 26.6667% and 28.5714%.</strong></p></section></section>"},{"id":"q1b","title":"Q1(b) Genetic algorithm applications [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(b)</strong> <span class=\"marks\">[5 marks · 2025-04-28]</span><p>List the applications of genetic algorithm and explain any one application in detail.</p></div><h3>Answer</h3><p><strong>Genetic algorithm (GA)</strong> is a population-based search method that evolves encoded candidate solutions using fitness evaluation, selection, crossover and mutation.</p><ul><li>Job-shop scheduling and timetable construction.</li><li>Vehicle routing and travelling-salesman-type optimization.</li><li>Feature selection and hyperparameter search in machine learning.</li><li>Engineering design, such as selecting dimensions subject to strength or cost constraints.</li><li>Resource allocation and placement problems.</li></ul><h3>Detailed application: examination timetable</h3><div class=\"table-wrap\"><table><thead><tr><th>Stage</th><th>How it is used</th></tr></thead><tbody><tr><td>Representation</td><td>A chromosome assigns a time slot and room to every examination. A gene identifies one exam's assignment.</td></tr><tr><td>Fitness</td><td>Penalize student clashes, room-capacity violations and unavailable slots; among feasible schedules, reward spread-out exams and efficient room use.</td></tr><tr><td>Initial population</td><td>Create several different candidate timetables, using random assignments or constructive rules.</td></tr><tr><td>Selection</td><td>Prefer feasible and lower-penalty timetables while retaining diversity.</td></tr><tr><td>Crossover</td><td>Combine assignments from two parents; repair conflicts if the operator can violate feasibility.</td></tr><tr><td>Mutation</td><td>Move an exam to another permitted slot or swap compatible assignments. Recheck constraints.</td></tr><tr><td>Replacement / stopping</td><td>Keep useful candidates, often protecting the best feasible schedule; stop at a generation/time limit or sufficient improvement.</td></tr></tbody></table></div><p><strong>Illustrative example:</strong> 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.</p><p><strong>Benefit:</strong> explores many combinations without exhaustively listing all timetables. <strong>Limitation:</strong> stochastic search can stagnate and does not guarantee a global optimum; poorly designed penalties can reward unusable schedules.</p></section>"},{"id":"q1c","title":"Q1(c) Fuzzy union, intersection and complements [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(c)</strong> <span class=\"marks\">[5 marks · 2025-04-28]</span><p>Consider two fuzzy sets</p><p>X={(c1,0.6),(c2,0.8),(c3,0.3),(c4,0.5),(c5,0.7)}</p><p>Y={(c1,0.4),(c2,0.5),(c3,0.9),(c4,0.6),(c5,0.2)}</p><p>Find 1) X∪Y  2) X∩Y  3) ¬X∪¬Y  4) ¬X∩¬Y</p></div><h3>Answer</h3><h3>Given</h3><p>The same universe {c1, c2, c3, c4, c5} is used for both sets.</p><h3>To find</h3><p>All four membership vectors, keeping the element order fixed.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/f1157faae69b5acb.svg\" alt=\"\\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))\" style=\"width:61.037ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/094fb09a37beb92f.svg\" alt=\"\\mu_{\\neg X}(c)=1-\\mu_X(c)\" style=\"width:19.291ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Union takes the larger membership, intersection the smaller, and standard complement subtracts from 1. Apply each operation separately at the same element.</p><section class=\"step\"><h3>Step 1. Find complements</h3><div class=\"table-wrap\"><table><thead><tr><th>Element</th><th>X</th><th>Y</th><th>1−X</th><th>1−Y</th></tr></thead><tbody><tr><td>c1</td><td>0.6</td><td>0.4</td><td>1−0.6=0.4</td><td>1−0.4=0.6</td></tr><tr><td>c2</td><td>0.8</td><td>0.5</td><td>1−0.8=0.2</td><td>1−0.5=0.5</td></tr><tr><td>c3</td><td>0.3</td><td>0.9</td><td>1−0.3=0.7</td><td>1−0.9=0.1</td></tr><tr><td>c4</td><td>0.5</td><td>0.6</td><td>1−0.5=0.5</td><td>1−0.6=0.4</td></tr><tr><td>c5</td><td>0.7</td><td>0.2</td><td>1−0.7=0.3</td><td>1−0.2=0.8</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 2. Compute the four results element by element</h3><div class=\"table-wrap\"><table><thead><tr><th>Element</th><th>X∪Y = max (X, Y)</th><th>X∩Y = min (X, Y)</th><th>¬X∪¬Y</th><th>¬X∩¬Y</th></tr></thead><tbody><tr><td>c1</td><td>max(0.6,0.4)=0.6</td><td>min(0.6,0.4)=0.4</td><td>max(0.4,0.6)=0.6</td><td>min(0.4,0.6)=0.4</td></tr><tr><td>c2</td><td>max(0.8,0.5)=0.8</td><td>min(0.8,0.5)=0.5</td><td>max(0.2,0.5)=0.5</td><td>min(0.2,0.5)=0.2</td></tr><tr><td>c3</td><td>max(0.3,0.9)=0.9</td><td>min(0.3,0.9)=0.3</td><td>max(0.7,0.1)=0.7</td><td>min(0.7,0.1)=0.1</td></tr><tr><td>c4</td><td>max(0.5,0.6)=0.6</td><td>min(0.5,0.6)=0.5</td><td>max(0.5,0.4)=0.5</td><td>min(0.5,0.4)=0.4</td></tr><tr><td>c5</td><td>max(0.7,0.2)=0.7</td><td>min(0.7,0.2)=0.2</td><td>max(0.3,0.8)=0.8</td><td>min(0.3,0.8)=0.3</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 3. Write the final sets</h3><p><strong>X∪Y</strong>={(c1,0.6),(c2,0.8),(c3,0.9),(c4,0.6),(c5,0.7)}.</p><p><strong>X∩Y</strong>={(c1,0.4),(c2,0.5),(c3,0.3),(c4,0.5),(c5,0.2)}.</p><p><strong>¬X∪¬Y</strong>={(c1,0.6),(c2,0.5),(c3,0.7),(c4,0.5),(c5,0.8)}.</p><p><strong>¬X∩¬Y</strong>={(c1,0.4),(c2,0.2),(c3,0.1),(c4,0.4),(c5,0.3)}.</p><p>Yaad rakho: union bada, intersection chhota, complement one minus.</p></section></section>"},{"id":"q1d","title":"Q1(d) Cable-company Markov matrix and diagram [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(d)</strong> <span class=\"marks\">[5 marks · 2025-04-28]</span><p>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.</p><ul><li>Express the information above as a transition matrix which displays the probabilities of going from one state into another state.</li><li>Draw the State diagram for the above information.</li></ul></div><h3>Answer</h3><h3>Given</h3><p>Order the states as B=BestTV and C=CableCast.</p><h3>To find</h3><p>The one-year transition matrix and all directed state transitions.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/ac80fe221bb10516.svg\" alt=\"P_{ij}=P(\\text{next state}=j\\mid\\text{current state}=i),\\qquad\\sum_jP_{ij}=1\" style=\"width:57.357ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>Rows mean current state; columns mean next state. Each row includes every possible destination.</p><section class=\"step\"><h3>Step 1. Complete the missing stay probability</h3><p>BestTV stays =1−0.40=0.60. CableCast stays =1−0.30=0.70.</p></section><section class=\"step\"><h3>Step 2. Place each probability in its row</h3><div class=\"math-display\"><img src=\"math/f73b0238f5d9fefe.svg\" alt=\"P=\\begin{bmatrix}0.60&amp;0.40\\\\0.30&amp;0.70\\end{bmatrix}_{(B,C)}\" style=\"width:21.72ex;height:5.91ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"table-wrap\"><table><thead><tr><th>Current → next</th><th>BestTV</th><th>CableCast</th><th>Row total</th></tr></thead><tbody><tr><td>BestTV</td><td>0.6</td><td>0.4</td><td>1</td></tr><tr><td>CableCast</td><td>0.3</td><td>0.7</td><td>1</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 3. Draw the state diagram</h3><figure><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy25-cable.c15b41f741.svg\" width=\"800\" height=\"430\" alt=\"BestTV → CableCast:0.40; CableCast → BestTV:0.30. Self-loops:0.60 and 0.70.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>BestTV → CableCast:0.40; CableCast → BestTV:0.30. Self-loops:0.60 and 0.70.</figcaption></figure></section></section>"},{"id":"q2a","title":"Q2(a) Fuzzy investment-controller design and centroid [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q2(a)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>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.</p><p>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.</p></div><h3>Answer</h3><h3>Given</h3><p><strong>Printed inputs:</strong> 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.</p><h3>To find</h3><p>One fully specified fuzzy system and the crisp output for these inputs.</p><h3>Formula and why</h3><p>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.</p><div class=\"math-display\"><img src=\"math/3619dbb6f7443588.svg\" alt=\"z^*=\\frac{\\int_1^{100}z\\mu_{agg}(z)\\,dz}{\\int_1^{100}\\mu_{agg}(z)\\,dz}\" style=\"width:20.921ex;height:7.033ex\" loading=\"lazy\" decoding=\"async\"></div><section class=\"step\"><h3>Step 1. Specify all membership functions</h3><p>For either input t∈[1,100], choose Low as a left shoulder, Medium as a triangle and High as a right shoulder:</p><div class=\"math-display\"><img src=\"math/6b2ac0fe5ac34f60.svg\" alt=\"\\mu_L(t)=\\begin{cases}(50-t)/49&amp;1\\le t\\le50\\\\0&amp;50&lt;t\\le100\\end{cases}\" style=\"width:35.701ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6ad9728f32af11c4.svg\" alt=\"\\mu_M(t)=\\begin{cases}(t-1)/49&amp;1\\le t\\le50\\\\(100-t)/50&amp;50&lt;t\\le100\\end{cases}\" style=\"width:37.424ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e4429c897c410965.svg\" alt=\"\\mu_H(t)=\\begin{cases}0&amp;1\\le t\\le50\\\\(t-50)/50&amp;50&lt;t\\le100\\end{cases}\" style=\"width:36.032ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><figure><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy25-memberships.904ed2cacf.svg\" width=\"800\" height=\"430\" alt=\"Declared membership design. Both inputs and the output use the same breakpoints 1,50,100, with different linguistic labels.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Declared membership design. Both inputs and the output use the same breakpoints 1,50,100, with different linguistic labels.</figcaption></figure></section><section class=\"step\"><h3>Step 2. State the nine rules</h3><div class=\"table-wrap\"><table><thead><tr><th>Risk tolerance</th><th>Historical performance</th><th>Output</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>Conservative</td></tr><tr><td>Low</td><td>Medium</td><td>Conservative</td></tr><tr><td>Low</td><td>High</td><td>Conservative</td></tr><tr><td>Medium</td><td>Low</td><td>Conservative</td></tr><tr><td>Medium</td><td>Medium</td><td>Balanced</td></tr><tr><td>Medium</td><td>High</td><td>Balanced</td></tr><tr><td>High</td><td>Low</td><td>Balanced</td></tr><tr><td>High</td><td>Medium</td><td>Aggressive</td></tr><tr><td>High</td><td>High</td><td>Aggressive</td></tr></tbody></table></div><p>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.</p></section><section class=\"step\"><h3>Step 3. Fuzzify the two printed numbers</h3><div class=\"table-wrap\"><table><thead><tr><th>Input</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Risk 40</td><td>(50−40)/49=10/49=0.204082</td><td>(40−1)/49=39/49=0.795918</td><td>0</td></tr><tr><td>Performance 8</td><td>(50−8)/49=42/49=0.857143</td><td>(8−1)/49=7/49=1/7=0.142857</td><td>0</td></tr></tbody></table></div><p><strong>8 is retained exactly; it is not replaced with 80.</strong></p></section><section class=\"step\"><h3>Step 4. Evaluate all nonzero rules</h3><div class=\"table-wrap\"><table><thead><tr><th>Rule</th><th>AND calculation</th><th>Firing strength</th><th>Consequent</th></tr></thead><tbody><tr><td>Low &amp; Low</td><td>min(10/49,42/49)</td><td>10/49</td><td>Conservative</td></tr><tr><td>Low &amp; Medium</td><td>min(10/49,7/49)</td><td>7/49</td><td>Conservative</td></tr><tr><td>Medium &amp; Low</td><td>min(39/49,42/49)</td><td>39/49</td><td>Conservative</td></tr><tr><td>Medium &amp; Medium</td><td>min(39/49,7/49)</td><td>7/49</td><td>Balanced</td></tr></tbody></table></div><p>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.</p></section><section class=\"step\"><h3>Step 5. Construct the aggregated output</h3><div class=\"math-display\"><img src=\"math/b4a4496253a59f9d.svg\" alt=\"\\mu_{agg}(z)=\\max\\{\\min(39/49,\\mu_L(z)),\\min(1/7,\\mu_M(z))\\}\" style=\"width:50.857ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><div class=\"math-display\"><img src=\"math/b2489917bec1091e.svg\" alt=\"\\mu_{agg}(z)=\\begin{cases}39/49&amp;1\\le z\\le11\\\\(50-z)/49&amp;11&lt;z\\le43\\\\1/7&amp;43&lt;z\\le650/7\\\\(100-z)/50&amp;650/7&lt;z\\le100\\end{cases}\" style=\"width:42.529ex;height:10.407ex\" loading=\"lazy\" decoding=\"async\"></div><figure><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy25-centroid.6d2be43cdb.svg\" width=\"800\" height=\"430\" alt=\"Actual max-aggregated output for risk 40 and performance 8. The shaded area has centroid 30.379571.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Actual max-aggregated output for risk 40 and performance 8. The shaded area has centroid 30.379571.</figcaption></figure></section><section class=\"step\"><h3>Step 6. Calculate area and first moment for each segment</h3><p>For a segment µ(z)=mz+c between a and b, integrate its area A and first moment M as follows:</p><div class=\"math-display\"><img src=\"math/1c36be6d1316a809.svg\" alt=\"A=\\frac m2(b^2-a^2)+c(b-a),\\qquad M=\\frac m3(b^3-a^3)+\\frac c2(b^2-a^2)\" style=\"width:62.941ex;height:4.131ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"table-wrap\"><table><thead><tr><th>Interval</th><th>Membership</th><th>Area A</th><th>First moment M</th></tr></thead><tbody><tr><td>1 to 11</td><td>39/49</td><td>7.959183673</td><td>47.755102041</td></tr><tr><td>11 to 43</td><td>(50−z)/49</td><td>15.020408163</td><td>349.823129252</td></tr><tr><td>43 to 650/7</td><td>1/7</td><td>7.122448980</td><td>483.817784257</td></tr><tr><td>650/7 to 100</td><td>(100−z)/50</td><td>0.510204082</td><td>48.590864917</td></tr></tbody></table></div><p>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.</p></section><section class=\"step\"><h3>Step 7. Divide moment by area and interpret</h3><div class=\"math-display\"><img src=\"math/302b0a0b55fb1874.svg\" alt=\"\\sum A=1500/49\\approx30.612244898\" style=\"width:32.366ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5cd3d9be4d829cea.svg\" alt=\"\\sum M=637971/686\\approx929.986880466\" style=\"width:37.572ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/19f8c5be600656c4.svg\" alt=\"z^*=\\frac{637971/686}{1500/49}=\\frac{212657}{7000}\\approx\\boxed{30.379571}\" style=\"width:42.068ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section></section>"},{"id":"q2b","title":"Q2(b) GMM versus k-means, log likelihood and parameter count [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q2(b)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>With reference to Gaussian Mixture model (GMM), answer the following</p><ul><li>Compare GMM with K-means algorithm</li><li>Derive the equation for Log likelihood function.</li><li>What will be the no of parameters to be computed if K=5</li></ul></div><h3>Answer</h3><p><strong>Gaussian mixture model:</strong> 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.</p><div class=\"table-wrap\"><table><thead><tr><th>Aspect</th><th>K-means</th><th>GMM</th></tr></thead><tbody><tr><td>Assignment</td><td>Hard: choose one closest centroid</td><td>Soft: a posterior responsibility for each component</td></tr><tr><td>Parameters</td><td>K centroid vectors</td><td>Mixture weights, mean vectors and covariance matrices</td></tr><tr><td>Objective</td><td>Minimize within-cluster squared Euclidean distances</td><td>Maximize data likelihood or log likelihood</td></tr><tr><td>Shape</td><td>Nearest-centroid partitions suit roughly spherical/equal-scale groups</td><td>Full covariance allows tilted ellipsoids; restricted covariance gives simpler shapes</td></tr><tr><td>Updates</td><td>Alternate assignment and centroid averaging</td><td>EM: responsibility calculation and weighted parameter updates</td></tr><tr><td>Uncertainty</td><td>No probability from basic assignment alone</td><td>Responsibilities quantify ambiguity under the fitted model</td></tr></tbody></table></div><h3>Log-likelihood derivation</h3><section class=\"step\"><h3>Step 1. Write one observation's density</h3><div class=\"math-display\"><img src=\"math/b313ea1944e92313.svg\" alt=\"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\" style=\"width:54.269ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e8919c0c3aee3455.svg\" alt=\"\\mathcal N(x\\mid\\mu,\\Sigma)=\\frac{\\exp[-\\frac12(x-\\mu)^T\\Sigma^{-1}(x-\\mu)]}{(2\\pi)^{d/2}|\\Sigma|^{1/2}}\" style=\"width:42.99ex;height:6.107ex\" loading=\"lazy\" decoding=\"async\"></div><p>πk is the probability of component k; µk is its centre; Σk describes spread and correlation. Assume positive-definite full covariances for this density.</p></section><section class=\"step\"><h3>Step 2. Multiply independent observations</h3><div class=\"math-display\"><img src=\"math/e3640e9995db4c3c.svg\" alt=\"\\mathcal L(\\theta)=\\prod_{i=1}^{N}\\left[\\sum_{k=1}^{K}\\pi_k\\mathcal N(x_i\\mid\\mu_k,\\Sigma_k)\\right]\" style=\"width:33.202ex;height:6.822ex\" loading=\"lazy\" decoding=\"async\"></div><p>The product follows from the usual independent, identically distributed training-sample assumption. The sum inside handles the unobserved component choice.</p></section><section class=\"step\"><h3>Step 3. Take the natural logarithm</h3><div class=\"math-display\"><img src=\"math/ac7ba81fe410766e.svg\" alt=\"\\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]\" style=\"width:46.896ex;height:6.822ex\" loading=\"lazy\" decoding=\"async\"></div><p>Log turns the product across samples into a sum. It does <strong>not</strong> turn the mixture sum inside each logarithm into a sum of logarithms. The coupled terms motivate iterative optimization such as EM.</p></section><section class=\"step\"><h3>Step 4. Count parameters and state the missing assumption</h3><p>The question gives K=5 but does not give dimension d or covariance structure, so one universal integer cannot be determined.</p><div class=\"table-wrap\"><table><thead><tr><th>Component</th><th>Independent parameters</th></tr></thead><tbody><tr><td>Means</td><td>Kd</td></tr><tr><td>Full symmetric covariances</td><td>K d (d+1)/2</td></tr><tr><td>Mixture weights</td><td>K−1, because their sum is 1</td></tr></tbody></table></div><div class=\"math-display\"><img src=\"math/24096c582fbc12b9.svg\" alt=\"n_{free}=Kd+K\\frac{d(d+1)}2+(K-1)\" style=\"width:35.059ex;height:4.855ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d72da4a5707e5b6a.svg\" alt=\"K=5:\\quad n_{free}=5d+\\frac{5d(d+1)}2+4\" style=\"width:37.07ex;height:4.855ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>If one-dimensional data are intended:</strong> five means+five variances+four independent weights=<strong>14 free parameters</strong>. 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.</p></section></section>"},{"id":"q3a","title":"Q3(a) Bayesian-network conditional cough probability [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q3(a)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><figure><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy25-bayes.7f566dbf34.svg\" width=\"800\" height=\"430\" alt=\"Original graph: Smoking→Lung Cancer→Cough; Pneumonia→Cough and Pneumonia→Fever.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Original graph: Smoking→Lung Cancer→Cough; Pneumonia→Cough and Pneumonia→Fever.</figcaption></figure><div class=\"table-wrap\"><table><thead><tr><th>Smoking S</th><th>P(S)</th></tr></thead><tbody><tr><td>T</td><td>0.3</td></tr><tr><td>F</td><td>0.7</td></tr></tbody></table></div><div class=\"table-wrap\"><table><thead><tr><th>Smoking S</th><th>P(C=T|S)</th><th>P(C=F|S)</th></tr></thead><tbody><tr><td>T</td><td>0.1</td><td>0.9</td></tr><tr><td>F</td><td>0.01</td><td>0.99</td></tr></tbody></table></div><div class=\"table-wrap\"><table><thead><tr><th>Pneumonia P</th><th>P(P)</th></tr></thead><tbody><tr><td>T</td><td>0.3</td></tr><tr><td>F</td><td>0.7</td></tr></tbody></table></div><div class=\"table-wrap\"><table><thead><tr><th>C</th><th>P</th><th>P(Co=T|C, P)</th><th>P(Co=F|C, P)</th></tr></thead><tbody><tr><td>T</td><td>T</td><td>0.95</td><td>0.05</td></tr><tr><td>T</td><td>F</td><td>0.8</td><td>0.2</td></tr><tr><td>F</td><td>T</td><td>0.7</td><td>0.3</td></tr><tr><td>F</td><td>F</td><td>0.1</td><td>0.9</td></tr></tbody></table></div><div class=\"table-wrap\"><table><thead><tr><th>P</th><th>P(Fever=T|P)</th><th>P(Fever=F|P)</th></tr></thead><tbody><tr><td>T</td><td>0.9</td><td>0.1</td></tr><tr><td>F</td><td>0.01</td><td>0.99</td></tr></tbody></table></div><p>Given the above tables for the Bayesian network, calculate Probability of a person having cough given he doesn’t have lung cancer but Smokes.</p></div><h3>Answer</h3><h3>Given</h3><p>Evidence: C=F (no lung cancer), S=T (smokes). Query: Co=T. Pneumonia is not observed; sum over its two states.</p><h3>To find</h3><p>P(Co=T | C=F, S=T).</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/09e203ebfdf53e2b.svg\" alt=\"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)\" style=\"width:61.1ex;height:5.371ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"step\"><h3>Step 1. Write the network factorization</h3><div class=\"math-display\"><img src=\"math/dfc06603bb26a3be.svg\" alt=\"P(S,C,P,Co,F)=P(S)P(C\\mid S)P(P)P(Co\\mid C,P)P(F\\mid P)\" style=\"width:59.816ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>This factorization expresses the model, not a general medical truth. Fever is unobserved and its two conditional probabilities sum to 1.</p></section><section class=\"step\"><h3>Step 2. Select the correct cough rows</h3><div class=\"table-wrap\"><table><thead><tr><th>Hidden pneumonia state</th><th>Cough probability with C=F</th><th>Pneumonia weight</th></tr></thead><tbody><tr><td>P=T</td><td>P(Co=T|C=F, P=T)=0.70</td><td>0.30</td></tr><tr><td>P=F</td><td>P(Co=T|C=F, P=F)=0.10</td><td>0.70</td></tr></tbody></table></div><p>Do not use 0.95 or 0.80: those rows assume lung cancer is present, which contradicts the given evidence.</p></section><section class=\"step\"><h3>Step 3. Multiply each conditional probability by its weight</h3><div class=\"math-display\"><img src=\"math/e8bf2d5761946110.svg\" alt=\"0.70\\times0.30=0.21,\\qquad0.10\\times0.70=0.07\" style=\"width:41.232ex;height:1.968ex\" loading=\"lazy\" decoding=\"async\"></div></section><section class=\"step\"><h3>Step 4. Add the mutually exclusive pneumonia cases</h3><div class=\"math-display\"><img src=\"math/b36e6cc824d0d47d.svg\" alt=\"P(Co=T\\mid C=F,S=T)=0.21+0.07=\\boxed{0.28}\" style=\"width:48.354ex;height:2.765ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Final answer:28%.</strong> We do not multiply the final answer byP(smoking)=0.3: smoking is already a condition, not an additional joint event.</p></section><section class=\"step\"><h3>Step 5. Verify using joint-over-evidence</h3><div class=\"math-display\"><img src=\"math/27b16cf13dc13276.svg\" alt=\"P(\\neg C,S)=0.9\\times0.3=0.27\" style=\"width:27.758ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/51760d268143a4b5.svg\" alt=\"P(Co,\\neg C,S)=0.27\\times0.28=0.0756\" style=\"width:36.106ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ad2987ff1355d124.svg\" alt=\"P(Co\\mid\\neg C,S)=0.0756/0.27=0.28\" style=\"width:35.351ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></section></section>"},{"id":"q3b","title":"Q3(b) Fuzzy Cartesian relations and composition-domain ambiguity [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q3(b)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>Consider 2 fuzzy sets</p><p>A={0.8/small+0.5/medium+0.2/large}</p><p>B={0.6/slow+0.9/moderate+0.4/fast}</p><ul><li>Find the fuzzy relation R=A×B (Cartesian Product)</li><li>Given another fuzzy set C={0.7/small+0.3/medium+0.5/large}. Find the fuzzy relation S=C×B</li><li>Calculate the max-min composition S∘R</li></ul></div><h3>Answer</h3><h3>Given</h3><p>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.</p><h3>To find</h3><p>R and S; then explain and resolve the composition convention explicitly.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/e9a9f703d571640c.svg\" alt=\"\\mu_{A\\times B}(x,y)=\\min(\\mu_A(x),\\mu_B(y)),\\quad T_{ij}=\\max_k\\min(U_{ik},V_{kj})\" style=\"width:57.624ex;height:3.454ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"step\"><h3>Step 1. Calculate all entries of R</h3><div class=\"table-wrap\"><table><thead><tr><th>Size / speed</th><th>slow 0.6</th><th>moderate 0.9</th><th>fast 0.4</th></tr></thead><tbody><tr><td>small 0.8</td><td>min(0.8,0.6)=0.6</td><td>min(0.8,0.9)=0.8</td><td>min(0.8,0.4)=0.4</td></tr><tr><td>medium 0.5</td><td>min(0.5,0.6)=0.5</td><td>min(0.5,0.9)=0.5</td><td>min(0.5,0.4)=0.4</td></tr><tr><td>large 0.2</td><td>min(0.2,0.6)=0.2</td><td>min(0.2,0.9)=0.2</td><td>min(0.2,0.4)=0.2</td></tr></tbody></table></div><div class=\"math-display\"><img src=\"math/52316a1420d445ac.svg\" alt=\"R=\\begin{bmatrix}0.6&amp;0.8&amp;0.4\\\\0.5&amp;0.5&amp;0.4\\\\0.2&amp;0.2&amp;0.2\\end{bmatrix}\" style=\"width:20.951ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></section><section class=\"step\"><h3>Step 2. Calculate all entries of S</h3><div class=\"table-wrap\"><table><thead><tr><th>Size / speed</th><th>slow 0.6</th><th>moderate 0.9</th><th>fast 0.4</th></tr></thead><tbody><tr><td>small 0.7</td><td>min(0.7,0.6)=0.6</td><td>min(0.7,0.9)=0.7</td><td>min(0.7,0.4)=0.4</td></tr><tr><td>medium 0.3</td><td>min(0.3,0.6)=0.3</td><td>min(0.3,0.9)=0.3</td><td>min(0.3,0.4)=0.3</td></tr><tr><td>large 0.5</td><td>min(0.5,0.6)=0.5</td><td>min(0.5,0.9)=0.5</td><td>min(0.5,0.4)=0.4</td></tr></tbody></table></div><div class=\"math-display\"><img src=\"math/0a4c516a6ffc1e2a.svg\" alt=\"S=\\begin{bmatrix}0.6&amp;0.7&amp;0.4\\\\0.3&amp;0.3&amp;0.3\\\\0.5&amp;0.5&amp;0.4\\end{bmatrix}\" style=\"width:20.694ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></section><section class=\"step\"><h3>Step 3. State the source-domain problem</h3><p><strong>As typed relations, both R and S map X→Y.</strong> 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.</p></section><section class=\"step\"><h3>Step 4. If the examiner intends an indexed matrix operation, state it first</h3><p><strong>Conditional classroom calculation:</strong> 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”.</p><div class=\"table-wrap\"><table><thead><tr><th>Entry</th><th>Three minimum terms</th><th>Maximum</th></tr></thead><tbody><tr><td>T11</td><td>min(0.6,0.6)=0.6, min(0.7,0.5)=0.5, min(0.4,0.2)=0.2</td><td>0.6</td></tr><tr><td>T12</td><td>min(0.6,0.8)=0.6, min(0.7,0.5)=0.5, min(0.4,0.2)=0.2</td><td>0.6</td></tr><tr><td>T13</td><td>min(0.6,0.4)=0.4, min(0.7,0.4)=0.4, min(0.4,0.2)=0.2</td><td>0.4</td></tr><tr><td>T21</td><td>min(0.3,0.6)=0.3, min(0.3,0.5)=0.3, min(0.3,0.2)=0.2</td><td>0.3</td></tr><tr><td>T22</td><td>min(0.3,0.8)=0.3, min(0.3,0.5)=0.3, min(0.3,0.2)=0.2</td><td>0.3</td></tr><tr><td>T23</td><td>min(0.3,0.4)=0.3, min(0.3,0.4)=0.3, min(0.3,0.2)=0.2</td><td>0.3</td></tr><tr><td>T31</td><td>min(0.5,0.6)=0.5, min(0.5,0.5)=0.5, min(0.4,0.2)=0.2</td><td>0.5</td></tr><tr><td>T32</td><td>min(0.5,0.8)=0.5, min(0.5,0.5)=0.5, min(0.4,0.2)=0.2</td><td>0.5</td></tr><tr><td>T33</td><td>min(0.5,0.4)=0.4, min(0.5,0.4)=0.4, min(0.4,0.2)=0.2</td><td>0.4</td></tr></tbody></table></div><div class=\"math-display\"><img src=\"math/fef1c19f50df11d5.svg\" alt=\"T=S\\odot R=\\begin{bmatrix}0.6&amp;0.6&amp;0.4\\\\0.3&amp;0.3&amp;0.3\\\\0.5&amp;0.5&amp;0.4\\end{bmatrix}\" style=\"width:29.786ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section><section class=\"step\"><h3>Step 5. Show a mathematically valid typed repair</h3><p>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:</p><div class=\"math-display\"><img src=\"math/3a687cf430317d18.svg\" alt=\"U=R\\odot S^T=\\begin{bmatrix}0.7&amp;0.3&amp;0.5\\\\0.5&amp;0.3&amp;0.5\\\\0.2&amp;0.2&amp;0.2\\end{bmatrix}\" style=\"width:31.36ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/62612d777f597842.svg\" alt=\"U_{11}=\\max\\{\\min(0.6,0.6),\\min(0.8,0.7),\\min(0.4,0.4)\\}=0.7\" style=\"width:57.705ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>This last matrix answers the explicitly repaired task, not an unannounced correction to the printed question.</p></section></section>"},{"id":"q4a","title":"Q4(a) PSO one iteration with missing initialization [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q4(a)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>Maximize the F(x) = x1² − x1.x2 + x2² + 3x1 + 4x2 + 5 using Particle Swarm Optimization.</p><p>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.</p></div><h3>Answer</h3><h3>Given</h3><p>F(x1, x2)=x1²−x1x2+x2²+3x1+4x2+5; inertia 0.9; c1=c2=1.5; r1=0.5949; r2=0.0855.</p><h3>To find</h3><p>One PSO update, while stating why the printed information does not determine a unique swarm result.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/7d9ccf789fe769f1.svg\" alt=\"v_{ij}^{t+1}=wv_{ij}^t+c_1r_1(pbest_{ij}-x_{ij}^t)+c_2r_2(gbest_j-x_{ij}^t)\" style=\"width:51.228ex;height:2.988ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/566cb0a85349654b.svg\" alt=\"x_{ij}^{t+1}=x_{ij}^t+v_{ij}^{t+1}\" style=\"width:16.487ex;height:2.988ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"step\"><h3>Step 1. Identify missing data and the unbounded objective</h3><p>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:</p><div class=\"math-display\"><img src=\"math/b88e59abd3293f46.svg\" alt=\"F(t,t)=t^2+7t+5\\longrightarrow+\\infty\\quad(t\\to+\\infty)\" style=\"width:40.893ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>There is no finite global maximum on an unrestricted plane.</strong> A bounded domain would be required for a finite maximization target.</p></section><section class=\"step\"><h3>Step 2. Declare a permissible illustrative initialization</h3><p>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.</p><div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>Position</th><th>Velocity</th><th>Objective</th><th>Initial pbest</th></tr></thead><tbody><tr><td>A</td><td>(0,0)</td><td>(0,0)</td><td>5</td><td>(0,0)</td></tr><tr><td>B</td><td>(1,1)</td><td>(0,0)</td><td>1−1+1+3+4+5=13</td><td>(1,1)</td></tr></tbody></table></div><p>The old gbest is B=(1,1), with value 13. These particle coordinates are assumptions, not data from the scan.</p></section><section class=\"step\"><h3>Step 3. Compute the attraction coefficients</h3><div class=\"math-display\"><img src=\"math/df63d53634007eba.svg\" alt=\"c_1r_1=1.5(0.5949)=0.89235,\\quad c_2r_2=1.5(0.0855)=0.12825\" style=\"width:59.993ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The cognitive term is zero for both particles because each starts at its own pbest.</p></section><section class=\"step\"><h3>Step 4. Update particle A, coordinate by coordinate</h3><div class=\"math-display\"><img src=\"math/9c531ea472a5b2fe.svg\" alt=\"v_{A1}^{1}=0.9(0)+0.89235(0-0)+0.12825(1-0)=0.12825\" style=\"width:56.459ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f5e85d68eed20ee1.svg\" alt=\"v_{A2}^{1}=0.9(0)+0.89235(0-0)+0.12825(1-0)=0.12825\" style=\"width:56.459ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3d974cd8e38814b0.svg\" alt=\"x_A^1=(0+0.12825,0+0.12825)=(0.12825,0.12825)\" style=\"width:51.707ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7930f3e2597545dd.svg\" alt=\"F(x_A^1)=(0.12825)^2+7(0.12825)+5=5.9141980625\" style=\"width:52.378ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></div><p>This exceeds 5, so A's pbest becomes its new position.</p></section><section class=\"step\"><h3>Step 5. Update particle B and select the new swarm best</h3><div class=\"math-display\"><img src=\"math/86465ec4ca89266b.svg\" alt=\"v_{B1}^{1}=v_{B2}^{1}=0.9(0)+0.89235(1-1)+0.12825(1-1)=0\" style=\"width:56.504ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>B remains at(1,1), with objective 13. Compare 13 against 5.9141980625: the best found after this assumed iteration is still <strong>(1,1), F=13</strong>. This is only the best of the two evaluated particles, not the nonexistent unrestricted global maximum.</p></section></section>"},{"id":"q4b","title":"Q4(b) Naive Bayes product-purchase classification [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q4(b)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><div class=\"table-wrap\"><table><thead><tr><th>Age</th><th>Income Level</th><th>Previous Purchase</th><th>Buy Product</th></tr></thead><tbody><tr><td>Young</td><td>Low</td><td>No</td><td>No</td></tr><tr><td>Middle-aged</td><td>Medium</td><td>Yes</td><td>Yes</td></tr><tr><td>Senior</td><td>High</td><td>No</td><td>No</td></tr><tr><td>Young</td><td>Medium</td><td>Yes</td><td>Yes</td></tr><tr><td>Senior</td><td>Low</td><td>No</td><td>No</td></tr><tr><td>Middle-aged</td><td>High</td><td>Yes</td><td>Yes</td></tr><tr><td>Young</td><td>Low</td><td>Yes</td><td>Yes</td></tr><tr><td>Senior</td><td>Medium</td><td>No</td><td>No</td></tr></tbody></table></div><p>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.</p></div><h3>Answer</h3><h3>Given</h3><p>Eight training rows; query=(Young, High, No). No smoothing instruction is printed.</p><h3>To find</h3><p>The two class scores and the larger-posterior class.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/0629d7338a1ecd30.svg\" alt=\"s_c=P(c)P(Young\\mid c)P(High\\mid c)P(PreviousNo\\mid c)\" style=\"width:52.309ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"step\"><h3>Step 1. Count the classes</h3><p>Yes occurs in rows 2,4,6,7:4 rows. No occurs in rows 1,3,5,8:4 rows.</p><div class=\"math-display\"><img src=\"math/c54c9411a1740830.svg\" alt=\"P(Yes)=4/8=1/2,\\quad P(No)=4/8=1/2\" style=\"width:42.778ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></section><section class=\"step\"><h3>Step 2. Count each query feature within each class</h3><div class=\"table-wrap\"><table><thead><tr><th>Query feature</th><th>Count among Yes /4</th><th>Count among No /4</th></tr></thead><tbody><tr><td>Young</td><td>2/4</td><td>1/4</td></tr><tr><td>High income</td><td>1/4</td><td>1/4</td></tr><tr><td>Previous purchase No</td><td>0/4</td><td>4/4</td></tr></tbody></table></div><p>The denominator is the class count 4, not the full dataset 8.</p></section><section class=\"step\"><h3>Step 3. Multiply the Yes score</h3><div class=\"math-display\"><img src=\"math/7af34167018bca92.svg\" alt=\"s_{Yes}=\\frac12\\times\\frac24\\times\\frac14\\times\\frac04=0\" style=\"width:27.935ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><p>The zero comes from no training Yes row having Previous Purchase=No.</p></section><section class=\"step\"><h3>Step 4. Multiply the No score</h3><div class=\"math-display\"><img src=\"math/e376b189fb5efc12.svg\" alt=\"s_{No}=\\frac12\\times\\frac14\\times\\frac14\\times\\frac44=\\frac1{32}=0.03125\" style=\"width:39.975ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></section><section class=\"step\"><h3>Step 5. Normalize and predict</h3><div class=\"math-display\"><img src=\"math/6e2299fa87aa4056.svg\" alt=\"P(Yes\\mid x)=\\frac0{0+0.03125}=0,\\quad P(No\\mid x)=\\frac{0.03125}{0.03125}=1\" style=\"width:58.546ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Predicted class: No, under the unsmoothed model.</strong> 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.</p></section><section class=\"step\"><h3>Step 6. If smoothing is explicitly required, state the alternative</h3><p>With add-one smoothing, Age and Income each have 3 categories and Previous Purchase has 2. Keep the class priors 1/2. Then:</p><div class=\"math-display\"><img src=\"math/df5992f5cc97daef.svg\" alt=\"s_{Yes}^{(+1)}=\\frac12\\frac37\\frac27\\frac16=\\frac1{98},\\quad s_{No}^{(+1)}=\\frac12\\frac27\\frac27\\frac56=\\frac5{147}\" style=\"width:49.074ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c94cdf7b26810ac7.svg\" alt=\"P_{+1}(Yes\\mid x)=3/13,\\quad P_{+1}(No\\mid x)=10/13\" style=\"width:43.682ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The decision is still No. This is a labeled alternative, not a silent change to the printed task.</p></section></section>"},{"id":"q5a","title":"Q5(a) Binary GA crossover, one-bit mutation and fitness [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q5(a)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>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.</p></div><h3>Answer</h3><h3>Given</h3><p>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.</p><h3>To find</h3><p>Crossover children, explicit mutated chromosomes and objective comparison.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/7000daead38032a9.svg\" alt=\"x=8b_1+4b_2+2b_3+b_4,\\qquad f(x)=x^3-4x^2+6x\" style=\"width:50.333ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>Split after the second bit, swap the right halves, then flip exactly the declared mutation bit. Fitness is the stated objective; maximize it.</p><section class=\"step\"><h3>Step 1. Encode and evaluate the four parents</h3><div class=\"table-wrap\"><table><thead><tr><th>Parent x</th><th>4-bit code</th><th>Fitness calculation</th><th>f (x)</th></tr></thead><tbody><tr><td>10</td><td>1010</td><td>10³−4(10²)+6(10)</td><td>660</td></tr><tr><td>12</td><td>1100</td><td>12³−4(12²)+6(12)</td><td>1224</td></tr><tr><td>7</td><td>0111</td><td>7³−4(7²)+6(7)</td><td>189</td></tr><tr><td>3</td><td>0011</td><td>3³−4(3²)+6(3)</td><td>9</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 2. Declare pairing and form children</h3><p>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.</p><div class=\"table-wrap\"><table><thead><tr><th>Pair</th><th>Split parents</th><th>Child 1</th><th>Child 2</th></tr></thead><tbody><tr><td>10 with 12</td><td>10|10 and 11|00</td><td>10|00=1000₂=8</td><td>11|10=1110₂=14</td></tr><tr><td>7 with 3</td><td>01|11 and 00|11</td><td>01|11=0111₂=7</td><td>00|11=0011₂=3</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 3. Perform one explicitly chosen bit flip per child</h3><p>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.</p><div class=\"table-wrap\"><table><thead><tr><th>Before mutation</th><th>Flip bit 4</th><th>After mutation</th><th>Decimal</th></tr></thead><tbody><tr><td>1000</td><td>0→1</td><td>1001</td><td>9</td></tr><tr><td>1110</td><td>0→1</td><td>1111</td><td>15</td></tr><tr><td>0111</td><td>1→0</td><td>0110</td><td>6</td></tr><tr><td>0011</td><td>1→0</td><td>0010</td><td>2</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 4. Evaluate every offspring and compare</h3><div class=\"table-wrap\"><table><thead><tr><th>Child x before mutation</th><th>f (x) before</th><th>Child x after mutation</th><th>f (x) after</th></tr></thead><tbody><tr><td>8</td><td>304</td><td>9</td><td>459</td></tr><tr><td>14</td><td>2044</td><td>15</td><td>2565</td></tr><tr><td>7</td><td>189</td><td>6</td><td>108</td></tr><tr><td>3</td><td>9</td><td>2</td><td>4</td></tr></tbody></table></div><div class=\"math-display\"><img src=\"math/5600d463abeea9e2.svg\" alt=\"f(15)=15^3-4(15^2)+6(15)=3375-900+90=2565\" style=\"width:54.632ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section><section class=\"step\"><h3>Step 5. State the result without hiding stochastic choices</h3><p><strong>For these declared pairings and mutations, offspring are 9,15,6,2 and the best is 15.</strong> 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.</p></section></section>"},{"id":"q5b","title":"Q5(b) Bike-sharing Markov transitions, retention and gains [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q5(b)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>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.</p><ul><li>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.</li><li>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.</li><li>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.</li></ul><ul><li>Develop a Transition Probability matrix</li><li>Interpret the state transition matrix regarding a) Retention &amp; loss b) Retention &amp; gain</li><li>Draw the State transition diagram</li></ul></div><h3>Answer</h3><h3>Given</h3><p>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.</p><h3>To find</h3><p>Transition matrix, retention/outflow/inflow interpretation and state diagram.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/f39ae5af858943b8.svg\" alt=\"\\mathbf n_{t+1}=\\mathbf n_tP\" style=\"width:11.183ex;height:2.016ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"step\"><h3>Step 1. Write the transition matrix</h3><div class=\"math-display\"><img src=\"math/18c74fdbd43cdfe0.svg\" alt=\"P=\\begin{bmatrix}0.30&amp;0.50&amp;0.20\\\\0.10&amp;0.60&amp;0.30\\\\0.10&amp;0.10&amp;0.80\\end{bmatrix}\" style=\"width:24.327ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section><section class=\"step\"><h3>Step 2. Interpret retention and loss from each station</h3><div class=\"table-wrap\"><table><thead><tr><th>Origin</th><th>Retained at origin</th><th>Leaves origin</th><th>Where the losses go</th></tr></thead><tbody><tr><td>A</td><td>30%</td><td>70%</td><td>50% toB;20% toC</td></tr><tr><td>B</td><td>60%</td><td>40%</td><td>10% toA;30% toC</td></tr><tr><td>C</td><td>80%</td><td>20%</td><td>10% toA;10% toB</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 3. Express retention and incoming gains correctly</h3><p>Let a, b, c be the starting numbers of bikes. Then:</p><div class=\"math-display\"><img src=\"math/aee58f980f95f13c.svg\" alt=\"a_{next}=0.30a+0.10b+0.10c\" style=\"width:28.346ex;height:1.927ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/24b806632ba7642d.svg\" alt=\"b_{next}=0.50a+0.60b+0.10c\" style=\"width:28.12ex;height:1.927ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8fa41e7634228ffe.svg\" alt=\"c_{next}=0.20a+0.30b+0.80c\" style=\"width:28.129ex;height:1.927ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"table-wrap\"><table><thead><tr><th>Station</th><th>Retained component</th><th>Incoming gain from other stations</th><th>Net change</th></tr></thead><tbody><tr><td>A</td><td>0.30a</td><td>0.10b+0.10c</td><td>−0.70a+0.10b+0.10c</td></tr><tr><td>B</td><td>0.60b</td><td>0.50a+0.10c</td><td>0.50a−0.40b+0.10c</td></tr><tr><td>C</td><td>0.80c</td><td>0.20a+0.30b</td><td>0.20a+0.30b−0.20c</td></tr></tbody></table></div><p>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.</p></section><section class=\"step\"><h3>Step 4. Illustrate only if initial counts are explicitly assumed</h3><p>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.</p></section><section class=\"step\"><h3>Step 5. Draw all directed transitions</h3><figure><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy25-bikes.7db03f5dcb.svg\" width=\"800\" height=\"430\" alt=\"Three-state diagram with all six cross-station probabilities and self-loop retention 0.30,0.60,0.80.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Three-state diagram with all six cross-station probabilities and self-loop retention 0.30,0.60,0.80.</figcaption></figure></section></section>"},{"id":"q6a","title":"Q6(a) ACO tour lengths, evaporation and pheromone deposition [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q6(a)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>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</p><div class=\"table-wrap\"><table><thead><tr><th>Pheromone</th><th>A</th><th>B</th><th>C</th><th>D</th></tr></thead><tbody><tr><td>A</td><td>0</td><td>15</td><td>5</td><td>4</td></tr><tr><td>B</td><td>15</td><td>0</td><td>4</td><td>8</td></tr><tr><td>C</td><td>5</td><td>4</td><td>0</td><td>1</td></tr><tr><td>D</td><td>4</td><td>8</td><td>1</td><td>0</td></tr></tbody></table></div><div class=\"table-wrap\"><table><thead><tr><th>Cost</th><th>A</th><th>B</th><th>C</th><th>D</th></tr></thead><tbody><tr><td>A</td><td>0</td><td>10</td><td>4</td><td>3</td></tr><tr><td>B</td><td>10</td><td>0</td><td>1</td><td>2</td></tr><tr><td>C</td><td>4</td><td>1</td><td>0</td><td>1</td></tr><tr><td>D</td><td>3</td><td>2</td><td>1</td><td>0</td></tr></tbody></table></div><p>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</p></div><h3>Answer</h3><h3>Given</h3><p>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.</p><h3>To find</h3><p>Tour lengths and updated edge pheromones after evaporation and both deposits.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/d62616a1401fbf2a.svg\" alt=\"L_k=\\sum_{(i,j)\\in tour_k}d_{ij},\\quad\\Delta\\tau_{ij}^{k}=\\begin{cases}Q/L_k&amp;(i,j)\\in tour_k\\\\0&amp;\\text{otherwise}\\end{cases}\" style=\"width:48.706ex;height:6.501ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/657b62b2f2dbf71a.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}^{old}+\\sum_k\\Delta\\tau_{ij}^{k}\" style=\"width:28.42ex;height:4.899ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><section class=\"step\"><h3>Step 1. Compute tour 1 from the cost matrix</h3><div class=\"math-display\"><img src=\"math/ac9a78a66f280841.svg\" alt=\"L_1=d_{AB}+d_{BC}+d_{CD}+d_{DA}=10+1+1+3=15\" style=\"width:51.459ex;height:1.945ex\" loading=\"lazy\" decoding=\"async\"></div></section><section class=\"step\"><h3>Step 2. Compute tour 2 from the cost matrix</h3><div class=\"math-display\"><img src=\"math/cd7de0bca5f15da5.svg\" alt=\"L_2=d_{AC}+d_{CB}+d_{BD}+d_{DA}=4+1+2+3=10\" style=\"width:50.327ex;height:1.951ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section><section class=\"step\"><h3>Step 3. List which ants use each undirected edge</h3><div class=\"table-wrap\"><table><thead><tr><th>Edge</th><th>Old τ</th><th>After evaporation 0.5τ</th><th>Deposits</th><th>New τ</th></tr></thead><tbody><tr><td>AB</td><td>15</td><td>7.5</td><td>Q/15</td><td>7.5+Q/15</td></tr><tr><td>AC</td><td>5</td><td>2.5</td><td>Q/10</td><td>2.5+Q/10</td></tr><tr><td>AD</td><td>4</td><td>2</td><td>Q/15+Q/10=Q/6</td><td>2+Q/6</td></tr><tr><td>BC</td><td>4</td><td>2</td><td>Q/15+Q/10=Q/6</td><td>2+Q/6</td></tr><tr><td>BD</td><td>8</td><td>4</td><td>Q/10</td><td>4+Q/10</td></tr><tr><td>CD</td><td>1</td><td>0.5</td><td>Q/15</td><td>0.5+Q/15</td></tr></tbody></table></div><p>BC andCB are the same undirected edge here; both tours also useDA. Both deposits must be included on those shared edges.</p></section><section class=\"step\"><h3>Step 4. If Q=1 is assumed, substitute</h3><div class=\"math-display\"><img src=\"math/b935c574afe72660.svg\" alt=\"\\tau^{new}\\approx\\begin{bmatrix}0&amp;7.566667&amp;2.600000&amp;2.166667\\\\7.566667&amp;0&amp;2.166667&amp;4.100000\\\\2.600000&amp;2.166667&amp;0&amp;0.566667\\\\2.166667&amp;4.100000&amp;0.566667&amp;0\\end{bmatrix}\" style=\"width:51.343ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section></section>"},{"id":"q6b","title":"Q6(b) Two-step walking/cycling Markov transition [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q6(b)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>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.</p><ul><li>Express this information in a transition matrix.</li><li>if it is assumed that the initial day is Monday, write a matrix that gives probabilities of a transition from Monday to Wednesday.</li></ul></div><h3>Answer</h3><h3>Given</h3><p>State orderW=walk, C=cycle. One transition is one day.</p><h3>To find</h3><p>P for one day andP² for Monday→Wednesday.</p><h3>Formula and why</h3><div class=\"math-display\"><img src=\"math/1fa028a29cde1ac6.svg\" alt=\"(P^2)_{ij}=\\sum_kP_{ik}P_{kj}\" style=\"width:18.791ex;height:4.899ex\" loading=\"lazy\" decoding=\"async\"></div><p>There are two transitions, Monday→Tuesday and Tuesday→Wednesday. Multiply along each possible intermediate Tuesday state and add the alternatives.</p><section class=\"step\"><h3>Step 1. Complete the one-day rows</h3><p>From walking:W→W=1/2 andW→C=1/2. From cycling:C→W=1/4, soC→C=1−1/4=3/4.</p><div class=\"math-display\"><img src=\"math/ed5dd48ea3dd8f9e.svg\" alt=\"P=\\begin{bmatrix}1/2&amp;1/2\\\\1/4&amp;3/4\\end{bmatrix}\" style=\"width:16.155ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div></section><section class=\"step\"><h3>Step 2. Compute all four two-day entries</h3><div class=\"table-wrap\"><table><thead><tr><th>Monday→Wednesday</th><th>Sum over Tuesday W or C</th><th>Result</th></tr></thead><tbody><tr><td>W→W</td><td>(1/2)(1/2)+(1/2)(1/4)=1/4+1/8</td><td>3/8</td></tr><tr><td>W→C</td><td>(1/2)(1/2)+(1/2)(3/4)=1/4+3/8</td><td>5/8</td></tr><tr><td>C→W</td><td>(1/4)(1/2)+(3/4)(1/4)=1/8+3/16</td><td>5/16</td></tr><tr><td>C→C</td><td>(1/4)(1/2)+(3/4)(3/4)=1/8+9/16</td><td>11/16</td></tr></tbody></table></div></section><section class=\"step\"><h3>Step 3. Write the requested matrix</h3><div class=\"math-display\"><img src=\"math/a532335af3e981b5.svg\" alt=\"P^2=\\begin{bmatrix}3/8&amp;5/8\\\\5/16&amp;11/16\\end{bmatrix}=\\begin{bmatrix}0.375&amp;0.625\\\\0.3125&amp;0.6875\\end{bmatrix}\" style=\"width:40.901ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section></section>"},{"id":"q7a","title":"Q7(a) Fuzzy logic applications and complete controller example [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(a)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>List the applications of Fuzzy logic. Explain one in detail.</p></div><h3>Answer</h3><p><strong>Fuzzy logic</strong> 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.</p><ul><li>Air-conditioning and automatic fan-speed control.</li><li>Washing-machine adjustment of wash time, agitation or water use.</li><li>Camera autofocus/exposure control.</li><li>Vehicle and industrial process control.</li><li>Decision support and multicriteria scoring when judgments are linguistic.</li><li>Pattern recognition and fuzzy clustering.</li></ul><h3>Detailed example: room-temperature fan controller</h3><figure><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy25-controller.80f7bae29e.svg\" width=\"800\" height=\"430\" alt=\"Crisp measurements → fuzzification → rule evaluation → output aggregation/defuzzification → fan command. The rule base defines linguistic responses.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Crisp measurements → fuzzification → rule evaluation → output aggregation/defuzzification → fan command. The rule base defines linguistic responses.</figcaption></figure><div class=\"table-wrap\"><table><thead><tr><th>Block</th><th>Role in this example</th></tr></thead><tbody><tr><td>Sensors / crisp input</td><td>Measure room temperature and occupancy</td></tr><tr><td>Fuzzifier</td><td>Convert each measurement to memberships such asCool, Warm, Hot andLow, High occupancy</td></tr><tr><td>Knowledge base</td><td>Store membership-function definitions and IF–THEN rules</td></tr><tr><td>Inference engine</td><td>Evaluate each rule's antecedent strength using the stated AND/OR operations</td></tr><tr><td>Defuzzifier / output computation</td><td>Convert the activated outputs to one fan command</td></tr><tr><td>Actuator</td><td>Apply the bounded fan-speed command; sensors provide fresh input for the next cycle</td></tr></tbody></table></div><h3>Illustrative rules and a transparent calculation</h3><p>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.</p><ul><li>IF temperature isWarm THEN fan command=50%.</li><li>IF temperature isHot THEN fan command=90%.</li></ul><p>Use a <strong>zero-order Sugeno</strong> design with these constant consequents, so its weighted output is:</p><div class=\"math-display\"><img src=\"math/fb20d690460ddd1a.svg\" alt=\"fan=\\frac{0.5(50)+0.5(90)}{0.5+0.5}=\\frac{25+45}{1}=70\\%\" style=\"width:42.872ex;height:5.041ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h3>Advantages and limitations</h3><ul><li>Smooth transitions avoid an abrupt full-speed jump at one fixed threshold.</li><li>Rules are interpretable and can incorporate expert knowledge without requiring an exact plant equation.</li><li>Membership functions and rules still require validation; poor design can create unsuitable or unstable behavior.</li><li>More inputs and linguistic sets can make the rule base large. Safety limits and fallback behavior must be engineered separately.</li></ul><p>Yaad rakho: measured number→kitnaWarm/Hot→rules→one usable fan command.</p></section>"},{"id":"q7b","title":"Q7(b) Bellman equations and reinforcement-learning applications [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(b)</strong> <span class=\"marks\">[10 marks · 2025-04-28]</span><p>Explain Bellman equation in reinforcement learning. Also give applications of reinforcement learning.</p></div><h3>Answer</h3><p><strong>Reinforcement learning (RL)</strong> 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.</p><div class=\"table-wrap\"><table><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>s, a</td><td>Current state and selected action</td></tr><tr><td>s′, r</td><td>Next state and one-step reward</td></tr><tr><td>γ</td><td>Discount factor; usually 0≤γ&lt;1 for discounted continuing tasks</td></tr><tr><td>π(a|s)</td><td>Probability of actiona under the policy</td></tr><tr><td>Vπ(s)</td><td>Expected discounted return starting in state s and followingπ</td></tr><tr><td>Qπ(s, a)</td><td>Expected discounted return after first choosinga in s, then followingπ</td></tr></tbody></table></div><section class=\"step\"><h3>Step 1. Split the return into present reward and remaining future</h3><div class=\"math-display\"><img src=\"math/97caee2822bc6475.svg\" alt=\"G_t=R_{t+1}+\\gamma R_{t+2}+\\gamma^2R_{t+3}+\\cdots=R_{t+1}+\\gamma G_{t+1}\" style=\"width:49.778ex;height:2.489ex\" loading=\"lazy\" decoding=\"async\"></div><p>This one-step decomposition is the basis of the Bellman equation: value now equals expected immediate reward plus discounted value of what follows.</p></section><section class=\"step\"><h3>Step 2. Write the Bellman expectation equation</h3><div class=\"math-display\"><img src=\"math/80ef2d8261fa9e17.svg\" alt=\"V^\\pi(s)=\\sum_a\\pi(a\\mid s)\\sum_{s&#39;,r}p(s&#39;,r\\mid s,a)\\left[r+\\gamma V^\\pi(s&#39;)\\right]\" style=\"width:49.135ex;height:5.178ex\" loading=\"lazy\" decoding=\"async\"></div><p>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′).</p></section><section class=\"step\"><h3>Step 3. Write the optimality form</h3><div class=\"math-display\"><img src=\"math/863310fc89ae0de3.svg\" alt=\"V^*(s)=\\max_a\\sum_{s&#39;,r}p(s&#39;,r\\mid s,a)\\left[r+\\gamma V^*(s&#39;)\\right]\" style=\"width:42.284ex;height:5.178ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1f89cb0381d5b714.svg\" alt=\"Q^*(s,a)=\\sum_{s&#39;,r}p(s&#39;,r\\mid s,a)\\left[r+\\gamma\\max_{a&#39;}Q^*(s&#39;,a&#39;)\\right]\" style=\"width:48.028ex;height:6.308ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></section><section class=\"step\"><h3>Step 4. Use a concrete numerical example</h3><p>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.</p><div class=\"table-wrap\"><table><thead><tr><th>Action</th><th>Bellman backup</th><th>Value</th></tr></thead><tbody><tr><td>A</td><td>2+0.9×10</td><td>11</td></tr><tr><td>B</td><td>5+0.9×4</td><td>8.6</td></tr></tbody></table></div><p>The optimality backup choosesA because 11&gt;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.</p></section><h3>Applications</h3><div class=\"table-wrap\"><table><thead><tr><th>Application</th><th>State / action / reward example</th></tr></thead><tbody><tr><td>Robot navigation</td><td>State:location/sensors; action:move; reward:goal reached with penalties for collision and delay</td></tr><tr><td>Game playing</td><td>State:board configuration; action:legal move; reward:win/loss or a carefully designed game score</td></tr><tr><td>Traffic-signal control</td><td>State:queue lengths; action:signal phase; reward:reduced delay with safety constraints</td></tr><tr><td>Resource scheduling</td><td>State:workload/resources; action:allocate jobs; reward:throughput or energy objective</td></tr><tr><td>Adaptive recommendation</td><td>State:user/context history; action:recommend an item; reward:measured engagement or another validated long-term outcome</td></tr></tbody></table></div><p>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.</p></section>"}]},{"id":"paper-2024-reexam","title":"Re-examination · 25 Jun 2024","unit":"paper","scope":"Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.","sections":[{"id":"q1a","title":"Q1(a) Traditional versus evolutionary optimization [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(a)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>Compare traditional optimization and evolutionary optimization algorithms. Illustrate the basic framework of evolutionary algorithms.</p></div><h3>Answer</h3><p><strong>Optimization</strong> searches for a feasible candidate that maximizes or minimizes an objective. Evolutionary algorithms use a population, fitness-based selection and variation inspired by evolution.</p><table><thead><tr><th>Aspect</th><th>Traditional methods (typical examples)</th><th>Evolutionary methods</th></tr></thead><tbody><tr><td>Search state</td><td>Often one current candidate, e.g. gradient descent</td><td>Usually a population of candidates</td></tr><tr><td>Information</td><td>Gradient/Hessian in derivative methods; not required by all traditional methods</td><td>Primarily objective/fitness evaluations</td></tr><tr><td>Variation</td><td>A mathematically derived step or deterministic search rule</td><td>Crossover and mutation with stochastic choices</td></tr><tr><td>Landscape</td><td>Strong efficiency/guarantees possible under assumptions such as convexity</td><td>Useful for discrete, non-smooth, mixed or multimodal search</td></tr><tr><td>Guarantee</td><td>Depends on the algorithm and assumptions</td><td>No general finite-run global-optimum guarantee</td></tr><tr><td>Cost</td><td>May require fewer evaluations on suitable smooth problems</td><td>Often needs many evaluations and parameter tuning</td></tr></tbody></table><p><strong>Framework:</strong> encode candidates → initialize feasible population → evaluate fitness → select parents → crossover → mutate → evaluate offspring → choose survivors → repeat until stopping criterion → return best observed candidate.</p><p>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.</p></section>"},{"id":"q1b","title":"Q1(b) Bayes posterior for red ball [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(b)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>A has 7 balls, B has 9; red likelihoods 3/7 and 4/9.</p><h4>To find</h4><p>P(A|red).</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/ba4aa6be7e570107.svg\" alt=\"P(A\\mid R)=\\frac{P(R\\mid A)P(A)}{P(R\\mid A)P(A)+P(R\\mid B)P(B)}\" style=\"width:43.409ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 1. Weight each red likelihood by its bag prior</h5><div class=\"math-display\"><img src=\"math/a518125ef5d2bed8.svg\" alt=\"P(R,A)=\\frac37\\frac12=\\frac3{14},\\quad P(R,B)=\\frac49\\frac12=\\frac29\" style=\"width:45.007ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Add all ways to see red</h5><div class=\"math-display\"><img src=\"math/8383f96e6caef877.svg\" alt=\"P(R)=\\frac3{14}+\\frac29=\\frac{27+28}{126}=\\frac{55}{126}\" style=\"width:35.053ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Normalize the A contribution</h5><div class=\"math-display\"><img src=\"math/7b275c539000ed1c.svg\" alt=\"P(A\\mid R)=\\frac{3/14}{55/126}=\\frac{27}{55}\\approx0.490909\" style=\"width:37.399ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 27/55 ≈ 0.490909 under equal bag-selection priors.</div></section>"},{"id":"q1c","title":"Q1(c) Fuzzy union, intersection and complements [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(c)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>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̄.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Memberships A and B as printed; use the listed element order.</p><h4>To find</h4><p>Union, intersection and the requested operations on the complements.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/8ef43c082b1d8a4a.svg\" alt=\"\\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)\" style=\"width:84.04ex;height:2.444ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Compute complements before combining them</h5><p>At x₁: 1−0.7=0.3, and 1−0.2=0.8. Never subtract the element label; subtract its membership.</p></div><div class=\"step\"><h5>Step 2. Work element by element</h5><table><thead><tr><th>Element</th><th>A</th><th>B</th><th>1−A</th><th>1−B</th><th>max (A, B)</th><th>min (A, B)</th><th>max(1−A,1−B)</th><th>min(1−A,1−B)</th></tr></thead><tbody><tr><td>x₁</td><td>0.7</td><td>0.2</td><td>0.3</td><td>0.8</td><td>0.7</td><td>0.2</td><td>0.8</td><td>0.3</td></tr><tr><td>x₂</td><td>0.3</td><td>0.5</td><td>0.7</td><td>0.5</td><td>0.5</td><td>0.3</td><td>0.7</td><td>0.5</td></tr><tr><td>x₃</td><td>0.9</td><td>0.7</td><td>0.1</td><td>0.3</td><td>0.9</td><td>0.7</td><td>0.3</td><td>0.1</td></tr><tr><td>x₄</td><td>0.1</td><td>0.4</td><td>0.9</td><td>0.6</td><td>0.4</td><td>0.1</td><td>0.9</td><td>0.6</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Read the requested columns in the original order</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> (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].</div></section>"},{"id":"q1d","title":"Q1(d) Irreducibility and stationary distribution [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(d)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Two states, row-stochastic matrix [[.8,.2],[.3,.7]].</p><h4>To find</h4><p>Mutual reachability and a probability row vector π with πP=π.</p></div><h4>Formula and why it applies</h4><p>Irreducible means every state can reach every other with positive probability in some number of steps. Stationary means one transition leaves the distribution unchanged.</p><div class=\"math-display\"><img src=\"math/bf18c709d7b4ad37.svg\" alt=\"\\pi=\\pi P,\\quad\\pi_1+\\pi_2=1\" style=\"width:22.032ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Check both directions</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24r-stationary.41b587e21f.svg\" width=\"760\" height=\"430\" alt=\"Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.</figcaption></figure><p>1→2 has probability .2&gt;0 and 2→1 has probability .3&gt;0. Each state reaches the other in one step; the chain is irreducible. Self-loops also make it aperiodic.</p></div><div class=\"step\"><h5>Step 2. Balance probability entering state 1</h5><div class=\"math-display\"><img src=\"math/bd5f35e7318e17ca.svg\" alt=\"\\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\" style=\"width:49.254ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Normalize</h5><div class=\"math-display\"><img src=\"math/d630dbfb75f1cbad.svg\" alt=\"1.5\\pi_2+\\pi_2=1\\Rightarrow\\pi_2=0.4,\\quad\\pi_1=0.6\" style=\"width:37.519ex;height:1.971ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Verify both columns</h5><div class=\"math-display\"><img src=\"math/ff5d9937f5d667c5.svg\" alt=\"[0.6,0.4]P=[0.48+0.12,\\;0.12+0.28]=[0.6,0.4]\" style=\"width:48.342ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Yes, irreducible; π=[0.6,0.4].</div></section>"},{"id":"q2a","title":"Q2(a) GMM modified log likelihood and parameters [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q2(a)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>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.</p></div><h3>Answer</h3><p>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><div class=\"math-display\"><img src=\"math/34e74a21f3e93c71.svg\" alt=\"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\" style=\"width:53.891ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"step\"><h5>Step 1. Form the observed-data log likelihood</h5><p>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.</p><div class=\"math-display\"><img src=\"math/68bab3da61241a5e.svg\" alt=\"\\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]\" style=\"width:65.678ex;height:6.785ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. E-step: estimate component membership</h5><p>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.</p><div class=\"math-display\"><img src=\"math/3463c7734eab2353.svg\" alt=\"\\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)}\" style=\"width:26.1ex;height:6.058ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Use the expected complete-data log likelihood</h5><p>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.</p><div class=\"math-display\"><img src=\"math/da8bce8c31e000fa.svg\" alt=\"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]\" style=\"width:50.07ex;height:4.899ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. M-step: weighted estimates</h5><div class=\"math-display\"><img src=\"math/c63266009fda4bdb.svg\" alt=\"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}\" style=\"width:46.66ex;height:6.098ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/433755f43e0968ba.svg\" alt=\"\\Sigma_k^{new}=\\frac{\\sum_i\\gamma_{ik}(x_i-\\mu_k^{new})(x_i-\\mu_k^{new})^T}{N_k}\" style=\"width:38.175ex;height:5.585ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 5. Count parameters without inventing the dimension</h5><p>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.</p><div class=\"math-display\"><img src=\"math/24096c582fbc12b9.svg\" alt=\"n_{free}=Kd+K\\frac{d(d+1)}2+(K-1)\" style=\"width:35.059ex;height:4.855ex\" loading=\"lazy\" decoding=\"async\"></div><p>For a stated one-dimensional assumption: 6 means + 6 variances + 5 independent weights = <strong>17 free parameters</strong>. 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.</p></div></section>"},{"id":"q2b","title":"Q2(b) Fuzzy washing-machine controller [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q2(b)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>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%.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Dirt=60, Grease=70; ranges 0–100; three input terms and five output terms.</p><h4>To find</h4><p>A complete controller: membership graphs, rules, inference and crisp output.</p></div><h4>Formula and why it applies</h4><p>Fuzzification translates measured values into degrees. Min implements AND, max combines rules, and centroid converts the fuzzy output to one numerical command.</p><div class=\"math-display\"><img src=\"math/07c525af02eb813b.svg\" alt=\"\\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}\" style=\"width:46.008ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 1. Specify the inputs and output</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-wash-inputs.c512a5765f.svg\" width=\"780\" height=\"420\" alt=\"Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.</figcaption></figure><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-wash-outputs.bb86080be7.svg\" width=\"780\" height=\"420\" alt=\"Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.</figcaption></figure></div><div class=\"step\"><h5>Step 2. Define all nine IF–THEN rules</h5><table><thead><tr><th>Dirt / Grease</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Very short</td><td>Short</td><td>Medium</td></tr><tr><td>Medium</td><td>Short</td><td>Medium</td><td>High</td></tr><tr><td>High</td><td>Medium</td><td>High</td><td>Very high</td></tr></tbody></table><p>Greater dirt or grease never reduces the rule consequent. This implements the requested monotonic relationship.</p></div><div class=\"step\"><h5>Step 3. Fuzzify the two crisp readings</h5><table><thead><tr><th>Input</th><th>Low membership</th><th>Medium membership</th><th>High membership</th></tr></thead><tbody><tr><td>Dirt=60</td><td>0</td><td>4/5</td><td>1/5</td></tr><tr><td>Grease=70</td><td>0</td><td>3/5</td><td>2/5</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 4. Fire every active rule with minimum</h5><table><thead><tr><th>Dirt</th><th>Grease</th><th>AND strength</th><th>Output descriptor</th></tr></thead><tbody><tr><td>Medium</td><td>Medium</td><td>min(0.8, 0.6) = 0.6</td><td>Medium</td></tr><tr><td>Medium</td><td>High</td><td>min(0.8, 0.4) = 0.4</td><td>High</td></tr><tr><td>High</td><td>Medium</td><td>min(0.2, 0.6) = 0.2</td><td>High</td></tr><tr><td>High</td><td>High</td><td>min(0.2, 0.4) = 0.2</td><td>Very high</td></tr></tbody></table><p>The other rules have a zero antecedent membership and therefore fire at zero.</p></div><div class=\"step\"><h5>Step 5. Aggregate rules and clip each output membership</h5><table><thead><tr><th>Descriptor</th><th>Maximum firing strength</th></tr></thead><tbody><tr><td>Very short</td><td>0.0</td></tr><tr><td>Short</td><td>0.0</td></tr><tr><td>Medium</td><td>0.6</td></tr><tr><td>High</td><td>0.4</td></tr><tr><td>Very high</td><td>0.2</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/fa8dd4982ac39cbc.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{B_r}(z))\" style=\"width:29.354ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-wash-aggregate.b750073d41.svg\" width=\"780\" height=\"420\" alt=\"Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.</figcaption></figure></div><div class=\"step\"><h5>Step 6. Calculate centroid area and first moment</h5><p>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.</p><div class=\"math-display\"><img src=\"math/ed18c6126c4569a0.svg\" alt=\"A=(b-a)\\frac{u+v}{2},\\qquad M=aA+\\frac{(b-a)^2(u+2v)}6,\\qquad z^*=\\frac{\\sum M}{\\sum A}\" style=\"width:67.597ex;height:5.665ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Segment [a, b]</th><th>Heights [u, v]</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>[25, 40]</td><td>[0, 0.6]</td><td>4.500000</td><td>157.500000</td></tr><tr><td>[40, 50]</td><td>[0.6, 0.6]</td><td>6.000000</td><td>270.000000</td></tr><tr><td>[50, 60]</td><td>[0.6, 0.6]</td><td>6.000000</td><td>330.000000</td></tr><tr><td>[60, 65]</td><td>[0.6, 0.4]</td><td>2.500000</td><td>155.833333</td></tr><tr><td>[65, 75]</td><td>[0.4, 0.4]</td><td>4.000000</td><td>280.000000</td></tr><tr><td>[75, 80]</td><td>[0.4, 0.4]</td><td>2.000000</td><td>155.000000</td></tr><tr><td>[80, 90]</td><td>[0.4, 0.4]</td><td>4.000000</td><td>340.000000</td></tr><tr><td>[90, 95]</td><td>[0.4, 0.2]</td><td>1.500000</td><td>138.333333</td></tr><tr><td>[95, 100]</td><td>[0.2, 0.2]</td><td>1.000000</td><td>97.500000</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/8c383994ebbe02fc.svg\" alt=\"z^*=\\frac{1924.166667}{31.500000}\\approx 61.084656\" style=\"width:30.689ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Demonstrate the longer-wash response</h5><p>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.</p><table><thead><tr><th>Dirt</th><th>Grease</th><th>Exact centroid</th><th>Wash-time index</th></tr></thead><tbody><tr><td>20</td><td>70</td><td>1925/41</td><td>46.951220</td></tr><tr><td>60</td><td>70</td><td>11545/189</td><td>61.084656</td></tr><tr><td>80</td><td>70</td><td>6580/99</td><td>66.464646</td></tr></tbody></table><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> With the stated membership functions and rules, the output is 61.084656 on the given 0–100 scale.</div></section>"},{"id":"q3a","title":"Q3(a) Fuzzy relation and max-product comparison [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q3(a)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>D labels 0,1,2; I and V labels 20,30,40.</p><h4>To find</h4><p>The 3×3 relation and the two resulting memberships on D’s universe.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/322f826c4ddc94dd.svg\" alt=\"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)\" style=\"width:60.947ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Create each Cartesian-product row</h5><table><thead><tr><th>D label</th><th>D membership</th><th>Min with.5</th><th>Min with.6</th><th>Min with.8</th></tr></thead><tbody><tr><td>0</td><td>0.3</td><td>0.3</td><td>0.3</td><td>0.3</td></tr><tr><td>1</td><td>0.7</td><td>0.5</td><td>0.6</td><td>0.7</td></tr><tr><td>2</td><td>1</td><td>0.5</td><td>0.6</td><td>0.8</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/a6d0138a2e4b14ec.svg\" alt=\"R=\\begin{bmatrix}0.3&amp;0.3&amp;0.3\\\\0.5&amp;0.6&amp;0.7\\\\0.5&amp;0.6&amp;0.8\\end{bmatrix}\" style=\"width:20.951ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Max–min: pair each row with V</h5><table><thead><tr><th>Output cell</th><th>Compare every matching middle index</th><th>Take the largest result</th></tr></thead><tbody><tr><td>(1, 1)</td><td>min(0.3, 0.6) = 0.3, min(0.3, 0.5) = 0.3, min(0.3, 0.4) = 0.3</td><td>max(0.3, 0.3, 0.3) = 0.3</td></tr><tr><td>(2, 1)</td><td>min(0.5, 0.6) = 0.5, min(0.6, 0.5) = 0.5, min(0.7, 0.4) = 0.4</td><td>max(0.5, 0.5, 0.4) = 0.5</td></tr><tr><td>(3, 1)</td><td>min(0.5, 0.6) = 0.5, min(0.6, 0.5) = 0.5, min(0.8, 0.4) = 0.4</td><td>max(0.5, 0.5, 0.4) = 0.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Max–product: multiply instead of taking the minimum</h5><table><thead><tr><th>Output cell</th><th>Compare every matching middle index</th><th>Take the largest result</th></tr></thead><tbody><tr><td>(1, 1)</td><td>0.3 × 0.6 = 0.18, 0.3 × 0.5 = 0.15, 0.3 × 0.4 = 0.12</td><td>max(0.18, 0.15, 0.12) = 0.18</td></tr><tr><td>(2, 1)</td><td>0.5 × 0.6 = 0.3, 0.6 × 0.5 = 0.3, 0.7 × 0.4 = 0.28</td><td>max(0.3, 0.3, 0.28) = 0.3</td></tr><tr><td>(3, 1)</td><td>0.5 × 0.6 = 0.3, 0.6 × 0.5 = 0.3, 0.8 × 0.4 = 0.32</td><td>max(0.3, 0.3, 0.32) = 0.32</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Attach the original D labels</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> R=[[.3,.3,.3],[.5,.6,.7],[.5,.6,.8]]; max–min=[.3,.5,.5]; max–product=[.18,.30,.32].</div></section>"},{"id":"q3b","title":"Q3(b) PSO maximization, supplied parameters [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q3(b)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>The four x values; zero velocities; w=1, c₁=c₂=1, r₁=r₂=.5; bounded domain[−6,4].</p><h4>To find</h4><p>One iteration and the best value actually reached.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/99893bd63a6f8a01.svg\" alt=\"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}\" style=\"width:67.528ex;height:2.273ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find initial fitness and gbest</h5><table><thead><tr><th>Particle</th><th>Position</th><th>−x²</th><th>5x</th><th>f (x)</th></tr></thead><tbody><tr><td>1</td><td>-5.6</td><td>-31.36</td><td>-28.0</td><td>-39.36</td></tr><tr><td>2</td><td>-5.2</td><td>-27.04</td><td>-26.0</td><td>-33.04</td></tr><tr><td>3</td><td>-1.1</td><td>-1.21</td><td>-5.5</td><td>13.29</td></tr><tr><td>4</td><td>2.3</td><td>-5.29</td><td>11.5</td><td>26.21</td></tr></tbody></table><p>Initial values [−39.36,−33.04,13.29,26.21]. Maximum 26.21 occurs at x=2.3.</p></div><div class=\"step\"><h5>Step 2. Compute new velocities</h5><p>The first two terms are zero: old velocity=0 and pbest−x=0. Thus vnew=.5(2.3−x).</p><table><thead><tr><th>Particle</th><th>Social difference</th><th>Velocity</th><th>New position</th></tr></thead><tbody><tr><td>1</td><td>2.3−(-5.6)=7.9</td><td>.5×(7.9)=3.95</td><td>-5.6 + (3.95)=-1.65</td></tr><tr><td>2</td><td>2.3−(-5.2)=7.5</td><td>.5×(7.5)=3.75</td><td>-5.2 + (3.75)=-1.45</td></tr><tr><td>3</td><td>2.3−(-1.1)=3.4</td><td>.5×(3.4)=1.7</td><td>-1.1 + (1.7)=0.6</td></tr><tr><td>4</td><td>2.3−(2.3)=0</td><td>.5×(0)=0</td><td>2.3 + (0)=2.3</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Evaluate the new positions</h5><table><thead><tr><th>New x</th><th>−x²+5x+20</th><th>New fitness</th></tr></thead><tbody><tr><td>-1.65</td><td>−(-1.65)²+5(-1.65)+20</td><td>9.0275</td></tr><tr><td>-1.4500000000000002</td><td>−(-1.45)²+5(-1.45)+20</td><td>10.6475</td></tr><tr><td>0.5999999999999999</td><td>−(0.6)²+5(0.6)+20</td><td>22.64</td></tr><tr><td>2.3</td><td>−(2.3)²+5(2.3)+20</td><td>26.21</td></tr></tbody></table><p>All new positions are in [−6,4], so no boundary repair is required.</p></div><div class=\"step\"><h5>Step 4. Update pbest and gbest</h5><p>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.</p><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After iteration 1: positions[−1.65,−1.45,.6,2.3], gbest=2.3, achieved fitness 26.21.</div></section>"},{"id":"q4a","title":"Q4(a) Naive Bayes and Laplace smoothing [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q4(a)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>(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.</p><table><thead><tr><th>ID</th><th>Age</th><th>Income</th><th>Freelancer</th><th>Buys computer</th></tr></thead><tbody><tr><td>1</td><td>Young</td><td>High</td><td>No</td><td>No</td></tr><tr><td>2</td><td>Young</td><td>High</td><td>No</td><td>No</td></tr><tr><td>3</td><td>Middle Age</td><td>High</td><td>No</td><td>Yes</td></tr><tr><td>4</td><td>Old</td><td>Medium</td><td>No</td><td>Yes</td></tr><tr><td>5</td><td>Old</td><td>Low</td><td>Yes</td><td>Yes</td></tr><tr><td>6</td><td>Old</td><td>Low</td><td>Yes</td><td>No</td></tr><tr><td>7</td><td>Middle Age</td><td>Low</td><td>Yes</td><td>Yes</td></tr><tr><td>8</td><td>Young</td><td>Medium</td><td>No</td><td>No</td></tr><tr><td>9</td><td>Young</td><td>Low</td><td>Yes</td><td>Yes</td></tr><tr><td>10</td><td>Young</td><td>Medium</td><td>Yes</td><td>Yes</td></tr></tbody></table></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Ten records; query (Old, Medium, Yes). Class counts Yes 6, No 4.</p><h4>To find</h4><p>Class scores, normalized comparison and smoothing impact.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/839a41948edad8ea.svg\" alt=\"s(c)=P(c)\\prod_j P(x_j\\mid c),\\qquad P(c\\mid x)=\\frac{s(c)}{\\sum_{k}s(k)}\" style=\"width:48.318ex;height:6.309ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Count query-feature matches within each class</h5><table><thead><tr><th>Class</th><th>N</th><th>Old</th><th>Medium income</th><th>FreelancerYes</th></tr></thead><tbody><tr><td>Yes</td><td>6</td><td>2</td><td>2</td><td>4</td></tr><tr><td>No</td><td>4</td><td>1</td><td>1</td><td>1</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 2. Compute unsmoothed Yes score</h5><div class=\"math-display\"><img src=\"math/ff3411bced348831.svg\" alt=\"s(Y)=\\frac6{10}\\frac26\\frac26\\frac46=\\frac2{45}\\approx0.0444444\" style=\"width:36.173ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Compute unsmoothed No score</h5><div class=\"math-display\"><img src=\"math/237fd941cadfe143.svg\" alt=\"s(N)=\\frac4{10}\\frac14\\frac14\\frac14=\\frac1{160}=0.00625\" style=\"width:35.325ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Normalize and classify</h5><div class=\"math-display\"><img src=\"math/d8ec61024e51e1a4.svg\" alt=\"P(Y\\mid x)=\\frac{2/45}{2/45+1/160}=\\frac{64}{73}\\approx0.876712\" style=\"width:43.164ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd660d78450f1519.svg\" alt=\"P(N\\mid x)=\\frac9{73}\\approx0.123288\" style=\"width:26.488ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><p>Predict Yes because its score is larger.</p></div><div class=\"step\"><h5>Step 5. Explain add-one smoothing</h5><p>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><div class=\"math-display\"><img src=\"math/08b794e505b1bd84.svg\" alt=\"P(x_j=v\\mid c)=\\frac{N_{jvc}+1}{N_c+K_j}\" style=\"width:24.823ex;height:5.469ex\" loading=\"lazy\" decoding=\"async\"></div><p>There are 3 age categories,3 income categories and 2 freelancer categories. Retaining empirical priors:</p><div class=\"math-display\"><img src=\"math/4ae4ba086320b944.svg\" alt=\"s_{+1}(Y)=\\frac6{10}\\frac{2+1}{6+3}\\frac{2+1}{6+3}\\frac{4+1}{6+2}=\\frac1{24}\\approx0.0416667\" style=\"width:50.097ex;height:4.799ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2e5b140a14fedb05.svg\" alt=\"s_{+1}(N)=\\frac4{10}\\frac{1+1}{4+3}\\frac{1+1}{4+3}\\frac{1+1}{4+2}=\\frac8{735}\\approx0.0108844\" style=\"width:51.511ex;height:4.799ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Compare the smoothed result</h5><div class=\"math-display\"><img src=\"math/1a4ef59913a7687a.svg\" alt=\"P_{+1}(Y\\mid x)=\\frac{1/24}{1/24+8/735}=\\frac{245}{309}\\approx0.792880\" style=\"width:46.281ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><p>The predicted class remains Yes, while certainty decreases. Stating whether priors are smoothed matters; here only feature likelihoods were add-one smoothed.</p></div><div class=\"answer\"><strong>Final answer.</strong> Unsmoothed predictionYes, posterior 64/73. Add-one feature smoothing still predictsYes, posterior 245/309.</div></section>"},{"id":"q4b","title":"Q4(b) Transition matrix properties and two-step probabilities [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q4(b)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>(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₁⁽²⁾.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>P and p⁽⁰⁾ as printed; row-vector convention.</p><h4>To find</h4><p>Two-step conditional transition probabilities, the full two-step matrix and unconditional state 1 probability at time 2.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/aef8325cefd5071a.svg\" alt=\"(P^2)_{ij}=\\sum_kP_{ik}P_{kj},\\qquad p^{(2)}=p^{(0)}P^2\" style=\"width:36.892ex;height:4.899ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Sum every possible two-step path</h5><table><thead><tr><th>Entry</th><th>Via state 1</th><th>Via state 2</th><th>Sum</th></tr></thead><tbody><tr><td>(P²)11</td><td>(1/2)(1/2)=1/4</td><td>(1/2)(3/4)=3/8</td><td>5/8</td></tr><tr><td>(P²)12</td><td>(1/2)(1/2)=1/4</td><td>(1/2)(1/4)=1/8</td><td>3/8</td></tr><tr><td>(P²)21</td><td>(3/4)(1/2)=3/8</td><td>(1/4)(3/4)=3/16</td><td>9/16</td></tr><tr><td>(P²)22</td><td>(3/4)(1/2)=3/8</td><td>(1/4)(1/4)=1/16</td><td>7/16</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Write the transition matrix and requested entries</h5><div class=\"math-display\"><img src=\"math/063d8bbaa02b11f7.svg\" alt=\"P^2=\\begin{bmatrix}5/8&amp;3/8\\\\9/16&amp;7/16\\end{bmatrix}\" style=\"width:19.531ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><p>Therefore (a) P₂₁⁽²⁾=9/16 and (b) P₁₂⁽²⁾=3/8. Each entry conditions on a specific starting state.</p></div><div class=\"step\"><h5>Step 3. Mix over the supplied initial distribution</h5><div class=\"math-display\"><img src=\"math/223d07fbdc1aa402.svg\" alt=\"p_1^{(2)}=\\frac14\\frac58+\\frac34\\frac9{16}=\\frac{10+27}{64}=\\frac{37}{64}=0.578125\" style=\"width:47.934ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c5238d8cc5680149.svg\" alt=\"p_2^{(2)}=1-37/64=27/64=0.421875\" style=\"width:36.178ex;height:3.072ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Keep matrix and distribution notation separate</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> P₂₁⁽²⁾=9/16; P₁₂⁽²⁾=3/8; P²=[[5/8,3/8],[9/16,7/16]]; p⁽²⁾=[37/64,27/64].</div></section>"},{"id":"q5a","title":"Q5(a) GA selection, crossover and survivor replacement [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q5(a)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>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.</p><table><thead><tr><th>No.</th><th>Chromosome</th><th>Fitness</th><th>Age</th></tr></thead><tbody><tr><td>1</td><td>01000000</td><td>64</td><td>8</td></tr><tr><td>2</td><td>01011111</td><td>95</td><td>2</td></tr><tr><td>3</td><td>01010000</td><td>80</td><td>13</td></tr><tr><td>4</td><td>01011001</td><td>89</td><td>9</td></tr><tr><td>5</td><td>01011110</td><td>94</td><td>4</td></tr><tr><td>6</td><td>01001111</td><td>79</td><td>10</td></tr><tr><td>7</td><td>01010001</td><td>81</td><td>12</td></tr><tr><td>8</td><td>01000001</td><td>65</td><td>15</td></tr><tr><td>9</td><td>01011000</td><td>88</td><td>10</td></tr><tr><td>10</td><td>01000000</td><td>64</td><td>20</td></tr></tbody></table></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Ten 8-bit chromosomes with supplied fitness and ages; larger fitness is better.</p><h4>To find</h4><p>Four offspring and two independent survivor-selection outcomes.</p></div><h4>Formula and why it applies</h4><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Rank and choose the top two</h5><table><thead><tr><th>Fitness rank</th><th>Individual</th><th>Fitness</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>95</td></tr><tr><td>2</td><td>5</td><td>94</td></tr><tr><td>3</td><td>4</td><td>89</td></tr><tr><td>4</td><td>9</td><td>88</td></tr><tr><td>5</td><td>7</td><td>81</td></tr><tr><td>6</td><td>3</td><td>80</td></tr><tr><td>7</td><td>6</td><td>79</td></tr><tr><td>8</td><td>8</td><td>65</td></tr><tr><td>9</td><td>1</td><td>64</td></tr><tr><td>10</td><td>10</td><td>64</td></tr></tbody></table><p>Select 2(95) and 5(94). Split 0101|1111 and 0101|1110. Swapping suffixes gives 01011110(94) and 01011111(95).</p></div><div class=\"step\"><h5>Step 2. Conduct the specified tournaments</h5><p>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.</p><p>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.</p></div><div class=\"step\"><h5>Step 3. Fitness-based survivor replacement</h5><p>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.</p><div class=\"math-display\"><img src=\"math/73527afb9489efc7.svg\" alt=\"\\text{retained sum}=95+80+89+94+81+88=527\" style=\"width:49.483ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/df9902dbae821985.svg\" alt=\"\\bar f_{fitness}=\\frac{527+378}{10}=90.5\" style=\"width:27.117ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Age-based replacement, reset to the original table first</h5><p>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.</p><div class=\"math-display\"><img src=\"math/b892f89037dda209.svg\" alt=\"\\text{retained sum}=64+95+89+94+79+88=509\" style=\"width:49.483ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5fdd0bc72d39766b.svg\" alt=\"\\bar f_{age}=\\frac{509+378}{10}=88.7\" style=\"width:24.257ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Explain the difference</h5><div class=\"math-display\"><img src=\"math/66d0b787f8c6800c.svg\" alt=\"\\bar f_{original}=799/10=79.9\" style=\"width:23.788ex;height:2.83ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> Children have fitness 94,95,95,94. New mean 90.5 under fitness replacement and 88.7 under age replacement.</div></section>"},{"id":"q5b","title":"Q5(b) Mean of maxima and centroid of trapezoids [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q5(b)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>For the given membership functions determine the crisp output using (1) Mean of Maxima and (2) Centroid / Center of Area.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24r-defuzz-a.4cd4ea6810.svg\" width=\"780\" height=\"420\" alt=\"First printed membership function: height 0.75, corners x=0,2,3,4.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>First printed membership function: height 0.75, corners x=0,2,3,4.</figcaption></figure><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24r-defuzz-b.b1f504dbf4.svg\" width=\"780\" height=\"420\" alt=\"Second printed membership function: height 1, corners x=0,3,4,7.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Second printed membership function: height 1, corners x=0,3,4,7.</figcaption></figure></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>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).</p><h4>To find</h4><p>MOM and centroid for each graph.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/083457b6b2635a4c.svg\" alt=\"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}\" style=\"width:50.064ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. MOM of the first graph</h5><p>Maximum height.75 occurs throughout[2,3].</p><div class=\"math-display\"><img src=\"math/54f0d91e056c6e0b.svg\" alt=\"z_{MOM,1}=(2+3)/2=2.5\" style=\"width:25.044ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Centroid of the first graph</h5><table><thead><tr><th>Piece</th><th>Area</th><th>x centroid</th><th>Moment</th></tr></thead><tbody><tr><td>Triangle 0–2</td><td>½×2×.75=.75</td><td>(0+2+2)/3=4/3</td><td>1</td></tr><tr><td>Rectangle 2–3</td><td>1×.75=.75</td><td>2.5</td><td>1.875</td></tr><tr><td>Triangle 3–4</td><td>½×1×.75=.375</td><td>(3+3+4)/3=10/3</td><td>1.25</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/e3b301b5ea6a74cd.svg\" alt=\"z_{COA,1}=\\frac{1+1.875+1.25}{.75+.75+.375}=\\frac{4.125}{1.875}=2.2\" style=\"width:41.047ex;height:4.799ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. MOM of the second graph</h5><div class=\"math-display\"><img src=\"math/4ea913e911135351.svg\" alt=\"z_{MOM,2}=(3+4)/2=3.5\" style=\"width:25.044ex;height:2.347ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Centroid of the second graph</h5><table><thead><tr><th>Piece</th><th>Area</th><th>x centroid</th><th>Moment</th></tr></thead><tbody><tr><td>Triangle 0–3</td><td>1.5</td><td>2</td><td>3</td></tr><tr><td>Rectangle 3–4</td><td>1</td><td>3.5</td><td>3.5</td></tr><tr><td>Triangle 4–7</td><td>1.5</td><td>5</td><td>7.5</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/656c9873a2d32c03.svg\" alt=\"z_{COA,2}=\\frac{3+3.5+7.5}{1.5+1+1.5}=\\frac{14}{4}=3.5\" style=\"width:34.762ex;height:4.799ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"answer\"><strong>Final answer.</strong> Graph 1:MOM 2.5, centroid 2.2. Graph 2:MOM 3.5, centroid 3.5.</div></section>"},{"id":"q6a","title":"Q6(a) Genetic algorithm for four-city TSP [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q6(a)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>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.</p></div><h3>Answer</h3><p><strong>Representation.</strong> 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.</p><div class=\"step\"><h5>Step 1. Initialize distinct valid tours</h5><p>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.</p></div><div class=\"step\"><h5>Step 2. Evaluate route length and fitness</h5><div class=\"math-display\"><img src=\"math/5d153218d012483f.svg\" alt=\"L=d_{AB}+d_{BC}+d_{CD}+d_{DA},\\qquad fitness=1/L\\quad(L&gt;0)\" style=\"width:57.659ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 3. Use permutation-preserving crossover</h5><p>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.</p></div><div class=\"step\"><h5>Step 4. Mutate without losing cities</h5><p>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.</p></div><div class=\"step\"><h5>Step 5. Select, replace and stop</h5><p>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.</p></div></section>"},{"id":"q6b","title":"Q6(b) Markov process and homework transition paths [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q6(b)</strong> <span class=\"marks\">[10 marks · 2024-06-25]</span><p>(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).</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24r-homework.4001dfd62e.svg\" width=\"760\" height=\"430\" alt=\"Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.</figcaption></figure></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>The labeled arrows in the original diagram; state orderF, H, N.</p><h4>To find</h4><p>The transition matrix and one-step/two-step probabilities.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/23d2321daf991110.svg\" alt=\"P(X_{t+n}=j\\mid X_t=i)=(P^n)_{ij}\" style=\"width:29.722ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Read all outgoing arrows into rows</h5><div class=\"math-display\"><img src=\"math/17d3fd5cb7fb6fac.svg\" alt=\"P=\\begin{bmatrix}0.3&amp;0.25&amp;0.45\\\\0.45&amp;0.4&amp;0.15\\\\0.65&amp;0.25&amp;0.1\\end{bmatrix}\" style=\"width:24.327ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Row</th><th>Sum</th></tr></thead><tbody><tr><td>F</td><td>.30+.25+.45=1</td></tr><tr><td>H</td><td>.45+.40+.15=1</td></tr><tr><td>N</td><td>.65+.25+.10=1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Part (b): one transition N→F</h5><div class=\"math-display\"><img src=\"math/b86a579af37c69bb.svg\" alt=\"P(X_3=F\\mid X_2=N)=P_{NF}=0.65\" style=\"width:35.121ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Part (c): one transition H→N</h5><div class=\"math-display\"><img src=\"math/061a644323cfaa64.svg\" alt=\"P(X_2=N\\mid X_1=H)=P_{HN}=0.15\" style=\"width:35.658ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Part (d): two transitions F→?→H</h5><p>The time difference is 4−2=2. Sum three mutually exclusive intermediate-state routes.</p><table><thead><tr><th>Intermediate state</th><th>Path product</th></tr></thead><tbody><tr><td>F</td><td>.30×.25=.075</td></tr><tr><td>H</td><td>.25×.40=.100</td></tr><tr><td>N</td><td>.45×.25=.1125</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/ff6357103803b6cd.svg\" alt=\"(P^2)_{FH}=.075+.100+.1125=.2875\" style=\"width:37.298ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> (b).65; (c).15; (d).2875; TPM shown above.</div></section>"},{"id":"q7a","title":"Q7(a) Expectation Maximization algorithm [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(a)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>Discuss the Expectation Maximization (EM) algorithm.</p></div><h3>Answer</h3><p>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><div class=\"math-display\"><img src=\"math/34e74a21f3e93c71.svg\" alt=\"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\" style=\"width:53.891ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"step\"><h5>Step 1. Form the observed-data log likelihood</h5><p>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.</p><div class=\"math-display\"><img src=\"math/68bab3da61241a5e.svg\" alt=\"\\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]\" style=\"width:65.678ex;height:6.785ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. E-step: estimate component membership</h5><p>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.</p><div class=\"math-display\"><img src=\"math/3463c7734eab2353.svg\" alt=\"\\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)}\" style=\"width:26.1ex;height:6.058ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Use the expected complete-data log likelihood</h5><p>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.</p><div class=\"math-display\"><img src=\"math/da8bce8c31e000fa.svg\" alt=\"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]\" style=\"width:50.07ex;height:4.899ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. M-step: weighted estimates</h5><div class=\"math-display\"><img src=\"math/c63266009fda4bdb.svg\" alt=\"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}\" style=\"width:46.66ex;height:6.098ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/433755f43e0968ba.svg\" alt=\"\\Sigma_k^{new}=\\frac{\\sum_i\\gamma_{ik}(x_i-\\mu_k^{new})(x_i-\\mu_k^{new})^T}{N_k}\" style=\"width:38.175ex;height:5.585ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><p><strong>Small responsibility example.</strong> 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.</p></section>"},{"id":"q7b","title":"Q7(b) Lambda-cut of a fuzzy relation [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(b)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>For the fuzzy relation R below, find the λ-cut relations for λ=.003 and λ=.5.</p><div class=\"math-display\"><img src=\"math/fe401cd453e2d902.svg\" alt=\"R=\\begin{bmatrix}1&amp;0.1&amp;0&amp;0.4\\\\0.001&amp;0.5&amp;0.5&amp;0.6\\\\0.3&amp;1&amp;0.5&amp;0\\\\0&amp;0.4&amp;0.002&amp;0.1\\end{bmatrix}\" style=\"width:30.63ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>A4×4 fuzzy relation with entries between 0 and 1.</p><h4>To find</h4><p>Two crisp 0/1 relations retaining entries at or above the threshold.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/fcd0258f1fdf1909.svg\" alt=\"(R_\\lambda)_{ij}=\\begin{cases}1&amp;R_{ij}\\geq\\lambda\\\\0&amp;R_{ij}&lt;\\lambda\\end{cases}\" style=\"width:21.556ex;height:5.428ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Threshold at.003</h5><p>Zero,.001 and.002 are below.003 and become 0. All other positive entries are at least.1, so become 1.</p><div class=\"math-display\"><img src=\"math/69c4d4d1862cfea7.svg\" alt=\"R_{.003}=\\begin{bmatrix}1&amp;1&amp;0&amp;1\\\\0&amp;1&amp;1&amp;1\\\\1&amp;1&amp;1&amp;0\\\\0&amp;1&amp;0&amp;1\\end{bmatrix}\" style=\"width:22.097ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Threshold at.5, including equality</h5><p>Entries equal to.5 are retained. Values 1,.5,.6 become 1; values.4,.3,.1,.002,.001,0 become 0.</p><div class=\"math-display\"><img src=\"math/3083e2884959ed29.svg\" alt=\"R_{.5}=\\begin{bmatrix}1&amp;0&amp;0&amp;0\\\\0&amp;1&amp;1&amp;1\\\\0&amp;1&amp;1&amp;0\\\\0&amp;0&amp;0&amp;0\\end{bmatrix}\" style=\"width:20.497ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Verify one included and one excluded entry</h5><p>R₂₃=.5≥.5, so output(2,3)=1. R₄₃=.002&lt;.003, so output(4,3)=0. The row/column labels and 4×4 shape do not change.</p></div><div class=\"answer\"><strong>Final answer.</strong> The two crisp matrices above are the weak λ-cuts.</div></section>"},{"id":"q7c","title":"Q7(c) ACO path length and pheromone update [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(c)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>For the four-city travelling salesman problem, row and column order is A, B, C, D. The pheromone and cost matrices are:</p><div class=\"math-display\"><img src=\"math/772dd747e10284ad.svg\" alt=\"\\tau=\\begin{bmatrix}0&amp;15&amp;5&amp;4\\\\15&amp;0&amp;4&amp;8\\\\5&amp;4&amp;0&amp;1\\\\4&amp;8&amp;1&amp;0\\end{bmatrix}\" style=\"width:20.78ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bddf9ec4c2c0baa6.svg\" alt=\"D=\\begin{bmatrix}0&amp;10&amp;4&amp;3\\\\10&amp;0&amp;1&amp;2\\\\4&amp;1&amp;0&amp;1\\\\3&amp;2&amp;1&amp;0\\end{bmatrix}\" style=\"width:21.483ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Two tours: A–B–C–D–A and A–C–B–D–A; evaporation ρ=0.5; printed matrices above.</p><h4>To find</h4><p>Both tour lengths and updated pheromone on every edge.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/0e8184d1b87733c1.svg\" alt=\"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\" style=\"width:66.203ex;height:5.371ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 1. Calculate tour 1 length</h5><div class=\"math-display\"><img src=\"math/ac9a78a66f280841.svg\" alt=\"L_1=d_{AB}+d_{BC}+d_{CD}+d_{DA}=10+1+1+3=15\" style=\"width:51.459ex;height:1.945ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Calculate tour 2 length</h5><div class=\"math-display\"><img src=\"math/cd7de0bca5f15da5.svg\" alt=\"L_2=d_{AC}+d_{CB}+d_{BD}+d_{DA}=4+1+2+3=10\" style=\"width:50.327ex;height:1.951ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate deposit per used edge</h5><div class=\"math-display\"><img src=\"math/31ae3d58c7494e4d.svg\" alt=\"\\Delta\\tau_1=1/15\\approx0.0666667,\\qquad\\Delta\\tau_2=1/10=0.1\" style=\"width:46.941ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"step\"><h5>Step 4. Update each distinct undirected edge</h5><table><thead><tr><th>Edge</th><th>Old pheromone</th><th>After evaporation</th><th>Deposit from tour 1</th><th>Deposit from tour 2</th><th>New pheromone</th></tr></thead><tbody><tr><td>AB</td><td>15</td><td>7.5</td><td>1/15</td><td>0</td><td>7.566667</td></tr><tr><td>AC</td><td>5</td><td>2.5</td><td>0</td><td>1/10</td><td>2.600000</td></tr><tr><td>AD</td><td>4</td><td>2</td><td>1/15</td><td>1/10</td><td>2.166667</td></tr><tr><td>BC</td><td>4</td><td>2</td><td>1/15</td><td>1/10</td><td>2.166667</td></tr><tr><td>BD</td><td>8</td><td>4</td><td>0</td><td>1/10</td><td>4.100000</td></tr><tr><td>CD</td><td>1</td><td>0.5</td><td>1/15</td><td>0</td><td>0.566667</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Assemble the symmetric matrix</h5><div class=\"math-display\"><img src=\"math/4905d8df69aaed31.svg\" alt=\"\\begin{bmatrix}0&amp;7.566667&amp;2.6&amp;2.166667\\\\7.566667&amp;0&amp;2.166667&amp;4.1\\\\2.6&amp;2.166667&amp;0&amp;0.566667\\\\2.166667&amp;4.1&amp;0.566667&amp;0\\end{bmatrix}\" style=\"width:43.995ex;height:11.765ex\" loading=\"lazy\" decoding=\"async\"></div><p>The diagonal remains zero because an ant does not travel from a city to itself.</p></div><div class=\"answer\"><strong>Final answer.</strong> Tour lengths are 15 and 10. The table and matrix give all updated edge pheromones under Q=1.</div></section>"},{"id":"q7d","title":"Q7(d) Bellman equation [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(d)</strong> <span class=\"marks\">[5 marks · 2024-06-25]</span><p>Explain the Bellman equation in reinforcement learning.</p></div><h3>Answer</h3><p>The <strong>Bellman equation</strong> 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.</p><div class=\"math-display\"><img src=\"math/e076ba9a7dcf48af.svg\" alt=\"G_t=R_{t+1}+\\gamma G_{t+1}\" style=\"width:18.67ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c42f67b85b9dd072.svg\" alt=\"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]\" style=\"width:55.44ex;height:4.767ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>s, a, s′</td><td>Current state, chosen action, next state</td></tr><tr><td>π(a|s)</td><td>Policy probability of choosing actiona</td></tr><tr><td>P(s′|s, a)</td><td>Environment transition probability</td></tr><tr><td>R(s, a, s′)</td><td>Expected immediate reward for that transition</td></tr><tr><td>γ</td><td>Discount factor, usually 0≤γ&lt;1 for continuing tasks</td></tr><tr><td>Vπ(s)</td><td>Expected discounted return following policyπ</td></tr></tbody></table><p>For a fixed policy, average over its action probabilities. For the optimal value, replace the policy-weighted average by the best action:</p><div class=\"math-display\"><img src=\"math/0d0ba7664438689d.svg\" alt=\"V^*(s)=\\max_a\\sum_{s\\prime}P(s\\prime\\mid s,a)\\left[R(s,a,s\\prime)+\\gamma V^*(s\\prime)\\right]\" style=\"width:48.589ex;height:4.767ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Numerical illustration.</strong> 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.</p></section>"}]},{"id":"paper-2024-final","title":"Final examination · 17 Apr 2024","unit":"paper","scope":"Actual historical paper ·100 marks attempted /140 offered · Q1 compulsory + any four of Q2–Q7. Source defects and solution assumptions are explicitly identified.","sections":[{"id":"q1a","title":"Q1(a) Conditional probability from fruit counts [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(a)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>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).</p><table><thead><tr><th>Fruit</th><th>Yellow</th><th>Sweet</th><th>Long</th><th>Total</th></tr></thead><tbody><tr><td>Mango</td><td>350</td><td>450</td><td>0</td><td>650</td></tr><tr><td>Banana</td><td>400</td><td>300</td><td>350</td><td>400</td></tr><tr><td>Others</td><td>50</td><td>100</td><td>50</td><td>150</td></tr><tr><td>Total</td><td>800</td><td>850</td><td>400</td><td>1200</td></tr></tbody></table></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>650 mangoes, of which 350 are yellow; 400 bananas, of which 300 are sweet.</p><h4>To find</h4><p>The two probabilities in the printed order.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/f893878b79f9bfdd.svg\" alt=\"P(A\\mid B)=\\frac{P(A\\cap B)}{P(B)}=\\frac{\\text{count satisfying A and B}}{\\text{count satisfying B}}\" style=\"width:50.24ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Restrict to mangoes</h5><div class=\"math-display\"><img src=\"math/730d82f2aaccc80b.svg\" alt=\"P(Yellow\\mid Mango)=\\frac{350}{650}=\\frac7{13}\\approx0.538462\" style=\"width:44.546ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Restrict to bananas</h5><div class=\"math-display\"><img src=\"math/c65d5aa64de25ddd.svg\" alt=\"P(Sweet\\mid Banana)=\\frac{300}{400}=\\frac34=0.75\" style=\"width:38.962ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Check the direction of the condition</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> P(Yellow | Mango)=7/13 ≈ 0.538462; P(Sweet | Banana)=0.75.</div></section>"},{"id":"q1b","title":"Q1(b) Membership function and age sketch [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(b)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>Define a membership function in the context of fuzzy logic. Using your intuition, sketch fuzzy membership functions for the “age of people”.</p></div><h3>Answer</h3><p>A <strong>membership function</strong> assigns each element x of a universe X a degree μA(x) between 0 and 1, indicating compatibility with a linguistic concept A.</p><div class=\"math-display\"><img src=\"math/ba33a453b276adb3.svg\" alt=\"\\mu_A:X\\rightarrow[0,1]\" style=\"width:14.611ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-age.140e92bbb3.svg\" width=\"780\" height=\"420\" alt=\"Illustrative age memberships, not universal demographic boundaries. An age can belong partly to two terms.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Illustrative age memberships, not universal demographic boundaries. An age can belong partly to two terms.</figcaption></figure><table><thead><tr><th>Term</th><th>One explicit assumed shape</th></tr></thead><tbody><tr><td>Young</td><td>1 until age 20; then decreases linearly to 0 at age 40.</td></tr><tr><td>Middle-aged</td><td>0 up to 25; rises to 1 at 45; falls to 0 at 65.</td></tr><tr><td>Old</td><td>0 up to 50; rises to 1 at 70; then remains 1.</td></tr></tbody></table><p>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.</p><p><strong>Remember:</strong> membership = “kitna fit hota hai is label mein”. State the axis labels and the assumed age breakpoints when sketching.</p></section>"},{"id":"q1c","title":"Q1(c) Mutation operators [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(c)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>Cite and illustrate various mutation operators in the genetic algorithm.</p></div><h3>Answer</h3><p><strong>Mutation</strong> 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.</p><table><thead><tr><th>Operator</th><th>Before → after</th><th>Suitable representation</th></tr></thead><tbody><tr><td>Bit flip</td><td>10110 → 10010 (third bit 1→0)</td><td>Binary chromosome</td></tr><tr><td>Random resetting</td><td>[2,7,4] → [2,3,4] (replace gene 2 by a valid value)</td><td>Integer/discrete</td></tr><tr><td>Swap</td><td>A B C D E → A D C B E (swap positions 2 and 4)</td><td>Permutation / TSP</td></tr><tr><td>Inversion</td><td>A | B C D | E → A | D C B | E</td><td>Permutation / TSP</td></tr><tr><td>Insertion</td><td>A B C D E → A D B C E (remove D and insert after A)</td><td>Permutation / TSP</td></tr><tr><td>Gaussian perturbation</td><td>[1.2,2.0] → [1.2,2.0+0.1]=[1.2,2.1]</td><td>Real-valued; respect bounds</td></tr></tbody></table><p>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.</p></section>"},{"id":"q1d","title":"Q1(d) Markov chain diagram and path probability [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q1(d)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>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><div class=\"math-display\"><img src=\"math/1f388f49cad4444e.svg\" alt=\"P=\\begin{bmatrix}1/2&amp;1/4&amp;1/4\\\\1/3&amp;0&amp;2/3\\\\1/2&amp;1/2&amp;0\\end{bmatrix}\" style=\"width:22.44ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>The printed matrix; ambiguous condition reproduced above.</p><h4>To find</h4><p>All nonzero transitions and the joint probability of the path 3→2→1.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/250a6ac8bef84a28.svg\" alt=\"P(X_1=3,X_2=2,X_3=1)=P(X_1=3)P_{32}P_{21}\" style=\"width:46.465ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Draw the matrix as arrows</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-three-state.d3ab43c06c.svg\" width=\"760\" height=\"430\" alt=\"Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.</figcaption></figure><table><thead><tr><th>From</th><th>Outgoing destinations</th></tr></thead><tbody><tr><td>1</td><td>1 with 1/2; 2 with 1/4; 3 with 1/4</td></tr><tr><td>2</td><td>1 with 1/3; 3 with 2/3</td></tr><tr><td>3</td><td>1 with 1/2; 2 with 1/2</td></tr></tbody></table></div><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 2. Solve the literal reading</h5><p>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.</p><div class=\"math-display\"><img src=\"math/052bbb970339e754.svg\" alt=\"\\frac14=p_1P_{12}+p_2P_{22}+p_3P_{32}=\\frac14\\frac14+0+\\frac12p_3\" style=\"width:44.958ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4c1768a409855602.svg\" alt=\"\\frac12p_3=\\frac14-\\frac1{16}=\\frac3{16}\\quad\\Rightarrow\\quad p_3=\\frac38\" style=\"width:37.009ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c24f3d84f730db29.svg\" alt=\"P(3,2,1)=\\frac38\\cdot\\frac12\\cdot\\frac13=\\frac1{16}=0.0625\" style=\"width:37.108ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Show the alternative if the second subscript was a typo</h5><p>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><div class=\"math-display\"><img src=\"math/6a536bdcde0eb5da.svg\" alt=\"P(3,2,1)=\\frac12\\cdot\\frac12\\cdot\\frac13=\\frac1{12}\\approx0.0833333\" style=\"width:40.502ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Literal time-2 condition gives 1/16. Corrected initial-state condition gives 1/12; the source wording must be clarified.</div></section>"},{"id":"q2a","title":"Q2(a) Bayesian network joint probabilities [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q2(a)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-exam-bn.9070a35002.svg\" width=\"760\" height=\"430\" alt=\"Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.</figcaption></figure><table><thead><tr><th>Root</th><th>P(0)</th><th>P(1)</th></tr></thead><tbody><tr><td>E</td><td>0.7</td><td>0.3</td></tr><tr><td>I</td><td>0.8</td><td>0.2</td></tr></tbody></table><table><thead><tr><th>I</th><th>E</th><th>P(M=0)</th><th>P(M=1)</th></tr></thead><tbody><tr><td>0</td><td>0</td><td>0.6</td><td>0.4</td></tr><tr><td>0</td><td>1</td><td>0.9</td><td>0.1</td></tr><tr><td>1</td><td>0</td><td>0.5</td><td>0.5</td></tr><tr><td>1</td><td>1</td><td>0.8</td><td>0.2</td></tr></tbody></table><table><thead><tr><th>I</th><th>P(S=0)</th><th>P(S=1)</th></tr></thead><tbody><tr><td>0</td><td>0.75</td><td>0.25</td></tr><tr><td>1</td><td>0.4</td><td>0.6</td></tr></tbody></table><table><thead><tr><th>M</th><th>P(A=0)</th><th>P(A=1)</th></tr></thead><tbody><tr><td>0</td><td>0.6</td><td>0.4</td></tr><tr><td>1</td><td>0.9</td><td>0.1</td></tr></tbody></table></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>All five variables and their CPTs are reproduced above.</p><h4>To find</h4><p>The two complete joint-event probabilities.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/2567b59d7d2c83ad.svg\" alt=\"P(E,I,M,S,A)=P(E)P(I)P(M\\mid E,I)P(S\\mid I)P(A\\mid M)\" style=\"width:57.653ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 1. Write event (a) in symbols</h5><div class=\"math-display\"><img src=\"math/8adff69e2c0b00ef.svg\" alt=\"(E,I,M,S,A)=(1,0,1,0,1)\" style=\"width:28.645ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Select one CPT entry for each node</h5><table><thead><tr><th>Factor</th><th>Why this entry</th><th>Value</th></tr></thead><tbody><tr><td>P(E=1)</td><td>Difficult</td><td>0.3</td></tr><tr><td>P(I=0)</td><td>Low IQ</td><td>0.8</td></tr><tr><td>P(M=1|E=1, I=0)</td><td>Pass, difficult, low IQ</td><td>0.1</td></tr><tr><td>P(S=0|I=0)</td><td>Low aptitude given low IQ</td><td>0.75</td></tr><tr><td>P(A=1|M=1)</td><td>Admission given pass</td><td>0.1</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Multiply without dropping root probabilities</h5><div class=\"math-display\"><img src=\"math/79f6ccced168cd06.svg\" alt=\"0.3\\times0.8=0.24\\quad;\\quad0.24\\times0.1=0.024\" style=\"width:38.97ex;height:1.971ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e0cfdfc6521b1e91.svg\" alt=\"0.024\\times0.75=0.018\\quad;\\quad0.018\\times0.1=0.0018\" style=\"width:45.757ex;height:1.971ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Write and solve event (b)</h5><div class=\"math-display\"><img src=\"math/fa60b6f67d870af3.svg\" alt=\"(E,I,M,S,A)=(0,1,0,1,0)\" style=\"width:28.645ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e1a6504a28d510dd.svg\" alt=\"0.7\\times0.2\\times0.5\\times0.6\\times0.6=0.0252\" style=\"width:34.822ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> Under the declared coding and joint-event reading: (a) 0.0018, (b) 0.0252.</div></section>"},{"id":"q2b","title":"Q2(b) Fuzzy Cartesian product and composition [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q2(b)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>A, B, C memberships as printed. Rows of R/S: low, medium, high; columns: positive, zero, negative.</p><h4>To find</h4><p>Both Cartesian-product matrices and a carefully stated interpretation of the requested composition.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/7ef66022cb4ba451.svg\" alt=\"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})\" style=\"width:64.69ex;height:3.454ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Build R one row at a time</h5><table><thead><tr><th>A row</th><th>Min with 0.9</th><th>Min with 0.3</th><th>Min with 0.8</th></tr></thead><tbody><tr><td>1</td><td>min(1,0.9)=0.9</td><td>min(1,0.3)=0.3</td><td>min(1,0.8)=0.8</td></tr><tr><td>0.2</td><td>min(0.2,0.9)=0.2</td><td>min(0.2,0.3)=0.2</td><td>min(0.2,0.8)=0.2</td></tr><tr><td>0.6</td><td>min(0.6,0.9)=0.6</td><td>min(0.6,0.3)=0.3</td><td>min(0.6,0.8)=0.6</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/ca9c5503d687e49c.svg\" alt=\"R=\\begin{bmatrix}0.9&amp;0.3&amp;0.8\\\\0.2&amp;0.2&amp;0.2\\\\0.6&amp;0.3&amp;0.6\\end{bmatrix}\" style=\"width:20.951ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Build S the same way</h5><table><thead><tr><th>C row</th><th>Min with 0.9</th><th>Min with 0.3</th><th>Min with 0.8</th></tr></thead><tbody><tr><td>0.3</td><td>min(0.3,0.9)=0.3</td><td>min(0.3,0.3)=0.3</td><td>min(0.3,0.8)=0.3</td></tr><tr><td>0.4</td><td>min(0.4,0.9)=0.4</td><td>min(0.4,0.3)=0.3</td><td>min(0.4,0.8)=0.4</td></tr><tr><td>0.6</td><td>min(0.6,0.9)=0.6</td><td>min(0.6,0.3)=0.3</td><td>min(0.6,0.8)=0.6</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/2c582f7ae6099f7e.svg\" alt=\"S=\\begin{bmatrix}0.3&amp;0.3&amp;0.3\\\\0.4&amp;0.3&amp;0.4\\\\0.6&amp;0.3&amp;0.6\\end{bmatrix}\" style=\"width:20.694ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><aside class=\"note\"><strong>Source / assumption note.</strong> 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ᵀ.</aside><div class=\"step\"><h5>Step 3. State the R-then-S index convention and calculate all nine cells</h5><p>Here S∘R means apply R first, then S, so use row R and column S.</p><table><thead><tr><th>Output cell</th><th>Compare every matching middle index</th><th>Take the largest result</th></tr></thead><tbody><tr><td>(1, 1)</td><td>min(0.9, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.8, 0.6) = 0.6</td><td>max(0.3, 0.3, 0.6) = 0.6</td></tr><tr><td>(1, 2)</td><td>min(0.9, 0.3) = 0.3, min(0.3, 0.3) = 0.3, min(0.8, 0.3) = 0.3</td><td>max(0.3, 0.3, 0.3) = 0.3</td></tr><tr><td>(1, 3)</td><td>min(0.9, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.8, 0.6) = 0.6</td><td>max(0.3, 0.3, 0.6) = 0.6</td></tr><tr><td>(2, 1)</td><td>min(0.2, 0.3) = 0.2, min(0.2, 0.4) = 0.2, min(0.2, 0.6) = 0.2</td><td>max(0.2, 0.2, 0.2) = 0.2</td></tr><tr><td>(2, 2)</td><td>min(0.2, 0.3) = 0.2, min(0.2, 0.3) = 0.2, min(0.2, 0.3) = 0.2</td><td>max(0.2, 0.2, 0.2) = 0.2</td></tr><tr><td>(2, 3)</td><td>min(0.2, 0.3) = 0.2, min(0.2, 0.4) = 0.2, min(0.2, 0.6) = 0.2</td><td>max(0.2, 0.2, 0.2) = 0.2</td></tr><tr><td>(3, 1)</td><td>min(0.6, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.6, 0.6) = 0.6</td><td>max(0.3, 0.3, 0.6) = 0.6</td></tr><tr><td>(3, 2)</td><td>min(0.6, 0.3) = 0.3, min(0.3, 0.3) = 0.3, min(0.6, 0.3) = 0.3</td><td>max(0.3, 0.3, 0.3) = 0.3</td></tr><tr><td>(3, 3)</td><td>min(0.6, 0.3) = 0.3, min(0.3, 0.4) = 0.3, min(0.6, 0.6) = 0.6</td><td>max(0.3, 0.3, 0.6) = 0.6</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/4a88f859d09d91ef.svg\" alt=\"T=\\begin{bmatrix}0.6&amp;0.3&amp;0.6\\\\0.2&amp;0.2&amp;0.2\\\\0.6&amp;0.3&amp;0.6\\end{bmatrix}\" style=\"width:20.827ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Distinguish the other common notation convention</h5><p>If your course writes S∘R as the matrix product with S on the left, the index result is instead:</p><div class=\"math-display\"><img src=\"math/035832180398151c.svg\" alt=\"\\begin{bmatrix}0.3&amp;0.3&amp;0.3\\\\0.4&amp;0.3&amp;0.4\\\\0.6&amp;0.3&amp;0.6\\end{bmatrix}\" style=\"width:16.217ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><p>For a correctly typed relation between the input universes, compose R with the inverse relation Sᵀ; the row/column labels then match:</p><div class=\"math-display\"><img src=\"math/c371ee91de2bed68.svg\" alt=\"R\\circ S^T=\\begin{bmatrix}0.3&amp;0.4&amp;0.6\\\\0.2&amp;0.2&amp;0.2\\\\0.3&amp;0.4&amp;0.6\\end{bmatrix}\" style=\"width:25.978ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"q3a","title":"Q3(a) GMM versus K-means [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q3(a)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>Discuss the significance of using Gaussian Mixture Models (GMMs) over K-means clustering in capturing complex data distributions.</p></div><h3>Answer</h3><p><strong>GMM</strong> models the density as a weighted sum of Gaussian components. <strong>K-means</strong> minimizes within-cluster squared Euclidean distance and assigns each point to one nearest centroid.</p><div class=\"math-display\"><img src=\"math/3599d1d0f37ccb77.svg\" alt=\"p(x)=\\sum_{k=1}^K\\pi_k\\mathcal N(x\\mid\\mu_k,\\Sigma_k)\" style=\"width:26.366ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Aspect</th><th>K-means</th><th>Gaussian mixture</th></tr></thead><tbody><tr><td>Assignment</td><td>Hard: one cluster label</td><td>Soft: posterior responsibility for each component</td></tr><tr><td>Cluster shape</td><td>Voronoi regions from Euclidean distance; suited to compact roughly spherical groups</td><td>Full covariance allows elongated and differently oriented ellipses</td></tr><tr><td>Spread</td><td>No explicit cluster-specific covariance in the standard objective</td><td>Separate covariance estimates model unequal spreads</td></tr><tr><td>Overlap</td><td>Boundary points assigned completely to one side</td><td>Uncertainty is represented by partial memberships</td></tr><tr><td>Output</td><td>Centroids and assignments</td><td>Density, mixing weights, means, covariances and responsibilities</td></tr><tr><td>Training</td><td>Alternate assignment and centroid mean</td><td>EM responsibility and parameter updates</td></tr><tr><td>Cost</td><td>Usually simpler and faster</td><td>More parameters and cost; can overfit or develop singular covariance</td></tr><tr><td>Initialization</td><td>Can reach local minima</td><td>Can reach local likelihood maxima; multiple restarts help</td></tr></tbody></table><p><strong>Example.</strong> 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.</p><p><strong>Why this matters.</strong> 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.</p><p><strong>Selection and limitations.</strong> 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.</p></section>"},{"id":"q3b","title":"Q3(b) Center of sums defuzzification [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q3(b)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>For the given membership functions, determine the defuzzified crisp output using the Center of Sums method.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-centre-sums.6ec254a338.svg\" width=\"780\" height=\"420\" alt=\"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).\" loading=\"lazy\" decoding=\"async\"></div><figcaption>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).</figcaption></figure></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>A1 has height 0.5 and support [1,8], plateau [3,7]; A2 has height 0.3 and support [3,9], plateau [4,8].</p><h4>To find</h4><p>Center of sums of the two clipped output sets.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/b24773ebdb90677f.svg\" alt=\"z_{COS}=\\frac{A_1c_1+A_2c_2}{A_1+A_2}=\\frac{M_1+M_2}{A_1+A_2}\" style=\"width:33.933ex;height:5.041ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Area and moment of A1</h5><table><thead><tr><th>Piece</th><th>Area</th><th>Centroid x</th><th>Area × centroid</th></tr></thead><tbody><tr><td>Left triangle [1,3]</td><td>½×2×0.5=0.5</td><td>(1+3+3)/3=7/3</td><td>7/6</td></tr><tr><td>Rectangle [3,7]</td><td>4×0.5=2</td><td>(3+7)/2=5</td><td>10</td></tr><tr><td>Right triangle [7,8]</td><td>½×1×0.5=0.25</td><td>(7+7+8)/3=22/3</td><td>11/6</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/dcc4edef182cedf3.svg\" alt=\"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\" style=\"width:81.12ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Area and moment of A2</h5><table><thead><tr><th>Piece</th><th>Area</th><th>Centroid x</th><th>Moment</th></tr></thead><tbody><tr><td>Left triangle [3,4]</td><td>0.15</td><td>11/3</td><td>0.55</td></tr><tr><td>Rectangle [4,8]</td><td>1.2</td><td>6</td><td>7.2</td></tr><tr><td>Right triangle [8,9]</td><td>0.15</td><td>25/3</td><td>1.25</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/6325190477396ab2.svg\" alt=\"A_2=0.15+1.2+0.15=1.5,\\quad M_2=0.55+7.2+1.25=9,\\quad c_2=6\" style=\"width:67.546ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Weight centroids by areas</h5><div class=\"math-display\"><img src=\"math/b790fc2742ec49ac.svg\" alt=\"z_{COS}=\\frac{13+9}{2.75+1.5}=\\frac{22}{4.25}=\\frac{88}{17}\\approx5.176471\" style=\"width:44.275ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> Center of Sums = 88/17 ≈ 5.176471.</div></section>"},{"id":"q4a","title":"Q4(a) Fuzzy quality-control design [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q4(a)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Pressure=40, Material quality=80; ranges 0–100; three input terms and five output terms.</p><h4>To find</h4><p>A complete controller: membership graphs, rules, inference and crisp output.</p></div><h4>Formula and why it applies</h4><p>Fuzzification translates measured values into degrees. Min implements AND, max combines rules, and centroid converts the fuzzy output to one numerical command.</p><div class=\"math-display\"><img src=\"math/07c525af02eb813b.svg\" alt=\"\\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}\" style=\"width:46.008ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 1. Specify the inputs and output</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-quality-inputs.c512a5765f.svg\" width=\"780\" height=\"420\" alt=\"Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Explicit design assumption: overlapping low, medium and high input memberships, covering the full 0–100 range.</figcaption></figure><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-quality-outputs.e8de6dab72.svg\" width=\"780\" height=\"420\" alt=\"Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Five assumed output descriptors. Endpoint descriptors are shoulders, so 0 and 100 remain covered.</figcaption></figure></div><div class=\"step\"><h5>Step 2. Define all nine IF–THEN rules</h5><table><thead><tr><th>Pressure / Material quality</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Very high defect</td><td>High defect</td><td>Medium defect</td></tr><tr><td>Medium</td><td>High defect</td><td>Medium defect</td><td>Low defect</td></tr><tr><td>High</td><td>Medium defect</td><td>Low defect</td><td>Very low defect</td></tr></tbody></table><p>Higher pressure and better material reduce defect severity, as stipulated in this question. This is an exam design assumption, not a universal manufacturing rule.</p></div><div class=\"step\"><h5>Step 3. Fuzzify the two crisp readings</h5><table><thead><tr><th>Input</th><th>Low membership</th><th>Medium membership</th><th>High membership</th></tr></thead><tbody><tr><td>Pressure=40</td><td>1/5</td><td>4/5</td><td>0</td></tr><tr><td>Material quality=80</td><td>0</td><td>2/5</td><td>3/5</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 4. Fire every active rule with minimum</h5><table><thead><tr><th>Pressure</th><th>Material quality</th><th>AND strength</th><th>Output descriptor</th></tr></thead><tbody><tr><td>Low</td><td>Medium</td><td>min(0.2, 0.4) = 0.2</td><td>High defect</td></tr><tr><td>Low</td><td>High</td><td>min(0.2, 0.6) = 0.2</td><td>Medium defect</td></tr><tr><td>Medium</td><td>Medium</td><td>min(0.8, 0.4) = 0.4</td><td>Medium defect</td></tr><tr><td>Medium</td><td>High</td><td>min(0.8, 0.6) = 0.6</td><td>Low defect</td></tr></tbody></table><p>The other rules have a zero antecedent membership and therefore fire at zero.</p></div><div class=\"step\"><h5>Step 5. Aggregate rules and clip each output membership</h5><table><thead><tr><th>Descriptor</th><th>Maximum firing strength</th></tr></thead><tbody><tr><td>Very low defect</td><td>0.0</td></tr><tr><td>Low defect</td><td>0.6</td></tr><tr><td>Medium defect</td><td>0.4</td></tr><tr><td>High defect</td><td>0.2</td></tr><tr><td>Very high defect</td><td>0.0</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/fa8dd4982ac39cbc.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{B_r}(z))\" style=\"width:29.354ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-quality-aggregate.dae0d30118.svg\" width=\"780\" height=\"420\" alt=\"Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Clipped consequents are combined using maximum; overlapping areas are counted once for the centroid.</figcaption></figure></div><div class=\"step\"><h5>Step 6. Calculate centroid area and first moment</h5><p>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.</p><div class=\"math-display\"><img src=\"math/ed18c6126c4569a0.svg\" alt=\"A=(b-a)\\frac{u+v}{2},\\qquad M=aA+\\frac{(b-a)^2(u+2v)}6,\\qquad z^*=\\frac{\\sum M}{\\sum A}\" style=\"width:67.597ex;height:5.665ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>Segment [a, b]</th><th>Heights [u, v]</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>[0, 15]</td><td>[0, 0.6]</td><td>4.500000</td><td>45.000000</td></tr><tr><td>[15, 25]</td><td>[0.6, 0.6]</td><td>6.000000</td><td>120.000000</td></tr><tr><td>[25, 35]</td><td>[0.6, 0.6]</td><td>6.000000</td><td>180.000000</td></tr><tr><td>[35, 40]</td><td>[0.6, 0.4]</td><td>2.500000</td><td>93.333333</td></tr><tr><td>[40, 50]</td><td>[0.4, 0.4]</td><td>4.000000</td><td>180.000000</td></tr><tr><td>[50, 55]</td><td>[0.4, 0.4]</td><td>2.000000</td><td>105.000000</td></tr><tr><td>[55, 65]</td><td>[0.4, 0.4]</td><td>4.000000</td><td>240.000000</td></tr><tr><td>[65, 70]</td><td>[0.4, 0.2]</td><td>1.500000</td><td>100.833333</td></tr><tr><td>[70, 75]</td><td>[0.2, 0.2]</td><td>1.000000</td><td>72.500000</td></tr><tr><td>[75, 95]</td><td>[0.2, 0.2]</td><td>4.000000</td><td>340.000000</td></tr><tr><td>[95, 100]</td><td>[0.2, 0]</td><td>0.500000</td><td>48.333333</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/2cfff2284cb1a5a3.svg\" alt=\"z^*=\\frac{1525.000000}{36.000000}\\approx 42.361111\" style=\"width:30.689ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Make the accept/reject decision</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"q4b","title":"Q4(b) ACO components and roles [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q4(b)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>Describe the key components of an Ant Colony Optimization algorithm and their respective roles in finding optimal solutions.</p></div><h3>Answer</h3><p><strong>Ant Colony Optimization (ACO)</strong> 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.</p><table><thead><tr><th>Component</th><th>Role</th><th>TSP interpretation</th></tr></thead><tbody><tr><td>Problem graph / feasible moves</td><td>Defines allowable solution components and constraints</td><td>Cities are nodes, travel edges have costs</td></tr><tr><td>Artificial ants</td><td>Construct candidate solutions incrementally</td><td>Build tours visiting each city once then return</td></tr><tr><td>Pheromone τᵢⱼ</td><td>Learned desirability from prior successful tours</td><td>Strong trails favor often-rewarded edges</td></tr><tr><td>Heuristic ηᵢⱼ</td><td>Problem-specific local guidance</td><td>Often 1/dᵢⱼ: shorter edges look attractive</td></tr><tr><td>Tabu/visited set</td><td>Prevents invalid repeat decisions</td><td>Do not revisit a city before the closing edge</td></tr><tr><td>Probabilistic transition</td><td>Balances learned and local guidance</td><td>Normalize desirabilities over unvisited cities</td></tr><tr><td>Evaporation ρ</td><td>Forgets old trails; helps avoid stagnation</td><td>Multiply old pheromone by 1−ρ</td></tr><tr><td>Deposit / reinforcement</td><td>Rewards useful solutions</td><td>Ant on tour of length L deposits Q/L</td></tr><tr><td>Best-tour memory</td><td>Retains best solution discovered</td><td>Shorter tour replaces incumbent</td></tr><tr><td>Termination</td><td>Bounds computation</td><td>Iteration/time/no-improvement limit</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/d58589c662f1dcac.svg\" alt=\"p_{ij}^{(k)}=\\frac{\\tau_{ij}^{\\alpha}\\eta_{ij}^{\\beta}}{\\sum_{h\\in allowed_k}\\tau_{ih}^{\\alpha}\\eta_{ih}^{\\beta}}\" style=\"width:23.815ex;height:7.316ex\" loading=\"lazy\" decoding=\"async\"></div><p>α 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.</p><div class=\"math-display\"><img src=\"math/5e92452bfde69641.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}^{old}+\\sum_k Q/L_k\\;\\text{on edges used by ant }k\" style=\"width:52.079ex;height:4.899ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Algorithm flow:</strong> 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.</p></section>"},{"id":"q5a","title":"Q5(a) PSO inspiration, parameters and one iteration [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q5(a)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>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.</p></div><h3>Answer</h3><p>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.</p><table><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>xᵢ</td><td>Current position / candidate solution</td></tr><tr><td>vᵢ</td><td>Velocity / proposed movement</td></tr><tr><td>pbestᵢ</td><td>Best position visited by this particle</td></tr><tr><td>gbest</td><td>Best position visited by the swarm</td></tr><tr><td>w</td><td>Inertia, retains part of previous velocity</td></tr><tr><td>c₁, c₂</td><td>Cognitive and social acceleration weights</td></tr><tr><td>r₁, r₂</td><td>Random multipliers in [0,1]</td></tr><tr><td>N / limit</td><td>Number of particles / stopping condition</td></tr></tbody></table><div class=\"given\"><h4>Given</h4><p>Five positions and objective as printed. The question explicitly permits parameter assumptions.</p><h4>To find</h4><p>Updated velocities, positions, fitnesses and best records after one synchronous iteration.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/99893bd63a6f8a01.svg\" alt=\"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}\" style=\"width:67.528ex;height:2.273ex\" loading=\"lazy\" decoding=\"async\"></div><p>For minimization, a smaller objective is better. Freeze gbest while moving the entire swarm; update best records only after evaluating the new positions.</p><h4>Solution</h4><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 1. Evaluate all initial candidates</h5><table><thead><tr><th>Particle</th><th>x</th><th>3x²+4x+10</th></tr></thead><tbody><tr><td>1</td><td>-9</td><td>243 + (-36) + 10 = 217</td></tr><tr><td>2</td><td>-6</td><td>108 + (-24) + 10 = 94</td></tr><tr><td>3</td><td>-2</td><td>12 + (-8) + 10 = 14</td></tr><tr><td>4</td><td>8</td><td>192 + (32) + 10 = 234</td></tr><tr><td>5</td><td>10</td><td>300 + (40) + 10 = 350</td></tr></tbody></table><p>Smallest value is 14 at x=−2, so freeze gbest=−2.</p></div><div class=\"step\"><h5>Step 2. Simplify the velocity formula</h5><p>Initial velocity is zero and pbest equals the current position; therefore inertia and cognitive terms are both zero.</p><div class=\"math-display\"><img src=\"math/4a6d06df6529bc16.svg\" alt=\"v_i^{new}=0.5(-2-x_i)\" style=\"width:19.496ex;height:2.273ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Calculate every new velocity and position</h5><table><thead><tr><th>Particle</th><th>Velocity calculation</th><th>New position</th><th>New fitness</th></tr></thead><tbody><tr><td>1</td><td>0.5×(−2−(-9))=3.5</td><td>-9+(3.5)=-5.5</td><td>78.75</td></tr><tr><td>2</td><td>0.5×(−2−(-6))=2</td><td>-6+(2)=-4</td><td>42</td></tr><tr><td>3</td><td>0.5×(−2−(-2))=0</td><td>-2+(0)=-2</td><td>14</td></tr><tr><td>4</td><td>0.5×(−2−(8))=-5</td><td>8+(-5)=3</td><td>49</td></tr><tr><td>5</td><td>0.5×(−2−(10))=-6</td><td>10+(-6)=4</td><td>74</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Update best records</h5><p>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.</p><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> After one stated-assumption iteration: positions [−5.5,−4,−2,3,4]; swarm best x=−2, f=14.</div></section>"},{"id":"q5b","title":"Q5(b) Brand-switching transition matrix [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q5(b)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>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.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>A→A=.80; B→B=.90. Two exhaustive states A and B.</p><h4>To find</h4><p>Transition matrix, diagram, and correct flow interpretation.</p></div><h4>Formula and why it applies</h4><p>Every row lists all possible destinations from one origin; its probabilities sum to one. Missing switch probability is 1 minus retention.</p><div class=\"math-display\"><img src=\"math/e570af7d131502f2.svg\" alt=\"P_{ij}=P(\\text{next}=j\\mid\\text{current}=i)\" style=\"width:30.476ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Find the two switch probabilities</h5><div class=\"math-display\"><img src=\"math/8f12974205c3ad53.svg\" alt=\"P_{AB}=1-0.8=0.2,\\quad P_{BA}=1-0.9=0.1\" style=\"width:42.805ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Put origins in rows</h5><div class=\"math-display\"><img src=\"math/a352d238bb02bc14.svg\" alt=\"P=\\begin{bmatrix}0.8&amp;0.2\\\\0.1&amp;0.9\\end{bmatrix}\" style=\"width:15.151ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-brands.f41eb4de5f.svg\" width=\"760\" height=\"430\" alt=\"Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Interpret retention, loss and gain with consistent populations</h5><p>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.</p><div class=\"math-display\"><img src=\"math/ddeb66c690da3b9e.svg\" alt=\"A_{next}=0.8A+0.1B,\\quad B_{next}=0.2A+0.9B\" style=\"width:43.413ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> P=[[0.8,0.2],[0.1,0.9]], with the four labeled arrows above.</div></section>"},{"id":"q6a","title":"Q6(a) GA ranking and three crossover methods [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q6(a)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>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?</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>Four ten-gene parents and a signed linear fitness function.</p><h4>To find</h4><p>Ranking, two children per crossover, child fitness and fair population comparison.</p></div><h4>Formula and why it applies</h4><p>One-point crossover swaps suffixes. Two-point crossover swaps the middle block. Arithmetic crossover takes weighted gene values.</p><div class=\"math-display\"><img src=\"math/686b6d11dfecb89a.svg\" alt=\"child_1=\\alpha P+(1-\\alpha)Q,\\quad child_2=(1-\\alpha)P+\\alpha Q\" style=\"width:50.721ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Evaluate each signed pair sum</h5><table><thead><tr><th>Parent</th><th>(a+b)−(c+d)+(e+f)+(g+h)−(i+j)</th><th>Fitness</th></tr></thead><tbody><tr><td>x1</td><td>11−5+8+5−8</td><td>11</td></tr><tr><td>x2</td><td>15−3+12+1−6</td><td>19</td></tr><tr><td>x3</td><td>5−11+3+13−10</td><td>0</td></tr><tr><td>x4</td><td>5−13+2+13−8</td><td>-1</td></tr></tbody></table><p>Descending order: x₂ (19), x₁ (11), x₃ (0), x₄ (−1).</p></div><div class=\"step\"><h5>Step 2. One-point crossover after gene 5</h5><p>x₂=87126 | 60124; x₁=65413 | 53253. Exchange the right blocks.</p><table><thead><tr><th>Child</th><th>Genes</th><th>Fitness</th></tr></thead><tbody><tr><td>C1</td><td>8712653253</td><td>20</td></tr><tr><td>C2</td><td>6541360124</td><td>10</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Two-point crossover after b and after f</h5><p>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.</p><table><thead><tr><th>Child</th><th>Genes</th><th>Fitness</th></tr></thead><tbody><tr><td>C3</td><td>6592123253</td><td>0</td></tr><tr><td>C4</td><td>2341358546</td><td>11</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Arithmetic crossover of x₂ and x₃</h5><table><thead><tr><th>Position</th><th>x₂</th><th>x₃</th><th>0.5x₂+0.5x₃</th></tr></thead><tbody><tr><td>1</td><td>8</td><td>2</td><td>5.0</td></tr><tr><td>2</td><td>7</td><td>3</td><td>5.0</td></tr><tr><td>3</td><td>1</td><td>9</td><td>5.0</td></tr><tr><td>4</td><td>2</td><td>2</td><td>2.0</td></tr><tr><td>5</td><td>6</td><td>1</td><td>3.5</td></tr><tr><td>6</td><td>6</td><td>2</td><td>4.0</td></tr><tr><td>7</td><td>0</td><td>8</td><td>4.0</td></tr><tr><td>8</td><td>1</td><td>5</td><td>3.0</td></tr><tr><td>9</td><td>2</td><td>4</td><td>3.0</td></tr><tr><td>10</td><td>4</td><td>6</td><td>5.0</td></tr></tbody></table><p>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.</p><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside></div><div class=\"step\"><h5>Step 5. Show every offspring fitness calculation</h5><table><thead><tr><th>Child</th><th>Pair sums with signs</th><th>Fitness</th></tr></thead><tbody><tr><td>C1</td><td>15−3+11+5−8</td><td>20</td></tr><tr><td>C2</td><td>11−5+9+1−6</td><td>10</td></tr><tr><td>C3</td><td>11−11+3+5−8</td><td>0</td></tr><tr><td>C4</td><td>5−5+8+13−10</td><td>11</td></tr><tr><td>C5</td><td>10−7+7.5+7−8</td><td>9.5</td></tr><tr><td>C6</td><td>10−7+7.5+7−8</td><td>9.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Compare averages, not totals from different population sizes</h5><div class=\"math-display\"><img src=\"math/07b0b7549d04f350.svg\" alt=\"\\bar f_{old}=(11+19+0-1)/4=7.25\" style=\"width:32.545ex;height:2.729ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/539cf61121bb4c13.svg\" alt=\"\\bar f_{new}=((20)+(10)+(0)+(11)+(9.5)+(9.5))/6=10\" style=\"width:54.557ex;height:2.729ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section>"},{"id":"q6b","title":"Q6(b) Markov property and weather path [10]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q6(b)</strong> <span class=\"marks\">[10 marks · 2024-04-17]</span><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/legacy24-weather.575ab21d0e.svg\" width=\"760\" height=\"430\" alt=\"Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Redrawn transition diagram. Each arrow goes from the current state to the next state; labels are probabilities.</figcaption></figure></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>State order Sunny, Cloudy, Rainy. The diagram gives P=[[.8,.05,.15],[.75,.2,.05],[.38,.02,.6]].</p><h4>To find</h4><p>Definition and both requested conditional probabilities.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/acdbeb13aace7aac.svg\" alt=\"P(X_{t+1}\\mid X_t,X_{t-1},\\ldots)=P(X_{t+1}\\mid X_t)\" style=\"width:37.698ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Read origin row and destination column</h5><div class=\"math-display\"><img src=\"math/b7e30adc50b915ab.svg\" alt=\"P=\\begin{bmatrix}0.8&amp;0.05&amp;0.15\\\\0.75&amp;0.2&amp;0.05\\\\0.38&amp;0.02&amp;0.6\\end{bmatrix}\" style=\"width:24.327ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div><p>For example P(Sunny→Rainy)=0.15 while P(Rainy→Sunny)=0.38; arrow directions cannot be interchanged. Each row sums to 1.</p></div><div class=\"step\"><h5>Step 2. Multiply along the specified S→S→R path</h5><div class=\"math-display\"><img src=\"math/f206e4e596cad948.svg\" alt=\"P(X_{t+1}=S,X_{t+2}=R\\mid X_t=S)=P_{SS}P_{SR}=0.8\\times0.15=0.12\" style=\"width:62.387ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>Do not sum all two-day routes ending in rain: tomorrow is specifically required to be sunny.</p></div><div class=\"step\"><h5>Step 3. Use the current cloudy state in part (b)</h5><div class=\"math-display\"><img src=\"math/72bc7a0f35b98e71.svg\" alt=\"P(X_{t+1}=S\\mid X_t=C,X_{t-1}=R)=P_{CS}=0.75\" style=\"width:46.248ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> (a) 0.12; (b) 0.75.</div></section>"},{"id":"q7a","title":"Q7(a) Bayes bag posterior [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(a)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>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₁.</p></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>P(W|B₁)=3/10; P(W|B₂)=5/8.</p><h4>To find</h4><p>P(B₁|W).</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/e49e2acd2af82aac.svg\" alt=\"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)}\" style=\"width:50.37ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><aside class=\"note\"><strong>Source / assumption note.</strong> 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.</aside><div class=\"step\"><h5>Step 1. Calculate both white-event contributions</h5><div class=\"math-display\"><img src=\"math/797903c04a87ae2d.svg\" alt=\"P(W,B_1)=\\frac3{10}\\frac12=\\frac3{20}=0.15\" style=\"width:31.258ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/44aff1e67025be81.svg\" alt=\"P(W,B_2)=\\frac58\\frac12=\\frac5{16}=0.3125\" style=\"width:32.389ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Find total white probability</h5><div class=\"math-display\"><img src=\"math/0310d0eb2cb65a99.svg\" alt=\"P(W)=\\frac3{20}+\\frac5{16}=\\frac{12+25}{80}=\\frac{37}{80}=0.4625\" style=\"width:45.009ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Normalize the B₁ contribution</h5><div class=\"math-display\"><img src=\"math/6bf86459a0c31fc3.svg\" alt=\"P(B_1\\mid W)=\\frac{3/20}{37/80}=\\frac3{20}\\frac{80}{37}=\\frac{12}{37}\\approx0.324324\" style=\"width:47.462ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Under equal bag-selection priors, 12/37 ≈ 0.324324.</div></section>"},{"id":"q7b","title":"Q7(b) Max–min relational composition [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(b)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>For the following fuzzy relations R and S, obtain T using max–min composition.</p><div class=\"math-display\"><img src=\"math/ab04f42254fa9175.svg\" alt=\"R=\\begin{bmatrix}0.6&amp;0.3\\\\0.2&amp;0.5\\end{bmatrix},\\quad S=\\begin{bmatrix}1&amp;0.4&amp;0.5\\\\0.8&amp;0.3&amp;0.8\\end{bmatrix}\" style=\"width:38.502ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div></div><h3>Answer</h3><div class=\"given\"><h4>Given</h4><p>R is 2×2 and S is 2×3.</p><h4>To find</h4><p>A 2×3 relation T connecting the first and last universes.</p></div><h4>Formula and why it applies</h4><p>Use a row of R and a column of S. The common middle dimension is 2. Take two minima, then the larger of them.</p><div class=\"math-display\"><img src=\"math/e1639920f7163459.svg\" alt=\"T_{ij}=\\max_{k=1,2}\\min(R_{ik},S_{kj})\" style=\"width:23.22ex;height:3.746ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Verify dimensions</h5><p>(2×2) composed with (2×3) gives 2×3. Ordinary dot-product addition is not used.</p></div><div class=\"step\"><h5>Step 2. Calculate every output cell</h5><table><thead><tr><th>Output cell</th><th>Compare every matching middle index</th><th>Take the largest result</th></tr></thead><tbody><tr><td>(1, 1)</td><td>min(0.6, 1) = 0.6, min(0.3, 0.8) = 0.3</td><td>max(0.6, 0.3) = 0.6</td></tr><tr><td>(1, 2)</td><td>min(0.6, 0.4) = 0.4, min(0.3, 0.3) = 0.3</td><td>max(0.4, 0.3) = 0.4</td></tr><tr><td>(1, 3)</td><td>min(0.6, 0.5) = 0.5, min(0.3, 0.8) = 0.3</td><td>max(0.5, 0.3) = 0.5</td></tr><tr><td>(2, 1)</td><td>min(0.2, 1) = 0.2, min(0.5, 0.8) = 0.5</td><td>max(0.2, 0.5) = 0.5</td></tr><tr><td>(2, 2)</td><td>min(0.2, 0.4) = 0.2, min(0.5, 0.3) = 0.3</td><td>max(0.2, 0.3) = 0.3</td></tr><tr><td>(2, 3)</td><td>min(0.2, 0.5) = 0.2, min(0.5, 0.8) = 0.5</td><td>max(0.2, 0.5) = 0.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. Write the final relation</h5><div class=\"math-display\"><img src=\"math/d993cd17e860e89f.svg\" alt=\"T=\\begin{bmatrix}0.6&amp;0.4&amp;0.5\\\\0.5&amp;0.3&amp;0.5\\end{bmatrix}\" style=\"width:20.198ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> T=[[0.6,0.4,0.5],[0.5,0.3,0.5]].</div></section>"},{"id":"q7c","title":"Q7(c) Point versus uniform crossover [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(c)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>Differentiate between point crossover and uniform crossover.</p></div><h3>Answer</h3><p><strong>Crossover</strong> recombines genes from two parents to form children. Its purpose is to combine useful building blocks; mutation introduces an independent local change.</p><table><thead><tr><th>Aspect</th><th>Point crossover</th><th>Uniform crossover</th></tr></thead><tbody><tr><td>Selection mechanism</td><td>Choose one or more cut locations; exchange contiguous segments</td><td>Choose parent at each position using a binary mask</td></tr><tr><td>Linkage</td><td>Tends to preserve neighboring gene blocks</td><td>Mixes genes more independently; may break useful adjacent blocks</td></tr><tr><td>Control</td><td>Number and position of cut points</td><td>Mask / per-gene mixing probability</td></tr><tr><td>Example parents</td><td>P1=111100, P2=000011</td><td>Same parents</td></tr><tr><td>Rule</td><td>Cut after position 3: 111|100 and 000|011</td><td>Mask 101010: child 1 takes P1 where mask=1, otherwise P2</td></tr><tr><td>Children</td><td>111011 and 000100</td><td>101001 and 010110</td></tr></tbody></table><p>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.</p></section>"},{"id":"q7d","title":"Q7(d) Applications of reinforcement learning [5]","html":"<section class=\"example\"><div class=\"question complete-source-question\"><strong>Question. Q7(d)</strong> <span class=\"marks\">[5 marks · 2024-04-17]</span><p>Discuss the applications of reinforcement learning.</p></div><h3>Answer</h3><p><strong>Reinforcement learning</strong> 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.</p><table><thead><tr><th>Application</th><th>State and action</th><th>Reward / reason RL fits</th></tr></thead><tbody><tr><td>Robot navigation</td><td>State: pose/obstacles; action: movement</td><td>Reward for reaching goal, penalties for collision; actions affect future states</td></tr><tr><td>Game playing</td><td>State: board; action: legal move</td><td>Win/loss and long-term strategy; a weak immediate move may yield a later win</td></tr><tr><td>Traffic signal control</td><td>State: queue lengths; action: phase/timing</td><td>Reduced delay and congestion over time</td></tr><tr><td>Resource scheduling</td><td>State: jobs/load; action: allocation</td><td>Throughput and latency rewards under changing demand</td></tr><tr><td>Recommendation sequences</td><td>State: interaction history; action: next item</td><td>Long-term engagement rather than only one click</td></tr></tbody></table><p><strong>One worked interpretation:</strong> 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.</p></section>"}]}],"mocks":[{"id":"paper-final-2025","title":"Final examination · 24 Nov 2025","unit":"paper","scope":"100-mark timed practice using the actual Final 2025 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.","sections":[{"id":"q1a","title":"Q1(a) Joint probability table [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>The printed eight entries are reproduced below. Their total is 1.002, not 1. Therefore the table is inconsistent as a probability distribution.</p><div class=\"table-wrap\"><table><thead><tr><th></th><th>Credit, female</th><th>Credit, male</th><th>Debit, female</th><th>Debit, male</th></tr></thead><tbody>\r\n<tr><td><strong>Premium (Y=1)</strong></td><td>0.08</td><td>0.10</td><td>0.072</td><td>0.05</td></tr>\r\n<tr><td><strong>Regular (Y=0)</strong></td><td>0.10</td><td>0.15</td><td>0.25</td><td>0.20</td></tr></tbody></table></div><h4>To find</h4><p>The five requested probabilities, stating how the inconsistent data are interpreted.</p></div><h4>Formula and why it applies</h4><p>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><div class=\"math-display\"><img src=\"math/e29a33f81d36c3d3.svg\" alt=\"P(E)=\\frac{\\text{sum of weights for }E}{\\text{sum of all weights}}\" style=\"width:29.187ex;height:5.143ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/656f97e9f0aa20fc.svg\" alt=\"P(A\\mid E)=\\frac{\\text{sum of weights for }A\\cap E}{\\text{sum of weights for }E}\" style=\"width:36.981ex;height:5.167ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Validate the full table</h5><div class=\"math-display\"><img src=\"math/96cf20835aaf1e81.svg\" alt=\"0.08+0.10+0.072+0.05+0.10+0.15+0.25+0.20=1.002\" style=\"width:60.843ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><p>Use total weight 1.002 consistently for unconditional probabilities.</p></div><div class=\"step\"><h5>Step 2. Premium row total</h5><div class=\"math-display\"><img src=\"math/455884f740d33473.svg\" alt=\"w(premium)=0.08+0.10+0.072+0.05=0.302\" style=\"width:49.347ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. Female given premium</h5><div class=\"math-display\"><img src=\"math/61d38ae71dd8a06e.svg\" alt=\"P(female\\mid premium)=\\frac{0.08+0.072}{0.302}=\\frac{0.152}{0.302}\\approx0.503311\" style=\"width:58.502ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Credit given premium</h5><div class=\"math-display\"><img src=\"math/f1511f5b6ec07db0.svg\" alt=\"P(credit\\mid premium)=\\frac{0.08+0.10}{0.302}=\\frac{0.18}{0.302}\\approx0.596026\" style=\"width:55.988ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Normalised premium marginal</h5><div class=\"math-display\"><img src=\"math/3465c1e9a29a79c1.svg\" alt=\"P(premium)=\\frac{0.302}{1.002}\\approx0.301397\" style=\"width:33.45ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Normalised credit marginal</h5><div class=\"math-display\"><img src=\"math/594c62fd5c571144.svg\" alt=\"P(credit)=\\frac{0.08+0.10+0.10+0.15}{1.002}=\\frac{0.43}{1.002}\\approx0.429142\" style=\"width:58.419ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Regular given male and debit</h5><div class=\"math-display\"><img src=\"math/7f500d88c2aab86f.svg\" alt=\"P(regular\\mid male,debit)=\\frac{0.20}{0.05+0.20}=0.8\" style=\"width:44.133ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Under common normalisation: (a) 0.503311 and 0.596026; (b) 0.301397 and 0.429142; (c) 0.8.</div><p><strong>Alternative correction:</strong> 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.</p></section>"},{"id":"q1b","title":"Q1(b) Applications of ACO [5]","html":"<p class=\"question\"><strong>List the applications of Ant Colony Optimization and explain any one application in detail.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Travelling salesman problem</strong>: shortest tour visiting every city once.</li>\r\n<li><strong>Vehicle routing</strong>: delivery routes for a fleet with capacity and time windows (minimising distance, time, fuel).</li>\r\n<li><strong>Network routing</strong>: adaptive routing of data packets in communication and sensor networks (AntNet).</li>\r\n<li><strong>Job-shop and project scheduling</strong>: assigning jobs to machines to minimise completion time.</li>\r\n<li><strong>Image processing</strong>: edge detection, with ants moving over pixel-intensity graphs.</li>\r\n<li><strong>Assignment problems</strong>: quadratic assignment, timetabling, graph colouring.</li>\r\n<li><strong>Feature selection and data mining</strong>: Ant-Miner for classification rules.</li>\r\n<li><strong>Load balancing</strong> in distributed systems and cloud task allocation.</li>\r\n</ol>\r\n<h3>One application in detail: vehicle routing (or TSP)</h3>\r\n<ol>\r\n<li><strong>Graph.</strong> Depot and customers are nodes; travel times or distances are edge weights.</li>\r\n<li><strong>Ants.</strong> Each ant builds a complete set of routes. From its current customer it chooses the next with probability <span class=\"math-inline\"><img src=\"math/7d200da3be6a78d4.svg\" alt=\"\\propto\\tau_{ij}\\,(1/d_{ij})\" style=\"width:11.752ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></span>, skipping customers already served or that would exceed the vehicle capacity; when the vehicle is full it returns to the depot.</li>\r\n<li><strong>Evaluation.</strong> Total distance (plus penalties for late deliveries).</li>\r\n<li><strong>Learning.</strong> Pheromone evaporates everywhere and is added in proportion to <span class=\"math-inline\"><img src=\"math/afe42919eb73e68a.svg\" alt=\"Q/L\" style=\"width:4.462ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> on the routes of good solutions, so short connections are reinforced.</li>\r\n<li><strong>Result.</strong> 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.</li>\r\n</ol>\r\n<h3>Advantages and limitations</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Limitations</th></tr></thead><tbody>\r\n<tr><td>Naturally suited to graph and routing problems</td><td>Several parameters to tune (α, β, ρ, number of ants)</td></tr>\r\n<tr><td>Can share useful route information and adapt search to changing graphs</td><td>Convergence time is uncertain; may stagnate on a sub-optimal path</td></tr>\r\n<tr><td>Positive feedback + parallel ants</td><td>Theoretical analysis is difficult</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> ACO = “raaste wale problems” (TSP, routing, scheduling). PSO = “numbers wale problems” (continuous function, weights).</div>\r\n"},{"id":"q1c","title":"Q1(c) Fuzzy set operations [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The aligned X and Y memberships printed in this question.</p><h4>To find</h4><p>The four requested membership lists in the original element order.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1−μ for NOT. <div class=\"math-display\"><img src=\"math/e32ad02c5ba3dae5.svg\" alt=\"\\mu_{X\\cup Y}=\\max(\\mu_X,\\mu_Y),\\quad\\mu_{X\\cap Y}=\\min(\\mu_X,\\mu_Y)\" style=\"width:44.598ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div> Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Complements</h5><p>¬X = {0.4, 0.2, 0.7, 0.5, 0.3}; ¬Y = {0.6, 0.5, 0.1, 0.4, 0.8}.</p></div>\r\n<div class=\"step\"><h5>Step 2. Table</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th></tr></thead><tbody>\r\n<tr><td>X</td><td>0.6</td><td>0.8</td><td>0.3</td><td>0.5</td><td>0.7</td></tr>\r\n<tr><td>Y</td><td>0.4</td><td>0.5</td><td>0.9</td><td>0.6</td><td>0.2</td></tr>\r\n<tr><td><strong>X ∪ Y = max</strong></td><td>0.6</td><td>0.8</td><td>0.9</td><td>0.6</td><td>0.7</td></tr>\r\n<tr><td><strong>X ∩ Y = min</strong></td><td>0.4</td><td>0.5</td><td>0.3</td><td>0.5</td><td>0.2</td></tr>\r\n<tr><td><strong>¬X ∪ ¬Y</strong></td><td>0.6</td><td>0.5</td><td>0.7</td><td>0.5</td><td>0.8</td></tr>\r\n<tr><td><strong>¬X ∩ ¬Y</strong></td><td>0.4</td><td>0.2</td><td>0.1</td><td>0.4</td><td>0.3</td></tr>\r\n</tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Check with De Morgan's law</h5><p>¬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} ✓.</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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)}.</div>\r\n<p class=\"marks-split\">Official marking: 1 + 1 + 1.5 + 1.5.</p>\r\n</section>\r\n\r\n<!-- depth:element-working:start -->\r\n<div class=\"concept-bridge\"><h2>Calculate every element separately</h2><h3>Element c1</h3><div class=\"math-display\"><img src=\"math/ab521a108b232136.svg\" alt=\"\\neg X:1-0.6=0.4\\qquad\\neg Y:1-0.4=0.6\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9fba815e535802c7.svg\" alt=\"X\\cup Y:\\max(0.6,0.4)=0.6\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/580180c90f774b30.svg\" alt=\"X\\cap Y:\\min(0.6,0.4)=0.4\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ac5d994d1c80e0dd.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.4,0.6)=0.6\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f8ad2bf1c74a8449.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.4,0.6)=0.4\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c2</h3><div class=\"math-display\"><img src=\"math/994b18481ef2566a.svg\" alt=\"\\neg X:1-0.8=0.2\\qquad\\neg Y:1-0.5=0.5\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/34ae0707b407acaa.svg\" alt=\"X\\cup Y:\\max(0.8,0.5)=0.8\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/276fcc7ea7945a48.svg\" alt=\"X\\cap Y:\\min(0.8,0.5)=0.5\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e450f31b46fa1e42.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.2,0.5)=0.5\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/503c7cc18cb10c65.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.2,0.5)=0.2\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c3</h3><div class=\"math-display\"><img src=\"math/abbf5f7c84a2a614.svg\" alt=\"\\neg X:1-0.3=0.7\\qquad\\neg Y:1-0.9=0.1\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b75d7a85a782c820.svg\" alt=\"X\\cup Y:\\max(0.3,0.9)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/33c018c6e76860e7.svg\" alt=\"X\\cap Y:\\min(0.3,0.9)=0.3\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b158ec14569973da.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.7,0.1)=0.7\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7b8935d4bd0523c1.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.7,0.1)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c4</h3><div class=\"math-display\"><img src=\"math/9b11f9a14b9e240f.svg\" alt=\"\\neg X:1-0.5=0.5\\qquad\\neg Y:1-0.6=0.4\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/30d486e82175d463.svg\" alt=\"X\\cup Y:\\max(0.5,0.6)=0.6\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd263e46a0f4e96c.svg\" alt=\"X\\cap Y:\\min(0.5,0.6)=0.5\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bc8abd6badb711b9.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.5,0.4)=0.5\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2acca2b0b18cfada.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.5,0.4)=0.4\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c5</h3><div class=\"math-display\"><img src=\"math/b115216f7121911a.svg\" alt=\"\\neg X:1-0.7=0.3\\qquad\\neg Y:1-0.2=0.8\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ca6e5562fab61517.svg\" alt=\"X\\cup Y:\\max(0.7,0.2)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3de60cd86ef1a257.svg\" alt=\"X\\cap Y:\\min(0.7,0.2)=0.2\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0712a083103a814e.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.3,0.8)=0.8\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6274e157a87eaf7b.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.3,0.8)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:element-working:end -->"},{"id":"q1d","title":"Q1(d) Brand-switching Markov chain [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: X, Y.</p><h4>To find</h4><p>The transition matrix and state diagram.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>X</th><th>Y</th></tr></thead><tbody><tr><td>X</td><td>0.75</td><td>0.25</td></tr><tr><td>Y</td><td>0.4</td><td>0.6</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_brand.c2c4be3e6a.svg\" width=\"520\" height=\"280\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"answer\"><strong>Final answer.</strong> The transition matrix and state diagram are given above.</div></section>"},{"id":"q2a","title":"Q2(a) PSO, one iteration [10]","html":"<p class=\"question\"><strong>Question. Maximize <span class=\"math-inline\"><img src=\"math/51d7b4f8ba214898.svg\" alt=\"F(x_1,x_2)=2x_1^2-3x_1x_2+x_2^2+5x_1+2x_2+7\" style=\"width:45.217ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using Particle Swarm Optimization. <span class=\"math-inline\"><img src=\"math/cf25c61c163c59c7.svg\" alt=\"X=\\begin{bmatrix}2.5&amp;-3.0\\\\3.5&amp;-1.5\\end{bmatrix},\\;V=\\begin{bmatrix}0.2&amp;0.3\\\\0.1&amp;0.25\\end{bmatrix}\" style=\"width:35.097ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Take <span class=\"math-inline\"><img src=\"math/d99737a5fc79423b.svg\" alt=\"W=0.9,\\;c_1=c_2=1.5,\\;r_1=0.5949,\\;r_2=0.0855\" style=\"width:48.665ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></span>. Optimize and give the solution after 1 iteration showing the step-by-step process.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4><p>Particle 1: <span class=\"math-inline\"><img src=\"math/85ac77f48027edb2.svg\" alt=\"x=(2.5,\\,-3.0)\" style=\"width:14.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/438166430b0200d4.svg\" alt=\"v=(0.2,\\,0.3)\" style=\"width:13.041ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. Particle 2: <span class=\"math-inline\"><img src=\"math/a92c6e5b7c6f437f.svg\" alt=\"x=(3.5,\\,-1.5)\" style=\"width:14.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/3bf1b4b0830b2535.svg\" alt=\"v=(0.1,\\,0.25)\" style=\"width:14.172ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/24c25a9332d3129e.svg\" alt=\"c_1r_1=1.5\\times0.5949=0.89235,\\qquad c_2r_2=1.5\\times0.0855=0.12825\" style=\"width:64.267ex;height:1.971ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<h4>To find</h4><p>Fitness, pbest, gbest; new velocities and positions; updated pbest and gbest.</p></div>\r\n<h4>Formula and why it applies</h4>\r\n<div class=\"math-display\"><img src=\"math/15c9c9495dc886c9.svg\" alt=\"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}\" style=\"width:62.375ex;height:3.036ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Each particle is pulled by its own memory and by the swarm's best; we maximise, so the larger <span class=\"math-inline\"><img src=\"math/277a47abb82a8255.svg\" alt=\"F\" style=\"width:1.695ex;height:1.538ex\" loading=\"lazy\" decoding=\"async\"></span> is better.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Fitness of particle 1</h5><div class=\"math-display\"><img src=\"math/3938546a658fac5b.svg\" alt=\"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\" style=\"width:97.613ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Fitness of particle 2</h5><div class=\"math-display\"><img src=\"math/4d48c40dfb866c17.svg\" alt=\"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\" style=\"width:101.006ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. pbest and gbest</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>Position</th><th>F</th><th>pbest</th></tr></thead><tbody><tr><td>1</td><td>(2.5, −3.0)</td><td>57.5</td><td>(2.5, −3.0)</td></tr><tr><td>2</td><td>(3.5, −1.5)</td><td>64</td><td>(3.5, −1.5)</td></tr></tbody></table></div>\r\n<p>No previous iteration, so pbest = current position. Largest fitness is 64, so <strong>gbest = (3.5, −1.5)</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 4. Velocity and position of particle 1</h5>\r\n<div class=\"math-display\"><img src=\"math/c5345abf4a118373.svg\" alt=\"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\" style=\"width:85.978ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/aa0bacfeb906b753.svg\" alt=\"x_{11}=2.5+0.30825=2.80825\" style=\"width:29.606ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/a3af7b24f214c46d.svg\" alt=\"v_{12}=0.9(0.3)+0.89235(0)+0.12825(-1.5-(-3.0))=0.27+0.192375=0.462375\" style=\"width:82.207ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c09ac9a314e4985c.svg\" alt=\"x_{12}=-3.0+0.462375=-2.537625\" style=\"width:35.388ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 5. Velocity and position of particle 2 (it is gbest, so both pull terms are 0)</h5>\r\n<div class=\"math-display\"><img src=\"math/d5ef6ea1fa183f88.svg\" alt=\"v_{21}=0.9(0.1)+0+0=0.09,\\qquad x_{21}=3.5+0.09=3.59\" style=\"width:56.628ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/cdc998e6ae01e141.svg\" alt=\"v_{22}=0.9(0.25)+0+0=0.225,\\qquad x_{22}=-1.5+0.225=-1.275\" style=\"width:64.673ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 6. New fitness</h5>\r\n<div class=\"math-display\"><img src=\"math/d85fb6275e35f72d.svg\" alt=\"F(2.80825,-2.537625)=15.772536+21.378856+6.439541+14.04125-5.07525+7=59.5569\" style=\"width:94.464ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/df29fd84a6cdf039.svg\" alt=\"F(3.59,-1.275)=25.7762+13.73175+1.625625+17.95-2.55+7=63.5336\" style=\"width:77.495ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 7. Update pbest and gbest</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>New position</th><th>New F</th><th>Old pbest F</th><th>pbest after iteration</th></tr></thead><tbody>\r\n<tr><td>1</td><td>(2.80825, −2.537625)</td><td>59.5569</td><td>57.5</td><td>(2.80825, −2.537625) — improved</td></tr>\r\n<tr><td>2</td><td>(3.59, −1.275)</td><td>63.5336</td><td>64</td><td>(3.5, −1.5) — kept</td></tr></tbody></table></div>\r\n<p>The best pbest fitness is still 64, so gbest stays (3.5, −1.5).</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/4cf56ad79b60f4ff.svg\" alt=\"V=\\begin{bmatrix}0.30825&amp;0.462375\\\\0.09&amp;0.225\\end{bmatrix}\" style=\"width:25.372ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/befb5808089844a6.svg\" alt=\"X=\\begin{bmatrix}2.80825&amp;-2.537625\\\\3.59&amp;-1.275\\end{bmatrix}\" style=\"width:27.32ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. After one iteration particle 1 improved to F = 59.5569; the best solution so far is gbest = (3.5, −1.5) with F = 64.</div>\r\n<p class=\"marks-split\">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 <span class=\"math-inline\"><img src=\"math/e82facc124656ec6.svg\" alt=\"x_{11}\" style=\"width:3.082ex;height:1.339ex\" loading=\"lazy\" decoding=\"async\"></span>; that is a copying slip.</p>\r\n</section>\r\n"},{"id":"q2b","title":"Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Read the derivation’s symbols first</h2><p>“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. λ<sub>k</sub><sup>i</sup> in some notes is the same responsibility that other sections call γ<sub>ik</sub>. A superscript i here labels the observation, not an exponent.</p><p>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.</p><table><thead><tr><th>Parameter</th><th>Number in a 1D K-component GMM</th><th>Why</th></tr></thead><tbody><tr><td>Means</td><td>K</td><td>One centre for each component</td></tr><tr><td>Variances</td><td>K</td><td>One spread for each component</td></tr><tr><td>Independent mixing weights</td><td>K−1</td><td>The last weight is 1 minus the others</td></tr><tr><td>Total</td><td>3K−1</td><td>K+K+(K−1)</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n\r\n\r\n<div class=\"answer-box\">\r\n<h3>1. GMM versus k-means</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Aspect</th><th>k-means</th><th>GMM</th></tr></thead><tbody>\r\n<tr><td>Assignment</td><td>Hard: each point in exactly one cluster</td><td>Soft: probability <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> of belonging to each cluster</td></tr>\r\n<tr><td>Model</td><td>Geometric: nearest centroid</td><td>Probabilistic generative model <span class=\"math-inline\"><img src=\"math/04ce4e1e89065414.svg\" alt=\"\\sum_k\\pi_k\\mathcal N(\\mu_k,\\Sigma_k)\" style=\"width:16.12ex;height:2.448ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Cluster shape</td><td>Spherical, similar size</td><td>Elliptical, any size/orientation; overlapping clusters</td></tr>\r\n<tr><td>Parameters</td><td>K centroids</td><td>Weights, means, covariances (1-D: 3K − 1)</td></tr>\r\n<tr><td>Algorithm / objective</td><td>Assign–update; minimise squared distances</td><td>EM; maximise log-likelihood</td></tr>\r\n<tr><td>Output</td><td>Hard labels and fitted centroids</td><td>Labels, membership probabilities and a density (useful for anomaly detection)</td></tr>\r\n<tr><td>Relation</td><td colspan=\"2\">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.</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>2. Derivation of the log-likelihood</h3>\r\n<p><strong>Step 1. Model.</strong> Each point is generated by choosing component k with probability <span class=\"math-inline\"><img src=\"math/e60970d7047375ff.svg\" alt=\"\\pi_k\" style=\"width:2.311ex;height:1.332ex\" loading=\"lazy\" decoding=\"async\"></span> and drawing <span class=\"math-inline\"><img src=\"math/f66cfb5e517110e8.svg\" alt=\"x_i\\sim\\mathcal N(\\mu_k,\\sigma_k^2)\" style=\"width:14.731ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>, so its density is <span class=\"math-inline\"><img src=\"math/6550a4aaf9e87286.svg\" alt=\"f_{mix}(x_i)=\\sum_k\\pi_k\\mathcal N(x_i\\mid\\mu_k,\\sigma_k^2)\" style=\"width:30.677ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<p><strong>Step 2. Likelihood.</strong> Points are i.i.d., so the likelihood is a product (θ = all parameters):</p>\r\n<div class=\"math-display\"><img src=\"math/41dc390b2652cd78.svg\" alt=\"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]\" style=\"width:35.259ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 3. Log-likelihood.</strong> Logs turn the product into a sum:</p>\r\n<div class=\"math-display\"><img src=\"math/9a0bb26e3ef13adb.svg\" alt=\"\\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)\" style=\"width:42.737ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 4. Why it cannot be solved directly.</strong> The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.</p>\r\n<p><strong>Step 5. Jensen's inequality.</strong> log is concave, so for weights <span class=\"math-inline\"><img src=\"math/5006fcb64f6c3cf6.svg\" alt=\"\\lambda_k\\ge0,\\;\\sum\\lambda_k=1\" style=\"width:17.378ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: <span class=\"math-inline\"><img src=\"math/742b7c09a1ce32a4.svg\" alt=\"\\log\\big(\\sum_k\\lambda_ka_k\\big)\\ge\\sum_k\\lambda_k\\log a_k\" style=\"width:29.072ex;height:2.713ex\" loading=\"lazy\" decoding=\"async\"></span>. Introduce <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> for every point (<span class=\"math-inline\"><img src=\"math/fbe0441b97e0b9c1.svg\" alt=\"\\sum_k\\lambda_k^i=1\" style=\"width:10.276ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span>), multiply and divide inside the log:</p>\r\n<div class=\"math-display\"><img src=\"math/06dff5bae3d2cfe1.svg\" alt=\"\\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}\" style=\"width:78.361ex;height:6.391ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 6. Estimation (EM).</strong> Maximise the lower bound alternately. Fixing θ gives the E-step <span class=\"math-inline\"><img src=\"math/662cdc674fe7b2c5.svg\" alt=\"\\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)\" style=\"width:41.37ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></span>. Fixing λ and differentiating (with a Lagrange multiplier for <span class=\"math-inline\"><img src=\"math/131aa1c87311a5f9.svg\" alt=\"\\sum\\pi_k=1\" style=\"width:9.225ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>) gives the M-step:</p>\r\n<div class=\"math-display\"><img src=\"math/ffbe3f9b626d2a86.svg\" alt=\"\\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}\" style=\"width:59.614ex;height:6.179ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h3>3. Number of parameters for K = 5</h3><p>The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:</p>\r\n<div class=\"math-display\"><img src=\"math/5d57bdfd8f83239c.svg\" alt=\"2K+(K-1)=3K-1=3(5)-1=\\mathbf{14}\" style=\"width:40.189ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>(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.</p>\r\n</div>\r\n<div class=\"keyfix\"><strong>Slide note.</strong> One slide puts the convex inequality under the “concave” heading. Correct: log is <em>concave</em>, so <span class=\"math-inline\"><img src=\"math/2ddf537dc44d74a6.svg\" alt=\"f(\\sum\\lambda a)\\ge\\sum\\lambda f(a)\" style=\"width:19.59ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (≥, not &gt;).</div>\r\n"},{"id":"q3a","title":"Q3(a) Bayesian network: wet grass given no rain [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>C→S, C→R, (S,R)→W. Root and conditional probabilities are listed in the question. Evidence R=false.</p><h4>To find</h4><p>P(W=true | R=false). Hidden variables C and S must be summed out.</p></div><h4>Formula and why it applies</h4><p>Use the network joint and divide by the evidence probability. <div class=\"math-display\"><img src=\"math/ec8db3b28ef749de.svg\" alt=\"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)}\" style=\"width:54.182ex;height:5.963ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/bn_sprinkler.a251583272.svg\" width=\"600\" height=\"360\" alt=\"Final 2025 Q3a: sprinkler network\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<div class=\"step\"><h5>Step 1. Joint by the chain rule</h5><div class=\"math-display\"><img src=\"math/62a8884ca57ac2e6.svg\" alt=\"P(C,S,R,W)=P(C)\\,P(S\\mid C)\\,P(R\\mid C)\\,P(W\\mid S,R)\" style=\"width:52.278ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Sum over C and S with R = false, W = true</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>C</th><th>S</th><th>P(C)</th><th>P(S|C)</th><th>P(¬R|C)</th><th>P(W|S,¬R)</th><th>Product</th></tr></thead><tbody>\r\n<tr><td>T</td><td>T</td><td>0.5</td><td>0.1</td><td>0.2</td><td>0.90</td><td>0.0090</td></tr>\r\n<tr><td>T</td><td>F</td><td>0.5</td><td>0.9</td><td>0.2</td><td>0.01</td><td>0.0009</td></tr>\r\n<tr><td>F</td><td>T</td><td>0.5</td><td>0.5</td><td>0.8</td><td>0.90</td><td>0.1800</td></tr>\r\n<tr><td>F</td><td>F</td><td>0.5</td><td>0.5</td><td>0.8</td><td>0.01</td><td>0.0020</td></tr>\r\n<tr><td colspan=\"6\"><strong>P(W, ¬R)</strong></td><td><strong>0.1919</strong></td></tr></tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Evidence</h5><div class=\"math-display\"><img src=\"math/97de213766352c7b.svg\" alt=\"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\" style=\"width:73.203ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/c18c31810569b62d.svg\" alt=\"P(W\\mid\\lnot R)=\\frac{0.1919}{0.5}=0.3838\" style=\"width:30.542ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> P(grass wet | no rain) ≈ <strong>0.384</strong>. Without rain, the grass is wet mainly when the sprinkler runs (more likely on non-cloudy days).</div>\r\n<div class=\"keyfix\"><strong>Keep the requested conditional probability separate.</strong> 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.</div>\r\n<h4>Optional comparison: calculate P(Wet) from the same network</h4>\r\n<p>The four no-rain cases already total 0.1919. Now add the four rain cases, keeping the same Cloudy/Sprinkler order.</p>\r\n<div class=\"math-display\"><img src=\"math/fa867c388246e93b.svg\" alt=\"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)\" style=\"width:91.777ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/43750abdd00f3218.svg\" alt=\"P(W,R)=0.0396+0.324+0.0495+0.045=0.4581\" style=\"width:52.048ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/9357fadf4faa85ed.svg\" alt=\"P(W)=P(W,R)+P(W,\\neg R)=0.4581+0.1919=0.6500\" style=\"width:57.884ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/a03cc788f3ded23d.svg\" alt=\"P(R\\mid W)=\\frac{0.4581}{0.6500}\\approx0.704769231\" style=\"width:34.689ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Meaning:</strong> 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.</p>\r\n<div class=\"trap\"><strong>Trap.</strong> 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).</div>\r\n</section>\r\n"},{"id":"q3b","title":"Q3(b) Fuzzy loan-approval system [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Crisp value</th></tr></thead><tbody><tr><td>Credit Score</td><td>55</td></tr><tr><td>Income Stability</td><td>35</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>A complete stated design and its continuous Mamdani centroid.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/5aa4acd6aab4215a.svg\" alt=\"z^*=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:18.101ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Specify the membership functions</h5><table><thead><tr><th>Input / output position</th><th>Triangle</th><th>Peak</th></tr></thead><tbody><tr><td>Low / Reject</td><td>(1,25,50)</td><td>25</td></tr><tr><td>Medium / Consider</td><td>(25,50,75)</td><td>50</td></tr><tr><td>High / Approve</td><td>(50,75,100)</td><td>75</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 2. Write all nine rules</h5><table><thead><tr><th>Credit Score / Income Stability</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Reject</td><td>Reject</td><td>Consider</td></tr><tr><td>Medium</td><td>Reject</td><td>Consider</td><td>Approve</td></tr><tr><td>High</td><td>Consider</td><td>Approve</td><td>Approve</td></tr></tbody></table><p>Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.</p></div><div class=\"step\"><h5>Step 3. Fuzzify Credit Score = 55</h5><div class=\"math-display\"><img src=\"math/b1adf4cfc2121094.svg\" alt=\"\\mu_{Low}(55)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0625f25570fc580f.svg\" alt=\"\\mu_{Medium}(55)=\\frac{75-55}{75-50}=0.8\" style=\"width:28.917ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6f64cb8c41f3eca0.svg\" alt=\"\\mu_{High}(55)=\\frac{55-50}{75-50}=0.2\" style=\"width:26.443ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Fuzzify Income Stability = 35</h5><div class=\"math-display\"><img src=\"math/c3eeae587085fbae.svg\" alt=\"\\mu_{Low}(35)=\\frac{50-35}{50-25}=0.6\" style=\"width:25.797ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d607a558d66f8791.svg\" alt=\"\\mu_{Medium}(35)=\\frac{35-25}{50-25}=0.4\" style=\"width:28.917ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1509e75effd66d75.svg\" alt=\"\\mu_{High}(35)=0\" style=\"width:13.38ex;height:2.364ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Evaluate all rules and aggregate matching consequents</h5><table><thead><tr><th>Credit Score</th><th>Income Stability</th><th>Firing strength</th><th>Consequent</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>min(0,0.6) = 0</td><td>Reject</td></tr><tr><td>Low</td><td>Medium</td><td>min(0,0.4) = 0</td><td>Reject</td></tr><tr><td>Low</td><td>High</td><td>min(0,0) = 0</td><td>Consider</td></tr><tr><td>Medium</td><td>Low</td><td>min(0.8,0.6) = 0.6</td><td>Reject</td></tr><tr><td>Medium</td><td>Medium</td><td>min(0.8,0.4) = 0.4</td><td>Consider</td></tr><tr><td>Medium</td><td>High</td><td>min(0.8,0) = 0</td><td>Approve</td></tr><tr><td>High</td><td>Low</td><td>min(0.2,0.6) = 0.2</td><td>Consider</td></tr><tr><td>High</td><td>Medium</td><td>min(0.2,0.4) = 0.2</td><td>Approve</td></tr><tr><td>High</td><td>High</td><td>min(0.2,0) = 0</td><td>Approve</td></tr></tbody></table><p>Aggregated label strengths: Reject = 0.6, Consider = 0.4, Approve = 0.2.</p><div class=\"math-display\"><img src=\"math/d1c2a08444481d0c.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:29.283ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Draw the aggregated output</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_loan_aggregate.2c5ffa32a7.svg\" width=\"680\" height=\"300\" alt=\"The shaded upper envelope counts any overlap only once.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The shaded upper envelope counts any overlap only once.</figcaption></figure></div><div class=\"step\"><h5>Step 7. Calculate area and moment of each straight-line strip</h5><p>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.</p><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d68335c9ce0df62c.svg\" alt=\"M=\\frac{b-a}{6}\\big[(2a+b)u+(a+2b)v\\big]\" style=\"width:34.017ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>1</td><td>15.4</td><td>0</td><td>0.6</td><td>4.32</td><td>45.792</td></tr><tr><td>15.4</td><td>25</td><td>0.6</td><td>0.6</td><td>5.76</td><td>116.352</td></tr><tr><td>25</td><td>35</td><td>0.6</td><td>0.6</td><td>6</td><td>180</td></tr><tr><td>35</td><td>40</td><td>0.6</td><td>0.4</td><td>2.5</td><td>93.333333333</td></tr><tr><td>40</td><td>50</td><td>0.4</td><td>0.4</td><td>4</td><td>180</td></tr><tr><td>50</td><td>55</td><td>0.4</td><td>0.4</td><td>2</td><td>105</td></tr><tr><td>55</td><td>65</td><td>0.4</td><td>0.4</td><td>4</td><td>240</td></tr><tr><td>65</td><td>70</td><td>0.4</td><td>0.2</td><td>1.5</td><td>100.833333333</td></tr><tr><td>70</td><td>75</td><td>0.2</td><td>0.2</td><td>1</td><td>72.5</td></tr><tr><td>75</td><td>95</td><td>0.2</td><td>0.2</td><td>4</td><td>340</td></tr><tr><td>95</td><td>100</td><td>0.2</td><td>0</td><td>0.5</td><td>48.333333333</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Divide total moment by total area</h5><div class=\"math-display\"><img src=\"math/04fe6e4450abbfe1.svg\" alt=\"\\sum A=35.58\" style=\"width:13.512ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/db33614c63a7fe19.svg\" alt=\"\\sum M=1522.144\" style=\"width:17.586ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dd239737d0e6ec58.svg\" alt=\"z^*=\\frac{1522.144}{35.58}\\approx42.780888139\" style=\"width:30.689ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:centroid-working:start -->\r\n<div class=\"concept-bridge\"><h2>How the centroid table’s breakpoints are obtained</h2><p>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.</p><p>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.</p><section class=\"example\"><p class=\"question\"><strong>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.</strong> <span class=\"marks\">[3 marks · Worked example]</span></p><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>A and M for one table row.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ee3fb707739e8b69.svg\" alt=\"M=\\frac{b-a}{6}[(2a+b)u+(a+2b)v]\" style=\"width:33.388ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><p>A is trapezoid area. M weights every small area by its horizontal position; this formula integrates a straight line.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Width and height sum</h5><div class=\"math-display\"><img src=\"math/49c4a9b06649aac9.svg\" alt=\"b-a=15.4-1=14.4\\qquad u+v=0.6\" style=\"width:38.5ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 2. Area</h5><div class=\"math-display\"><img src=\"math/344db3e57e5c18d1.svg\" alt=\"A=14.4\\times0.6/2=8.64/2=4.32\" style=\"width:32.998ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 3. First bracket term</h5><div class=\"math-display\"><img src=\"math/f077b4473411d432.svg\" alt=\"(2a+b)u=(2+15.4)\\times0=0\" style=\"width:29.861ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Second bracket term</h5><div class=\"math-display\"><img src=\"math/79c1733b7155a919.svg\" alt=\"(a+2b)v=(1+30.8)\\times0.6=31.8\\times0.6=19.08\" style=\"width:48.144ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Moment</h5><div class=\"math-display\"><img src=\"math/26cef63984606712.svg\" alt=\"M=(14.4/6)(0+19.08)=2.4\\times19.08=45.792\" style=\"width:47.381ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> Area=4.32; moment=45.792. Repeat the same arithmetic for each row, then sum the areas and moments separately.</div></section></div>\r\n<!-- depth:centroid-working:end --><h3>Interpret the loan result using an explicit decision rule</h3><p>Choose the output label having the greatest membership at the centroid; this is an additional stated interpretation rule. At z=42.780888139:</p><div class=\"math-display\"><img src=\"math/388fb9433b0d08db.svg\" alt=\"\\mu_{Reject}=(50-z)/25\\approx0.288764474,\\quad\\mu_{Consider}=(z-25)/25\\approx0.711235526,\\quad\\mu_{Approve}=0\" style=\"width:90.776ex;height:2.363ex\" loading=\"lazy\" decoding=\"async\"></div><p>The resulting recommendation is <strong>Consider / manual review</strong>; 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.</p>"},{"id":"q4a","title":"Q4(a) Cartesian product and max–min composition [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The fuzzy sets or relation matrices and their listed row/column order.</p><h4>To find</h4><p>The relation matrix/matrices and the composition specified in the question.</p></div><h4>Formula and why it applies</h4><p>For Cartesian products take min of row and column membership. For the ordered matrix composition shown here: <div class=\"math-display\"><img src=\"math/1a39e95150df91b7.svg\" alt=\"T_{ik}=\\max_j\\min(S_{ij},R_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div> If max–product is asked instead, replace the inner min by multiplication.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. R = A × B (rows small, medium, large; columns slow, moderate, fast)</h5>\r\n<div class=\"math-display\"><img src=\"math/9db67d15872888f6.svg\" alt=\"R=\\begin{bmatrix}\\min(.4,.2)&amp;\\min(.4,.7)&amp;\\min(.4,.3)\\\\\\min(.3,.2)&amp;\\min(.3,.7)&amp;\\min(.3,.3)\\\\\\min(.1,.2)&amp;\\min(.1,.7)&amp;\\min(.1,.3)\\end{bmatrix}=\\begin{bmatrix}0.2&amp;0.4&amp;0.3\\\\0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\end{bmatrix}\" style=\"width:61.686ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. S = C × B</h5>\r\n<div class=\"math-display\"><img src=\"math/03c1b332a4b4facf.svg\" alt=\"S=\\begin{bmatrix}0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\\\0.2&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:20.694ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. S ∘ R by max–min (row of S with column of R)</h5>\r\n<p>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.</p>\r\n<div class=\"math-display\"><img src=\"math/2134a14de60dd459.svg\" alt=\"(1,1)=\\max[\\min(.2,.2),\\min(.3,.2),\\min(.3,.1)]=\\max(.2,.2,.1)=0.2\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/b81568f26ae092d4.svg\" alt=\"(1,2)=\\max[\\min(.2,.4),\\min(.3,.3),\\min(.3,.1)]=\\max(.2,.3,.1)=0.3\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/0857c1f332a31d0c.svg\" alt=\"(1,3)=\\max[\\min(.2,.3),\\min(.3,.3),\\min(.3,.1)]=0.3\" style=\"width:51.609ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Row 2 of S is all 0.1, so every entry of row 2 is 0.1.</p>\r\n<div class=\"math-display\"><img src=\"math/7cbca4576287a20a.svg\" alt=\"(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\" style=\"width:108.309ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/564480fc64ab9d52.svg\" alt=\"S\\circ R=\\begin{bmatrix}0.2&amp;0.3&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\\\0.2&amp;0.3&amp;0.3\\end{bmatrix}\" style=\"width:24.548ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> 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.</div>\r\n<div class=\"note\"><strong>A careful remark you can add.</strong> 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.</div>\r\n</section>\r\n\r\n<!-- depth:all-cells:start -->\r\n<div class=\"concept-bridge\"><h2>Every cell without the row shortcuts</h2><p>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.</p><h3>R: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>R11</td><td>0.4</td><td>0.2</td><td>0.2</td></tr><tr><td>R12</td><td>0.4</td><td>0.7</td><td>0.4</td></tr><tr><td>R13</td><td>0.4</td><td>0.3</td><td>0.3</td></tr><tr><td>R21</td><td>0.3</td><td>0.2</td><td>0.2</td></tr><tr><td>R22</td><td>0.3</td><td>0.7</td><td>0.3</td></tr><tr><td>R23</td><td>0.3</td><td>0.3</td><td>0.3</td></tr><tr><td>R31</td><td>0.1</td><td>0.2</td><td>0.1</td></tr><tr><td>R32</td><td>0.1</td><td>0.7</td><td>0.1</td></tr><tr><td>R33</td><td>0.1</td><td>0.3</td><td>0.1</td></tr></tbody></table><h3>S: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>S11</td><td>0.3</td><td>0.2</td><td>0.2</td></tr><tr><td>S12</td><td>0.3</td><td>0.7</td><td>0.3</td></tr><tr><td>S13</td><td>0.3</td><td>0.3</td><td>0.3</td></tr><tr><td>S21</td><td>0.1</td><td>0.2</td><td>0.1</td></tr><tr><td>S22</td><td>0.1</td><td>0.7</td><td>0.1</td></tr><tr><td>S23</td><td>0.1</td><td>0.3</td><td>0.1</td></tr><tr><td>S31</td><td>0.4</td><td>0.2</td><td>0.2</td></tr><tr><td>S32</td><td>0.4</td><td>0.7</td><td>0.4</td></tr><tr><td>S33</td><td>0.4</td><td>0.3</td><td>0.3</td></tr></tbody></table><p><strong>Result cell (1,1)</strong></p><div class=\"math-display\"><img src=\"math/04a79caa9a98c1c4.svg\" alt=\"\\max\\{\\min(0.2,0.2),\\min(0.3,0.2),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,2)</strong></p><div class=\"math-display\"><img src=\"math/fb42face9e153c77.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.3,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,3)</strong></p><div class=\"math-display\"><img src=\"math/4535d46543709132.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.3,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,1)</strong></p><div class=\"math-display\"><img src=\"math/b8bd41528e9d1a36.svg\" alt=\"\\max\\{\\min(0.1,0.2),\\min(0.1,0.2),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,2)</strong></p><div class=\"math-display\"><img src=\"math/9eda900daa88d0f0.svg\" alt=\"\\max\\{\\min(0.1,0.4),\\min(0.1,0.3),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,3)</strong></p><div class=\"math-display\"><img src=\"math/a0554ac89675d583.svg\" alt=\"\\max\\{\\min(0.1,0.3),\\min(0.1,0.3),\\min(0.1,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2caac33b19e2f71f.svg\" alt=\"=\\max\\{0.1,0.1,0.1\\}=0.1\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,1)</strong></p><div class=\"math-display\"><img src=\"math/7738d5099a9e3ab1.svg\" alt=\"\\max\\{\\min(0.2,0.2),\\min(0.4,0.2),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,2)</strong></p><div class=\"math-display\"><img src=\"math/952b0167063f5e45.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,3)</strong></p><div class=\"math-display\"><img src=\"math/859d029599adbb59.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/6d394999310022b5.svg\" alt=\"=\\max\\{0.2,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:all-cells:end -->"},{"id":"q4b","title":"Q4(b) Naive Bayes: flu [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>The full training data are in Step 1. Query: Fever=Yes, Cough=Yes, Temperature=Normal. The main calculation uses unsmoothed counts.</p><h4>To find</h4><p>Both class scores and the predicted class.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/e0195b1e4ddb0473.svg\" alt=\"score(C)=P(C)\\prod_jP(a_j\\mid C)\" style=\"width:29.642ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the training rows as a table</h5><table><thead><tr><th>Row</th><th>Fever</th><th>Cough</th><th>Temperature</th><th>Class</th></tr></thead><tbody><tr><td>1</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>2</td><td>No</td><td>No</td><td>Normal</td><td>No</td></tr><tr><td>3</td><td>Yes</td><td>No</td><td>Low</td><td>No</td></tr><tr><td>4</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>5</td><td>No</td><td>Yes</td><td>Normal</td><td>No</td></tr><tr><td>6</td><td>Yes</td><td>Yes</td><td>High</td><td>Yes</td></tr><tr><td>7</td><td>No</td><td>No</td><td>Low</td><td>No</td></tr><tr><td>8</td><td>Yes</td><td>No</td><td>Normal</td><td>No</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Separate the two class groups</h5><table><thead><tr><th>Class</th><th>Rows in this group</th><th>Class count</th><th>Prior</th></tr></thead><tbody><tr><td>Yes</td><td>1, 4, 6</td><td>3</td><td>3/8 = 0.375</td></tr><tr><td>No</td><td>2, 3, 5, 7, 8</td><td>5</td><td>5/8 = 0.625</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. For class Yes, count Fever=Yes</h5><p>Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.</p><div class=\"math-display\"><img src=\"math/bf71c2b5401bc336.svg\" alt=\"P(\\text{Fever}=\\text{Yes}\\mid C=\\text{Yes})=\\frac{3}{3}=1\" style=\"width:35.144ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. For class Yes, count Cough=Yes</h5><p>Look only at class Yes rows 1, 4, 6. The matching rows are 1, 4, 6.</p><div class=\"math-display\"><img src=\"math/a6ffcdb19b7e5a36.svg\" alt=\"P(\\text{Cough}=\\text{Yes}\\mid C=\\text{Yes})=\\frac{3}{3}=1\" style=\"width:35.988ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. For class Yes, count Temperature=Normal</h5><p>Look only at class Yes rows 1, 4, 6. No row in this class has that feature value.</p><div class=\"math-display\"><img src=\"math/2bcd33037561157b.svg\" alt=\"P(\\text{Temperature}=\\text{Normal}\\mid C=\\text{Yes})=\\frac{0}{3}=0\" style=\"width:46.176ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the Yes score one factor at a time</h5><div class=\"math-display\"><img src=\"math/c3f053c53b40a9b7.svg\" alt=\"P(Yes)=3/8=0.375\" style=\"width:21.883ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f8249f6f69de64a.svg\" alt=\"0.375\\times1=0.375\" style=\"width:17.222ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f8249f6f69de64a.svg\" alt=\"0.375\\times1=0.375\" style=\"width:17.222ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e5245fc04fe5be62.svg\" alt=\"0.375\\times0=0\" style=\"width:13.199ex;height:1.715ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. For class No, count Fever=Yes</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 3, 8.</p><div class=\"math-display\"><img src=\"math/2feb71df5b426bfc.svg\" alt=\"P(\\text{Fever}=\\text{Yes}\\mid C=\\text{No})=\\frac{2}{5}=0.4\" style=\"width:36.14ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. For class No, count Cough=Yes</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/d406a69469adaf9b.svg\" alt=\"P(\\text{Cough}=\\text{Yes}\\mid C=\\text{No})=\\frac{1}{5}=0.2\" style=\"width:36.984ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. For class No, count Temperature=Normal</h5><p>Look only at class No rows 2, 3, 5, 7, 8. The matching rows are 2, 5, 8.</p><div class=\"math-display\"><img src=\"math/738acde5b7f3afea.svg\" alt=\"P(\\text{Temperature}=\\text{Normal}\\mid C=\\text{No})=\\frac{3}{5}=0.6\" style=\"width:47.171ex;height:4.636ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Multiply the No score one factor at a time</h5><div class=\"math-display\"><img src=\"math/b83bf0fcbd8f3bee.svg\" alt=\"P(No)=5/8=0.625\" style=\"width:21.147ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ccabec7597d2610a.svg\" alt=\"0.625\\times0.4=0.25\" style=\"width:17.851ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4b7931095eb1884c.svg\" alt=\"0.25\\times0.2=0.05\" style=\"width:16.719ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fcec3b47d13c61a4.svg\" alt=\"0.05\\times0.6=0.03\" style=\"width:16.719ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Compare the scores</h5><div class=\"math-display\"><img src=\"math/9f7a6514218ef651.svg\" alt=\"score(Yes)=0\\qquad score(No)=0.03\" style=\"width:36.607ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The larger score belongs to No. Normalise only if a posterior probability is requested: divide each score by their total 0.03.</p></div><div class=\"answer\"><strong>Final answer.</strong> Predict No. Yes score=0; No score=0.03.</div></section><p>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.</p><p class=\"memory\"><strong>Yaad rakho:</strong> Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.</p>"},{"id":"q5a","title":"Q5(a) Hotel guest movement (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: P, L, R. Initial vector [50, 30, 20].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>P</th><th>L</th><th>R</th></tr></thead><tbody><tr><td>P</td><td>0.6</td><td>0.25</td><td>0.15</td></tr><tr><td>L</td><td>0.3</td><td>0.5</td><td>0.2</td></tr><tr><td>R</td><td>0.2</td><td>0.3</td><td>0.5</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_hotel.55f5204329.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to P</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to P</th><th>Contribution</th></tr></thead><tbody><tr><td>P</td><td>50</td><td>0.6</td><td>50 × 0.6 = 30</td></tr><tr><td>L</td><td>30</td><td>0.3</td><td>30 × 0.3 = 9</td></tr><tr><td>R</td><td>20</td><td>0.2</td><td>20 × 0.2 = 4</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/26b7dba609bb77e3.svg\" alt=\"P_{new}=30+9+4=43\" style=\"width:22.844ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to L</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to L</th><th>Contribution</th></tr></thead><tbody><tr><td>P</td><td>50</td><td>0.25</td><td>50 × 0.25 = 12.5</td></tr><tr><td>L</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr><tr><td>R</td><td>20</td><td>0.3</td><td>20 × 0.3 = 6</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/141ce72082fe6ed8.svg\" alt=\"L_{new}=12.5+15+6=33.5\" style=\"width:27.584ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to R</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to R</th><th>Contribution</th></tr></thead><tbody><tr><td>P</td><td>50</td><td>0.15</td><td>50 × 0.15 = 7.5</td></tr><tr><td>L</td><td>30</td><td>0.2</td><td>30 × 0.2 = 6</td></tr><tr><td>R</td><td>20</td><td>0.5</td><td>20 × 0.5 = 10</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/1cfa32a9ab8dc27f.svg\" alt=\"R_{new}=7.5+6+10=23.5\" style=\"width:26.629ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: write the Paris equation</h5><div class=\"math-display\"><img src=\"math/a8c5e214edbb94e4.svg\" alt=\"p=0.6p+0.3l+0.2r\" style=\"width:21.193ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bf5256a21829e5b4.svg\" alt=\"0.4p=0.3l+0.2r\" style=\"width:17.29ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><p>Divide every term by .4.</p><div class=\"math-display\"><img src=\"math/e7f829189002f918.svg\" alt=\"p=0.75l+0.5r\" style=\"width:15.529ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Write the London equation and substitute p</h5><div class=\"math-display\"><img src=\"math/809047184e208e3d.svg\" alt=\"l=0.25p+0.5l+0.3r\" style=\"width:21.861ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f791f1205fe97449.svg\" alt=\"0.5l=0.25(0.75l+0.5r)+0.3r\" style=\"width:30.417ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/bc67c26ec7fc1e90.svg\" alt=\"0.5l=0.1875l+0.125r+0.3r\" style=\"width:29.159ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Collect like terms</h5><div class=\"math-display\"><img src=\"math/ac05d4785e692e11.svg\" alt=\"(0.5-0.1875)l=(0.125+0.3)r\" style=\"width:30.985ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d21c86c6a141bc54.svg\" alt=\"0.3125l=0.425r\\quad\\Rightarrow\\quad l=1.36r\" style=\"width:32.929ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af26ae261b198416.svg\" alt=\"p=0.75(1.36r)+0.5r=1.52r\" style=\"width:29.718ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. Use total probability to get all three shares</h5><div class=\"math-display\"><img src=\"math/936703629ebeff23.svg\" alt=\"p+l+r=1\\quad\\Rightarrow\\quad1.52r+1.36r+r=1\" style=\"width:41.343ex;height:2.009ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/76317a80ed92e6f4.svg\" alt=\"3.88r=1\\quad r=1/3.88=25/97\" style=\"width:30.449ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/442f9f9b9a48c0ce.svg\" alt=\"l=1.36(25/97)=34/97\\quad p=1.52(25/97)=38/97\" style=\"width:50.333ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>P</td><td>0.5</td><td>0.391752577</td><td>-0.108247423</td><td>Loses</td></tr><tr><td>L</td><td>0.3</td><td>0.350515464</td><td>0.050515464</td><td>Gains</td></tr><tr><td>R</td><td>0.2</td><td>0.257731959</td><td>0.057731959</td><td>Gains</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [43.0, 33.5, 23.5]. Stationary shares ≈ [0.391752577, 0.350515464, 0.257731959]. P loses, L gains, R gains.</div></section>"},{"id":"q5b","title":"Q5(b) Genetic algorithm [10]","html":"<p class=\"question\"><strong>Implement a GA to maximise <span class=\"math-inline\"><img src=\"math/aacd674038ffd6be.svg\" alt=\"f(x)=2x^3-5x^2+7x\" style=\"width:22.099ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> 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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><p><strong>The printed data are inconsistent.</strong> 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.</p><p>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.</p><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Two valid children under the declared assumptions and their fitness.</p></div><h4>Formula and why it applies</h4><p>Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.</p><div class=\"math-display\"><img src=\"math/fb065d212fc56261.svg\" alt=\"f(x)=2x^3-5x^2+7x\" style=\"width:22.099ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Encode and evaluate the declared parent population</h5><table><thead><tr><th>x</th><th>Binary</th><th>Fitness substitution</th></tr></thead><tbody><tr><td>13</td><td>1101</td><td>2(13³) − 5(13²) + 7(13) = 3640</td></tr><tr><td>6</td><td>0110</td><td>2(6³) − 5(6²) + 7(6) = 294</td></tr><tr><td>2</td><td>0010</td><td>2(2³) − 5(2²) + 7(2) = 10</td></tr><tr><td>7</td><td>0111</td><td>2(7³) − 5(7²) + 7(7) = 490</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Select the two fittest under the stated assumption</h5><p>[13, 7] with fitness [3640, 490].</p></div><div class=\"step\"><h5>Step 3. Cut after bit 2 and exchange tails</h5><table><thead><tr><th>Parent 1</th><th>Parent 2</th><th>Child 1</th><th>Child 2</th></tr></thead><tbody><tr><td>11 | 01</td><td>01 | 11</td><td>1111</td><td>0101</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Flip the last bit of each child</h5><table><thead><tr><th>Before</th><th>After</th><th>Decoded x</th></tr></thead><tbody><tr><td>1111</td><td>1110</td><td>14</td></tr><tr><td>0101</td><td>0100</td><td>4</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Evaluate both children</h5><table><thead><tr><th>x</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>14</td><td>2(2744) − 5(196) + 7(14) = 4606</td></tr><tr><td>4</td><td>2(64) − 5(16) + 7(4) = 76</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Compare with the selected parents</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:polynomial-working:start -->\r\n<div class=\"concept-bridge\"><h2>Evaluate the polynomial without skipping the powers</h2><p>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.</p><h3>x=13</h3><div class=\"math-display\"><img src=\"math/3b2d51c91ac2cf33.svg\" alt=\"x^2=13\\times13=169\\qquad x^3=169\\times13=2197\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b223b59b645fb4b2.svg\" alt=\"2x^3=4394\\quad 5x^2=845\\quad 7x=91\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/729d7b573feaaf95.svg\" alt=\"f(13)=4394-845+91=3640\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=6</h3><div class=\"math-display\"><img src=\"math/4a05c63ed6e04319.svg\" alt=\"x^2=6\\times6=36\\qquad x^3=36\\times6=216\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/402fc08edced6189.svg\" alt=\"2x^3=432\\quad 5x^2=180\\quad 7x=42\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a5f219480ddd154a.svg\" alt=\"f(6)=432-180+42=294\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=2</h3><div class=\"math-display\"><img src=\"math/3a35f3beb07d2871.svg\" alt=\"x^2=2\\times2=4\\qquad x^3=4\\times2=8\" style=\"width:33.476ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/42f55d86ed2302e7.svg\" alt=\"2x^3=16\\quad 5x^2=20\\quad 7x=14\" style=\"width:29.615ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/235889b9921ff9b5.svg\" alt=\"f(2)=16-20+14=10\" style=\"width:24.751ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=7</h3><div class=\"math-display\"><img src=\"math/eac1f56ad09d694c.svg\" alt=\"x^2=7\\times7=49\\qquad x^3=49\\times7=343\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e9a8667a88c96f77.svg\" alt=\"2x^3=686\\quad 5x^2=245\\quad 7x=49\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8c54966ea16cb628.svg\" alt=\"f(7)=686-245+49=490\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=15</h3><div class=\"math-display\"><img src=\"math/8c2aaf117e33ac77.svg\" alt=\"x^2=15\\times15=225\\qquad x^3=225\\times15=3375\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9652ff9e90959bb5.svg\" alt=\"2x^3=6750\\quad 5x^2=1125\\quad 7x=105\" style=\"width:35.271ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1609c9dac811fd7a.svg\" alt=\"f(15)=6750-1125+105=5730\" style=\"width:33.801ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=5</h3><div class=\"math-display\"><img src=\"math/63703f64d73bd95d.svg\" alt=\"x^2=5\\times5=25\\qquad x^3=25\\times5=125\" style=\"width:38ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c7ab1b91c2eced73.svg\" alt=\"2x^3=250\\quad 5x^2=125\\quad 7x=35\" style=\"width:31.877ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b80fc8e2e02f0c86.svg\" alt=\"f(5)=250-125+35=160\" style=\"width:28.145ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=14</h3><div class=\"math-display\"><img src=\"math/13e67d57f1606f3f.svg\" alt=\"x^2=14\\times14=196\\qquad x^3=196\\times14=2744\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7a11853924c667dd.svg\" alt=\"2x^3=5488\\quad 5x^2=980\\quad 7x=98\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4be8ca3a4ac49622.svg\" alt=\"f(14)=5488-980+98=4606\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=4</h3><div class=\"math-display\"><img src=\"math/9c1546066fc40eda.svg\" alt=\"x^2=4\\times4=16\\qquad x^3=16\\times4=64\" style=\"width:36.869ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a4dd7bf5365d3c7e.svg\" alt=\"2x^3=128\\quad 5x^2=80\\quad 7x=28\" style=\"width:30.746ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/818af979753c0a98.svg\" alt=\"f(4)=128-80+28=76\" style=\"width:25.882ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>“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.</p></div>\r\n<!-- depth:polynomial-working:end -->"},{"id":"q6a","title":"Q6(a) Applications of fuzzy logic [10]","html":"<p class=\"question\"><strong>List the applications of fuzzy logic. Explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition</h3>\r\n<p>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”.</p>\r\n<h3>Applications</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Area</th><th>Examples</th></tr></thead><tbody>\r\n<tr><td>Home appliances</td><td>Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners</td></tr>\r\n<tr><td>Automotive</td><td>Automatic transmission, anti-lock braking (ABS), cruise control, engine control</td></tr>\r\n<tr><td>Transportation</td><td>Traffic-signal control, Sendai subway train control (smooth braking and acceleration)</td></tr>\r\n<tr><td>Consumer electronics</td><td>Camera autofocus and auto-exposure, image stabilisation</td></tr>\r\n<tr><td>Industrial control</td><td>Cement kilns, pH, temperature and distillation control in chemical plants</td></tr>\r\n<tr><td>Aerospace</td><td>Satellite and spacecraft attitude control</td></tr>\r\n<tr><td>Medicine</td><td>Diagnosis support, anaesthesia dosage control</td></tr>\r\n<tr><td>Finance and decisions</td><td>Loan approval, credit and fire-risk scoring, stock trading rules</td></tr>\r\n<tr><td>AI and robotics</td><td>Robot navigation, natural-language interfaces, expert systems</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>One application in detail: fuzzy washing machine</h3>\r\n<ol>\r\n<li><strong>Problem.</strong> 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.</li>\r\n<li><strong>Inputs and outputs.</strong> 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.</li>\r\n<li><strong>Fuzzification.</strong> Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.</li>\r\n<li><strong>Rule base.</strong> 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.</li>\r\n<li><strong>Inference.</strong> Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.</li>\r\n<li><strong>Defuzzification.</strong> 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.</li>\r\n<li><strong>Benefits.</strong> Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.</li>\r\n</ol>\r\n<h3>Advantages and disadvantages (bonus)</h3>\r\n<p><strong>Advantages:</strong> handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. <strong>Disadvantages:</strong> 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.</p>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.</div>\r\n"},{"id":"q6b","title":"Q6(b) Learner progression (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: B, I, A. Initial vector [50, 30, 20].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>B</th><th>I</th><th>A</th></tr></thead><tbody><tr><td>B</td><td>0.6</td><td>0.3</td><td>0.1</td></tr><tr><td>I</td><td>0.2</td><td>0.5</td><td>0.3</td></tr><tr><td>A</td><td>0</td><td>0.1</td><td>0.9</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_learning.61a789edc7.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to B</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to B</th><th>Contribution</th></tr></thead><tbody><tr><td>B</td><td>50</td><td>0.6</td><td>50 × 0.6 = 30</td></tr><tr><td>I</td><td>30</td><td>0.2</td><td>30 × 0.2 = 6</td></tr><tr><td>A</td><td>20</td><td>0</td><td>20 × 0 = 0</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/60af91b5a47e34d2.svg\" alt=\"B_{new}=30+6+0=36\" style=\"width:23.109ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to I</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to I</th><th>Contribution</th></tr></thead><tbody><tr><td>B</td><td>50</td><td>0.3</td><td>50 × 0.3 = 15</td></tr><tr><td>I</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr><tr><td>A</td><td>20</td><td>0.1</td><td>20 × 0.1 = 2</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/d10fe140b0e969ab.svg\" alt=\"I_{new}=15+15+2=32\" style=\"width:23.518ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to A</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to A</th><th>Contribution</th></tr></thead><tbody><tr><td>B</td><td>50</td><td>0.1</td><td>50 × 0.1 = 5</td></tr><tr><td>I</td><td>30</td><td>0.3</td><td>30 × 0.3 = 9</td></tr><tr><td>A</td><td>20</td><td>0.9</td><td>20 × 0.9 = 18</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/e07af325efaf974e.svg\" alt=\"A_{new}=5+9+18=32\" style=\"width:23.088ex;height:1.977ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: balance the Beginner column</h5><div class=\"math-display\"><img src=\"math/e6252d668732cace.svg\" alt=\"b=0.6b+0.2i\" style=\"width:14.287ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3a1b2778c1d42930.svg\" alt=\"0.4b=0.2i\\quad\\Rightarrow\\quad i=2b\" style=\"width:24.495ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Balance the Advanced column</h5><div class=\"math-display\"><img src=\"math/6e1d2349f082467b.svg\" alt=\"a=0.1b+0.3i+0.9a\" style=\"width:21.368ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e730f86d7c6fb366.svg\" alt=\"0.1a=0.1b+0.3(2b)=0.7b\" style=\"width:27.366ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4e3c76ca7c5b3101.svg\" alt=\"a=0.7b/0.1=7b\" style=\"width:17.217ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Use the sum of shares</h5><div class=\"math-display\"><img src=\"math/8e00c1c8e9302c7a.svg\" alt=\"b+i+a=1\\quad b+2b+7b=1\" style=\"width:29.744ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/401c3cb4b3606dfc.svg\" alt=\"10b=1\\quad b=0.1\\quad i=0.2\\quad a=0.7\" style=\"width:34.842ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><p>Advanced is not an absorbing state: its self-transition is .9, not 1.</p></div><div class=\"step\"><h5>Step 9. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>B</td><td>0.5</td><td>0.1</td><td>-0.4</td><td>Loses</td></tr><tr><td>I</td><td>0.3</td><td>0.2</td><td>-0.1</td><td>Loses</td></tr><tr><td>A</td><td>0.2</td><td>0.7</td><td>0.5</td><td>Gains</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [36.0, 32.0, 32.0]. Stationary shares ≈ [0.1, 0.2, 0.7]. B loses, I loses, A gains.</div></section>"},{"id":"q7a","title":"Q7(a) Applications of PSO [10]","html":"<p class=\"question\"><strong>List the applications of Particle Swarm Optimization and explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Function optimisation</strong>: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.</li>\r\n<li><strong>Neural-network training</strong>: optimising weights and biases (your Lab 8 uses the pyswarms library for this).</li>\r\n<li><strong>Hyper-parameter tuning</strong> of ML models (learning rate, number of hidden units, SVM C and γ).</li>\r\n<li><strong>Feature selection</strong>: choosing the most useful subset of features (binary PSO).</li>\r\n<li><strong>Image processing</strong>: threshold selection for segmentation, edge detection, image enhancement.</li>\r\n<li><strong>Path planning</strong> for robots and drones: shortest collision-free path.</li>\r\n<li><strong>Power systems</strong>: economic load dispatch, optimal placement of capacitors.</li>\r\n<li><strong>Control engineering</strong>: tuning PID controller gains.</li>\r\n<li><strong>Scheduling and wireless sensor networks</strong>: job scheduling, sensor node placement and clustering.</li>\r\n</ol>\r\n\r\n<h3>One application in detail: training a neural network with PSO</h3>\r\n<div class=\"flow\"><div class=\"node\">Training data</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Neural network with weights = particle position</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Error (fitness)</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">PSO moves the weights</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Best weights = gbest</div></div>\r\n<ol>\r\n<li><strong>Encoding.</strong> 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.</li>\r\n<li><strong>Fitness.</strong> 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).</li>\r\n<li><strong>Search.</strong> 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).</li>\r\n<li><strong>Stop</strong> after a fixed number of iterations or when the error stops improving; gbest is the trained network.</li>\r\n<li><strong>Why PSO here:</strong> 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. <strong>Limitation:</strong> 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.</li>\r\n</ol>\r\n\r\n<h3>Advantages and disadvantages (add for 10 marks)</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Disadvantages</th></tr></thead><tbody>\r\n<tr><td>Simple to implement; few parameters (w, c₁, c₂)</td><td>Can converge prematurely to a local optimum</td></tr>\r\n<tr><td>No derivatives needed</td><td>Sensitive to parameter choice</td></tr>\r\n<tr><td>Fast convergence in early iterations; memory (pbest, gbest)</td><td>No guarantee of the global optimum</td></tr>\r\n<tr><td>Objective evaluations can be parallel; particles share information through gbest</td><td>Less suited to discrete problems without modification</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<p class=\"marks-split\">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).</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.</div>\r\n"},{"id":"q7b","title":"Q7(b) ACO for TSP [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4>\r\n<div class=\"math-display\"><img src=\"math/ff22cd24b937efcc.svg\" alt=\"D=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;4&amp;2&amp;4\\\\B&amp;4&amp;0&amp;3&amp;6\\\\C&amp;2&amp;3&amp;0&amp;2\\\\D&amp;4&amp;6&amp;2&amp;0\\end{array}\\qquad \\tau=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;1&amp;1&amp;1\\\\B&amp;1&amp;0&amp;1&amp;1\\\\C&amp;1&amp;1&amp;0&amp;1\\\\D&amp;1&amp;1&amp;1&amp;0\\end{array}\" style=\"width:48.522ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Assume <span class=\"math-inline\"><img src=\"math/8fe45a81f0de6694.svg\" alt=\"\\alpha=\\beta=1\" style=\"width:9.894ex;height:2.034ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/d7320dc626d3d883.svg\" alt=\"\\rho=0.5\" style=\"width:7.078ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/bd5a6aec418f8f8f.svg\" alt=\"Q=1\" style=\"width:5.938ex;height:2.032ex\" loading=\"lazy\" decoding=\"async\"></span> (class convention; not stated in the question).</p>\r\n<h4>To find</h4><p>Tour of each ant, tour lengths, updated pheromone matrix.</p></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_final_graph.ac3cd4aeac.svg\" width=\"520\" height=\"380\" alt=\"Final 2025 Q7b: distances (all pheromones start at 1)\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n<h4>Formula and why it applies</h4>\r\n<div class=\"math-display\"><img src=\"math/4a0efb39e84f4c4e.svg\" alt=\"P_{ij}=\\frac{\\tau_{ij}\\,\\eta_{ij}}{\\sum_{l\\in\\text{allowed}}\\tau_{il}\\,\\eta_{il}},\\qquad\\eta_{ij}=\\frac1{d_{ij}}\" style=\"width:36.172ex;height:5.352ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/b8a3f5425a6d79b2.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}+\\sum_{k:\\,ij\\in\\mathrm{tour}_k}\\frac{Q}{L_k}\" style=\"width:30.857ex;height:6.181ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>The sum includes <strong>only ants whose completed tour contains edge ij</strong>. 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.</p>\r\n<h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Probabilities from A (both ants start at A)</h5>\r\n<div class=\"math-display\"><img src=\"math/b5d4297d164fecda.svg\" alt=\"\\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\" style=\"width:89.871ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Move</th><th>P</th><th>Cumulative</th><th>Range</th></tr></thead><tbody><tr><td>A→B</td><td>0.25</td><td>0.25</td><td>0–0.25</td></tr><tr><td>A→C</td><td>0.50</td><td>0.75</td><td>0.25–0.75</td></tr><tr><td>A→D</td><td>0.25</td><td>1.00</td><td>0.75–1</td></tr></tbody></table></div>\r\n<p>Ant 1: r = 0.3 → <strong>C</strong>. Ant 2: r = 0.5 → <strong>C</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 2. Probabilities from C (B and D left)</h5>\r\n<div class=\"math-display\"><img src=\"math/52a7763a8065747e.svg\" alt=\"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\" style=\"width:83.999ex;height:2.773ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative in city order: B 0–0.4, D 0.4–1. Ant 1: r = 0.8 → <strong>D</strong>. Ant 2: r = 0.7 → <strong>D</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 3. Complete the tours</h5><p>Only B is left, then return to A.</p>\r\n<div class=\"math-display\"><img src=\"math/d48c911f3133b5dc.svg\" alt=\"\\text{Ant 1}=\\text{Ant 2}:\\;A\\to C\\to D\\to B\\to A,\\qquad L=2+2+6+4=14\" style=\"width:67.567ex;height:2.059ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_final_tour.1dbfdb8b98.svg\" width=\"520\" height=\"380\" alt=\"Both ants: A → C → D → B → A, length 14\" loading=\"lazy\" decoding=\"async\"></div></figure></div>\r\n<div class=\"step\"><h5>Step 4. Pheromone update</h5>\r\n<p>Each ant deposits <span class=\"math-inline\"><img src=\"math/799732b628eacf45.svg\" alt=\"Q/L=1/14=0.0714\" style=\"width:21.306ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> on each edge of its tour; two ants used the same four edges (AC, CD, DB, BA), so each gets <span class=\"math-inline\"><img src=\"math/2b49c5f9ee4dd7a9.svg\" alt=\"2/14=0.1429\" style=\"width:13.827ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/beecdfda1143f6eb.svg\" alt=\"\\text{used edge: }(1-0.5)(1)+0.1429=0.6429\\qquad\\text{unused edge (AD, BC): }(1-0.5)(1)+0=0.5\" style=\"width:89.4ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/25cf4d02bee20e2a.svg\" alt=\"\\tau_{\\text{new}}=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;0.6429&amp;0.6429&amp;0.5\\\\B&amp;0.6429&amp;0&amp;0.5&amp;0.6429\\\\C&amp;0.6429&amp;0.5&amp;0&amp;0.6429\\\\D&amp;0.5&amp;0.6429&amp;0.6429&amp;0\\end{array}\" style=\"width:42.542ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> 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.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> 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.”</div>\r\n<p class=\"marks-split\">Official marking: path of Ant 1 (3) + path of Ant 2 (3) + pheromone matrix (4).</p>\r\n</section>\r\n"}]},{"id":"paper-reexam-2026","title":"Re-examination · 31 Jan 2026","unit":"paper","scope":"100-mark timed practice using the actual Re-exam 2026 paper. Q1 compulsory; any four of Q2–Q7. Worked solutions are below the questions.","sections":[{"id":"q1a","title":"Q1(a) Disease, fever and test joint table [5]","html":"<p class=\"question\"><strong>Question. For a disease Y with fever X as a symptom, a test Z is conducted. Joint probabilities: Disease (Y=1): fever &amp; test+ 0.576, fever &amp; test− 0.144, no fever &amp; test+ 0.072, no fever &amp; 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?</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The complete joint table or cell values printed in this question. The rows and columns identify the event combinations.</p><h4>To find</h4><p>All requested marginal and conditional probabilities.</p></div><h4>Formula and why it applies</h4><p>Marginal: add cells satisfying the event. Conditional: retain the evidence cells and divide the joint-event sum by the evidence sum. <div class=\"math-display\"><img src=\"math/3b42af132ac8057a.svg\" alt=\"P(A\\mid E)=\\frac{P(A\\cap E)}{P(E)},\\quad P(E)&gt;0\" style=\"width:34.787ex;height:5.475ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. (1)</h5><div class=\"math-display\"><img src=\"math/e2428bb7484a2222.svg\" alt=\"P(Y{=}1\\mid X{=}1,Z{=}1)=\\frac{0.576}{0.576+0.008}=\\frac{0.576}{0.584}=0.986\" style=\"width:54.738ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. (2) Add every test-positive cell</h5><div class=\"math-display\"><img src=\"math/4ae537c83ce53b71.svg\" alt=\"P(Z{=}1)=0.576+0.072+0.008+0.012=0.668\" style=\"width:48.087ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. (3)</h5><div class=\"math-display\"><img src=\"math/ab59aa2401b72e20.svg\" alt=\"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\" style=\"width:103.115ex;height:4.661ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> (1) 0.986; (2) 0.668; (3) 0.423.</div>\r\n<div class=\"keyfix\"><strong>Key correction.</strong> 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.</div>\r\n</section>"},{"id":"q1b","title":"Q1(b) Applications of PSO [5]","html":"<p class=\"question\"><strong>List the applications of Particle Swarm Optimization and explain any one application in detail.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3>\r\n\r\n<div class=\"answer-box\">\r\n<h3>Definition (1 line)</h3>\r\n<p>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.</p>\r\n\r\n<h3>Applications</h3>\r\n<ol>\r\n<li><strong>Function optimisation</strong>: maximising or minimising complex non-linear, multimodal functions where derivatives are unavailable.</li>\r\n<li><strong>Neural-network training</strong>: optimising weights and biases (your Lab 8 uses the pyswarms library for this).</li>\r\n<li><strong>Hyper-parameter tuning</strong> of ML models (learning rate, number of hidden units, SVM C and γ).</li>\r\n<li><strong>Feature selection</strong>: choosing the most useful subset of features (binary PSO).</li>\r\n<li><strong>Image processing</strong>: threshold selection for segmentation, edge detection, image enhancement.</li>\r\n<li><strong>Path planning</strong> for robots and drones: shortest collision-free path.</li>\r\n<li><strong>Power systems</strong>: economic load dispatch, optimal placement of capacitors.</li>\r\n<li><strong>Control engineering</strong>: tuning PID controller gains.</li>\r\n<li><strong>Scheduling and wireless sensor networks</strong>: job scheduling, sensor node placement and clustering.</li>\r\n</ol>\r\n\r\n<h3>One application in detail: training a neural network with PSO</h3>\r\n<div class=\"flow\"><div class=\"node\">Training data</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Neural network with weights = particle position</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Error (fitness)</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">PSO moves the weights</div><span class=\"arrow\" aria-hidden=\"true\">→</span><div class=\"node\">Best weights = gbest</div></div>\r\n<ol>\r\n<li><strong>Encoding.</strong> 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.</li>\r\n<li><strong>Fitness.</strong> 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).</li>\r\n<li><strong>Search.</strong> 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).</li>\r\n<li><strong>Stop</strong> after a fixed number of iterations or when the error stops improving; gbest is the trained network.</li>\r\n<li><strong>Why PSO here:</strong> 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. <strong>Limitation:</strong> 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.</li>\r\n</ol>\r\n\r\n<h3>Advantages and disadvantages (add for 10 marks)</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Advantages</th><th>Disadvantages</th></tr></thead><tbody>\r\n<tr><td>Simple to implement; few parameters (w, c₁, c₂)</td><td>Can converge prematurely to a local optimum</td></tr>\r\n<tr><td>No derivatives needed</td><td>Sensitive to parameter choice</td></tr>\r\n<tr><td>Fast convergence in early iterations; memory (pbest, gbest)</td><td>No guarantee of the global optimum</td></tr>\r\n<tr><td>Objective evaluations can be parallel; particles share information through gbest</td><td>Less suited to discrete problems without modification</td></tr>\r\n</tbody></table></div>\r\n</div>\r\n<p class=\"marks-split\">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).</p>\r\n\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application likhte waqt teen cheezein: particle kya hai, fitness kya hai, gbest ka matlab kya hai.</div>\r\n"},{"id":"q1c","title":"Q1(c) Fuzzy set operations [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The aligned X and Y memberships printed in this question.</p><h4>To find</h4><p>The four requested membership lists in the original element order.</p></div><h4>Formula and why it applies</h4><p>Use max for OR, min for AND, and 1−μ for NOT. <div class=\"math-display\"><img src=\"math/e32ad02c5ba3dae5.svg\" alt=\"\\mu_{X\\cup Y}=\\max(\\mu_X,\\mu_Y),\\quad\\mu_{X\\cap Y}=\\min(\\mu_X,\\mu_Y)\" style=\"width:44.598ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div> Complement both operands before applying the operator in ¬X∪¬Y or ¬X∩¬Y.</p><h4>Solution</h4>\r\n<div class=\"table-wrap\"><table><thead><tr><th></th><th>c1</th><th>c2</th><th>c3</th><th>c4</th><th>c5</th></tr></thead><tbody>\r\n<tr><td>¬X</td><td>0.3</td><td>0.1</td><td>0.8</td><td>0.6</td><td>0.1</td></tr>\r\n<tr><td>¬Y</td><td>0.4</td><td>0.7</td><td>0.2</td><td>0.3</td><td>0.9</td></tr>\r\n<tr><td><strong>X ∪ Y</strong></td><td>0.7</td><td>0.9</td><td>0.8</td><td>0.7</td><td>0.9</td></tr>\r\n<tr><td><strong>X ∩ Y</strong></td><td>0.6</td><td>0.3</td><td>0.2</td><td>0.4</td><td>0.1</td></tr>\r\n<tr><td><strong>¬X ∪ ¬Y</strong></td><td>0.4</td><td>0.7</td><td>0.8</td><td>0.6</td><td>0.9</td></tr>\r\n<tr><td><strong>¬X ∩ ¬Y</strong></td><td>0.3</td><td>0.1</td><td>0.2</td><td>0.3</td><td>0.1</td></tr>\r\n</tbody></table></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> As in the last four rows. De Morgan check: ¬X ∪ ¬Y = 1 − (X ∩ Y) and ¬X ∩ ¬Y = 1 − (X ∪ Y) ✓.</div>\r\n</section>\r\n\r\n<!-- depth:element-working:start -->\r\n<div class=\"concept-bridge\"><h2>Calculate every element separately</h2><h3>Element c1</h3><div class=\"math-display\"><img src=\"math/c590062072bce4a3.svg\" alt=\"\\neg X:1-0.7=0.3\\qquad\\neg Y:1-0.6=0.4\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a2eea0fe6bbb6b87.svg\" alt=\"X\\cup Y:\\max(0.7,0.6)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ecd4a7a60c39fa85.svg\" alt=\"X\\cap Y:\\min(0.7,0.6)=0.6\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1aca856a2f38fa09.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.3,0.4)=0.4\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4ef33b6f553800c5.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.3,0.4)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c2</h3><div class=\"math-display\"><img src=\"math/ce24f9cbda57e56d.svg\" alt=\"\\neg X:1-0.9=0.1\\qquad\\neg Y:1-0.3=0.7\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/05dee517321dfca3.svg\" alt=\"X\\cup Y:\\max(0.9,0.3)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/4a2bc31233f313e7.svg\" alt=\"X\\cap Y:\\min(0.9,0.3)=0.3\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/b188e2e037566b1e.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.1,0.7)=0.7\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/82b3199ed4befd72.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.1,0.7)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c3</h3><div class=\"math-display\"><img src=\"math/24c8a43adb44c324.svg\" alt=\"\\neg X:1-0.2=0.8\\qquad\\neg Y:1-0.8=0.2\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ddba21d8acd6b044.svg\" alt=\"X\\cup Y:\\max(0.2,0.8)=0.8\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/247907e255730431.svg\" alt=\"X\\cap Y:\\min(0.2,0.8)=0.2\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/41e12e8e143ca16d.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.8,0.2)=0.8\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ea5cfbc43203761d.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.8,0.2)=0.2\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c4</h3><div class=\"math-display\"><img src=\"math/0b5f5f89785edd94.svg\" alt=\"\\neg X:1-0.4=0.6\\qquad\\neg Y:1-0.7=0.3\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/05b7177b2b3fbf81.svg\" alt=\"X\\cup Y:\\max(0.4,0.7)=0.7\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1cfa1c76382cbe6b.svg\" alt=\"X\\cap Y:\\min(0.4,0.7)=0.4\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/1568254a4bf6e796.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.6,0.3)=0.6\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/edebdcb00abb9544.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.6,0.3)=0.3\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>Element c5</h3><div class=\"math-display\"><img src=\"math/f594ae61dd359b85.svg\" alt=\"\\neg X:1-0.9=0.1\\qquad\\neg Y:1-0.1=0.9\" style=\"width:40.362ex;height:1.731ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/da89b631e703aa27.svg\" alt=\"X\\cup Y:\\max(0.9,0.1)=0.9\" style=\"width:26.722ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5461384d5ad733c2.svg\" alt=\"X\\cap Y:\\min(0.9,0.1)=0.1\" style=\"width:26.283ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/2a8b87917a1340f9.svg\" alt=\"\\neg X\\cup\\neg Y:\\max(0.1,0.9)=0.9\" style=\"width:29.74ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/601ec64fa8926431.svg\" alt=\"\\neg X\\cap\\neg Y:\\min(0.1,0.9)=0.1\" style=\"width:29.301ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:element-working:end -->"},{"id":"q1d","title":"Q1(d) Savings and current accounts (Markov chain) [5]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[5 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: S, C.</p><h4>To find</h4><p>The transition matrix and state diagram.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>S</th><th>C</th></tr></thead><tbody><tr><td>S</td><td>0.8</td><td>0.2</td></tr><tr><td>C</td><td>0.1</td><td>0.9</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_bank.879499f6eb.svg\" width=\"520\" height=\"280\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"answer\"><strong>Final answer.</strong> The transition matrix and state diagram are given above.</div></section>"},{"id":"q2a","title":"Q2(a) Fuzzy fire-hazard system [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><table><thead><tr><th>Variable</th><th>Crisp value</th></tr></thead><tbody><tr><td>Temperature</td><td>65</td></tr><tr><td>Smoke Level</td><td>80</td></tr></tbody></table><p>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.</p><h4>To find</h4><p>A complete stated design and its continuous Mamdani centroid.</p></div><h4>Formula and why it applies</h4><p>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.</p><div class=\"math-display\"><img src=\"math/5aa4acd6aab4215a.svg\" alt=\"z^*=\\frac{\\int z\\mu_{out}(z)\\,dz}{\\int\\mu_{out}(z)\\,dz}\" style=\"width:18.101ex;height:5.977ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Specify the membership functions</h5><table><thead><tr><th>Input / output position</th><th>Triangle</th><th>Peak</th></tr></thead><tbody><tr><td>Low / Low</td><td>(1,25,50)</td><td>25</td></tr><tr><td>Medium / Moderate</td><td>(25,50,75)</td><td>50</td></tr><tr><td>High / High</td><td>(50,75,100)</td><td>75</td></tr></tbody></table><p>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.</p></div><div class=\"step\"><h5>Step 2. Write all nine rules</h5><table><thead><tr><th>Temperature / Smoke Level</th><th>Low</th><th>Medium</th><th>High</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>Low</td><td>Moderate</td></tr><tr><td>Medium</td><td>Low</td><td>Moderate</td><td>High</td></tr><tr><td>High</td><td>Moderate</td><td>High</td><td>High</td></tr></tbody></table><p>Read each cell as an IF–AND–THEN rule. For example, the centre cell combines Medium with Medium.</p></div><div class=\"step\"><h5>Step 3. Fuzzify Temperature = 65</h5><div class=\"math-display\"><img src=\"math/9e3859fafc31a24f.svg\" alt=\"\\mu_{Low}(65)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f35f654b9795c088.svg\" alt=\"\\mu_{Medium}(65)=\\frac{75-65}{75-50}=0.4\" style=\"width:28.917ex;height:4.796ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/de5666dfbbcb02fc.svg\" alt=\"\\mu_{High}(65)=\\frac{65-50}{75-50}=0.6\" style=\"width:26.443ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Fuzzify Smoke Level = 80</h5><div class=\"math-display\"><img src=\"math/0a1689e705282396.svg\" alt=\"\\mu_{Low}(80)=0\" style=\"width:12.734ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af4f190a786e2c05.svg\" alt=\"\\mu_{Medium}(80)=0\" style=\"width:15.853ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ec0cdd51e84c6204.svg\" alt=\"\\mu_{High}(80)=\\frac{100-80}{100-75}=0.8\" style=\"width:27.575ex;height:4.774ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Evaluate all rules and aggregate matching consequents</h5><table><thead><tr><th>Temperature</th><th>Smoke Level</th><th>Firing strength</th><th>Consequent</th></tr></thead><tbody><tr><td>Low</td><td>Low</td><td>min(0,0) = 0</td><td>Low</td></tr><tr><td>Low</td><td>Medium</td><td>min(0,0) = 0</td><td>Low</td></tr><tr><td>Low</td><td>High</td><td>min(0,0.8) = 0</td><td>Moderate</td></tr><tr><td>Medium</td><td>Low</td><td>min(0.4,0) = 0</td><td>Low</td></tr><tr><td>Medium</td><td>Medium</td><td>min(0.4,0) = 0</td><td>Moderate</td></tr><tr><td>Medium</td><td>High</td><td>min(0.4,0.8) = 0.4</td><td>High</td></tr><tr><td>High</td><td>Low</td><td>min(0.6,0) = 0</td><td>Moderate</td></tr><tr><td>High</td><td>Medium</td><td>min(0.6,0) = 0</td><td>High</td></tr><tr><td>High</td><td>High</td><td>min(0.6,0.8) = 0.6</td><td>High</td></tr></tbody></table><p>Aggregated label strengths: Low = 0, Moderate = 0, High = 0.6.</p><div class=\"math-display\"><img src=\"math/d1c2a08444481d0c.svg\" alt=\"\\mu_{out}(z)=\\max_r\\min(\\alpha_r,\\mu_{C_r}(z))\" style=\"width:29.283ex;height:3.323ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Draw the aggregated output</h5><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/v2_fire_aggregate.e0cab4ad42.svg\" width=\"680\" height=\"300\" alt=\"The shaded upper envelope counts any overlap only once.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>The shaded upper envelope counts any overlap only once.</figcaption></figure></div><div class=\"step\"><h5>Step 7. Calculate area and moment of each straight-line strip</h5><p>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.</p><div class=\"math-display\"><img src=\"math/a1493aef29965a09.svg\" alt=\"A=(b-a)(u+v)/2\" style=\"width:20.587ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d68335c9ce0df62c.svg\" alt=\"M=\\frac{b-a}{6}\\big[(2a+b)u+(a+2b)v\\big]\" style=\"width:34.017ex;height:4.701ex\" loading=\"lazy\" decoding=\"async\"></div><table><thead><tr><th>a</th><th>b</th><th>u</th><th>v</th><th>Area A</th><th>Moment M</th></tr></thead><tbody><tr><td>50</td><td>65</td><td>0</td><td>0.6</td><td>4.5</td><td>270</td></tr><tr><td>65</td><td>85</td><td>0.6</td><td>0.6</td><td>12</td><td>900</td></tr><tr><td>85</td><td>100</td><td>0.6</td><td>0</td><td>4.5</td><td>405</td></tr></tbody></table></div><div class=\"step\"><h5>Step 8. Divide total moment by total area</h5><div class=\"math-display\"><img src=\"math/2ffb3645f0d4cc76.svg\" alt=\"\\sum A=21\" style=\"width:10.62ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/0a14da79e18490bb.svg\" alt=\"\\sum M=1575\" style=\"width:13.564ex;height:3.167ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/647a203082aabc5c.svg\" alt=\"z^*=\\frac{1575}{21}\\approx75\" style=\"width:15.857ex;height:4.611ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"answer\"><strong>Final answer.</strong> For these stated triangles and rules, the centroid is 75. This is in the high-risk region of this illustrative fuzzy design.</div></section><p>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.</p>\r\n\r\n<!-- depth:centroid-working:start -->\r\n<div class=\"concept-bridge\"><h2>Why the clipped High shape is symmetric about 75</h2><p>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.</p><table><thead><tr><th>Piece</th><th>Area calculation</th><th>Centre</th><th>Moment</th></tr></thead><tbody><tr><td>Left triangle [50,65]</td><td>½×15×.6=4.5</td><td>(50+65+65)/3=60</td><td>4.5×60=270</td></tr><tr><td>Rectangle [65,85]</td><td>20×.6=12</td><td>(65+85)/2=75</td><td>12×75=900</td></tr><tr><td>Right triangle [85,100]</td><td>½×15×.6=4.5</td><td>(85+85+100)/3=90</td><td>4.5×90=405</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:centroid-working:end -->"},{"id":"q2b","title":"Q2(b) GMM: compare with k-means, log-likelihood, parameters [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><h2>Read the derivation’s symbols first</h2><p>“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. λ<sub>k</sub><sup>i</sup> in some notes is the same responsibility that other sections call γ<sub>ik</sub>. A superscript i here labels the observation, not an exponent.</p><p>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.</p><table><thead><tr><th>Parameter</th><th>Number in a 1D K-component GMM</th><th>Why</th></tr></thead><tbody><tr><td>Means</td><td>K</td><td>One centre for each component</td></tr><tr><td>Variances</td><td>K</td><td>One spread for each component</td></tr><tr><td>Independent mixing weights</td><td>K−1</td><td>The last weight is 1 minus the others</td></tr><tr><td>Total</td><td>3K−1</td><td>K+K+(K−1)</td></tr></tbody></table><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n\r\n\r\n<div class=\"answer-box\">\r\n<h3>1. GMM versus k-means</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Aspect</th><th>k-means</th><th>GMM</th></tr></thead><tbody>\r\n<tr><td>Assignment</td><td>Hard: each point in exactly one cluster</td><td>Soft: probability <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> of belonging to each cluster</td></tr>\r\n<tr><td>Model</td><td>Geometric: nearest centroid</td><td>Probabilistic generative model <span class=\"math-inline\"><img src=\"math/04ce4e1e89065414.svg\" alt=\"\\sum_k\\pi_k\\mathcal N(\\mu_k,\\Sigma_k)\" style=\"width:16.12ex;height:2.448ex\" loading=\"lazy\" decoding=\"async\"></span></td></tr>\r\n<tr><td>Cluster shape</td><td>Spherical, similar size</td><td>Elliptical, any size/orientation; overlapping clusters</td></tr>\r\n<tr><td>Parameters</td><td>K centroids</td><td>Weights, means, covariances (1-D: 3K − 1)</td></tr>\r\n<tr><td>Algorithm / objective</td><td>Assign–update; minimise squared distances</td><td>EM; maximise log-likelihood</td></tr>\r\n<tr><td>Output</td><td>Hard labels and fitted centroids</td><td>Labels, membership probabilities and a density (useful for anomaly detection)</td></tr>\r\n<tr><td>Relation</td><td colspan=\"2\">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.</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>2. Derivation of the log-likelihood</h3>\r\n<p><strong>Step 1. Model.</strong> Each point is generated by choosing component k with probability <span class=\"math-inline\"><img src=\"math/e60970d7047375ff.svg\" alt=\"\\pi_k\" style=\"width:2.311ex;height:1.332ex\" loading=\"lazy\" decoding=\"async\"></span> and drawing <span class=\"math-inline\"><img src=\"math/f66cfb5e517110e8.svg\" alt=\"x_i\\sim\\mathcal N(\\mu_k,\\sigma_k^2)\" style=\"width:14.731ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>, so its density is <span class=\"math-inline\"><img src=\"math/6550a4aaf9e87286.svg\" alt=\"f_{mix}(x_i)=\\sum_k\\pi_k\\mathcal N(x_i\\mid\\mu_k,\\sigma_k^2)\" style=\"width:30.677ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<p><strong>Step 2. Likelihood.</strong> Points are i.i.d., so the likelihood is a product (θ = all parameters):</p>\r\n<div class=\"math-display\"><img src=\"math/41dc390b2652cd78.svg\" alt=\"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]\" style=\"width:35.259ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 3. Log-likelihood.</strong> Logs turn the product into a sum:</p>\r\n<div class=\"math-display\"><img src=\"math/9a0bb26e3ef13adb.svg\" alt=\"\\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)\" style=\"width:42.737ex;height:6.784ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 4. Why it cannot be solved directly.</strong> The sum sits inside the log, so setting derivatives to zero gives no closed-form solution.</p>\r\n<p><strong>Step 5. Jensen's inequality.</strong> log is concave, so for weights <span class=\"math-inline\"><img src=\"math/5006fcb64f6c3cf6.svg\" alt=\"\\lambda_k\\ge0,\\;\\sum\\lambda_k=1\" style=\"width:17.378ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>: <span class=\"math-inline\"><img src=\"math/742b7c09a1ce32a4.svg\" alt=\"\\log\\big(\\sum_k\\lambda_ka_k\\big)\\ge\\sum_k\\lambda_k\\log a_k\" style=\"width:29.072ex;height:2.713ex\" loading=\"lazy\" decoding=\"async\"></span>. Introduce <span class=\"math-inline\"><img src=\"math/d61decbc739ada16.svg\" alt=\"\\lambda_k^i\" style=\"width:2.34ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span> for every point (<span class=\"math-inline\"><img src=\"math/fbe0441b97e0b9c1.svg\" alt=\"\\sum_k\\lambda_k^i=1\" style=\"width:10.276ex;height:2.61ex\" loading=\"lazy\" decoding=\"async\"></span>), multiply and divide inside the log:</p>\r\n<div class=\"math-display\"><img src=\"math/06dff5bae3d2cfe1.svg\" alt=\"\\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}\" style=\"width:78.361ex;height:6.391ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p><strong>Step 6. Estimation (EM).</strong> Maximise the lower bound alternately. Fixing θ gives the E-step <span class=\"math-inline\"><img src=\"math/662cdc674fe7b2c5.svg\" alt=\"\\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)\" style=\"width:41.37ex;height:2.618ex\" loading=\"lazy\" decoding=\"async\"></span>. Fixing λ and differentiating (with a Lagrange multiplier for <span class=\"math-inline\"><img src=\"math/131aa1c87311a5f9.svg\" alt=\"\\sum\\pi_k=1\" style=\"width:9.225ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>) gives the M-step:</p>\r\n<div class=\"math-display\"><img src=\"math/ffbe3f9b626d2a86.svg\" alt=\"\\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}\" style=\"width:59.614ex;height:6.179ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n\r\n<h3>3. Number of parameters for K = 5</h3><p>The dimension and covariance structure must also be specified. For the one-dimensional, independent-variance model used in the derivation:</p>\r\n<div class=\"math-display\"><img src=\"math/5d57bdfd8f83239c.svg\" alt=\"2K+(K-1)=3K-1=3(5)-1=\\mathbf{14}\" style=\"width:40.189ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>(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.</p>\r\n</div>\r\n<div class=\"keyfix\"><strong>Slide note.</strong> One slide puts the convex inequality under the “concave” heading. Correct: log is <em>concave</em>, so <span class=\"math-inline\"><img src=\"math/2ddf537dc44d74a6.svg\" alt=\"f(\\sum\\lambda a)\\ge\\sum\\lambda f(a)\" style=\"width:19.59ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> (≥, not &gt;).</div>\r\n"},{"id":"q3a","title":"Q3(a) Bayesian network: fever given no flu [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><!-- depth:bridge:start -->\r\n<div class=\"concept-bridge\"><p>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.</p></div>\r\n<!-- depth:bridge:end -->\r\n<section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>W→F, W→C, (F,C)→V. The complete probabilities are in the question. Evidence F=false.</p><h4>To find</h4><p>P(V=true | F=false), summing hidden W and C.</p></div><h4>Formula and why it applies</h4><p>Use the network joint and normalise by the no-Flu evidence. <div class=\"math-display\"><img src=\"math/e2104f63677bf585.svg\" alt=\"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)}\" style=\"width:55.005ex;height:5.963ex\" loading=\"lazy\" decoding=\"async\"></div></p><h4>Solution</h4>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/bn_flu.1d732f0fb6.svg\" width=\"600\" height=\"360\" alt=\"Re-exam 2026 Q3a: weather–flu–cough–fever network\" loading=\"lazy\" decoding=\"async\"></div></figure>\r\n\r\n<div class=\"step\"><h5>Step 1. Chain rule</h5><div class=\"math-display\"><img src=\"math/73135e72ac19cca4.svg\" alt=\"P(W,F,C,V)=P(W)\\,P(F\\mid W)\\,P(C\\mid W)\\,P(V\\mid F,C)\" style=\"width:54.335ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Sum over W and C with F = false, V = true</h5>\r\n<div class=\"table-wrap\"><table><thead><tr><th>W</th><th>C</th><th>P(W)</th><th>P(¬F|W)</th><th>P(C|W)</th><th>P(V|¬F,C)</th><th>Product</th></tr></thead><tbody>\r\n<tr><td>T</td><td>T</td><td>0.75</td><td>0.8</td><td>0.70</td><td>0.60</td><td>0.252</td></tr>\r\n<tr><td>T</td><td>F</td><td>0.75</td><td>0.8</td><td>0.30</td><td>0.01</td><td>0.0018</td></tr>\r\n<tr><td>F</td><td>T</td><td>0.25</td><td>0.5</td><td>0.25</td><td>0.60</td><td>0.01875</td></tr>\r\n<tr><td>F</td><td>F</td><td>0.25</td><td>0.5</td><td>0.75</td><td>0.01</td><td>0.0009375</td></tr>\r\n<tr><td colspan=\"6\"><strong>P(V, ¬F)</strong></td><td><strong>0.2734875</strong></td></tr></tbody></table></div></div>\r\n<div class=\"step\"><h5>Step 3. Evidence</h5><div class=\"math-display\"><img src=\"math/a396371c860e59b0.svg\" alt=\"P(\\lnot F)=0.75(0.8)+0.25(0.5)=0.6+0.125=0.725\" style=\"width:51.793ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 4. Divide</h5><div class=\"math-display\"><img src=\"math/a27699b35a63a308.svg\" alt=\"P(V\\mid\\lnot F)=\\frac{0.2734875}{0.725}=0.3772\" style=\"width:33.282ex;height:4.663ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> P(fever | no flu) ≈ <strong>0.377</strong> (fever without flu comes mostly from cough).</div>\r\n<div class=\"keyfix\"><strong>Key correction.</strong> 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).</div>\r\n</section>\r\n"},{"id":"q3b","title":"Q3(b) Fuzzy relations and composition [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n<div class=\"given\" data-v2-context=\"true\"><h4>Given</h4><p>The fuzzy sets or relation matrices and their listed row/column order.</p><h4>To find</h4><p>The relation matrix/matrices and the composition specified in the question.</p></div><h4>Formula and why it applies</h4><p>For Cartesian products take min of row and column membership. For the ordered matrix composition shown here: <div class=\"math-display\"><img src=\"math/1a39e95150df91b7.svg\" alt=\"T_{ik}=\\max_j\\min(S_{ij},R_{jk})\" style=\"width:23.22ex;height:3.71ex\" loading=\"lazy\" decoding=\"async\"></div> If max–product is asked instead, replace the inner min by multiplication.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. R and S</h5>\r\n<div class=\"math-display\"><img src=\"math/463247054a5e2b55.svg\" alt=\"R=\\begin{bmatrix}0.4&amp;0.6&amp;0.3\\\\0.4&amp;0.4&amp;0.3\\\\0.1&amp;0.1&amp;0.1\\end{bmatrix},\\qquad S=\\begin{bmatrix}0.4&amp;0.5&amp;0.3\\\\0.2&amp;0.2&amp;0.2\\\\0.4&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:47.176ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. S ∘ R</h5>\r\n<div class=\"math-display\"><img src=\"math/07a16abae3efd072.svg\" alt=\"(1,1)=\\max[\\min(.4,.4),\\min(.5,.4),\\min(.3,.1)]=\\max(.4,.4,.1)=0.4\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/8e54167083aa61b1.svg\" alt=\"(1,2)=\\max[\\min(.4,.6),\\min(.5,.4),\\min(.3,.1)]=\\max(.4,.4,.1)=0.4\" style=\"width:67.889ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/6ce0ff88a64ad0ef.svg\" alt=\"(1,3)=\\max[\\min(.4,.3),\\min(.5,.3),\\min(.3,.1)]=0.3\" style=\"width:51.609ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c87a743bfa211789.svg\" alt=\"\\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\" style=\"width:100.894ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/f54af3b992bbd86c.svg\" alt=\"R=\\begin{bmatrix}.4&amp;.6&amp;.3\\\\.4&amp;.4&amp;.3\\\\.1&amp;.1&amp;.1\\end{bmatrix}\" style=\"width:17.558ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/acc98fbd37745e57.svg\" alt=\"S=\\begin{bmatrix}.4&amp;.5&amp;.3\\\\.2&amp;.2&amp;.2\\\\.4&amp;.4&amp;.3\\end{bmatrix}\" style=\"width:17.3ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/291bb354e326dcfa.svg\" alt=\"S\\circ R=\\begin{bmatrix}0.4&amp;0.4&amp;0.3\\\\0.2&amp;0.2&amp;0.2\\\\0.4&amp;0.4&amp;0.3\\end{bmatrix}\" style=\"width:24.548ex;height:8.597ex\" loading=\"lazy\" decoding=\"async\"></span>. (The key gives R and S only.)</div>\r\n</section>\r\n\r\n<!-- depth:all-cells:start -->\r\n<div class=\"concept-bridge\"><h2>Every cell without the row shortcuts</h2><p>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.</p><h3>R: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>R11</td><td>0.6</td><td>0.4</td><td>0.4</td></tr><tr><td>R12</td><td>0.6</td><td>0.8</td><td>0.6</td></tr><tr><td>R13</td><td>0.6</td><td>0.3</td><td>0.3</td></tr><tr><td>R21</td><td>0.4</td><td>0.4</td><td>0.4</td></tr><tr><td>R22</td><td>0.4</td><td>0.8</td><td>0.4</td></tr><tr><td>R23</td><td>0.4</td><td>0.3</td><td>0.3</td></tr><tr><td>R31</td><td>0.1</td><td>0.4</td><td>0.1</td></tr><tr><td>R32</td><td>0.1</td><td>0.8</td><td>0.1</td></tr><tr><td>R33</td><td>0.1</td><td>0.3</td><td>0.1</td></tr></tbody></table><h3>S: Cartesian-product cells</h3><table><thead><tr><th>Cell</th><th>Row degree</th><th>Column degree</th><th>min result</th></tr></thead><tbody><tr><td>S11</td><td>0.5</td><td>0.4</td><td>0.4</td></tr><tr><td>S12</td><td>0.5</td><td>0.8</td><td>0.5</td></tr><tr><td>S13</td><td>0.5</td><td>0.3</td><td>0.3</td></tr><tr><td>S21</td><td>0.2</td><td>0.4</td><td>0.2</td></tr><tr><td>S22</td><td>0.2</td><td>0.8</td><td>0.2</td></tr><tr><td>S23</td><td>0.2</td><td>0.3</td><td>0.2</td></tr><tr><td>S31</td><td>0.4</td><td>0.4</td><td>0.4</td></tr><tr><td>S32</td><td>0.4</td><td>0.8</td><td>0.4</td></tr><tr><td>S33</td><td>0.4</td><td>0.3</td><td>0.3</td></tr></tbody></table><p><strong>Result cell (1,1)</strong></p><div class=\"math-display\"><img src=\"math/21233f6c94b2b173.svg\" alt=\"\\max\\{\\min(0.4,0.4),\\min(0.5,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,2)</strong></p><div class=\"math-display\"><img src=\"math/999b4f88f5256b56.svg\" alt=\"\\max\\{\\min(0.4,0.6),\\min(0.5,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (1,3)</strong></p><div class=\"math-display\"><img src=\"math/d50a44d1852d902c.svg\" alt=\"\\max\\{\\min(0.4,0.3),\\min(0.5,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f11631b96248ce3d.svg\" alt=\"=\\max\\{0.3,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,1)</strong></p><div class=\"math-display\"><img src=\"math/c683e55ca4bccac0.svg\" alt=\"\\max\\{\\min(0.2,0.4),\\min(0.2,0.4),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,2)</strong></p><div class=\"math-display\"><img src=\"math/5eeb6f5598722d4c.svg\" alt=\"\\max\\{\\min(0.2,0.6),\\min(0.2,0.4),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (2,3)</strong></p><div class=\"math-display\"><img src=\"math/524a01bd31cd2a0e.svg\" alt=\"\\max\\{\\min(0.2,0.3),\\min(0.2,0.3),\\min(0.2,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e40652bfd4dc8015.svg\" alt=\"=\\max\\{0.2,0.2,0.1\\}=0.2\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,1)</strong></p><div class=\"math-display\"><img src=\"math/4c61c54bcac1075e.svg\" alt=\"\\max\\{\\min(0.4,0.4),\\min(0.4,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,2)</strong></p><div class=\"math-display\"><img src=\"math/cedfe000344abbe9.svg\" alt=\"\\max\\{\\min(0.4,0.6),\\min(0.4,0.4),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/891d26c6d9632710.svg\" alt=\"=\\max\\{0.4,0.4,0.1\\}=0.4\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p><strong>Result cell (3,3)</strong></p><div class=\"math-display\"><img src=\"math/98186c591a86ee1c.svg\" alt=\"\\max\\{\\min(0.4,0.3),\\min(0.4,0.3),\\min(0.3,0.1)\\}\" style=\"width:45.446ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f11631b96248ce3d.svg\" alt=\"=\\max\\{0.3,0.3,0.1\\}=0.3\" style=\"width:25.456ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:all-cells:end -->"},{"id":"q4a","title":"Q4(a) PSO, one iteration [10]","html":"<p class=\"question\"><strong>Question. Maximize <span class=\"math-inline\"><img src=\"math/523616224185a5ce.svg\" alt=\"F(x)=x_1^2-x_1x_2+x_2^2+3x_1+4x_2+5\" style=\"width:38.679ex;height:2.538ex\" loading=\"lazy\" decoding=\"async\"></span> using Particle Swarm Optimization. <span class=\"math-inline\"><img src=\"math/0ba0d9983a41cf83.svg\" alt=\"X=\\begin{bmatrix}3.1472&amp;-4.0246\\\\4.0579&amp;-2.2150\\end{bmatrix},\\;V=\\begin{bmatrix}0.2194&amp;0.2449\\\\0.1908&amp;0.2228\\end{bmatrix}\" style=\"width:47.54ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Take <span class=\"math-inline\"><img src=\"math/d99737a5fc79423b.svg\" alt=\"W=0.9,\\;c_1=c_2=1.5,\\;r_1=0.5949,\\;r_2=0.0855\" style=\"width:48.665ex;height:1.984ex\" loading=\"lazy\" decoding=\"async\"></span>. Optimize and give the solution after 1 iteration showing the step-by-step process.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4><p>P1: <span class=\"math-inline\"><img src=\"math/f58367ac748ee874.svg\" alt=\"x=(3.1472,\\,-4.0246)\" style=\"width:21.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/582ec15d8b22479d.svg\" alt=\"v=(0.2194,\\,0.2449)\" style=\"width:19.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. P2: <span class=\"math-inline\"><img src=\"math/1588eb472c257b22.svg\" alt=\"x=(4.0579,\\,-2.2150)\" style=\"width:21.786ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/ea7da7e3a3880e01.svg\" alt=\"v=(0.1908,\\,0.2228)\" style=\"width:19.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. <span class=\"math-inline\"><img src=\"math/37a512f090105dd3.svg\" alt=\"c_1r_1=0.89235\" style=\"width:14.409ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/c760fda5e7728aea.svg\" alt=\"c_2r_2=0.12825\" style=\"width:14.409ex;height:1.846ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p>Updated velocities, positions, pbest and gbest after one iteration.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/d17ec7429fc5876d.svg\" alt=\"v^{new}=wv+c_1r_1(pbest-x)+c_2r_2(gbest-x),\\quad x^{new}=x+v^{new}\" style=\"width:63.829ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. Fitness of P1 (term by term)</h5>\r\n<div class=\"math-display\"><img src=\"math/3c47a0a1f1465e31.svg\" alt=\"x_1^2=9.904868,\\;-x_1x_2=+12.666221,\\;x_2^2=16.197405,\\;3x_1=9.4416,\\;4x_2=-16.0984\" style=\"width:84.466ex;height:2.559ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/10f900e5ecd1d222.svg\" alt=\"F_1=9.904868+12.666221+16.197405+9.4416-16.0984+5=37.1117\" style=\"width:72.459ex;height:1.878ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 2. Fitness of P2</h5>\r\n<div class=\"math-display\"><img src=\"math/323572bf8ccf630b.svg\" alt=\"F_2=16.466552+8.988249+4.906225+12.1737-8.86+5=38.6747\" style=\"width:69.065ex;height:1.878ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 3. pbest and gbest</h5><p>pbest = current positions. <span class=\"math-inline\"><img src=\"math/0858b2bce4269ef8.svg\" alt=\"38.6747&gt;37.1117\" style=\"width:17.85ex;height:1.622ex\" loading=\"lazy\" decoding=\"async\"></span>, so <strong>gbest = P2 = (4.0579, −2.2150)</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 4. Particle 1 updates</h5>\r\n<div class=\"math-display\"><img src=\"math/0c6669f7602148c0.svg\" alt=\"v_{11}=0.9(0.2194)+0+0.12825(4.0579-3.1472)=0.19746+0.116797=0.314257\" style=\"width:81.325ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/c789efe14e1349c9.svg\" alt=\"x_{11}=3.1472+0.314257=3.461457\" style=\"width:35.262ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/82dc2ed77545eeb8.svg\" alt=\"v_{12}=0.9(0.2449)+0+0.12825(-2.2150+4.0246)=0.22041+0.232081=0.452491\" style=\"width:83.085ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<div class=\"math-display\"><img src=\"math/daa1f4fff8808c55.svg\" alt=\"x_{12}=-4.0246+0.452491=-3.572109\" style=\"width:38.782ex;height:1.871ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 5. Particle 2 updates (gbest particle: only inertia acts)</h5>\r\n<div class=\"math-display\"><img src=\"math/42d42b7358982c8c.svg\" alt=\"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\" style=\"width:95.402ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"step\"><h5>Step 6. New fitness and bests</h5><div data-v2-fitness=\"true\"><p>Use the same objective at each new position. Keep full precision internally; displayed coordinates are rounded.</p><div class=\"math-display\"><img src=\"math/b030a3c1723e90f0.svg\" alt=\"F(3.461457275,-3.5721088)=(3.461457275)^2-(3.461457275)(-3.5721088)+(-3.5721088)^2+3(3.461457275)+4(-3.5721088)+5\" style=\"width:130.757ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/246cb1e4add2ab6e.svg\" alt=\"=11.981686467+12.364701993+12.759961279+10.384371825+(-14.2884352)+5\\approx38.202286364\" style=\"width:100.058ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3fe27d20d1a3f2c2.svg\" alt=\"F(4.22962,-2.01448)=(4.22962)^2-(4.22962)(-2.01448)+(-2.01448)^2+3(4.22962)+4(-2.01448)+5\" style=\"width:103.608ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/a64c8baf9521e960.svg\" alt=\"=17.889685344+8.520484898+4.05812967+12.68886+(-8.05792)+5\\approx40.099239912\" style=\"width:88.746ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Particle</th><th>New position</th><th>New F</th><th>Old F</th><th>pbest</th></tr></thead><tbody>\r\n<tr><td>1</td><td>(3.461457, −3.572109)</td><td>38.2023</td><td>37.1117</td><td>updated</td></tr>\r\n<tr><td>2</td><td>(4.22962, −2.01448)</td><td>40.0992</td><td>38.6747</td><td>updated</td></tr></tbody></table></div>\r\n<p>The best pbest is now P2's with F = 40.0992, so gbest moves to (4.22962, −2.01448).</p></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> <span class=\"math-inline\"><img src=\"math/181c38752c9bafe9.svg\" alt=\"V=\\begin{bmatrix}0.314257&amp;0.452491\\\\0.17172&amp;0.20052\\end{bmatrix}\" style=\"width:26.504ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>, <span class=\"math-inline\"><img src=\"math/751b3a44f8f94dbc.svg\" alt=\"X=\\begin{bmatrix}3.461457&amp;-3.572109\\\\4.22962&amp;-2.01448\\end{bmatrix}\" style=\"width:28.451ex;height:5.43ex\" loading=\"lazy\" decoding=\"async\"></span>. Both particles improved; new gbest = (4.22962, −2.01448) with F = 40.0992.</div>\r\n<div class=\"keyfix\"><strong>Official key warning.</strong> The re-exam answer key solves a <em>different</em> 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.</div>\r\n<p class=\"marks-split\">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).</p>\r\n</section>\r\n"},{"id":"q4b","title":"Q4(b) Naive Bayes: job offer [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>The full training data are in Step 1. Query: Experience=Mid, Salary=Low, Reputation=Good. The main calculation uses unsmoothed counts.</p><h4>To find</h4><p>Both class scores and the predicted class.</p></div><h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/e0195b1e4ddb0473.svg\" alt=\"score(C)=P(C)\\prod_jP(a_j\\mid C)\" style=\"width:29.642ex;height:5.155ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4><div class=\"step\"><h5>Step 1. Write the training rows as a table</h5><table><thead><tr><th>Row</th><th>Experience</th><th>Salary</th><th>Reputation</th><th>Class</th></tr></thead><tbody><tr><td>1</td><td>Fresher</td><td>Low</td><td>Good</td><td>Yes</td></tr><tr><td>2</td><td>Mid</td><td>High</td><td>Good</td><td>Yes</td></tr><tr><td>3</td><td>Senior</td><td>High</td><td>Average</td><td>No</td></tr><tr><td>4</td><td>Fresher</td><td>Medium</td><td>Average</td><td>Yes</td></tr><tr><td>5</td><td>Senior</td><td>Low</td><td>Good</td><td>No</td></tr><tr><td>6</td><td>Mid</td><td>Medium</td><td>Good</td><td>Yes</td></tr><tr><td>7</td><td>Fresher</td><td>High</td><td>Average</td><td>No</td></tr><tr><td>8</td><td>Senior</td><td>Medium</td><td>Average</td><td>No</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Separate the two class groups</h5><table><thead><tr><th>Class</th><th>Rows in this group</th><th>Class count</th><th>Prior</th></tr></thead><tbody><tr><td>Yes</td><td>1, 2, 4, 6</td><td>4</td><td>4/8 = 0.5</td></tr><tr><td>No</td><td>3, 5, 7, 8</td><td>4</td><td>4/8 = 0.5</td></tr></tbody></table></div><div class=\"step\"><h5>Step 3. For class Yes, count Experience=Mid</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 2, 6.</p><div class=\"math-display\"><img src=\"math/d14d2e65e85aa98c.svg\" alt=\"P(\\text{Experience}=\\text{Mid}\\mid C=\\text{Yes})=\\frac{2}{4}=0.5\" style=\"width:42.49ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. For class Yes, count Salary=Low</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1.</p><div class=\"math-display\"><img src=\"math/b6e871091f36d8f9.svg\" alt=\"P(\\text{Salary}=\\text{Low}\\mid C=\\text{Yes})=\\frac{1}{4}=0.25\" style=\"width:39.285ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. For class Yes, count Reputation=Good</h5><p>Look only at class Yes rows 1, 2, 4, 6. The matching rows are 1, 2, 6.</p><div class=\"math-display\"><img src=\"math/00e0bac1e035a9f7.svg\" alt=\"P(\\text{Reputation}=\\text{Good}\\mid C=\\text{Yes})=\\frac{3}{4}=0.75\" style=\"width:45.266ex;height:4.586ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Multiply the Yes score one factor at a time</h5><div class=\"math-display\"><img src=\"math/fa6d94e12c8c8a44.svg\" alt=\"P(Yes)=4/8=0.5\" style=\"width:19.62ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cd8320ff28f21681.svg\" alt=\"0.5\\times0.5=0.25\" style=\"width:15.588ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/646a455657cc6928.svg\" alt=\"0.25\\times0.25=0.0625\" style=\"width:20.113ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9df28e0200ccc17b.svg\" alt=\"0.0625\\times0.75=0.046875\" style=\"width:24.638ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. For class No, count Experience=Mid</h5><p>Look only at class No rows 3, 5, 7, 8. No row in this class has that feature value.</p><div class=\"math-display\"><img src=\"math/210f557f91613842.svg\" alt=\"P(\\text{Experience}=\\text{Mid}\\mid C=\\text{No})=\\frac{0}{4}=0\" style=\"width:39.966ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. For class No, count Salary=Low</h5><p>Look only at class No rows 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/e95fc4843fd44476.svg\" alt=\"P(\\text{Salary}=\\text{Low}\\mid C=\\text{No})=\\frac{1}{4}=0.25\" style=\"width:38.52ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. For class No, count Reputation=Good</h5><p>Look only at class No rows 3, 5, 7, 8. The matching rows are 5.</p><div class=\"math-display\"><img src=\"math/6f502d0eec66aa0e.svg\" alt=\"P(\\text{Reputation}=\\text{Good}\\mid C=\\text{No})=\\frac{1}{4}=0.25\" style=\"width:44.502ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 10. Multiply the No score one factor at a time</h5><div class=\"math-display\"><img src=\"math/7ee037eb525f597a.svg\" alt=\"P(No)=4/8=0.5\" style=\"width:18.885ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/e71e2d0a61e9d301.svg\" alt=\"0.5\\times0=0\" style=\"width:10.937ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cf25ab85b70dd28a.svg\" alt=\"0\\times0.25=0\" style=\"width:12.068ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/cf25ab85b70dd28a.svg\" alt=\"0\\times0.25=0\" style=\"width:12.068ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 11. Compare the scores</h5><div class=\"math-display\"><img src=\"math/14926697646660d6.svg\" alt=\"score(Yes)=0.046875\\qquad score(No)=0\" style=\"width:41.131ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><p>The larger score belongs to Yes. Normalise only if a posterior probability is requested: divide each score by their total 0.046875.</p></div><div class=\"answer\"><strong>Final answer.</strong> Predict Yes. Yes score=0.046875; No score=0.</div></section><div class=\"keyfix\"><strong>Official key note.</strong> 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.</div><p class=\"memory\"><strong>Yaad rakho:</strong> Class ke rows alag karo. Har feature ka count usi class ke total se divide. Saare factors multiply karo.</p>"},{"id":"q5a","title":"Q5(a) Genetic algorithm [10]","html":"<p class=\"question\"><strong>Implement a GA to maximise <span class=\"math-inline\"><img src=\"math/d678d50d2d5c4ae4.svg\" alt=\"f(x)=2x^3-3x^2+8x\" style=\"width:22.099ex;height:2.452ex\" loading=\"lazy\" decoding=\"async\"></span> 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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><p><strong>The printed data are inconsistent.</strong> 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.</p><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>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.</p><h4>To find</h4><p>Two valid children under the declared assumptions and their fitness.</p></div><h4>Formula and why it applies</h4><p>Encoding must respect the candidate range. Crossover swaps tails; mutation flips the chosen bit. Fitness is evaluated after mutation.</p><div class=\"math-display\"><img src=\"math/68385220447af94f.svg\" alt=\"f(x)=2x^3-3x^2+8x\" style=\"width:22.099ex;height:2.565ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Encode and evaluate the declared parent population</h5><table><thead><tr><th>x</th><th>Binary</th><th>Fitness substitution</th></tr></thead><tbody><tr><td>12</td><td>001100</td><td>2(12³) − 3(12²) + 8(12) = 3120</td></tr><tr><td>20</td><td>010100</td><td>2(20³) − 3(20²) + 8(20) = 14960</td></tr><tr><td>17</td><td>010001</td><td>2(17³) − 3(17²) + 8(17) = 9095</td></tr><tr><td>13</td><td>001101</td><td>2(13³) − 3(13²) + 8(13) = 3991</td></tr></tbody></table></div><div class=\"step\"><h5>Step 2. Select the two fittest under the stated assumption</h5><p>[20, 17] with fitness [14960, 9095].</p></div><div class=\"step\"><h5>Step 3. Cut after bit 2 and exchange tails</h5><table><thead><tr><th>Parent 1</th><th>Parent 2</th><th>Child 1</th><th>Child 2</th></tr></thead><tbody><tr><td>01 | 0100</td><td>01 | 0001</td><td>010001</td><td>010100</td></tr></tbody></table></div><div class=\"step\"><h5>Step 4. Flip the last bit of each child</h5><table><thead><tr><th>Before</th><th>After</th><th>Decoded x</th></tr></thead><tbody><tr><td>010001</td><td>010000</td><td>16</td></tr><tr><td>010100</td><td>010101</td><td>21</td></tr></tbody></table></div><div class=\"step\"><h5>Step 5. Evaluate both children</h5><table><thead><tr><th>x</th><th>Fitness calculation</th></tr></thead><tbody><tr><td>16</td><td>2(4096) − 3(256) + 8(16) = 7552</td></tr><tr><td>21</td><td>2(9261) − 3(441) + 8(21) = 17367</td></tr></tbody></table></div><div class=\"step\"><h5>Step 6. Compare with the selected parents</h5><p>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.</p></div><div class=\"answer\"><strong>Final answer.</strong> 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.</div></section><p>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.</p>\r\n\r\n<!-- depth:polynomial-working:start -->\r\n<div class=\"concept-bridge\"><h2>Evaluate the polynomial without skipping the powers</h2><p>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.</p><h3>x=12</h3><div class=\"math-display\"><img src=\"math/68dcfd678cb95894.svg\" alt=\"x^2=12\\times12=144\\qquad x^3=144\\times12=1728\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5f6a8611548b73ce.svg\" alt=\"2x^3=3456\\quad 3x^2=432\\quad 8x=96\" style=\"width:33.009ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/ece74f225f6dc343.svg\" alt=\"f(12)=3456-432+96=3120\" style=\"width:31.538ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=20</h3><div class=\"math-display\"><img src=\"math/b143d22c2e5129d2.svg\" alt=\"x^2=20\\times20=400\\qquad x^3=400\\times20=8000\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/581d9ac708a9edf4.svg\" alt=\"2x^3=16000\\quad 3x^2=1200\\quad 8x=160\" style=\"width:36.402ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/af62ea37a6cc0979.svg\" alt=\"f(20)=16000-1200+160=14960\" style=\"width:36.063ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=17</h3><div class=\"math-display\"><img src=\"math/8106fc4d3ea404bb.svg\" alt=\"x^2=17\\times17=289\\qquad x^3=289\\times17=4913\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/3f446d5c18f6525b.svg\" alt=\"2x^3=9826\\quad 3x^2=867\\quad 8x=136\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/33f7934e87e644ca.svg\" alt=\"f(17)=9826-867+136=9095\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=13</h3><div class=\"math-display\"><img src=\"math/3b2d51c91ac2cf33.svg\" alt=\"x^2=13\\times13=169\\qquad x^3=169\\times13=2197\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/963b6763e9667406.svg\" alt=\"2x^3=4394\\quad 3x^2=507\\quad 8x=104\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/fb78bd652840ab88.svg\" alt=\"f(13)=4394-507+104=3991\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=16</h3><div class=\"math-display\"><img src=\"math/1a7d6636e629e211.svg\" alt=\"x^2=16\\times16=256\\qquad x^3=256\\times16=4096\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/116d99ec87e1c7e9.svg\" alt=\"2x^3=8192\\quad 3x^2=768\\quad 8x=128\" style=\"width:34.14ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/f0bfce15122fad53.svg\" alt=\"f(16)=8192-768+128=7552\" style=\"width:32.67ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><h3>x=21</h3><div class=\"math-display\"><img src=\"math/db60547636676c53.svg\" alt=\"x^2=21\\times21=441\\qquad x^3=441\\times21=9261\" style=\"width:44.788ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/7a74ad5911e6f0d8.svg\" alt=\"2x^3=18522\\quad 3x^2=1323\\quad 8x=168\" style=\"width:36.402ex;height:2.185ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/da828d5642e53dc9.svg\" alt=\"f(21)=18522-1323+168=17367\" style=\"width:36.063ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<!-- depth:polynomial-working:end -->"},{"id":"q5b","title":"Q5(b) Hotel booking channels (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: W, A, C. Initial vector [0.4, 0.35, 0.25].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>W</th><th>A</th><th>C</th></tr></thead><tbody><tr><td>W</td><td>0.5</td><td>0.3</td><td>0.2</td></tr><tr><td>A</td><td>0.4</td><td>0.4</td><td>0.2</td></tr><tr><td>C</td><td>0.2</td><td>0.3</td><td>0.5</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_booking.a7176dff51.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to W</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to W</th><th>Contribution</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.5</td><td>0.4 × 0.5 = 0.2</td></tr><tr><td>A</td><td>0.35</td><td>0.4</td><td>0.35 × 0.4 = 0.14</td></tr><tr><td>C</td><td>0.25</td><td>0.2</td><td>0.25 × 0.2 = 0.05</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/0367611df103826d.svg\" alt=\"W_{new}=0.2+0.14+0.05=0.39\" style=\"width:31.699ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to A</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to A</th><th>Contribution</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.3</td><td>0.4 × 0.3 = 0.12</td></tr><tr><td>A</td><td>0.35</td><td>0.4</td><td>0.35 × 0.4 = 0.14</td></tr><tr><td>C</td><td>0.25</td><td>0.3</td><td>0.25 × 0.3 = 0.075</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/5f59f5d8bf197b8d.svg\" alt=\"A_{new}=0.12+0.14+0.075=0.335\" style=\"width:34.654ex;height:1.977ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to C</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to C</th><th>Contribution</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.2</td><td>0.4 × 0.2 = 0.08</td></tr><tr><td>A</td><td>0.35</td><td>0.2</td><td>0.35 × 0.2 = 0.07</td></tr><tr><td>C</td><td>0.25</td><td>0.5</td><td>0.25 × 0.5 = 0.125</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/7892e8414e63bbd0.svg\" alt=\"C_{new}=0.08+0.07+0.125=0.275\" style=\"width:34.575ex;height:1.952ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: find Counter first</h5><div class=\"math-display\"><img src=\"math/39cb7355944fbe4a.svg\" alt=\"c=0.2w+0.2a+0.5c\" style=\"width:21.999ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div><p>Since w+a+c=1, replace w+a with 1−c.</p><div class=\"math-display\"><img src=\"math/49f2613d4b58dc75.svg\" alt=\"c=0.2(1-c)+0.5c=0.2+0.3c\" style=\"width:32.707ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/eaaea4df9a4e16b6.svg\" alt=\"0.7c=0.2\\quad c=2/7\" style=\"width:19.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Find App in terms of Website</h5><div class=\"math-display\"><img src=\"math/ac7bb8ac13980636.svg\" alt=\"a=0.3w+0.4a+0.3c\" style=\"width:22.216ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/5e60a8a8d562c8fe.svg\" alt=\"0.6a=0.3w+0.3c\\quad a=0.5w+0.5c\" style=\"width:35.878ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Use the sum to isolate Website</h5><div class=\"math-display\"><img src=\"math/748747a4be5b6069.svg\" alt=\"w+(0.5w+0.5c)+c=1\" style=\"width:25.188ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/9499078f217c4146.svg\" alt=\"1.5w=1-1.5c=1-3/7=4/7\" style=\"width:32.015ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/38376c6530974a73.svg\" alt=\"w=(4/7)/1.5=8/21\" style=\"width:21.355ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/afad15a4af697ec7.svg\" alt=\"a=1-w-c=1-8/21-6/21=7/21=1/3\" style=\"width:46.158ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>W</td><td>0.4</td><td>0.380952381</td><td>-0.019047619</td><td>Loses</td></tr><tr><td>A</td><td>0.35</td><td>0.333333333</td><td>-0.016666667</td><td>Loses</td></tr><tr><td>C</td><td>0.25</td><td>0.285714286</td><td>0.035714286</td><td>Gains</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [0.39, 0.335, 0.275]. Stationary shares ≈ [0.380952381, 0.333333333, 0.285714286]. W loses, A loses, C gains.</div></section>"},{"id":"q6a","title":"Q6(a) ACO for TSP [10]","html":"<p class=\"question\"><strong>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.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\">\r\n\r\n<div class=\"given\"><h4>Given</h4>\r\n<div class=\"math-display\"><img src=\"math/21fbc23ee8a38afa.svg\" alt=\"D=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;1&amp;2&amp;3\\\\B&amp;1&amp;0&amp;4&amp;5\\\\C&amp;2&amp;4&amp;0&amp;6\\\\D&amp;3&amp;5&amp;6&amp;0\\end{array},\\qquad\\tau_{ij}=1\\;(i\\ne j)\" style=\"width:41.536ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Assume <span class=\"math-inline\"><img src=\"math/215be7d8bc049557.svg\" alt=\"\\alpha=\\beta=1,\\;\\rho=0.5,\\;Q=1\" style=\"width:26.18ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>.</p><h4>To find</h4><p>Both tours, their lengths and the pheromone matrix after one iteration.</p></div>\r\n<h4>Formula and why it applies</h4><div class=\"math-display\"><img src=\"math/5b888e9e5a3c73eb.svg\" alt=\"P_{ij}=\\frac{\\tau_{ij}^{\\alpha}(1/d_{ij})^\\beta}{\\sum_{k\\in allowed}\\tau_{ik}^{\\alpha}(1/d_{ik})^\\beta}\" style=\"width:27.444ex;height:6.404ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/d5297204b4481c8e.svg\" alt=\"\\tau_{ij}^{new}=(1-\\rho)\\tau_{ij}+\\sum_{k:\\,ij\\in tour_k}\\frac{Q}{L_k}\" style=\"width:30.908ex;height:6.181ex\" loading=\"lazy\" decoding=\"async\"></div><p>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.</p><h4>Solution</h4>\r\n<div class=\"step\"><h5>Step 1. From A</h5>\r\n<div class=\"math-display\"><img src=\"math/d7a22769c0bad254.svg\" alt=\"\\eta:\\;B=1,\\;C=0.5,\\;D=0.3333;\\;\\text{sum}=1.8333\\Rightarrow P=0.5455,\\;0.2727,\\;0.1818\" style=\"width:76.91ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative: B 0–0.5455, C 0.5455–0.8182, D 0.8182–1. Ant 1 (0.3) → <strong>B</strong>; Ant 2 (0.5) → <strong>B</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 2. From B (C and D left)</h5>\r\n<div class=\"math-display\"><img src=\"math/9d1964928f02cbff.svg\" alt=\"\\eta:\\;C=0.25,\\;D=0.2;\\;\\text{sum}=0.45\\Rightarrow P_{BC}=0.5556,\\;P_{BD}=0.4444\" style=\"width:66.532ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<p>Cumulative: C 0–0.5556, D 0.5556–1. Ant 1 (0.8) → <strong>D</strong>; Ant 2 (0.7) → <strong>D</strong>.</p></div>\r\n<div class=\"step\"><h5>Step 3. Complete the tours</h5>\r\n<div class=\"math-display\"><img src=\"math/1409076465c0fee4.svg\" alt=\"A\\to B\\to D\\to C\\to A,\\qquad L=1+5+6+2=14\\;\\text{(both ants)}\" style=\"width:62.614ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div>\r\n<figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/aco_reexam_graph.02195c6ee9.svg\" width=\"520\" height=\"380\" alt=\"Re-exam 2026 Q6a: both ants A → B → D → C → A, length 14\" loading=\"lazy\" decoding=\"async\"></div></figure></div>\r\n<div class=\"step\"><h5>Step 4. Pheromone update</h5>\r\n<p>Used edges AB, BD, DC, CA get <span class=\"math-inline\"><img src=\"math/a677db1cbc02a07c.svg\" alt=\"0.5(1)+2\\times\\frac1{14}=0.6429\" style=\"width:24.343ex;height:2.737ex\" loading=\"lazy\" decoding=\"async\"></span>; unused edges AD and BC become <span class=\"math-inline\"><img src=\"math/97dede1883211cd7.svg\" alt=\"0.5\" style=\"width:2.891ex;height:1.557ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\r\n<div class=\"math-display\"><img src=\"math/25cf4d02bee20e2a.svg\" alt=\"\\tau_{\\text{new}}=\\begin{array}{c|cccc}&amp;A&amp;B&amp;C&amp;D\\\\\\hline A&amp;0&amp;0.6429&amp;0.6429&amp;0.5\\\\B&amp;0.6429&amp;0&amp;0.5&amp;0.6429\\\\C&amp;0.6429&amp;0.5&amp;0&amp;0.6429\\\\D&amp;0.5&amp;0.6429&amp;0.6429&amp;0\\end{array}\" style=\"width:42.542ex;height:15.09ex\" loading=\"lazy\" decoding=\"async\"></div></div>\r\n<div class=\"answer\"><strong>Final answer.</strong> Both ants: A → B → D → C → A, length 14. Pheromone 0.6429 on AB, BD, CD, AC; 0.5 on AD, BC.</div>\r\n<div class=\"keyfix\"><strong>Official key note.</strong> This key applies <em>no evaporation</em> (<span class=\"math-inline\"><img src=\"math/7856892795a9fcf9.svg\" alt=\"1+0.1428=1.1428\" style=\"width:19.484ex;height:1.717ex\" loading=\"lazy\" decoding=\"async\"></span>) 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.</div>\r\n</section>\r\n"},{"id":"q6b","title":"Q6(b) Aircraft movement between hubs (Markov chain) [10]","html":"<p class=\"question\"><strong>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?</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3><section class=\"example\"><div class=\"given\"><h4>Given</h4><p>All transition values are given in the full question. State order: A, B, C. Initial vector [30, 40, 30].</p><h4>To find</h4><p>The matrix, diagram, next-step vector and long-run comparison.</p></div><h4>Formula and why it applies</h4><p>Rows mean current state; columns mean next state. For each destination, multiply each origin amount by its transition probability, then add.</p><div class=\"math-display\"><img src=\"math/b179f364b70ac72c.svg\" alt=\"x_{next}=x_{now}P\\qquad\\pi=\\pi P,\\quad\\sum_i\\pi_i=1\" style=\"width:38.67ex;height:4.847ex\" loading=\"lazy\" decoding=\"async\"></div><h4>Solution</h4><div class=\"step\"><h5>Step 1. Convert every origin row to probabilities</h5><table><thead><tr><th>From / To</th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr><td>A</td><td>0.5</td><td>0.3</td><td>0.2</td></tr><tr><td>B</td><td>0.4</td><td>0.4</td><td>0.2</td></tr><tr><td>C</td><td>0.25</td><td>0.25</td><td>0.5</td></tr></tbody></table><p>Each row sums to 1 because it lists all possible destinations for that origin. A percentage is divided by 100: 25%=.25.</p></div><div class=\"step\"><h5>Step 2. Interpret entries and draw the transitions</h5><p>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.</p><figure class=\"fig\"><span class=\"diagram-hint\">Swipe across the diagram to read its labels ↔</span><div class=\"diagram-pan\" tabindex=\"0\" role=\"group\" aria-label=\"Teaching diagram; use left and right arrow keys to scroll\"><img src=\"fig/mk_airline.779a8c5fd6.svg\" width=\"560\" height=\"390\" alt=\"Each arrow is labelled with the probability of that transition.\" loading=\"lazy\" decoding=\"async\"></div><figcaption>Each arrow is labelled with the probability of that transition.</figcaption></figure></div><div class=\"step\"><h5>Step 3. Next step: collect all contributions to A</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to A</th><th>Contribution</th></tr></thead><tbody><tr><td>A</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr><tr><td>B</td><td>40</td><td>0.4</td><td>40 × 0.4 = 16</td></tr><tr><td>C</td><td>30</td><td>0.25</td><td>30 × 0.25 = 7.5</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/67abb9b77cf134f6.svg\" alt=\"A_{new}=15+16+7.5=38.5\" style=\"width:27.74ex;height:1.977ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 4. Next step: collect all contributions to B</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to B</th><th>Contribution</th></tr></thead><tbody><tr><td>A</td><td>30</td><td>0.3</td><td>30 × 0.3 = 9</td></tr><tr><td>B</td><td>40</td><td>0.4</td><td>40 × 0.4 = 16</td></tr><tr><td>C</td><td>30</td><td>0.25</td><td>30 × 0.25 = 7.5</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/c43c2e3add5e9f7a.svg\" alt=\"B_{new}=9+16+7.5=32.5\" style=\"width:26.629ex;height:1.902ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 5. Next step: collect all contributions to C</h5><table><thead><tr><th>Origin</th><th>Current count/share</th><th>Transition to C</th><th>Contribution</th></tr></thead><tbody><tr><td>A</td><td>30</td><td>0.2</td><td>30 × 0.2 = 6</td></tr><tr><td>B</td><td>40</td><td>0.2</td><td>40 × 0.2 = 8</td></tr><tr><td>C</td><td>30</td><td>0.5</td><td>30 × 0.5 = 15</td></tr></tbody></table><div class=\"math-display\"><img src=\"math/e1d10b6213a4f6c2.svg\" alt=\"C_{new}=6+8+15=29\" style=\"width:23.009ex;height:1.952ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 6. Stationarity: find C first</h5><div class=\"math-display\"><img src=\"math/063ad466582b38bf.svg\" alt=\"c=0.2(a+b)+0.5c\" style=\"width:20.218ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/49f2613d4b58dc75.svg\" alt=\"c=0.2(1-c)+0.5c=0.2+0.3c\" style=\"width:32.707ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/eaaea4df9a4e16b6.svg\" alt=\"0.7c=0.2\\quad c=2/7\" style=\"width:19.432ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 7. Find B in terms of A</h5><div class=\"math-display\"><img src=\"math/8b2ff5dead1627ab.svg\" alt=\"b=0.3a+0.4b+0.25c\" style=\"width:22.472ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/463b4822655ff527.svg\" alt=\"0.6b=0.3a+0.25c\" style=\"width:18.735ex;height:1.756ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/c6b1f0d1f25d8a7c.svg\" alt=\"b=0.5a+\\frac5{12}c\" style=\"width:15.079ex;height:4.588ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 8. Use a+b=1−c</h5><div class=\"math-display\"><img src=\"math/2e4dfec7416e59d8.svg\" alt=\"a+0.5a+\\frac5{12}\\frac27=1-\\frac27=\\frac57\" style=\"width:30.386ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/dbf72a6e6a9bedfd.svg\" alt=\"1.5a=\\frac57-\\frac5{42}=\\frac{25}{42}\" style=\"width:21.531ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/8653487298ec14a0.svg\" alt=\"a=\\frac{25}{42}\\div\\frac32=\\frac{25}{63}\" style=\"width:18.639ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div><div class=\"math-display\"><img src=\"math/369b239ecbe26cbf.svg\" alt=\"b=1-\\frac{25}{63}-\\frac{18}{63}=\\frac{20}{63}\" style=\"width:23.441ex;height:4.638ex\" loading=\"lazy\" decoding=\"async\"></div></div><div class=\"step\"><h5>Step 9. Compare the stationary shares with the initial shares</h5><table><thead><tr><th>State</th><th>Initial share</th><th>Stationary share</th><th>Change in share</th><th>Conclusion</th></tr></thead><tbody><tr><td>A</td><td>0.3</td><td>0.396825397</td><td>0.096825397</td><td>Gains</td></tr><tr><td>B</td><td>0.4</td><td>0.317460317</td><td>-0.082539683</td><td>Loses</td></tr><tr><td>C</td><td>0.3</td><td>0.285714286</td><td>-0.014285714</td><td>Loses</td></tr></tbody></table><p>Compare like with like: divide counts by their total before comparing with stationary probabilities. “Stationary” means one more step leaves the shares unchanged.</p></div><div class=\"answer\"><strong>Final answer.</strong> Next-step vector [38.5, 32.5, 29.0]. Stationary shares ≈ [0.396825397, 0.317460317, 0.285714286]. A gains, B loses, C loses.</div></section>"},{"id":"q7a","title":"Q7(a) Applications of fuzzy logic [10]","html":"<p class=\"question\"><strong>List the applications of fuzzy logic. Explain any one application in detail.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\r\n<div class=\"answer-box\">\r\n<h3>Definition</h3>\r\n<p>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”.</p>\r\n<h3>Applications</h3>\r\n<div class=\"table-wrap\"><table><thead><tr><th>Area</th><th>Examples</th></tr></thead><tbody>\r\n<tr><td>Home appliances</td><td>Washing machines (wash time from dirt and load), air conditioners, refrigerators, rice cookers, vacuum cleaners</td></tr>\r\n<tr><td>Automotive</td><td>Automatic transmission, anti-lock braking (ABS), cruise control, engine control</td></tr>\r\n<tr><td>Transportation</td><td>Traffic-signal control, Sendai subway train control (smooth braking and acceleration)</td></tr>\r\n<tr><td>Consumer electronics</td><td>Camera autofocus and auto-exposure, image stabilisation</td></tr>\r\n<tr><td>Industrial control</td><td>Cement kilns, pH, temperature and distillation control in chemical plants</td></tr>\r\n<tr><td>Aerospace</td><td>Satellite and spacecraft attitude control</td></tr>\r\n<tr><td>Medicine</td><td>Diagnosis support, anaesthesia dosage control</td></tr>\r\n<tr><td>Finance and decisions</td><td>Loan approval, credit and fire-risk scoring, stock trading rules</td></tr>\r\n<tr><td>AI and robotics</td><td>Robot navigation, natural-language interfaces, expert systems</td></tr>\r\n</tbody></table></div>\r\n\r\n<h3>One application in detail: fuzzy washing machine</h3>\r\n<ol>\r\n<li><strong>Problem.</strong> 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.</li>\r\n<li><strong>Inputs and outputs.</strong> 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.</li>\r\n<li><strong>Fuzzification.</strong> Sensor readings are converted to membership degrees, e.g. dirt 60% → Medium 0.8, High 0.2.</li>\r\n<li><strong>Rule base.</strong> 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.</li>\r\n<li><strong>Inference.</strong> Mamdani min–max: rule strength = min of the two memberships; outputs combined by max.</li>\r\n<li><strong>Defuzzification.</strong> 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.</li>\r\n<li><strong>Benefits.</strong> Smooth adjustment to every load, saves water and electricity, easy to design from expert knowledge without an exact mathematical model.</li>\r\n</ol>\r\n<h3>Advantages and disadvantages (bonus)</h3>\r\n<p><strong>Advantages:</strong> handles imprecise or noisy data; mimics human reasoning; easy to design and modify; no exact model needed; low computational cost. <strong>Disadvantages:</strong> 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.</p>\r\n</div>\r\n<div class=\"memory\"><strong>Yaad rakho:</strong> Application explain karte waqt 5 cheezein: inputs, fuzzy sets, rules, inference (min/max), defuzzification + ek number ka example.</div>\r\n"},{"id":"q7b","title":"Q7(b) Bellman equation and applications of RL [10]","html":"<p class=\"question\"><strong>Explain the Bellman equation in reinforcement learning. Also give applications of reinforcement learning.</strong> <span class=\"marks\">[10 marks]</span></p><h3>Answer</h3>\n\n<p>Write the answer below in this order. It fits in about two pages.</p>\n\n<div class=\"answer-box\">\n<h3>Part A · Bellman equation (5 marks)</h3>\n<p><strong>1. Setting.</strong> Reinforcement learning problems are modelled as a Markov decision process <span class=\"math-inline\"><img src=\"math/2a8c7332f3030a47.svg\" alt=\"\\langle\\mathcal S,\\mathcal A,P,R,\\gamma\\rangle\" style=\"width:13.735ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>. The agent follows a policy <span class=\"math-inline\"><img src=\"math/f155e46af3f71ce4.svg\" alt=\"\\pi(a\\mid s)\" style=\"width:7.194ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and wants to maximise the return <span class=\"math-inline\"><img src=\"math/3f482d8ea694678d.svg\" alt=\"G_t=\\sum_{k\\ge0}\\gamma^kR_{t+k+1}\" style=\"width:20.364ex;height:2.798ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>2. Value functions.</strong> <span class=\"math-inline\"><img src=\"math/a27ddca95f461e82.svg\" alt=\"v_\\pi(s)=\\mathbb E_\\pi[G_t\\mid S_t=s]\" style=\"width:22.562ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> and <span class=\"math-inline\"><img src=\"math/0885e6b22d6c67c2.svg\" alt=\"q_\\pi(s,a)=\\mathbb E_\\pi[G_t\\mid S_t=s,A_t=a]\" style=\"width:32.358ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>3. Key idea.</strong> The return is recursive: <span class=\"math-inline\"><img src=\"math/837aecc6afff8d86.svg\" alt=\"G_t=R_{t+1}+\\gamma G_{t+1}\" style=\"width:18.67ex;height:2.084ex\" loading=\"lazy\" decoding=\"async\"></span>. Taking expectations gives the <strong>Bellman expectation equation</strong>:</p>\n<div class=\"math-display\"><img src=\"math/cd7f793810f9ae1e.svg\" alt=\"v_\\pi(s)=\\sum_a\\pi(a\\mid s)\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R(s,a,s&#39;)+\\gamma v_\\pi(s&#39;)]\" style=\"width:53.904ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\n<div class=\"math-display\"><img src=\"math/0aaca96cab3cf147.svg\" alt=\"q_\\pi(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,\\Big[R(s,a,s&#39;)+\\gamma\\sum_{a&#39;}\\pi(a&#39;\\mid s&#39;)q_\\pi(s&#39;,a&#39;)\\Big]\" style=\"width:60.894ex;height:5.335ex\" loading=\"lazy\" decoding=\"async\"></div>\n<p><strong>4. Optimality.</strong> For the optimal policy the average over actions becomes a maximum (<strong>Bellman optimality equation</strong>):</p>\n<div class=\"math-display\"><img src=\"math/cc767eadfe69fc8c.svg\" alt=\"v_*(s)=\\max_a\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma v_*(s&#39;)],\\qquad q_*(s,a)=\\sum_{s&#39;}P(s&#39;\\mid s,a)\\,[R+\\gamma\\max_{a&#39;}q_*(s&#39;,a&#39;)]\" style=\"width:89.433ex;height:4.883ex\" loading=\"lazy\" decoding=\"async\"></div>\n<p><strong>5. Meaning and use.</strong> 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 <span class=\"math-inline\"><img src=\"math/f3cf791d9745c384.svg\" alt=\"\\pi_*(s)=\\arg\\max_a q_*(s,a)\" style=\"width:24.284ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n<p><strong>6. Small illustration</strong> (adds clarity): if staying in a state gives +1 each step with <span class=\"math-inline\"><img src=\"math/c491a3a52610e919.svg\" alt=\"\\gamma=0.9\" style=\"width:7.137ex;height:1.995ex\" loading=\"lazy\" decoding=\"async\"></span>, then <span class=\"math-inline\"><img src=\"math/64606eb39a2dfd24.svg\" alt=\"v=1+0.9v\\Rightarrow v=10\" style=\"width:21.896ex;height:1.692ex\" loading=\"lazy\" decoding=\"async\"></span>.</p>\n\n<h3>Part B · Applications of reinforcement learning (5 marks)</h3>\n<ol>\n<li><strong>Game playing</strong>: AlphaGo (defeated Lee Sedol, 2016), Atari agents (DQN), and the Mario agent built in this course's lab.</li>\n<li><strong>Robotics</strong>: walking, grasping and balancing learned by trial and error in simulation.</li>\n<li><strong>Autonomous driving</strong>: lane changing, merging and parking decisions.</li>\n<li><strong>Recommendation systems</strong>: choosing content to maximise long-term engagement rather than single clicks.</li>\n<li><strong>Finance</strong>: trading and portfolio rebalancing as sequential decisions.</li>\n<li><strong>Healthcare</strong>: dynamic treatment regimes (dose adjustment over time).</li>\n<li><strong>Resource and energy management</strong>: data-centre cooling control, traffic-signal timing, inventory control.</li>\n<li><strong>Language models</strong>: reinforcement learning from human feedback (RLHF) for chatbots.</li>\n</ol>\n<h4>One application in detail: traffic-signal control</h4>\n<div class=\"table-wrap\"><table><tbody>\n<tr><th>Agent</th><td>Controller at an intersection.</td></tr>\n<tr><th>State</th><td>Queue length and waiting time on each approach, current signal phase.</td></tr>\n<tr><th>Actions</th><td>Keep the current phase or switch to the next green phase.</td></tr>\n<tr><th>Reward</th><td>Negative of total waiting time (or vehicles cleared per cycle).</td></tr>\n<tr><th>Learning</th><td>Q-learning updates <span class=\"math-inline\"><img src=\"math/0caba73ef360f772.svg\" alt=\"Q(s,a)\" style=\"width:6.814ex;height:2.262ex\" loading=\"lazy\" decoding=\"async\"></span> from observed traffic; ε-greedy exploration tries alternative timings.</td></tr>\n<tr><th>Benefit</th><td>Adapts to rush hours and incidents; fixed timers cannot.</td></tr>\n<tr><th>Challenge</th><td>Safety during exploration, so agents are trained in simulation first.</td></tr>\n</tbody></table></div>\n</div>\n\n<div class=\"memory\"><strong>Yaad rakho:</strong> Bellman ka sar: “value = reward abhi + γ × value aage”. Application likho to S, A, R batao: examiner ko yahi chahiye.</div>\n"}]}],"revision":[{"id":"m2-revision-v2","title":"Last-day revision","unit":"M2","scope":"A compact read after the worked lessons.","sections":[{"id":"final-read","title":"The final revision: methods, theory and common mistakes","html":"<h2>Q1: short calculations and definitions</h2><table><thead><tr><th>Asked for</th><th>Write</th></tr></thead><tbody>\r\n<tr><td>Union / intersection</td><td>Same element, max / min respectively.</td></tr><tr><td>Complement / difference</td><td>1−μA / min(μA,1−μB).</td></tr><tr><td>Triangle membership</td><td>Locate x; rising (x−a)/(b−a), falling (c−x)/(c−b), 0 outside, 1 at peak.</td></tr><tr><td>Swarm intelligence</td><td>Collective problem-solving emerging from interacting simple agents; explain PSO through position, velocity, pbest and gbest.</td></tr></tbody></table>\r\n<h2>GA: the table to make in the exam</h2><p>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.</p>\r\n<p>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.</p>\r\n<h2>PSO: the table to make in the exam</h2><p>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.</p>\r\n<p>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.</p>\r\n<h2>Fuzzy controller: five operations</h2><ol><li>Calculate input memberships using the specified graphs.</li><li>Apply AND=min or the supplied connective to obtain rule strengths.</li><li>Clip consequents using min-implication.</li><li>Combine output sets by max-aggregation.</li><li>Use the named defuzzification method. MoM, full area centroid and peak-weighted average are different operations.</li></ol>\r\n<h2>Three short theory answers to revise</h2><p><strong>Mamdani:</strong> 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.</p><p><strong>GA:</strong> population search inspired by evolution, using evaluation, selection, crossover, mutation and replacement. Flexible and derivative-free, but may be expensive or converge prematurely.</p><p><strong>PSO:</strong> particles move using inertia, personal best and swarm best. Simple and derivative-free, but parameter-dependent and not guaranteed to find a global optimum.</p>\r\n<h2>Calculator and rounding</h2><p>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.</p>\r\n<p class=\"memory\"><strong>Yaad rakho:</strong> Question ki instruction follow karo; answer ko sundar banane ke liye data ya operator mat badlo.</p>"}]},{"id":"tee-revision","title":"Last-day revision · TEE","unit":"0","scope":"Read the night before the TEE","sections":[{"id":"units-1-and-4","title":"Units 1 and 4 in one page","html":"<h2>Unit 1</h2>\n<ul>\n<li>Logic fails under uncertainty (laziness, theoretical and practical ignorance) → degrees of belief. Decision theory = probability + utility; maximise expected utility.</li>\n<li>Full joint: add the cells where the statement is true; for “given”, divide by the evidence cells. Check the table sums to 1.</li>\n<li>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.</li>\n<li>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.</li>\n<li>Bayesian network: DAG + CPTs; joint = Π P(node | parents); a node is independent of non-descendants given its parents; <span class=\"math-inline\"><img src=\"math/1e088370ad90412f.svg\" alt=\"2^k\" style=\"width:2.152ex;height:1.932ex\" loading=\"lazy\" decoding=\"async\"></span> numbers per Boolean node.</li>\n<li>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.</li>\n<li>Univariate GMM: <span class=\"math-inline\"><img src=\"math/68bcea7fd026bedf.svg\" alt=\"p(x)=\\sum_k\\pi_k\\mathcal N(x\\mid\\mu_k,\\sigma_k^2)\" style=\"width:26.168ex;height:2.601ex\" loading=\"lazy\" decoding=\"async\"></span>. 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.</li>\n<li>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.</li>\n</ul>\n<h2>Unit 4</h2>\n<ul>\n<li>Agent, environment, state, action, reward, policy, value, model; exploration vs exploitation (ε-greedy).</li>\n<li>Markov chain: rows = from, columns = to; row sums 1; next = row vector × P; diagram with self-loops.</li>\n<li>Steady state: π = πP, Σπ = 1; compare with today's shares for gain/loss; diagonal = retention.</li>\n<li>MP ⟨S, P⟩ → MRP ⟨S, P, R, γ⟩ → MDP ⟨S, A, P, R, γ⟩.</li>\n<li>Bellman: value = immediate reward + γ × expected next value; optimality replaces Σπ by max.</li>\n<li>Applications: games, robotics, self-driving, recommendation, finance, healthcare, traffic signals, data-centre cooling, RLHF.</li>\n</ul>\n<div class=\"trap\"><strong>Unit 1 and 4 traps:</strong> (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 (P<sub>ii</sub> must be 1).</div>"}]}],"about":[{"id":"about","title":"Portion, sources and corrections","unit":"0","scope":"What this guide covers, where it came from, and every error found in the slides and answer keys","sections":[{"id":"portion-sources","title":"Portion, source priority and what was checked","html":"<h2>M2</h2><p>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.</p>\r\n<h2>TEE official syllabus</h2><ol><li>Uncertain knowledge and reasoning: uncertainty, full joint distributions, Bayes, naive Bayes, Bayesian networks, mixture models, GMM, EM and clustering.</li><li>Fuzzy systems: rules, properties/operations, membership functions, intuition-based fuzzification, mean of maxima, centroid, Mamdani and applications.</li><li>Evolutionary intelligence: biological basis, GA terms/search space, simple/general GA, encoding/selection/crossover/mutation, stopping, constraints, GA-for-TSP, ACO and swarm optimisation.</li><li>Reinforcement learning: Markov processes, MRP, MDP, policies, value functions, Bellman equations and applications.</li></ol>\r\n<p>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.</p>\r\n<h2>Source priority</h2><p>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.</p>\r\n<p>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.</p>\r\n<h2>Technical references used for checking conventions</h2><ul>\r\n<li><a href=\"https://www.mathworks.com/help/fuzzy/fuzzy-inference-process.html\">MathWorks: fuzzy inference process</a> — separation of antecedent operations, implication, aggregation and defuzzification.</li>\r\n<li><a href=\"https://www.mathworks.com/help/fuzzy/defuzz.html\">MathWorks: defuzzification definitions</a> — centroid uses the area; MoM uses locations at the maximum.</li>\r\n<li><a href=\"https://www.mathworks.com/help/gads/particle-swarm-optimization-algorithm.html\">MathWorks: particle swarm update</a> — velocity components and best-position memory. Its adaptive neighbourhood implementation is not substituted for the fixed classroom global-best examples.</li></ul>\r\n<p>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.</p>"},{"id":"corrections","title":"How inconsistent source questions are handled","html":"<h2>State the issue before solving a changed question</h2><p>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.</p>\r\n<p>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.</p>\r\n<p>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.</p>\r\n<p>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.</p>"}]}]}}}
