Statistical AnalysisStatistical Analysis

From data summaries to confidence intervals, hypothesis tests and regression — and how they help catch attackers. Data summary থেকে confidence interval, hypothesis test আর regression — আর এগুলো দিয়ে কীভাবে attacker ধরা যায়।

About this chapter: This topic is for the BUET IICT MSc in Information Security written test. Statistical Analysis is an optional topic there (you answer any 6 of 10 topics). It builds on Chapter 04 (Probability & Statistics). Read Chapter 04 first if mean, variance, normal distribution or Bayes theorem feel new.
এই chapter সম্পর্কে: এই topic BUET IICT MSc in Information Security written test-এর জন্য। সেখানে Statistical Analysis একটা optional topic (10টা topic থেকে যেকোনো 6টা answer করতে হয়)। এটা Chapter 04 (Probability & Statistics)-এর উপর দাঁড়িয়ে আছে। Mean, variance, normal distribution বা Bayes theorem নতুন লাগলে আগে Chapter 04 পড়ে নাও।

1. Quick Recap and Data Summaries1. Quick Recap আর Data Summary

Quick recap (from Chapter 04)Quick recap (Chapter 04 থেকে)

Recap: These were fully explained in Chapter 04, Section 7. Here is the one-line version of each.
  • Mean \( \bar{x} = \frac{1}{n}\sum x_i \) — the average.
  • Median — the middle value after sorting.
  • Mode — the most frequent value.
  • Variance — average squared distance from the mean. Population: divide by \(N\). Sample: divide by \(n-1\).
  • Standard deviation (SD) — square root of variance. Same unit as the data.
In this chapter we go further: we use these numbers to make decisions about a population.
Recap: এগুলো পুরোটা ব্যাখ্যা করা আছে Chapter 04, Section 7-এ। এখানে প্রতিটার এক লাইনের version।
  • Mean \( \bar{x} = \frac{1}{n}\sum x_i \) — average।
  • Median — sort করার পর মাঝের value।
  • Mode — সবচেয়ে বেশিবার আসা value।
  • Variance — mean থেকে দূরত্বের square-এর average। Population হলে \(N\) দিয়ে ভাগ, sample হলে \(n-1\) দিয়ে ভাগ।
  • Standard deviation (SD) — variance-এর square root। Data-র unit-এই থাকে।
এই chapter-এ আমরা আরও এগোব: এই সংখ্যাগুলো দিয়ে population সম্পর্কে decision নেব।

Quartiles and the five-number summaryQuartile আর five-number summary

Quartiles cut sorted data into four equal parts.

  • Q1 (first quartile) — 25% of data is below it.
  • Q2 = the median — 50% is below it.
  • Q3 (third quartile) — 75% is below it.

The five-number summary is: Min, Q1, Median, Q3, Max. It tells you the centre and the spread in one line.

Simple method (use this in the exam): Sort the data. Find the median. Q1 is the median of the lower half. Q3 is the median of the upper half. If \(n\) is odd, leave the middle value out of both halves.

Quartile sorted data-কে চারটা সমান ভাগে কাটে।

  • Q1 (first quartile) — data-র 25% এর নিচে থাকে।
  • Q2 = median — 50% এর নিচে থাকে।
  • Q3 (third quartile) — 75% এর নিচে থাকে।

Five-number summary হলো: Min, Q1, Median, Q3, Max। এক লাইনেই centre আর spread বোঝা যায়।

সহজ method (exam-এ এটাই ব্যবহার করো): Data sort করো। Median বের করো। নিচের অর্ধেকের median = Q1। উপরের অর্ধেকের median = Q3। \(n\) odd হলে মাঝের value-টা কোনো অর্ধেকেই নিও না।

IQR and the 1.5 × IQR outlier ruleIQR আর 1.5 × IQR outlier rule

The interquartile range (IQR) is the width of the middle 50% of data. Unlike the range, it does not care about extreme values.

Interquartile range (IQR) হলো data-র মাঝের 50%-এর width। Range-এর মতো এটা extreme value-তে প্রভাবিত হয় না।

\[ \text{IQR} = Q_3 - Q_1, \qquad \text{Lower fence} = Q_1 - 1.5\,\text{IQR}, \qquad \text{Upper fence} = Q_3 + 1.5\,\text{IQR} \]

Any value below the lower fence or above the upper fence is an outlier.

Lower fence-এর নিচে বা upper fence-এর উপরে যেকোনো value হলো outlier।

Example (full worked): Number of failed logins per day on a server for 10 days:
3, 5, 7, 8, 9, 11, 13, 15, 18, 40 (already sorted, \(n = 10\)).
Step 1 — Median: \(n\) is even, so average the 5th and 6th values: \( \frac{9 + 11}{2} = 10 \).
Step 2 — Lower half: 3, 5, 7, 8, 9 → Q1 = 7.
Step 3 — Upper half: 11, 13, 15, 18, 40 → Q3 = 15.
Step 4 — IQR = 15 − 7 = 8.
Step 5 — Fences: lower = 7 − 1.5 × 8 = 7 − 12 = −5; upper = 15 + 12 = 27.
Step 6 — 40 > 27, so 40 is an outlier. Maybe that day someone ran a brute-force attack!
Five-number summary: Min = 3, Q1 = 7, Median = 10, Q3 = 15, Max = 40.
Example (full worked): একটা server-এ 10 দিনের প্রতিদিনের failed login সংখ্যা:
3, 5, 7, 8, 9, 11, 13, 15, 18, 40 (আগেই sorted, \(n = 10\))।
Step 1 — Median: \(n\) even, তাই 5th আর 6th value-র average: \( \frac{9 + 11}{2} = 10 \)।
Step 2 — নিচের অর্ধেক: 3, 5, 7, 8, 9 → Q1 = 7।
Step 3 — উপরের অর্ধেক: 11, 13, 15, 18, 40 → Q3 = 15।
Step 4 — IQR = 15 − 7 = 8।
Step 5 — Fence: lower = 7 − 1.5 × 8 = −5; upper = 15 + 12 = 27।
Step 6 — 40 > 27, তাই 40 একটা outlier। হয়তো সেদিন কেউ brute-force attack চালিয়েছিল!
Five-number summary: Min = 3, Q1 = 7, Median = 10, Q3 = 15, Max = 40।

Box plotBox plot

A box plot (box-and-whisker plot) draws the five-number summary. The box goes from Q1 to Q3. A line inside the box marks the median. The whiskers go out to the smallest and largest values that are not outliers. Outliers are drawn as separate dots.

Box plot (box-and-whisker plot) five-number summary-কে ছবিতে দেখায়। Box থাকে Q1 থেকে Q3 পর্যন্ত। Box-এর ভেতরের line হলো median। Whisker যায় সবচেয়ে ছোট আর সবচেয়ে বড় non-outlier value পর্যন্ত। Outlier আলাদা dot হিসেবে আঁকা হয়।

0 5 10 15 20 25 30 35 40 45 Upper fence = 27 Outlier = 40 Min = 3 Q1 = 7 Median = 10 Q3 = 15 Max* = 18 IQR = 15 − 7 = 8 * largest value that is not an outlier
Box plot of the failed-login data. The box is the middle 50% (IQR = 8). The day with 40 failed logins is beyond the upper fence (27), so it is shown as an outlier dot.Failed-login data-র box plot। Box হলো মাঝের 50% (IQR = 8)। 40টা failed login-এর দিনটা upper fence (27)-এর বাইরে, তাই এটা আলাদা outlier dot।
Box plot drawn above a normal distribution curve showing Q1, Q3, IQR and the whiskers
Box plot vs normal curve (Wikimedia Commons). For normal data, the box (IQR) holds the middle 50%, and the fences sit near ±2.7σ, so only about 0.7% of normal data is flagged as an outlier.Box plot বনাম normal curve (Wikimedia Commons)। Normal data-তে box (IQR)-এর ভেতর মাঝের 50% থাকে, আর fence প্রায় ±2.7σ-তে থাকে, তাই normal data-র মাত্র প্রায় 0.7% outlier ধরা হয়।

Skewness (the idea)Skewness (idea-টা)

Skewness tells you if the data has a long tail on one side.

  • Right (positive) skew: long tail to the right. Mean > Median. Example: income, file sizes, failed logins.
  • Left (negative) skew: long tail to the left. Mean < Median. Example: marks in a very easy exam.
  • Symmetric (like the normal curve): Mean ≈ Median ≈ Mode.

A quick measure is Pearson's skewness coefficient:

Skewness বলে data-র কোনো একদিকে লম্বা tail আছে কিনা।

  • Right (positive) skew: ডানদিকে লম্বা tail। Mean > Median। Example: income, file size, failed login।
  • Left (negative) skew: বামদিকে লম্বা tail। Mean < Median। Example: খুব সহজ exam-এর marks।
  • Symmetric (normal curve-এর মতো): Mean ≈ Median ≈ Mode।

একটা quick measure হলো Pearson's skewness coefficient:

\[ Sk = \frac{3(\bar{x} - \text{Median})}{s} \]
Example: For the failed-login data: sum = 129, so \( \bar{x} = 12.9 \). Median = 10. Sample SD \( s \approx 10.56 \).
\( Sk = \frac{3(12.9 - 10)}{10.56} = \frac{8.7}{10.56} \approx 0.82 \). Positive, so the data is right-skewed. The outlier 40 pulls the mean up.
Example: Failed-login data-তে: sum = 129, তাই \( \bar{x} = 12.9 \)। Median = 10। Sample SD \( s \approx 10.56 \)।
\( Sk = \frac{3(12.9 - 10)}{10.56} = \frac{8.7}{10.56} \approx 0.82 \)। Positive, তাই data right-skewed। Outlier 40 mean-কে উপরে টেনে নিচ্ছে।

z-score (standardization)z-score (standardization)

A z-score says how many standard deviations a value is away from the mean. Positive z = above the mean. Negative z = below the mean.

z-score বলে একটা value mean থেকে কত standard deviation দূরে। Positive z = mean-এর উপরে। Negative z = mean-এর নিচে।

\[ z = \frac{x - \mu}{\sigma} \qquad \text{(or } z = \frac{x - \bar{x}}{s} \text{ for a sample)} \]

If we convert every value to its z-score, the new data has mean 0 and SD 1. This is called standardization. It lets us compare values from different scales. If the data is normal, z follows the standard normal distribution \( N(0, 1) \).

সব value-কে z-score-এ convert করলে নতুন data-র mean হয় 0 আর SD হয় 1। একে বলে standardization। এতে আলাদা scale-এর value তুলনা করা যায়। Data normal হলে z follow করে standard normal distribution \( N(0, 1) \)।

Example: Rahim got 76 in a Networking test (class mean 60, SD 8). Karim got 78 in a Crypto test (class mean 70, SD 5). Who did relatively better?
Rahim: \( z = \frac{76 - 60}{8} = \frac{16}{8} = 2.0 \).
Karim: \( z = \frac{78 - 70}{5} = \frac{8}{5} = 1.6 \).
Rahim is 2 SDs above his class; Karim is only 1.6 SDs above. So Rahim did relatively better, even though his raw mark is lower.
Example: Rahim Networking test-এ পেয়েছে 76 (class mean 60, SD 8)। Karim Crypto test-এ পেয়েছে 78 (class mean 70, SD 5)। তুলনামূলকভাবে কে ভালো করেছে?
Rahim: \( z = \frac{76 - 60}{8} = 2.0 \)।
Karim: \( z = \frac{78 - 70}{5} = 1.6 \)।
Rahim তার class থেকে 2 SD উপরে; Karim মাত্র 1.6 SD উপরে। তাই raw mark কম হলেও Rahim তুলনামূলক ভালো করেছে।

A small standard normal tableছোট একটা standard normal table

\( \Phi(z) = P(Z \le z) \) is the area to the left of \(z\). For negative z use \( \Phi(-z) = 1 - \Phi(z) \). Memorise these — you will use them in every section below.

\( \Phi(z) = P(Z \le z) \) হলো \(z\)-এর বামদিকের area। Negative z-এর জন্য \( \Phi(-z) = 1 - \Phi(z) \)। এগুলো মুখস্থ রাখো — নিচের প্রতিটা section-এ লাগবে।

z1.001.501.6451.962.002.332.5763.00
\( \Phi(z) \)0.84130.93320.95000.97500.97720.99010.99500.9987
Exam tip: Different books compute quartiles in slightly different ways (so software may give Q1 = 6.5 instead of 7). In a written exam, state your method ("median of lower half") and stay consistent. Also: a box plot shows the median, not the mean.
Exam tip: আলাদা বই quartile একটু আলাদা ভাবে হিসাব করে (তাই software Q1 = 7-এর বদলে 6.5 দিতে পারে)। Written exam-এ তোমার method লিখে দাও ("নিচের অর্ধেকের median") আর সেটাই follow করো। আরেকটা কথা: box plot median দেখায়, mean না।

2. Sampling and the Central Limit Theorem2. Sampling আর Central Limit Theorem

Population, sample, parameter, statisticPopulation, sample, parameter, statistic

  • Population — every item we care about. Example: all packets that pass through a firewall in a year.
  • Sample — the small part we actually look at. Example: 500 packets we captured.
  • Parameter — a number about the population (usually unknown): \( \mu, \sigma, p \).
  • Statistic — a number computed from the sample: \( \bar{x}, s, \hat{p} \). We use statistics to guess parameters.

We sample because checking the whole population is too slow, too costly, or impossible.

  • Population — যত item নিয়ে আমরা ভাবছি, সবগুলো। Example: এক বছরে firewall দিয়ে যাওয়া সব packet।
  • Sample — ছোট অংশ যেটা আমরা আসলে দেখি। Example: capture করা 500টা packet।
  • Parameter — population সম্পর্কে একটা সংখ্যা (সাধারণত অজানা): \( \mu, \sigma, p \)।
  • Statistic — sample থেকে হিসাব করা সংখ্যা: \( \bar{x}, s, \hat{p} \)। Statistic দিয়ে আমরা parameter আন্দাজ করি।

Sample নেই কারণ পুরো population check করা অনেক ধীর, খরচবহুল, বা অসম্ভব।

Sampling methodsSampling method

MethodMethodHow it worksকীভাবে কাজ করেSecurity exampleSecurity example
Simple randomEvery item has the same chance. Pick using random numbers.প্রতিটা item-এর সমান chance। Random number দিয়ে বাছাই।Pick 200 log lines at random from 1 million.10 লাখ log line থেকে random 200টা নেওয়া।
StratifiedSplit into groups (strata) that are different from each other. Take a random sample from each group.Population-কে আলাদা ধরনের group (strata)-এ ভাগ করো। প্রতিটা group থেকে random sample নাও।Survey staff: sample from IT, HR, Finance separately, in proportion to their size.Staff survey: IT, HR, Finance থেকে আলাদা করে, তাদের size অনুযায়ী sample।
ClusterSplit into many similar groups (clusters). Randomly pick a few clusters and take everyone in them.অনেকগুলো একই রকম group (cluster)-এ ভাগ করো। Random কয়েকটা cluster বেছে তার সবাইকে নাও।Pick 5 branch offices at random and audit every PC there.Random 5টা branch office বেছে সেখানকার সব PC audit করা।
SystematicPick a random start, then take every k-th item.Random একটা শুরু, তারপর প্রতি k-তম item।Inspect every 100th packet (like NetFlow sampling).প্রতি 100-তম packet inspect করা (NetFlow sampling-এর মতো)।
Remember the difference: Stratified = sample from every group. Cluster = take all of some groups. A biased sample (for example, only daytime traffic) gives wrong answers no matter how large it is.
পার্থক্যটা মনে রাখো: Stratified = প্রতিটা group থেকে কিছু sample। Cluster = কয়েকটা group-এর সবাই। Biased sample (যেমন শুধু দিনের traffic) যত বড়ই হোক, ভুল answer দেয়।

Sampling distribution and standard errorSampling distribution আর standard error

Take a sample of size \(n\) and compute \( \bar{x} \). Take another sample — you get a slightly different \( \bar{x} \). If you repeat this many times, the values of \( \bar{x} \) form a distribution. This is the sampling distribution of the mean.

Its centre is the true mean \( \mu \). Its spread is called the standard error (SE):

Size \(n\)-এর একটা sample নিয়ে \( \bar{x} \) বের করো। আরেকটা sample নাও — একটু আলাদা \( \bar{x} \) পাবে। বারবার করলে \( \bar{x} \)-এর value-গুলো একটা distribution তৈরি করে। একে বলে sampling distribution of the mean।

এর centre হলো আসল mean \( \mu \)। এর spread-কে বলে standard error (SE):

\[ E[\bar{X}] = \mu, \qquad SE(\bar{X}) = \sigma_{\bar{x}} = \frac{\sigma}{\sqrt{n}} \]

Bigger sample → smaller SE → \( \bar{x} \) is closer to \( \mu \). But note the square root: to cut SE in half, you need 4 times the sample size.

Sample বড় → SE ছোট → \( \bar{x} \) \( \mu \)-এর আরও কাছে। কিন্তু square root খেয়াল করো: SE অর্ধেক করতে sample size 4 গুণ লাগে।

Example: \( \sigma = 20 \). With \( n = 25 \): SE = 20/5 = 4. With \( n = 100 \): SE = 20/10 = 2. Four times more data, half the error.
Example: \( \sigma = 20 \)। \( n = 25 \) হলে SE = 20/5 = 4। \( n = 100 \) হলে SE = 20/10 = 2। চার গুণ বেশি data, error অর্ধেক।

The Central Limit Theorem (CLT)Central Limit Theorem (CLT)

CLT in plain words: Take many random samples of size \(n\) from any population with mean \( \mu \) and SD \( \sigma \). If \(n\) is large enough (rule of thumb: \( n \ge 30 \)), the sample mean \( \bar{X} \) is approximately normal — even if the population itself is not normal.

This is why the normal curve appears everywhere in statistics. It is the reason we can build confidence intervals and do z-tests.

সহজ কথায় CLT: Mean \( \mu \) আর SD \( \sigma \) আছে এমন যেকোনো population থেকে size \(n\)-এর অনেক random sample নাও। \(n\) যথেষ্ট বড় হলে (rule of thumb: \( n \ge 30 \)), sample mean \( \bar{X} \) প্রায় normal হয় — population নিজে normal না হলেও।

এজন্যই statistics-এ normal curve সব জায়গায় দেখা যায়। এর কারণেই আমরা confidence interval বানাতে আর z-test করতে পারি।

\[ \bar{X} \approx N\!\left(\mu,\ \frac{\sigma^2}{n}\right) \quad\Longrightarrow\quad Z = \frac{\bar{X} - \mu}{\sigma / \sqrt{n}} \approx N(0, 1) \]
Illustration of the central limit theorem: whatever the population shape, the distribution of sample means tends to a bell curve
CLT illustration (Wikimedia Commons): whatever shape the population has, the distribution of sample means becomes bell-shaped, and its spread shrinks as \(n\) grows.CLT-এর ছবি (Wikimedia Commons): population-এর shape যেমনই হোক, sample mean-এর distribution bell-shaped হয়ে যায়, আর \(n\) বাড়লে spread কমে।
Population: σ = 120 Means of n = 4: SE = 60 Means of n = 36: SE = 20 200 300 400 500 600 700 800 μ = 500 P(x̄ > 530) ≈ 0.067 packet size (bytes)
Same mean (500), different spreads. The population (grey) is wide. Means of samples of size 4 are narrower. Means of samples of size 36 are very narrow (SE = 120/6 = 20). The orange tail is P(x̄ > 530) from the worked example below.একই mean (500), আলাদা spread। Population (ধূসর) চওড়া। Size 4 sample-এর mean আরও চিকন। Size 36 sample-এর mean খুবই চিকন (SE = 120/6 = 20)। কমলা tail হলো নিচের worked example-এর P(x̄ > 530)।
Worked example (CLT): Packet sizes on a network have mean \( \mu = 500 \) bytes and \( \sigma = 120 \) bytes. The distribution is not normal (it is skewed). We capture a random sample of \( n = 36 \) packets.
(a) What is the probability that the sample mean is more than 530 bytes?
(b) What is the probability that the sample mean is between 480 and 520 bytes?

Step 1 — \(n = 36 \ge 30\), so by CLT, \( \bar{X} \) is about normal.
Step 2 — \( SE = \frac{120}{\sqrt{36}} = \frac{120}{6} = 20 \).
Step 3 — (a) \( z = \frac{530 - 500}{20} = 1.5 \). \( P(\bar{X} > 530) = 1 - \Phi(1.5) = 1 - 0.9332 = \mathbf{0.0668} \).
Step 4 — (b) \( z_1 = \frac{480 - 500}{20} = -1 \), \( z_2 = \frac{520 - 500}{20} = 1 \). \( P = \Phi(1) - \Phi(-1) = 0.8413 - 0.1587 = \mathbf{0.6826} \).
So about 68% of sample means fall within ±20 bytes of the true mean.
Worked example (CLT): একটা network-এ packet size-এর mean \( \mu = 500 \) bytes আর \( \sigma = 120 \) bytes। Distribution normal না (skewed)। আমরা random \( n = 36 \)টা packet capture করলাম।
(a) Sample mean 530 bytes-এর বেশি হওয়ার probability কত?
(b) Sample mean 480 থেকে 520 bytes-এর মধ্যে হওয়ার probability কত?

Step 1 — \(n = 36 \ge 30\), তাই CLT অনুযায়ী \( \bar{X} \) প্রায় normal।
Step 2 — \( SE = \frac{120}{\sqrt{36}} = \frac{120}{6} = 20 \)।
Step 3 — (a) \( z = \frac{530 - 500}{20} = 1.5 \)। \( P(\bar{X} > 530) = 1 - \Phi(1.5) = 1 - 0.9332 = \mathbf{0.0668} \)।
Step 4 — (b) \( z_1 = -1 \), \( z_2 = 1 \)। \( P = \Phi(1) - \Phi(-1) = 0.8413 - 0.1587 = \mathbf{0.6826} \)।
মানে প্রায় 68% sample mean আসল mean-এর ±20 bytes-এর মধ্যে পড়ে।
Exam traps: (1) CLT is about the sample mean, not about single values. A single packet can still be 1500 bytes. (2) Use \( \sigma/\sqrt{n} \), not \( \sigma \), when the question asks about a mean of \(n\) items. (3) If the population is already normal, \( \bar{X} \) is exactly normal for any \(n\) — no need for \( n \ge 30 \).
Exam trap: (1) CLT sample mean নিয়ে, একক value নিয়ে না। একটা packet এখনো 1500 bytes হতে পারে। (2) প্রশ্ন \(n\)টা item-এর mean নিয়ে হলে \( \sigma \) না, \( \sigma/\sqrt{n} \) ব্যবহার করো। (3) Population আগেই normal হলে যেকোনো \(n\)-এ \( \bar{X} \) exactly normal — তখন \( n \ge 30 \) লাগে না।

3. Estimation and Confidence Intervals3. Estimation আর Confidence Interval

Point estimate vs interval estimatePoint estimate বনাম interval estimate

  • A point estimate is one single number as our best guess. Example: "the mean response time is 220 ms" (\( \bar{x} \) estimates \( \mu \); \( \hat{p} \) estimates \( p \)).
  • An interval estimate (confidence interval, CI) gives a range and a confidence level. Example: "the mean is between 210.2 and 229.8 ms, with 95% confidence".

A point estimate is almost never exactly right. An interval is more honest, because it shows how unsure we are.

An estimator is unbiased if, on average, it hits the true value. \( \bar{x} \) is unbiased for \( \mu \). \( s^2 \) (divide by \(n-1\)) is unbiased for \( \sigma^2 \).

  • Point estimate হলো best guess হিসেবে একটা মাত্র সংখ্যা। Example: "mean response time 220 ms" (\( \bar{x} \) দিয়ে \( \mu \) estimate; \( \hat{p} \) দিয়ে \( p \) estimate)।
  • Interval estimate (confidence interval, CI) একটা range আর confidence level দেয়। Example: "95% confidence-এ mean 210.2 থেকে 229.8 ms-এর মধ্যে"।

Point estimate প্রায় কখনোই একদম ঠিক হয় না। Interval বেশি সৎ, কারণ এটা দেখায় আমরা কতটা অনিশ্চিত।

কোনো estimator গড়ে আসল value-তে পৌঁছালে তাকে unbiased বলে। \( \bar{x} \) হলো \( \mu \)-এর unbiased estimator। \( s^2 \) (\(n-1\) দিয়ে ভাগ) হলো \( \sigma^2 \)-এর unbiased estimator।

General shape of a CICI-এর general shape

\[ \text{CI} = \text{estimate} \pm \underbrace{(\text{critical value}) \times (\text{standard error})}_{\text{margin of error } E} \]

Critical values tableCritical value table

For a two-sided \( (1-\alpha) \) CI we use \( z_{\alpha/2} \) or \( t_{\alpha/2,\,df} \). The t value is always bigger than z, and it gets closer to z as df grows.

Two-sided \( (1-\alpha) \) CI-এর জন্য \( z_{\alpha/2} \) বা \( t_{\alpha/2,\,df} \) ব্যবহার করি। t value সবসময় z-এর চেয়ে বড়, আর df বাড়লে z-এর কাছে চলে আসে।

ConfidenceConfidenceαzt (df = 4)t (df = 5)t (df = 9)t (df = 10)t (df = 15)t (df = 20)t (df = 30)
90%0.101.6452.1322.0151.8331.8121.7531.7251.697
95%0.051.9602.7762.5712.2622.2282.1312.0862.042
99%0.012.5764.6044.0323.2503.1692.9472.8452.750

Note: the 90% row is also the one-tailed 5% row (for example, 1.645 and \( t_{0.05,5} = 2.015 \)). Other values used in this chapter: \( t_{0.025,7} = 2.365 \), \( t_{0.025,8} = 2.306 \), \( t_{0.025,16} = 2.120 \), \( t_{0.05,7} = 1.895 \).

খেয়াল করো: 90% row-টাই one-tailed 5% row (যেমন 1.645 আর \( t_{0.05,5} = 2.015 \))। এই chapter-এ লাগবে এমন আরও value: \( t_{0.025,7} = 2.365 \), \( t_{0.025,8} = 2.306 \), \( t_{0.025,16} = 2.120 \), \( t_{0.05,7} = 1.895 \)।

CI for a mean when σ is known (z-interval)σ জানা থাকলে mean-এর CI (z-interval)

\[ \bar{x} \pm z_{\alpha/2}\,\frac{\sigma}{\sqrt{n}} \]
Example: A login server's response time has known \( \sigma = 35 \) ms. A sample of \( n = 49 \) logins gives \( \bar{x} = 220 \) ms. Find the 95% CI for the true mean.
Step 1 — \( SE = \frac{35}{\sqrt{49}} = \frac{35}{7} = 5 \).
Step 2 — \( z_{0.025} = 1.96 \). Margin \( E = 1.96 \times 5 = 9.8 \).
Step 3 — CI = \( 220 \pm 9.8 = (210.2,\ 229.8) \) ms.
For 99% we use 2.576: \( E = 12.88 \), CI = (207.12, 232.88). More confidence → wider interval.
Example: একটা login server-এর response time-এর \( \sigma = 35 \) ms জানা। \( n = 49 \)টা login-এর sample-এ \( \bar{x} = 220 \) ms। আসল mean-এর 95% CI বের করো।
Step 1 — \( SE = \frac{35}{7} = 5 \)।
Step 2 — \( z_{0.025} = 1.96 \)। Margin \( E = 1.96 \times 5 = 9.8 \)।
Step 3 — CI = \( 220 \pm 9.8 = (210.2,\ 229.8) \) ms।
99%-এর জন্য 2.576: \( E = 12.88 \), CI = (207.12, 232.88)। বেশি confidence → চওড়া interval।

CI for a mean when σ is unknown (t-interval)σ অজানা হলে mean-এর CI (t-interval)

In real life we rarely know \( \sigma \). So we use the sample SD \( s \) instead. This adds extra uncertainty, so we use the Student's t distribution with \( df = n - 1 \). The t curve looks like the normal curve but has fatter tails. (We assume the population is roughly normal, which matters most when \(n\) is small.)

বাস্তবে আমরা খুব কমই \( \sigma \) জানি। তাই এর বদলে sample SD \( s \) ব্যবহার করি। এতে অনিশ্চয়তা বাড়ে, তাই \( df = n - 1 \) সহ Student's t distribution ব্যবহার করি। t curve দেখতে normal-এর মতো, কিন্তু tail মোটা। (ধরে নিই population মোটামুটি normal — \(n\) ছোট হলে এটা বেশি জরুরি।)

\[ \bar{x} \pm t_{\alpha/2,\ n-1}\,\frac{s}{\sqrt{n}} \]
Example: A security team measured the time (hours) to patch 16 critical vulnerabilities. \( \bar{x} = 52.0 \), \( s = 8.0 \). Find a 95% CI for the mean patch time.
Step 1 — \( \sigma \) unknown and \(n = 16\) is small → use t with \( df = 15 \).
Step 2 — \( t_{0.025,15} = 2.131 \). \( SE = \frac{8}{\sqrt{16}} = 2 \).
Step 3 — \( E = 2.131 \times 2 = 4.262 \).
Step 4 — CI = \( 52.0 \pm 4.262 = (47.74,\ 56.26) \) hours.
If we had wrongly used z = 1.96, we would get \( \pm 3.92 \) — too narrow, too confident.
Example: একটা security team 16টা critical vulnerability patch করার সময় (hours) মাপল। \( \bar{x} = 52.0 \), \( s = 8.0 \)। Mean patch time-এর 95% CI বের করো।
Step 1 — \( \sigma \) অজানা আর \(n = 16\) ছোট → \( df = 15 \) সহ t।
Step 2 — \( t_{0.025,15} = 2.131 \)। \( SE = \frac{8}{4} = 2 \)।
Step 3 — \( E = 2.131 \times 2 = 4.262 \)।
Step 4 — CI = \( 52.0 \pm 4.262 = (47.74,\ 56.26) \) hours।
ভুল করে z = 1.96 নিলে \( \pm 3.92 \) পেতাম — বেশি চিকন, বেশি overconfident।

CI for a proportionProportion-এর CI

For yes/no data, \( \hat{p} = x/n \) (number of "yes" divided by sample size). This works well when \( n\hat{p} \ge 10 \) and \( n(1-\hat{p}) \ge 10 \).

Yes/no data-র জন্য \( \hat{p} = x/n \) ("yes"-এর সংখ্যা ÷ sample size)। \( n\hat{p} \ge 10 \) আর \( n(1-\hat{p}) \ge 10 \) হলে এটা ভালো কাজ করে।

\[ \hat{p} \pm z_{\alpha/2}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]
Example: An audit checks 400 random user accounts. 88 use a weak password. Find the 95% CI for the true proportion of weak passwords.
Step 1 — \( \hat{p} = 88/400 = 0.22 \). Check: \( 400 \times 0.22 = 88 \ge 10 \), \( 400 \times 0.78 = 312 \ge 10 \). OK.
Step 2 — \( SE = \sqrt{\frac{0.22 \times 0.78}{400}} = \sqrt{0.000429} = 0.02071 \).
Step 3 — \( E = 1.96 \times 0.02071 = 0.0406 \).
Step 4 — CI = \( 0.22 \pm 0.0406 = (0.179,\ 0.261) \). So between about 17.9% and 26.1% of all accounts have weak passwords.
Example: একটা audit random 400টা user account check করল। 88টায় weak password। Weak password-এর আসল proportion-এর 95% CI বের করো।
Step 1 — \( \hat{p} = 88/400 = 0.22 \)। Check: \( 400 \times 0.22 = 88 \ge 10 \), \( 400 \times 0.78 = 312 \ge 10 \)। ঠিক আছে।
Step 2 — \( SE = \sqrt{\frac{0.22 \times 0.78}{400}} = \sqrt{0.000429} = 0.02071 \)।
Step 3 — \( E = 1.96 \times 0.02071 = 0.0406 \)।
Step 4 — CI = \( 0.22 \pm 0.0406 = (0.179,\ 0.261) \)। মানে সব account-এর প্রায় 17.9% থেকে 26.1%-এ weak password।

What does "95% confidence" really mean?"95% confidence" আসলে কী বোঝায়?

This is the most common mistake. The true mean \( \mu \) is a fixed number. It does not move. The interval is what changes from sample to sample.

  • Correct: If we repeat the sampling many times and build a 95% CI each time, about 95% of those intervals will contain the true \( \mu \). We are 95% confident in the method.
  • Wrong: "There is a 95% probability that \( \mu \) is between 210.2 and 229.8." Once the interval is computed, \( \mu \) is either inside it or not.
  • Also wrong: "95% of the data lies in the CI." The CI is about the mean, not about single data values.

এটাই সবচেয়ে common ভুল। আসল mean \( \mu \) একটা fixed সংখ্যা। এটা নড়ে না। Sample থেকে sample-এ বদলায় interval।

  • ঠিক: বারবার sampling করে প্রতিবার 95% CI বানালে, সেই interval-গুলোর প্রায় 95%-এ আসল \( \mu \) থাকবে। আমরা method-এর উপর 95% confident।
  • ভুল: "\( \mu \) 210.2 আর 229.8-এর মধ্যে থাকার probability 95%।" Interval হিসাব হয়ে গেলে \( \mu \) হয় ভেতরে আছে, নয় নেই।
  • এটাও ভুল: "95% data CI-এর ভেতরে।" CI হলো mean নিয়ে, একক data value নিয়ে না।

Margin of error and sample sizeMargin of error আর sample size

If you want the margin of error to be at most \(E\), solve \( E = z\sigma/\sqrt{n} \) for \(n\). Always round UP to the next whole number.

Margin of error সর্বোচ্চ \(E\) চাইলে \( E = z\sigma/\sqrt{n} \) থেকে \(n\) বের করো। সবসময় উপরের দিকে round করো।

\[ n = \left(\frac{z_{\alpha/2}\,\sigma}{E}\right)^2 \quad \text{(mean)}, \qquad n = \frac{z_{\alpha/2}^2\,\hat{p}(1-\hat{p})}{E^2} \quad \text{(proportion; use } \hat{p} = 0.5 \text{ if unknown)} \]
Example 1 (mean): \( \sigma = 15 \) ms. We want a 95% CI with margin at most 3 ms.
\( n = \left(\frac{1.96 \times 15}{3}\right)^2 = (9.8)^2 = 96.04 \) → round up → \( n = 97 \). (Not 96! 96 would give a margin slightly above 3.)

Example 2 (proportion): How many users must we survey to estimate the share who reuse passwords within ±3% at 95%? No earlier guess, so \( \hat{p} = 0.5 \) (the worst case).
\( n = \frac{1.96^2 \times 0.5 \times 0.5}{0.03^2} = \frac{0.9604}{0.0009} = 1067.1 \) → \( n = 1068 \).
Example 1 (mean): \( \sigma = 15 \) ms। 95% CI চাই, margin সর্বোচ্চ 3 ms।
\( n = \left(\frac{1.96 \times 15}{3}\right)^2 = (9.8)^2 = 96.04 \) → উপরে round → \( n = 97 \)। (96 না! 96 নিলে margin 3-এর একটু বেশি হবে।)

Example 2 (proportion): কতজন user survey করলে 95%-এ ±3%-এর মধ্যে password reuse করা user-এর ভাগ estimate করা যাবে? আগের কোনো guess নেই, তাই \( \hat{p} = 0.5 \) (worst case)।
\( n = \frac{1.96^2 \times 0.25}{0.03^2} = \frac{0.9604}{0.0009} = 1067.1 \) → \( n = 1068 \)।
Exam tip: Which interval to use?
  • \( \sigma \) known → z-interval.
  • \( \sigma \) unknown and \(n\) small (< 30) → t-interval with \( df = n-1 \). This is the most tested case.
  • \( \sigma \) unknown but \(n\) large → t is best, but z gives almost the same answer.
  • Proportion → z-interval with \( \sqrt{\hat{p}(1-\hat{p})/n} \).
Halving the margin needs 4× the sample size, because \(n\) grows with \( 1/E^2 \).
Exam tip: কোন interval ব্যবহার করবে?
  • \( \sigma \) জানা → z-interval।
  • \( \sigma \) অজানা আর \(n\) ছোট (< 30) → \( df = n-1 \) সহ t-interval। এটাই সবচেয়ে বেশি আসে।
  • \( \sigma \) অজানা কিন্তু \(n\) বড় → t best, তবে z প্রায় একই answer দেয়।
  • Proportion → \( \sqrt{\hat{p}(1-\hat{p})/n} \) সহ z-interval।
Margin অর্ধেক করতে 4 গুণ sample লাগে, কারণ \(n\) বাড়ে \( 1/E^2 \) হারে।

4. Hypothesis Testing4. Hypothesis Testing

The big ideaমূল idea

A hypothesis test is like a court case. The accused is "innocent until proven guilty". In statistics, we assume "nothing special is happening" until the data gives strong evidence against it.

  • Null hypothesis \( H_0 \) — the "no change / no effect" claim. It always has an equals sign: \( \mu = 200 \).
  • Alternative hypothesis \( H_1 \) (or \( H_a \)) — what we want to find evidence for: \( \mu \ne 200 \), \( \mu > 200 \), or \( \mu < 200 \).

Hypothesis test একটা court case-এর মতো। অভিযুক্ত "দোষ প্রমাণ না হওয়া পর্যন্ত নির্দোষ"। Statistics-এ আমরা ধরে নিই "বিশেষ কিছু হচ্ছে না", যতক্ষণ না data এর বিরুদ্ধে শক্ত প্রমাণ দেয়।

  • Null hypothesis \( H_0 \) — "কোনো পরিবর্তন / effect নেই" দাবি। এতে সবসময় equals sign থাকে: \( \mu = 200 \)।
  • Alternative hypothesis \( H_1 \) (বা \( H_a \)) — যেটার পক্ষে প্রমাণ খুঁজছি: \( \mu \ne 200 \), \( \mu > 200 \), বা \( \mu < 200 \)।

Key wordsমূল শব্দগুলো

  • One-tailed test: \( H_1 \) has \( > \) or \( < \). All the rejection area is in one tail.
  • Two-tailed test: \( H_1 \) has \( \ne \). The rejection area is split: \( \alpha/2 \) in each tail.
  • Significance level \( \alpha \): how much risk of a false alarm we accept. Usually 0.05 (5%) or 0.01.
  • Test statistic: a number from the sample that measures how far the data is from \( H_0 \), in units of standard error. Example: \( z = \frac{\bar{x} - \mu_0}{\sigma/\sqrt{n}} \).
  • Critical value / critical region: the cut-off. If the test statistic falls in the critical (rejection) region, we reject \( H_0 \).
  • p-value: assuming \( H_0 \) is true, the probability of getting a result at least as extreme as the one we saw.
  • One-tailed test: \( H_1 \)-এ \( > \) বা \( < \)। পুরো rejection area এক tail-এ।
  • Two-tailed test: \( H_1 \)-এ \( \ne \)। Rejection area ভাগ হয়: প্রতি tail-এ \( \alpha/2 \)।
  • Significance level \( \alpha \): false alarm-এর কতটা risk আমরা মেনে নেব। সাধারণত 0.05 (5%) বা 0.01।
  • Test statistic: sample থেকে একটা সংখ্যা, যেটা মাপে data \( H_0 \) থেকে কত দূরে (standard error-এর unit-এ)। Example: \( z = \frac{\bar{x} - \mu_0}{\sigma/\sqrt{n}} \)।
  • Critical value / critical region: cut-off। Test statistic critical (rejection) region-এ পড়লে \( H_0 \) reject করি।
  • p-value: \( H_0 \) সত্য ধরে নিলে, আমরা যা দেখেছি তার সমান বা তার চেয়েও extreme result পাওয়ার probability।

The 5-step procedure (use it every time)5-step procedure (প্রতিবার এটাই)

Step 1: State \( H_0 \) and \( H_1 \).   Step 2: Choose \( \alpha \).   Step 3: Compute the test statistic.   Step 4: Find the critical value (or the p-value).   Step 5: Decide, and write the conclusion in plain words.
Step 1: \( H_0 \) আর \( H_1 \) লেখো।   Step 2: \( \alpha \) ঠিক করো।   Step 3: Test statistic হিসাব করো।   Step 4: Critical value (বা p-value) বের করো।   Step 5: Decision নাও, আর সহজ ভাষায় conclusion লেখো।

Decision rule: Reject \( H_0 \) if |test statistic| is beyond the critical value, or equivalently if p-value \( \le \alpha \). Both ways always give the same decision.

Decision rule: Test statistic critical value-এর বাইরে গেলে \( H_0 \) reject, অথবা একইভাবে p-value \( \le \alpha \) হলে reject। দুই উপায়েই সবসময় একই decision আসে।

Reject H₀α/2 = 0.025 Reject H₀α/2 = 0.025 Fail to reject H₀area = 0.95 Two-tailed test, α = 0.05 (H₁: μ ≠ μ₀) -3 -2 -1 0 1 2 3 −1.96 +1.96 z (standard normal)
Two-tailed test at α = 0.05: reject \( H_0 \) if \( z < -1.96 \) or \( z > 1.96 \). Each red tail has area 0.025.α = 0.05-এ two-tailed test: \( z < -1.96 \) বা \( z > 1.96 \) হলে \( H_0 \) reject। প্রতিটা লাল tail-এর area 0.025।
Reject H₀α = 0.05 Fail to reject H₀area = 0.95 z = 2.4 (our test) Right-tailed test, α = 0.05 (H₁: μ > μ₀) -3 -2 -1 0 1 2 3 1.645 z (standard normal)
Right-tailed test at α = 0.05: reject \( H_0 \) if \( z > 1.645 \). The whole 5% is in one tail, so the cut-off is smaller than 1.96. The test statistic from Example 1 (z = 2.4) lands in the rejection region.α = 0.05-এ right-tailed test: \( z > 1.645 \) হলে \( H_0 \) reject। পুরো 5% এক tail-এ, তাই cut-off 1.96-এর চেয়ে ছোট। Example 1-এর test statistic (z = 2.4) rejection region-এ পড়েছে।

Example 1: one-sample z-test (σ known)Example 1: one-sample z-test (σ জানা)

\[ z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} \]
Problem: A cloud vendor says its authentication API has mean response time 200 ms, with \( \sigma = 40 \) ms (known). You suspect it is slower. You test \( n = 64 \) requests and get \( \bar{x} = 212 \) ms. Test at \( \alpha = 0.05 \).

Step 1 — Hypotheses: \( H_0: \mu = 200 \), \( H_1: \mu > 200 \) (right-tailed, because you suspect "slower").
Step 2 — Level: \( \alpha = 0.05 \).
Step 3 — Statistic: \( SE = \frac{40}{\sqrt{64}} = 5 \). \( z = \frac{212 - 200}{5} = \frac{12}{5} = 2.4 \).
Step 4 — Critical value: right-tailed, \( z_{0.05} = 1.645 \). p-value \( = P(Z > 2.4) = 1 - 0.9918 = 0.0082 \).
Step 5 — Decision: \( 2.4 > 1.645 \) (and \( 0.0082 < 0.05 \)) → reject \( H_0 \). There is strong evidence that the API is slower than 200 ms on average.

What if the test was two-tailed (\( H_1: \mu \ne 200 \))? Critical values ±1.96; p-value = 2 × 0.0082 = 0.0164. Still reject at 5%. But at \( \alpha = 0.01 \) (critical ±2.576), 2.4 < 2.576 → fail to reject. The choice of α and tails can change the decision.
Problem: একটা cloud vendor বলছে তাদের authentication API-এর mean response time 200 ms, \( \sigma = 40 \) ms (জানা)। তোমার সন্দেহ এটা আরও ধীর। \( n = 64 \)টা request test করে পেলে \( \bar{x} = 212 \) ms। \( \alpha = 0.05 \)-এ test করো।

Step 1 — Hypotheses: \( H_0: \mu = 200 \), \( H_1: \mu > 200 \) (right-tailed, কারণ সন্দেহ "ধীর")।
Step 2 — Level: \( \alpha = 0.05 \)।
Step 3 — Statistic: \( SE = \frac{40}{8} = 5 \)। \( z = \frac{212 - 200}{5} = 2.4 \)।
Step 4 — Critical value: right-tailed, \( z_{0.05} = 1.645 \)। p-value \( = P(Z > 2.4) = 1 - 0.9918 = 0.0082 \)।
Step 5 — Decision: \( 2.4 > 1.645 \) (আর \( 0.0082 < 0.05 \)) → \( H_0 \) reject। API গড়ে 200 ms-এর চেয়ে ধীর — এর পক্ষে শক্ত প্রমাণ আছে।

Test two-tailed হলে (\( H_1: \mu \ne 200 \))? Critical value ±1.96; p-value = 2 × 0.0082 = 0.0164। 5%-এ এখনো reject। কিন্তু \( \alpha = 0.01 \)-এ (critical ±2.576) 2.4 < 2.576 → fail to reject। α আর tail বদলালে decision বদলাতে পারে।

Example 2: one-sample t-test (σ unknown, small n)Example 2: one-sample t-test (σ অজানা, ছোট n)

\[ t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}, \qquad df = n - 1 \]
Problem: A company policy says the average password length is 10 characters. An auditor checks 10 random passwords. Lengths: 8, 9, 7, 10, 9, 8, 11, 7, 9, 8. Is the true mean different from 10? Use \( \alpha = 0.05 \).

Step 1 — Hypotheses: \( H_0: \mu = 10 \), \( H_1: \mu \ne 10 \) (two-tailed).
Step 2 — Level: \( \alpha = 0.05 \).
Step 3 — Statistic:
  Sum = 86, so \( \bar{x} = 8.6 \).
  Deviations squared: \( 0.36, 0.16, 2.56, 1.96, 0.16, 0.36, 5.76, 2.56, 0.16, 0.36 \). Sum = 14.4.
  \( s^2 = \frac{14.4}{9} = 1.6 \), \( s = 1.265 \). \( SE = \frac{1.265}{\sqrt{10}} = 0.4 \).
  \( t = \frac{8.6 - 10}{0.4} = -3.5 \), with \( df = 9 \).
Step 4 — Critical value: \( t_{0.025,9} = 2.262 \). Reject if \( |t| > 2.262 \). (Exact p-value ≈ 0.0067.)
Step 5 — Decision: \( |-3.5| = 3.5 > 2.262 \) → reject \( H_0 \). The average password length is not 10; the data says it is shorter. The policy is not being followed.
Problem: Company policy বলে password-এর average length 10 character। একজন auditor random 10টা password check করল। Length: 8, 9, 7, 10, 9, 8, 11, 7, 9, 8। আসল mean কি 10 থেকে আলাদা? \( \alpha = 0.05 \) নাও।

Step 1 — Hypotheses: \( H_0: \mu = 10 \), \( H_1: \mu \ne 10 \) (two-tailed)।
Step 2 — Level: \( \alpha = 0.05 \)।
Step 3 — Statistic:
  Sum = 86, তাই \( \bar{x} = 8.6 \)।
  Deviation-এর square: \( 0.36, 0.16, 2.56, 1.96, 0.16, 0.36, 5.76, 2.56, 0.16, 0.36 \)। Sum = 14.4।
  \( s^2 = \frac{14.4}{9} = 1.6 \), \( s = 1.265 \)। \( SE = \frac{1.265}{\sqrt{10}} = 0.4 \)।
  \( t = \frac{8.6 - 10}{0.4} = -3.5 \), \( df = 9 \)।
Step 4 — Critical value: \( t_{0.025,9} = 2.262 \)। \( |t| > 2.262 \) হলে reject। (Exact p-value ≈ 0.0067।)
Step 5 — Decision: \( 3.5 > 2.262 \) → \( H_0 \) reject। Average password length 10 না; data বলছে এটা আরও ছোট। Policy মানা হচ্ছে না।

Type I and Type II errorsType I আর Type II error

Our decision can be wrong in two ways. In security, think of \( H_0 \) as "this traffic is normal".

আমাদের decision দুইভাবে ভুল হতে পারে। Security-তে \( H_0 \)-কে ভাবো "এই traffic normal"।

Decision ↓ / Truth →Decision ↓ / সত্য →\( H_0 \) true (normal traffic)\( H_0 \) সত্য (normal traffic)\( H_0 \) false (real attack)\( H_0 \) মিথ্যা (আসল attack)
Reject \( H_0 \) (raise alarm)\( H_0 \) reject (alarm দাও)Type I error (α)
False positive — IDS alarms on normal traffic.False positive — normal traffic-এ IDS alarm দিল।
Correct ✓ (power = 1 − β)
True positive — attack caught.
সঠিক ✓ (power = 1 − β)
True positive — attack ধরা পড়ল।
Fail to reject \( H_0 \) (stay quiet)\( H_0 \) reject না (চুপ থাকো)Correct ✓ (1 − α)
True negative.
সঠিক ✓ (1 − α)
True negative।
Type II error (β)
False negative — IDS misses a real attack.False negative — IDS আসল attack miss করল।
  • \( \alpha = P(\text{Type I}) = P(\text{reject } H_0 \mid H_0 \text{ true}) \).
  • \( \beta = P(\text{Type II}) = P(\text{fail to reject } H_0 \mid H_0 \text{ false}) \).
  • Power \( = 1 - \beta \) = chance of catching a real effect (a real attack).
  • Trade-off: for a fixed \(n\), lowering \( \alpha \) (fewer false alarms) raises \( \beta \) (more missed attacks). The only way to lower both is to get more data (bigger \(n\)) or a better test.
  • \( \alpha = P(\text{Type I}) = P(H_0 \text{ reject} \mid H_0 \text{ সত্য}) \)।
  • \( \beta = P(\text{Type II}) = P(H_0 \text{ reject না} \mid H_0 \text{ মিথ্যা}) \)।
  • Power \( = 1 - \beta \) = আসল effect (আসল attack) ধরার chance।
  • Trade-off: \(n\) fixed থাকলে \( \alpha \) কমালে (কম false alarm) \( \beta \) বাড়ে (বেশি attack miss)। দুটো একসাথে কমানোর উপায় শুধু বেশি data (বড় \(n\)) বা ভালো test।
Example (power): In Example 1 (\( \sigma = 40, n = 64 \), right-tailed, \( \alpha = 0.05 \)), suppose the true mean is really 215 ms. What is the power?
Step 1 — We reject when \( \bar{x} > 200 + 1.645 \times 5 = 208.225 \).
Step 2 — If \( \mu = 215 \): \( P(\bar{X} > 208.225) = P\!\left(Z > \frac{208.225 - 215}{5}\right) = P(Z > -1.355) \approx 0.912 \).
So power ≈ 91.2% and \( \beta \approx 8.8\% \). We catch the slow API 91% of the time.
Example (power): Example 1-এ (\( \sigma = 40, n = 64 \), right-tailed, \( \alpha = 0.05 \)) ধরো আসল mean আসলে 215 ms। Power কত?
Step 1 — Reject করি যখন \( \bar{x} > 200 + 1.645 \times 5 = 208.225 \)।
Step 2 — \( \mu = 215 \) হলে: \( P(\bar{X} > 208.225) = P(Z > -1.355) \approx 0.912 \)।
তাই power ≈ 91.2% আর \( \beta \approx 8.8\% \)। ধীর API-টা আমরা 91% সময় ধরতে পারব।
Exam traps (very important):
  • The p-value is NOT the probability that \( H_0 \) is true. It is P(data this extreme | \( H_0 \) true). A p-value of 0.03 does not mean "3% chance \( H_0 \) is true".
  • "Fail to reject \( H_0 \)" is NOT the same as "accept \( H_0 \)". Not guilty ≠ proven innocent. Maybe the sample was just too small to see the effect.
  • Use t (not z) when \( \sigma \) is unknown and \(n\) is small. \( df = n - 1 \).
  • Decide one- or two-tailed before looking at the data. Words like "more than", "slower", "increased" → one-tailed. Words like "different", "changed" → two-tailed.
  • Statistically significant ≠ practically important. With huge \(n\), a 0.1 ms difference can be "significant".
Exam trap (খুব গুরুত্বপূর্ণ):
  • p-value মানে \( H_0 \) সত্য হওয়ার probability না। এটা হলো P(এত extreme data | \( H_0 \) সত্য)। p-value 0.03 মানে "\( H_0 \) সত্য হওয়ার chance 3%" না।
  • "\( H_0 \) fail to reject" আর "\( H_0 \) accept" এক না। দোষী প্রমাণ হয়নি ≠ নির্দোষ প্রমাণ হয়েছে। হয়তো sample এত ছোট ছিল যে effect দেখা যায়নি।
  • \( \sigma \) অজানা আর \(n\) ছোট হলে t ব্যবহার করো (z না)। \( df = n - 1 \)।
  • One- নাকি two-tailed, সেটা data দেখার আগে ঠিক করো। "বেশি", "ধীর", "বেড়েছে" → one-tailed। "আলাদা", "বদলেছে" → two-tailed।
  • Statistically significant ≠ বাস্তবে গুরুত্বপূর্ণ। অনেক বড় \(n\)-এ 0.1 ms পার্থক্যও "significant" হতে পারে।

5. Comparing Groups (t, Chi-square, ANOVA)5. Group তুলনা (t, Chi-square, ANOVA)

Section 4 compared one sample with a fixed number. Now we compare two or more groups. Pick the test by the type of data and the number of groups:

Section 4-এ একটা sample-কে একটা fixed সংখ্যার সাথে তুলনা করেছি। এখন দুই বা তার বেশি group তুলনা করব। Test বাছাই করো data-র ধরন আর group-এর সংখ্যা দেখে:

SituationSituationTestTestdf
Means of 2 independent groups (numbers)2টা independent group-এর mean (সংখ্যা)Two-sample (pooled) t-test\( n_1 + n_2 - 2 \)
Same items measured twice (before/after)একই item দুইবার মাপা (before/after)Paired t-test\( n - 1 \) (n = pairs)
Two categorical variables — related or not?দুইটা categorical variable — সম্পর্ক আছে কিনা?Chi-square test of independence\( (r-1)(c-1) \)
One categorical variable — does it fit a claimed distribution?একটা categorical variable — দাবি করা distribution-এর সাথে মেলে কিনা?Chi-square goodness-of-fit\( k - 1 \)
Means of 3 or more groups3 বা তার বেশি group-এর meanOne-way ANOVA (F-test)\( (k-1,\ N-k) \)

5.1 Two-sample t-test (independent groups, equal variance)5.1 Two-sample t-test (independent group, সমান variance)

We have two separate groups (different people or machines in each). We assume both populations are about normal with the same variance. First we "pool" the two sample variances into one:

দুইটা আলাদা group আছে (প্রতিটায় আলাদা মানুষ বা machine)। ধরে নিই দুই population মোটামুটি normal আর variance সমান। প্রথমে দুই sample variance-কে "pool" করে একটা বানাই:

\[ s_p^2 = \frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}, \qquad t = \frac{\bar{x}_1 - \bar{x}_2}{s_p\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}, \qquad df = n_1 + n_2 - 2 \]
Problem: Two intrusion detection tools are tested. Time to detect an attack (seconds):
Tool A: \( n_1 = 8,\ \bar{x}_1 = 12.5,\ s_1 = 2.0 \). Tool B: \( n_2 = 10,\ \bar{x}_2 = 10.2,\ s_2 = 2.4 \).
Is there a difference in mean detection time? \( \alpha = 0.05 \).

Step 1: \( H_0: \mu_A = \mu_B \), \( H_1: \mu_A \ne \mu_B \) (two-tailed).
Step 2: \( \alpha = 0.05 \).
Step 3: \( s_p^2 = \frac{7(4) + 9(5.76)}{16} = \frac{28 + 51.84}{16} = \frac{79.84}{16} = 4.99 \), \( s_p = 2.234 \).
  \( SE = 2.234 \times \sqrt{\frac{1}{8} + \frac{1}{10}} = 2.234 \times \sqrt{0.225} = 2.234 \times 0.4743 = 1.060 \).
  \( t = \frac{12.5 - 10.2}{1.060} = \frac{2.3}{1.060} = 2.17 \), \( df = 8 + 10 - 2 = 16 \).
Step 4: \( t_{0.025,16} = 2.120 \). (Exact p ≈ 0.045.)
Step 5: \( 2.17 > 2.120 \) → reject \( H_0 \). The mean detection times are different; Tool B is faster. (It is close, though — at \( \alpha = 0.01 \) we would not reject.)
Problem: দুইটা intrusion detection tool test করা হলো। Attack detect করার সময় (seconds):
Tool A: \( n_1 = 8,\ \bar{x}_1 = 12.5,\ s_1 = 2.0 \)। Tool B: \( n_2 = 10,\ \bar{x}_2 = 10.2,\ s_2 = 2.4 \)।
Mean detection time-এ কি পার্থক্য আছে? \( \alpha = 0.05 \)।

Step 1: \( H_0: \mu_A = \mu_B \), \( H_1: \mu_A \ne \mu_B \) (two-tailed)।
Step 2: \( \alpha = 0.05 \)।
Step 3: \( s_p^2 = \frac{7(4) + 9(5.76)}{16} = \frac{79.84}{16} = 4.99 \), \( s_p = 2.234 \)।
  \( SE = 2.234 \times \sqrt{0.225} = 2.234 \times 0.4743 = 1.060 \)।
  \( t = \frac{2.3}{1.060} = 2.17 \), \( df = 16 \)।
Step 4: \( t_{0.025,16} = 2.120 \)। (Exact p ≈ 0.045।)
Step 5: \( 2.17 > 2.120 \) → \( H_0 \) reject। Mean detection time আলাদা; Tool B দ্রুত। (তবে খুব কাছাকাছি — \( \alpha = 0.01 \)-এ reject হতো না।)
Note: Remember to square the SDs before pooling (\( 2.4^2 = 5.76 \)). A very common mistake is to pool \( s \) instead of \( s^2 \). If the variances look very different, a better version is Welch's t-test — but for the exam the pooled version is usually enough.
Note: Pool করার আগে SD-কে square করতে ভুলো না (\( 2.4^2 = 5.76 \))। খুব common ভুল হলো \( s^2 \)-এর বদলে \( s \) pool করা। Variance খুব আলাদা মনে হলে Welch's t-test ভালো — কিন্তু exam-এ সাধারণত pooled version-ই যথেষ্ট।

5.2 Paired t-test (before / after)5.2 Paired t-test (before / after)

When the same machines, users, or files are measured twice, the two lists are linked. Take the difference \( d = \text{before} - \text{after} \) for each pair, then do a one-sample t-test on the \( d \) values.

একই machine, user বা file দুইবার মাপা হলে দুই list জোড়া-জোড়া যুক্ত। প্রতিটা pair-এর difference \( d = \text{before} - \text{after} \) নাও, তারপর \( d \) value-গুলোর উপর one-sample t-test করো।

\[ t = \frac{\bar{d} - 0}{s_d / \sqrt{n}}, \qquad df = n - 1 \]
Problem: A new security patch is installed on 6 servers. CPU load (%) before and after:
Before: 68, 72, 75, 70, 80, 65. After: 64, 70, 71, 69, 74, 63.
Does the patch reduce CPU load? \( \alpha = 0.05 \).

Step 1: \( d = \) before − after. \( H_0: \mu_d = 0 \), \( H_1: \mu_d > 0 \) (right-tailed: "reduce" means before is bigger).
Step 2: \( \alpha = 0.05 \).
Step 3: \( d = 4, 2, 4, 1, 6, 2 \). Sum = 19, \( \bar{d} = 3.167 \).
  \( \sum (d - \bar{d})^2 = 0.694 + 1.361 + 0.694 + 4.694 + 8.028 + 1.361 = 16.833 \).
  \( s_d^2 = \frac{16.833}{5} = 3.367 \), \( s_d = 1.835 \). \( SE = \frac{1.835}{\sqrt{6}} = 0.749 \).
  \( t = \frac{3.167}{0.749} = 4.23 \), \( df = 5 \).
Step 4: one-tailed \( t_{0.05,5} = 2.015 \). (Exact p ≈ 0.004.)
Step 5: \( 4.23 > 2.015 \) → reject \( H_0 \). The patch lowers CPU load, by about 3.2 percentage points on average.
Problem: 6টা server-এ নতুন security patch দেওয়া হলো। CPU load (%) আগে ও পরে:
আগে: 68, 72, 75, 70, 80, 65। পরে: 64, 70, 71, 69, 74, 63।
Patch কি CPU load কমায়? \( \alpha = 0.05 \)।

Step 1: \( d = \) আগে − পরে। \( H_0: \mu_d = 0 \), \( H_1: \mu_d > 0 \) (right-tailed: "কমায়" মানে আগেরটা বড়)।
Step 2: \( \alpha = 0.05 \)।
Step 3: \( d = 4, 2, 4, 1, 6, 2 \)। Sum = 19, \( \bar{d} = 3.167 \)।
  \( \sum (d - \bar{d})^2 = 16.833 \)।
  \( s_d^2 = \frac{16.833}{5} = 3.367 \), \( s_d = 1.835 \)। \( SE = \frac{1.835}{\sqrt{6}} = 0.749 \)।
  \( t = \frac{3.167}{0.749} = 4.23 \), \( df = 5 \)।
Step 4: one-tailed \( t_{0.05,5} = 2.015 \)। (Exact p ≈ 0.004।)
Step 5: \( 4.23 > 2.015 \) → \( H_0 \) reject। Patch CPU load কমায়, গড়ে প্রায় 3.2 percentage point।
Why pairing matters: Each server has its own "normal" load (65 to 80). This server-to-server spread is noise. Taking differences removes it, so the test becomes much stronger. If you wrongly used the two-sample test on this data, the big spread would hide the effect.
Pairing কেন জরুরি: প্রতিটা server-এর নিজস্ব "normal" load আছে (65 থেকে 80)। Server-থেকে-server এই spread হলো noise। Difference নিলে এটা বাদ যায়, তাই test অনেক শক্তিশালী হয়। এই data-তে ভুল করে two-sample test করলে বড় spread effect-টাকে লুকিয়ে ফেলত।

5.3 Chi-square test of independence5.3 Chi-square test of independence

Use it when both variables are categories (yes/no, department, email type). We put counts in a table (a contingency table) and ask: are the two variables related?

দুইটা variable-ই category হলে (yes/no, department, email type) এটা ব্যবহার করো। Count-গুলো একটা table-এ রাখি (contingency table) আর প্রশ্ন করি: দুই variable কি সম্পর্কিত?

\[ E_{ij} = \frac{(\text{row } i \text{ total}) \times (\text{column } j \text{ total})}{\text{grand total}}, \qquad \chi^2 = \sum \frac{(O - E)^2}{E}, \qquad df = (r-1)(c-1) \]

\(O\) = observed count, \(E\) = expected count if \( H_0 \) (independence) is true. The test is always right-tailed: a big \( \chi^2 \) means observed is far from expected.

\(O\) = observed count, \(E\) = \( H_0 \) (independence) সত্য হলে expected count। Test সবসময় right-tailed: বড় \( \chi^2 \) মানে observed expected থেকে অনেক দূরে।

Problem: 200 emails are checked. Is being phishing related to containing a link? \( \alpha = 0.05 \).
Problem: 200টা email check করা হলো। Phishing হওয়া আর link থাকা কি সম্পর্কিত? \( \alpha = 0.05 \)।
Observed (Expected)Observed (Expected)Has linkLink আছেNo linkLink নেইRow totalRow total
Phishing40 (25)10 (25)50
Legitimate60 (75)90 (75)150
Column totalColumn total100100200
Step 1: \( H_0 \): email type and link are independent. \( H_1 \): they are related.
Step 2: \( \alpha = 0.05 \).
Step 3: Expected counts: \( E_{11} = \frac{50 \times 100}{200} = 25 \), \( E_{12} = 25 \), \( E_{21} = \frac{150 \times 100}{200} = 75 \), \( E_{22} = 75 \).
  \( \chi^2 = \frac{(40-25)^2}{25} + \frac{(10-25)^2}{25} + \frac{(60-75)^2}{75} + \frac{(90-75)^2}{75} = 9 + 9 + 3 + 3 = 24 \).
Step 4: \( df = (2-1)(2-1) = 1 \). Critical \( \chi^2_{0.05,1} = 3.841 \). (p ≈ 0.000001.)
Step 5: \( 24 > 3.841 \) → reject \( H_0 \). Phishing and links are related: 80% of phishing emails have a link, but only 40% of legit ones do. A "has link" feature is useful for a spam filter.
Step 1: \( H_0 \): email type আর link independent। \( H_1 \): এরা সম্পর্কিত।
Step 2: \( \alpha = 0.05 \)।
Step 3: Expected count: \( E_{11} = \frac{50 \times 100}{200} = 25 \), \( E_{12} = 25 \), \( E_{21} = \frac{150 \times 100}{200} = 75 \), \( E_{22} = 75 \)।
  \( \chi^2 = \frac{15^2}{25} + \frac{15^2}{25} + \frac{15^2}{75} + \frac{15^2}{75} = 9 + 9 + 3 + 3 = 24 \)।
Step 4: \( df = (2-1)(2-1) = 1 \)। Critical \( \chi^2_{0.05,1} = 3.841 \)। (p ≈ 0.000001।)
Step 5: \( 24 > 3.841 \) → \( H_0 \) reject। Phishing আর link সম্পর্কিত: phishing email-এর 80%-এ link আছে, কিন্তু legit email-এর মাত্র 40%-এ। Spam filter-এর জন্য "link আছে" feature কাজের।
Chi-square critical values (α = 0.05)Chi-square critical value (α = 0.05)df = 123456
\( \chi^2_{0.05} \)3.8415.9917.8159.48811.07012.592

5.4 Chi-square goodness-of-fit5.4 Chi-square goodness-of-fit

One categorical variable. We test whether the counts match a claimed distribution. \( df = k - 1 \), where \(k\) = number of categories.

একটা categorical variable। Count-গুলো দাবি করা distribution-এর সাথে মেলে কিনা test করি। \( df = k - 1 \), যেখানে \(k\) = category সংখ্যা।

Problem: A random number generator (RNG) in a game should give 1 to 6 with equal chance. In 60 outputs we saw: 1→8, 2→9, 3→12, 4→11, 5→6, 6→14. Is the RNG fair? \( \alpha = 0.05 \).

Step 1: \( H_0 \): each number has probability 1/6 (fair). \( H_1 \): not fair.
Step 2: \( \alpha = 0.05 \).
Step 3: Expected = 60/6 = 10 each.
  \( \chi^2 = \frac{(8-10)^2 + (9-10)^2 + (12-10)^2 + (11-10)^2 + (6-10)^2 + (14-10)^2}{10} = \frac{4+1+4+1+16+16}{10} = 4.2 \).
Step 4: \( df = 6 - 1 = 5 \), critical = 11.070. (p ≈ 0.52.)
Step 5: \( 4.2 < 11.070 \) → fail to reject \( H_0 \). No evidence that the RNG is unfair. (This does not prove it is fair or secure — only 60 outputs were tested.)
Problem: একটা game-এর random number generator (RNG) 1 থেকে 6 সমান chance-এ দেওয়ার কথা। 60টা output-এ পেলাম: 1→8, 2→9, 3→12, 4→11, 5→6, 6→14। RNG কি fair? \( \alpha = 0.05 \)।

Step 1: \( H_0 \): প্রতিটা সংখ্যার probability 1/6 (fair)। \( H_1 \): fair না।
Step 2: \( \alpha = 0.05 \)।
Step 3: Expected = 60/6 = প্রতিটা 10।
  \( \chi^2 = \frac{4+1+4+1+16+16}{10} = 4.2 \)।
Step 4: \( df = 6 - 1 = 5 \), critical = 11.070। (p ≈ 0.52।)
Step 5: \( 4.2 < 11.070 \) → \( H_0 \) fail to reject। RNG unfair — এমন প্রমাণ নেই। (এটা fair বা secure প্রমাণ করে না — মাত্র 60টা output test হয়েছে।)
Exam tips for chi-square: (1) Use counts, never percentages. (2) Every expected count should be at least 5. (3) \( df = (r-1)(c-1) \) for independence, \( k-1 \) for goodness-of-fit. For a 3 × 4 table, df = 2 × 3 = 6. (4) \( \chi^2 \) can never be negative.
Chi-square-এর exam tip: (1) Count ব্যবহার করো, কখনো percentage না। (2) প্রতিটা expected count কমপক্ষে 5 হওয়া উচিত। (3) Independence-এ \( df = (r-1)(c-1) \), goodness-of-fit-এ \( k-1 \)। 3 × 4 table-এ df = 2 × 3 = 6। (4) \( \chi^2 \) কখনো negative হয় না।

5.5 One-way ANOVA5.5 One-way ANOVA

To compare the means of 3 or more groups, we use ANOVA (Analysis of Variance). Why not do many t-tests? With 3 groups you need 3 t-tests, and each one has a 5% false-alarm risk. The total risk grows to about 14%. ANOVA does one test for all.

The idea: compare the spread between the group means with the spread within each group. If group means are far apart compared to the noise inside groups, the means are probably different.

3 বা তার বেশি group-এর mean তুলনা করতে ANOVA (Analysis of Variance) ব্যবহার করি। অনেকগুলো t-test কেন না? 3টা group-এ 3টা t-test লাগে, আর প্রতিটায় 5% false-alarm risk। মোট risk বেড়ে প্রায় 14% হয়। ANOVA সবার জন্য একটাই test করে।

Idea: group mean-গুলোর মধ্যে spread-কে প্রতিটা group-এর ভেতরের spread-এর সাথে তুলনা করো। Group-এর ভেতরের noise-এর তুলনায় group mean-গুলো অনেক দূরে হলে mean-গুলো সম্ভবত আলাদা।

\[ SSB = \sum_{i} n_i(\bar{x}_i - \bar{x})^2, \qquad SSW = \sum_i \sum_j (x_{ij} - \bar{x}_i)^2 \] \[ MSB = \frac{SSB}{k - 1}, \qquad MSW = \frac{SSW}{N - k}, \qquad F = \frac{MSB}{MSW} \]

Here \(k\) = number of groups, \(N\) = total observations, \( \bar{x} \) = grand mean. Also \( SST = SSB + SSW \). Reject \( H_0 \) if \( F > F_{\alpha}(k-1,\ N-k) \).

এখানে \(k\) = group সংখ্যা, \(N\) = মোট observation, \( \bar{x} \) = grand mean। আর \( SST = SSB + SSW \)। \( F > F_{\alpha}(k-1,\ N-k) \) হলে \( H_0 \) reject।

Problem: Three encryption libraries are timed (ms) on the same task, 3 runs each:
A: 5, 7, 6   B: 8, 9, 10   C: 4, 6, 5. Are the mean times equal? \( \alpha = 0.05 \).

Step 1: \( H_0: \mu_A = \mu_B = \mu_C \). \( H_1 \): at least one mean is different.
Step 2: \( \alpha = 0.05 \).
Step 3: Group means: 6, 9, 5. Grand mean = 60/9 = 6.667.
  \( SSB = 3[(6 - 6.667)^2 + (9 - 6.667)^2 + (5 - 6.667)^2] = 3[0.444 + 5.444 + 2.778] = 26 \).
  \( SSW \): A: \( 1 + 1 + 0 = 2 \); B: \( 1 + 0 + 1 = 2 \); C: \( 1 + 1 + 0 = 2 \). Total = 6.
  \( MSB = 26/2 = 13 \), \( MSW = 6/6 = 1 \), \( F = 13/1 = 13 \).
Step 4: \( F_{0.05}(2, 6) = 5.14 \). (p ≈ 0.0066.)
Step 5: \( 13 > 5.14 \) → reject \( H_0 \). At least one library has a different mean time (B looks slowest).
Problem: তিনটা encryption library-কে একই কাজে time করা হলো (ms), প্রতিটা 3 বার:
A: 5, 7, 6   B: 8, 9, 10   C: 4, 6, 5। Mean time কি সমান? \( \alpha = 0.05 \)।

Step 1: \( H_0: \mu_A = \mu_B = \mu_C \)। \( H_1 \): অন্তত একটা mean আলাদা।
Step 2: \( \alpha = 0.05 \)।
Step 3: Group mean: 6, 9, 5। Grand mean = 60/9 = 6.667।
  \( SSB = 3[0.444 + 5.444 + 2.778] = 26 \)।
  \( SSW \): A: 2; B: 2; C: 2। মোট = 6।
  \( MSB = 26/2 = 13 \), \( MSW = 6/6 = 1 \), \( F = 13 \)।
Step 4: \( F_{0.05}(2, 6) = 5.14 \)। (p ≈ 0.0066।)
Step 5: \( 13 > 5.14 \) → \( H_0 \) reject। অন্তত একটা library-র mean time আলাদা (B সবচেয়ে ধীর মনে হচ্ছে)।
SourceSSdfMSF
Between groupsBetween groups2621313
Within groups (error)Within groups (error)661
TotalTotal328
Exam tip: ANOVA only says "some mean is different". It does not say which one. (For that, a post-hoc test such as Tukey's is used.) Also, with 2 groups ANOVA gives the same answer as the pooled t-test: \( F = t^2 \).
Exam tip: ANOVA শুধু বলে "কোনো একটা mean আলাদা"। কোনটা, সেটা বলে না। (তার জন্য Tukey-র মতো post-hoc test লাগে।) আর 2টা group-এ ANOVA pooled t-test-এর মতোই answer দেয়: \( F = t^2 \)।

6. Correlation and Regression6. Correlation আর Regression

Scatter plotsScatter plot

When we have two numeric variables for each item (x, y), we draw each item as a dot. This is a scatter plot. It shows the direction (up or down), the form (straight or curved), and the strength (tight or loose) of the relationship.

প্রতিটা item-এর দুইটা numeric variable (x, y) থাকলে প্রতিটাকে একটা dot হিসেবে আঁকি। একে বলে scatter plot। এটা relationship-এর direction (উপরে না নিচে), form (সোজা না বাঁকা), আর strength (ঘন না ছড়ানো) দেখায়।

Pearson correlation coefficient rPearson correlation coefficient r

\( r \) measures the strength and direction of a straight-line relationship. \( -1 \le r \le 1 \). It has no unit.

\( r \) একটা সোজা-লাইন relationship-এর strength আর direction মাপে। \( -1 \le r \le 1 \)। এর কোনো unit নেই।

\[ S_{xx} = \sum (x - \bar{x})^2 = \sum x^2 - \frac{(\sum x)^2}{n}, \quad S_{yy} = \sum (y - \bar{y})^2, \quad S_{xy} = \sum (x - \bar{x})(y - \bar{y}) = \sum xy - \frac{\sum x \sum y}{n} \] \[ r = \frac{S_{xy}}{\sqrt{S_{xx}\,S_{yy}}} \]
|r|0 – 0.30.3 – 0.70.7 – 1
Strength (rough guide)Strength (মোটামুটি guide)weakweakmoderatemoderatestrongstrong
Worked example: 5 employees. x = hours of security-awareness training, y = score on a phishing quiz (out of 6).
Worked example: 5 জন employee। x = security-awareness training-এর ঘণ্টা, y = phishing quiz-এর score (6-এর মধ্যে)।
xy\( x - \bar{x} \)\( y - \bar{y} \)\( (x-\bar{x})^2 \)\( (y-\bar{y})^2 \)\( (x-\bar{x})(y-\bar{y}) \)
12−2−2444
24−10100
3501010
4410100
5521412
1520\( S_{xx} = 10 \)\( S_{yy} = 6 \)\( S_{xy} = 6 \)
Step 1 — \( \bar{x} = 15/5 = 3 \), \( \bar{y} = 20/5 = 4 \).
Step 2 — From the table: \( S_{xx} = 10,\ S_{yy} = 6,\ S_{xy} = 6 \).
Step 3 — \( r = \frac{6}{\sqrt{10 \times 6}} = \frac{6}{\sqrt{60}} = \frac{6}{7.746} = \mathbf{0.775} \).
Interpretation: a strong positive relationship. More training goes with higher quiz scores.
Check with the shortcut: \( \sum x^2 = 55,\ \sum xy = 66 \). \( S_{xx} = 55 - 225/5 = 10 \), \( S_{xy} = 66 - (15)(20)/5 = 6 \). Same.
Step 1 — \( \bar{x} = 15/5 = 3 \), \( \bar{y} = 20/5 = 4 \)।
Step 2 — Table থেকে: \( S_{xx} = 10,\ S_{yy} = 6,\ S_{xy} = 6 \)।
Step 3 — \( r = \frac{6}{\sqrt{60}} = \frac{6}{7.746} = \mathbf{0.775} \)।
Interpretation: strong positive relationship। বেশি training মানে সাধারণত বেশি quiz score।
Shortcut দিয়ে check: \( \sum x^2 = 55,\ \sum xy = 66 \)। \( S_{xx} = 55 - 225/5 = 10 \), \( S_{xy} = 66 - 300/5 = 6 \)। একই।

Correlation is not causationCorrelation মানেই causation না

A strong \(r\) does not prove that x causes y. There may be a hidden third variable (a confounder). Example: the number of antivirus alerts and the number of IT staff hired are correlated across companies. Buying more staff does not create viruses — bigger companies simply have both more computers and more staff.

Also: \( r \approx 0 \) only means no straight-line link. A U-shaped pattern can have \( r = 0 \) but a very strong relationship. Always look at the scatter plot. One outlier can also change \(r\) a lot.

বড় \(r\) প্রমাণ করে না যে x-এর কারণে y হয়। লুকানো তৃতীয় কোনো variable (confounder) থাকতে পারে। Example: বিভিন্ন company-তে antivirus alert-এর সংখ্যা আর IT staff নিয়োগের সংখ্যা correlated। বেশি staff নিলে virus তৈরি হয় না — বড় company-তে computer-ও বেশি, staff-ও বেশি।

আরও: \( r \approx 0 \) মানে শুধু সোজা-লাইন সম্পর্ক নেই। U-shaped pattern-এ \( r = 0 \) হতে পারে, অথচ সম্পর্ক খুব শক্ত। সবসময় scatter plot দেখো। একটা outlier-ও \(r\)-কে অনেক বদলে দিতে পারে।

Spearman rank correlation (one line)Spearman rank correlation (এক লাইনে)

Replace the values by their ranks and compute Pearson's r on the ranks. With no ties: \( r_s = 1 - \frac{6\sum d_i^2}{n(n^2 - 1)} \), where \( d_i \) = rank difference. It works for any monotonic (always up or always down) pattern and is robust to outliers.

Value-গুলোকে তাদের rank দিয়ে বদলে rank-এর উপর Pearson's r হিসাব করো। Tie না থাকলে: \( r_s = 1 - \frac{6\sum d_i^2}{n(n^2 - 1)} \), যেখানে \( d_i \) = rank-এর পার্থক্য। যেকোনো monotonic (সবসময় বাড়ে বা সবসময় কমে) pattern-এ কাজ করে আর outlier-এ কম প্রভাবিত হয়।

Simple linear regression (least squares)Simple linear regression (least squares)

Regression finds the best straight line \( \hat{y} = a + bx \) to predict y from x. "Best" means the line that makes the sum of squared errors \( \sum (y - \hat{y})^2 \) as small as possible (least squares).

Regression x থেকে y predict করার জন্য best সোজা লাইন \( \hat{y} = a + bx \) খুঁজে বের করে। "Best" মানে যে লাইনে squared error-এর sum \( \sum (y - \hat{y})^2 \) সবচেয়ে ছোট (least squares)।

\[ b = \frac{S_{xy}}{S_{xx}}, \qquad a = \bar{y} - b\,\bar{x}, \qquad \hat{y} = a + b\,x \]
Worked example (same data):
Step 1 — \( b = \frac{S_{xy}}{S_{xx}} = \frac{6}{10} = 0.6 \).
Step 2 — \( a = \bar{y} - b\bar{x} = 4 - 0.6 \times 3 = 2.2 \).
Step 3 — Line: \( \hat{y} = 2.2 + 0.6x \).
Meaning of b: each extra hour of training raises the predicted score by 0.6 points. Meaning of a: predicted score with 0 hours = 2.2.
Prediction: for \( x = 3.5 \) hours, \( \hat{y} = 2.2 + 0.6 \times 3.5 = 4.3 \).
Worked example (একই data):
Step 1 — \( b = \frac{S_{xy}}{S_{xx}} = \frac{6}{10} = 0.6 \)।
Step 2 — \( a = \bar{y} - b\bar{x} = 4 - 0.6 \times 3 = 2.2 \)।
Step 3 — Line: \( \hat{y} = 2.2 + 0.6x \)।
b-এর মানে: প্রতি এক ঘণ্টা বেশি training-এ predicted score 0.6 বাড়ে। a-এর মানে: 0 ঘণ্টায় predicted score = 2.2।
Prediction: \( x = 3.5 \) ঘণ্টায় \( \hat{y} = 2.2 + 0.6 \times 3.5 = 4.3 \)।
0 0 1 1 2 2 3 3 4 4 5 5 6 6 e = -0.8 e = +0.6 e = +1.0 e = -0.6 e = -0.2 (x̄, ȳ) = (3, 4) ŷ = 2.2 + 0.6x x = training hours y = quiz score dashed red = residual e = y − ŷ
Scatter plot with the least-squares line \( \hat{y} = 2.2 + 0.6x \). The line always passes through \( (\bar{x}, \bar{y}) = (3, 4) \). Red dashed lines are the residuals.Least-squares line \( \hat{y} = 2.2 + 0.6x \) সহ scatter plot। লাইনটা সবসময় \( (\bar{x}, \bar{y}) = (3, 4) \) দিয়ে যায়। লাল dashed line-গুলো residual।

Residuals and R²Residual আর R²

A residual is the prediction error for one point: \( e = y - \hat{y} \). For least squares, the residuals always add up to 0.

Residual হলো একটা point-এর prediction error: \( e = y - \hat{y} \)। Least squares-এ residual-গুলোর sum সবসময় 0।

\[ SSE = \sum (y - \hat{y})^2, \qquad R^2 = 1 - \frac{SSE}{S_{yy}} \quad (= r^2 \text{ for simple linear regression}) \]
Example: Predictions \( \hat{y} \) at x = 1..5: 2.8, 3.4, 4.0, 4.6, 5.2.
Residuals \( e = y - \hat{y} \): −0.8, +0.6, +1.0, −0.6, −0.2. (Sum = 0 ✓.)
\( SSE = 0.64 + 0.36 + 1.00 + 0.36 + 0.04 = 2.4 \).
\( R^2 = 1 - \frac{2.4}{6} = 0.6 \). Check: \( r^2 = 0.775^2 = 0.6 \) ✓.
Meaning: 60% of the variation in quiz scores is explained by training hours. The other 40% comes from other things.
Example: x = 1..5-এ prediction \( \hat{y} \): 2.8, 3.4, 4.0, 4.6, 5.2।
Residual \( e = y - \hat{y} \): −0.8, +0.6, +1.0, −0.6, −0.2। (Sum = 0 ✓।)
\( SSE = 0.64 + 0.36 + 1.00 + 0.36 + 0.04 = 2.4 \)।
\( R^2 = 1 - \frac{2.4}{6} = 0.6 \)। Check: \( r^2 = 0.775^2 = 0.6 \) ✓।
মানে: quiz score-এর variation-এর 60% training hours দিয়ে ব্যাখ্যা হয়। বাকি 40% অন্য কিছু থেকে আসে।
Exam tips:
  • \(b\) and \(r\) always have the same sign. Also \( b = r \cdot \frac{s_y}{s_x} \).
  • The regression of y on x is not the same as x on y (unless \( |r| = 1 \)).
  • Do not predict far outside the range of x in the data (extrapolation). The line may not hold there.
  • A good residual plot looks like random noise. A curve or funnel in the residuals means the straight-line model is wrong.
  • If r = −0.8, then R² = 0.64 (square kills the sign).
Exam tip:
  • \(b\) আর \(r\)-এর sign সবসময় এক। আর \( b = r \cdot \frac{s_y}{s_x} \)।
  • y on x regression আর x on y regression এক না (যদি না \( |r| = 1 \))।
  • Data-র x range-এর অনেক বাইরে predict কোরো না (extrapolation)। সেখানে লাইন খাটে নাও পারে।
  • ভালো residual plot দেখতে random noise-এর মতো। Residual-এ curve বা funnel shape মানে সোজা-লাইন model ভুল।
  • r = −0.8 হলে R² = 0.64 (square করলে sign চলে যায়)।

7. Statistics in Information Security7. Information Security-তে Statistics

This section ties everything to security. These ideas are very likely in an InfoSec written test, because they mix statistics with real security problems.

এই section সব কিছুকে security-র সাথে যুক্ত করে। InfoSec written test-এ এগুলো আসার সম্ভাবনা খুব বেশি, কারণ এখানে statistics আর বাস্তব security problem একসাথে।

7.1 The base-rate fallacy (Bayes and IDS)7.1 Base-rate fallacy (Bayes আর IDS)

An Intrusion Detection System (IDS) looks "99% accurate". Yet most of its alarms can be false. Why? Because attacks are rare. Ignoring how rare an event is (its base rate) is called the base-rate fallacy. We use Bayes' theorem (see Chapter 04, Section 4).

একটা Intrusion Detection System (IDS) দেখতে "99% accurate"। তবুও এর বেশিরভাগ alarm false হতে পারে। কেন? কারণ attack বিরল। কোনো event কতটা বিরল (এর base rate) সেটা ভুলে যাওয়াকে বলে base-rate fallacy। আমরা Bayes' theorem ব্যবহার করি (দেখো Chapter 04, Section 4)।

\[ P(A \mid \text{alarm}) = \frac{P(\text{alarm} \mid A)\,P(A)}{P(\text{alarm} \mid A)\,P(A) + P(\text{alarm} \mid \neg A)\,P(\neg A)} \]
Worked example: An IDS detects 99% of attacks (detection rate / recall = 0.99). It raises a false alarm on 1% of normal connections (FPR = 0.01). Only 0.1% of connections are attacks (\( P(A) = 0.001 \)). An alarm rings. What is the chance it is a real attack?

Step 1 — \( P(\text{alarm}) = 0.99 \times 0.001 + 0.01 \times 0.999 = 0.00099 + 0.00999 = 0.01098 \).
Step 2 — \( P(A \mid \text{alarm}) = \frac{0.00099}{0.01098} = \mathbf{0.090} \), about 9%.

So about 91% of alarms are false, even with a "99% accurate" IDS. Analysts get tired of false alarms and start ignoring them (alert fatigue).

Natural-frequency check: out of 1,000,000 connections: 1,000 attacks → 990 alarms; 999,000 normal → 9,990 false alarms. Real share = 990 / 10,980 = 9.0%.
Fix: lower the FPR to 0.1%: \( P(A \mid \text{alarm}) = \frac{0.00099}{0.00099 + 0.000999} = 0.498 \) ≈ 50%. For rare events, FPR matters more than detection rate.
Worked example: একটা IDS 99% attack ধরে (detection rate / recall = 0.99)। Normal connection-এর 1%-এ false alarm দেয় (FPR = 0.01)। মাত্র 0.1% connection attack (\( P(A) = 0.001 \))। একটা alarm বাজল। এটা আসল attack হওয়ার chance কত?

Step 1 — \( P(\text{alarm}) = 0.99 \times 0.001 + 0.01 \times 0.999 = 0.00099 + 0.00999 = 0.01098 \)।
Step 2 — \( P(A \mid \text{alarm}) = \frac{0.00099}{0.01098} = \mathbf{0.090} \), প্রায় 9%।

মানে "99% accurate" IDS হলেও প্রায় 91% alarm false। Analyst-রা false alarm-এ ক্লান্ত হয়ে সেগুলো ignore করা শুরু করে (alert fatigue)।

Natural-frequency check: 10,00,000 connection-এর মধ্যে: 1,000 attack → 990 alarm; 999,000 normal → 9,990 false alarm। আসল ভাগ = 990 / 10,980 = 9.0%।
সমাধান: FPR কমিয়ে 0.1% করলে: \( P(A \mid \text{alarm}) = \frac{0.00099}{0.00099 + 0.000999} = 0.498 \) ≈ 50%। বিরল event-এ detection rate-এর চেয়ে FPR বেশি গুরুত্বপূর্ণ।
1,000,000 eventsnetwork connections 1,000 attacks0.1% base rate 999,000 normal99.9% 990 alarmsTP (99% detect) 10 missedFN (Type II) 9,990 alarmsFP (1%, Type I) 989,010 quietTN Total alarms = 990 + 9,990 = 10,980 → real attacks = 990 / 10,980 ≈ 9.0%
Frequency tree for the IDS example. False alarms (9,990) swamp true alarms (990) because normal traffic is 999 times more common than attacks.IDS example-এর frequency tree। False alarm (9,990) true alarm (990)-কে ডুবিয়ে দেয়, কারণ normal traffic attack-এর চেয়ে 999 গুণ বেশি।

7.2 Anomaly detection with z-scores (3-sigma rule)7.2 z-score দিয়ে anomaly detection (3-sigma rule)

Learn what "normal" looks like (mean \( \mu \) and SD \( \sigma \) of some metric), then flag values that are too far away. For normal data:

  • about 68% lies within \( \mu \pm 1\sigma \),
  • about 95% within \( \mu \pm 2\sigma \),
  • about 99.7% within \( \mu \pm 3\sigma \).

3-sigma rule: flag a value as an anomaly if \( |z| > 3 \). For normal data this gives a false-alarm rate of only about 0.27%.

"Normal" দেখতে কেমন শেখো (কোনো metric-এর mean \( \mu \) আর SD \( \sigma \)), তারপর অনেক দূরের value flag করো। Normal data-তে:

  • প্রায় 68% থাকে \( \mu \pm 1\sigma \)-এর মধ্যে,
  • প্রায় 95% থাকে \( \mu \pm 2\sigma \)-এর মধ্যে,
  • প্রায় 99.7% থাকে \( \mu \pm 3\sigma \)-এর মধ্যে।

3-sigma rule: \( |z| > 3 \) হলে value-টাকে anomaly হিসেবে flag করো। Normal data-তে এতে false-alarm rate মাত্র প্রায় 0.27%।

Example: A web server normally sees \( \mu = 120 \) login attempts per hour, with \( \sigma = 15 \). This hour there are 190 attempts.
\( z = \frac{190 - 120}{15} = \frac{70}{15} = 4.67 \). Since \( 4.67 > 3 \), flag it — maybe a credential-stuffing attack.
Anything above \( 120 + 3 \times 15 = 165 \) or below \( 120 - 45 = 75 \) would be flagged. (A very low count can also be suspicious, for example if logging was switched off.)
Cost of the rule: if we check 1,000 normal hours, we expect about \( 1000 \times 0.0027 \approx 2.7 \) false alarms.
Example: একটা web server-এ সাধারণত ঘণ্টায় \( \mu = 120 \)টা login attempt হয়, \( \sigma = 15 \)। এই ঘণ্টায় হয়েছে 190টা।
\( z = \frac{190 - 120}{15} = \frac{70}{15} = 4.67 \)। \( 4.67 > 3 \), তাই flag করো — হয়তো credential-stuffing attack।
\( 120 + 3 \times 15 = 165 \)-এর উপরে বা \( 120 - 45 = 75 \)-এর নিচে যেকোনো কিছু flag হবে। (খুব কম count-ও সন্দেহজনক হতে পারে, যেমন logging বন্ধ করে দেওয়া হলে।)
Rule-এর খরচ: 1,000টা normal ঘণ্টা check করলে প্রায় \( 1000 \times 0.0027 \approx 2.7 \)টা false alarm আশা করা যায়।
Note: Real traffic is often skewed, not normal. Then the 3-sigma rule gives more false alarms than 0.27%. The IQR rule from Section 1, or a median-based method, is more robust. Also, the attack itself can inflate \( \mu \) and \( \sigma \) if it is inside the "training" data.
Note: বাস্তব traffic প্রায়ই skewed, normal না। তখন 3-sigma rule 0.27%-এর বেশি false alarm দেয়। Section 1-এর IQR rule বা median-based method বেশি robust। আর attack নিজেই "training" data-র ভেতরে থাকলে \( \mu \) আর \( \sigma \)-কে বাড়িয়ে দিতে পারে।

7.3 Confusion matrix metrics for an IDS7.3 IDS-এর confusion matrix metrics

Compare what the IDS said with the truth. "Positive" = attack.

IDS যা বলেছে তা সত্যের সাথে তুলনা করো। "Positive" = attack।

Actually attackআসলে attackActually normalআসলে normal
IDS says attackIDS বলে attackTP = 90FP = 40 (Type I)(Type I)
IDS says normalIDS বলে normalFN = 10 (Type II)(Type II)TN = 860
\[ \text{Precision} = \frac{TP}{TP + FP}, \quad \text{Recall (TPR)} = \frac{TP}{TP + FN}, \quad \text{FPR} = \frac{FP}{FP + TN}, \quad F_1 = \frac{2PR}{P + R} \]
Example (1,000 connections, table above):
Precision = 90 / 130 = 0.692 — when the IDS alarms, it is right 69% of the time.
Recall = 90 / 100 = 0.90 — it catches 90% of attacks.
FPR = 40 / 900 = 0.044 — it alarms on 4.4% of normal connections.
Accuracy = (90 + 860) / 1000 = 0.95. F1 = \( \frac{2 \times 0.692 \times 0.9}{0.692 + 0.9} = 0.783 \).
Warning: accuracy can fool you. An IDS that says "normal" for everything would get 90% accuracy here but catch zero attacks. For rare attacks, report precision, recall and FPR.
Example (1,000 connection, উপরের table):
Precision = 90 / 130 = 0.692 — IDS alarm দিলে 69% সময় ঠিক।
Recall = 90 / 100 = 0.90 — 90% attack ধরে।
FPR = 40 / 900 = 0.044 — normal connection-এর 4.4%-এ alarm দেয়।
Accuracy = (90 + 860) / 1000 = 0.95। F1 = \( \frac{2 \times 0.692 \times 0.9}{0.692 + 0.9} = 0.783 \)।
সতর্কতা: accuracy ধোঁকা দিতে পারে। যে IDS সবকিছুকে "normal" বলে, সে এখানে 90% accuracy পাবে কিন্তু একটাও attack ধরবে না। বিরল attack-এর ক্ষেত্রে precision, recall আর FPR দেখাও।

7.4 Entropy of passwords and keys7.4 Password আর key-এর entropy

Entropy (in bits) measures how hard something is to guess. If a password is chosen uniformly at random from a charset of size \(N\) with length \(L\), the number of possible passwords is \( N^L \), and:

Entropy (bits-এ) মাপে কোনো কিছু guess করা কতটা কঠিন। Size \(N\)-এর charset থেকে length \(L\)-এর password uniformly randomভাবে বাছলে সম্ভাব্য password \( N^L \)টা, আর:

\[ H = \log_2\!\left(N^L\right) = L \log_2 N \ \text{bits}, \qquad \text{Shannon: } H = -\sum_i p_i \log_2 p_i \]
Password typePassword typeNLEntropy (bits)Entropy (bits)
4-digit PIN4-digit PIN104\( 4 \times 3.322 = 13.3 \)
8 lowercase letters8টা lowercase letter268\( 8 \times 4.700 = 37.6 \)
8 printable ASCII8টা printable ASCII948\( 8 \times 6.555 = 52.4 \)
12 letters + digits12টা letter + digit6212\( 12 \times 5.954 = 71.5 \)
AES-128 random keyAES-128 random key2128128
Worked example: A random 8-character password from 94 printable characters. An attacker can try \( 10^{10} \) guesses per second (offline, with GPUs). How long on average to crack it?
Step 1 — Entropy: \( 8 \log_2 94 = 8 \times 6.555 = 52.4 \) bits.
Step 2 — Total passwords: \( 94^8 \approx 6.10 \times 10^{15} \) (≈ \( 2^{52.4} \)).
Step 3 — On average the attacker finds it after trying half: \( \frac{6.10 \times 10^{15}}{2 \times 10^{10}} = 3.05 \times 10^5 \) s ≈ 3.5 days.
Each extra bit doubles the work. Adding 4 more random characters (12 total, \( \approx 78.7 \) bits) makes it about \( 94^4 \approx 78 \) million times harder.
Worked example: 94টা printable character থেকে random 8-character password। Attacker প্রতি second-এ \( 10^{10} \)টা guess করতে পারে (offline, GPU দিয়ে)। গড়ে crack করতে কত সময় লাগবে?
Step 1 — Entropy: \( 8 \log_2 94 = 8 \times 6.555 = 52.4 \) bits।
Step 2 — মোট password: \( 94^8 \approx 6.10 \times 10^{15} \) (≈ \( 2^{52.4} \))।
Step 3 — গড়ে অর্ধেক try করার পর পাওয়া যায়: \( \frac{6.10 \times 10^{15}}{2 \times 10^{10}} = 3.05 \times 10^5 \) s ≈ 3.5 দিন।
প্রতি extra bit-এ কাজ দ্বিগুণ। আরও 4টা random character যোগ করলে (মোট 12, \( \approx 78.7 \) bits) প্রায় \( 94^4 \approx 7.8 \) কোটি গুণ কঠিন হয়।
Shannon entropy example: A biased random bit gives 1 with probability 0.9 and 0 with probability 0.1.
\( H = -(0.9 \log_2 0.9 + 0.1 \log_2 0.1) = -(0.9 \times (-0.152) + 0.1 \times (-3.322)) = 0.137 + 0.332 = 0.469 \) bits.
A fair bit has 1 bit of entropy. This biased source gives less than half a bit per output, so it is a bad source for keys.
Shannon entropy example: একটা biased random bit 0.9 probability-তে 1 আর 0.1 probability-তে 0 দেয়।
\( H = -(0.9 \log_2 0.9 + 0.1 \log_2 0.1) = 0.137 + 0.332 = 0.469 \) bits।
Fair bit-এর entropy 1 bit। এই biased source প্রতি output-এ অর্ধেক bit-এরও কম দেয়, তাই এটা key-এর জন্য খারাপ source।
Exam trap: \( L \log_2 N \) is only true for truly random passwords. Human passwords like "Password@123" follow patterns and have far lower real entropy, because attackers try dictionary words and common patterns first. Useful values: \( \log_2 10 = 3.322 \), \( \log_2 26 = 4.700 \), \( \log_2 36 = 5.170 \), \( \log_2 62 = 5.954 \), \( \log_2 94 = 6.555 \).
Exam trap: \( L \log_2 N \) শুধু সত্যিকারের random password-এর জন্য ঠিক। "Password@123"-এর মতো মানুষের বানানো password pattern follow করে, তাই আসল entropy অনেক কম — কারণ attacker আগে dictionary word আর common pattern try করে। কাজের value: \( \log_2 10 = 3.322 \), \( \log_2 26 = 4.700 \), \( \log_2 36 = 5.170 \), \( \log_2 62 = 5.954 \), \( \log_2 94 = 6.555 \)।

Practice Questions (Admission Style)Practice Questions (Admission Style)

20 questions, easy to hard: 7 MCQs and 13 written/calculation problems like the IICT InfoSec written test. Solve each on paper with the 5-step method before opening the answer. Use the tables in Sections 1, 3 and 5. 20টা প্রশ্ন, সহজ থেকে কঠিন: 7টা MCQ আর 13টা written/calculation problem, IICT InfoSec written test-এর মতো। Answer খোলার আগে 5-step method দিয়ে কাগজে solve করো। Section 1, 3 আর 5-এর table ব্যবহার করো।

Q1. (IICT MCQ style) Which measure of centre is least affected by a few extreme outliers in failed-login counts?
  • (a) Mean
  • (b) Median
  • (c) Range
  • (d) Standard deviation
Q1. (IICT MCQ style) Failed-login count-এ কয়েকটা extreme outlier থাকলে কোন centre measure সবচেয়ে কম প্রভাবিত হয়?
  • (a) Mean
  • (b) Median
  • (c) Range
  • (d) Standard deviation
Show Answerউত্তর দেখুন
Answer: (b) — The median only depends on the middle position, so one huge value does not move it. The mean is pulled toward outliers. Range and SD are measures of spread (not centre), and both are very sensitive to outliers.
Answer: (b) — Median শুধু মাঝের position-এর উপর নির্ভর করে, তাই একটা বিশাল value একে নড়াতে পারে না। Mean outlier-এর দিকে টেনে যায়। Range আর SD হলো spread-এর measure (centre না), আর দুটোই outlier-এ খুব sensitive।
Q2. (IICT MCQ style) A population has \( \sigma = 20 \). What is the standard error of the mean for a random sample of \( n = 100 \)?
  • (a) 0.2
  • (b) 2
  • (c) 20
  • (d) 200
Q2. (IICT MCQ style) একটা population-এর \( \sigma = 20 \)। \( n = 100 \)-এর random sample-এ mean-এর standard error কত?
  • (a) 0.2
  • (b) 2
  • (c) 20
  • (d) 200
Show Answerউত্তর দেখুন
Answer: (b) — \( SE = \frac{\sigma}{\sqrt{n}} = \frac{20}{\sqrt{100}} = \frac{20}{10} = 2 \). Option (a) comes from dividing by \(n\) instead of \( \sqrt{n} \) — a common trap.
Answer: (b) — \( SE = \frac{\sigma}{\sqrt{n}} = \frac{20}{10} = 2 \)। Option (a) আসে \( \sqrt{n} \)-এর বদলে \(n\) দিয়ে ভাগ করলে — common trap।
Q3. (IICT MCQ style) For a 99% two-sided confidence interval with known \( \sigma \), the critical value is:
  • (a) 1.645
  • (b) 1.960
  • (c) 2.326
  • (d) 2.576
Q3. (IICT MCQ style) \( \sigma \) জানা থাকলে 99% two-sided confidence interval-এর critical value হলো:
  • (a) 1.645
  • (b) 1.960
  • (c) 2.326
  • (d) 2.576
Show Answerউত্তর দেখুন
Answer: (d) — For 99%, \( \alpha = 0.01 \), so each tail has 0.005. \( z_{0.005} = 2.576 \) because \( \Phi(2.576) = 0.995 \). 1.645 is for 90%, 1.96 for 95%, and 2.326 is the one-tailed 1% value.
Answer: (d) — 99%-এ \( \alpha = 0.01 \), তাই প্রতি tail-এ 0.005। \( z_{0.005} = 2.576 \), কারণ \( \Phi(2.576) = 0.995 \)। 1.645 হলো 90%-এর, 1.96 হলো 95%-এর, আর 2.326 হলো one-tailed 1%-এর value।
Q4. (IICT MCQ style) Take \( H_0 \): "the traffic is normal". An IDS raises an alarm on perfectly normal traffic. This is a:
  • (a) Type I error (false positive)
  • (b) Type II error (false negative)
  • (c) True positive
  • (d) Sampling error
Q4. (IICT MCQ style) ধরো \( H_0 \): "traffic normal"। একটা IDS একদম normal traffic-এ alarm দিল। এটা হলো:
  • (a) Type I error (false positive)
  • (b) Type II error (false negative)
  • (c) True positive
  • (d) Sampling error
Show Answerউত্তর দেখুন
Answer: (a) — The IDS rejected \( H_0 \) ("raised an alarm") even though \( H_0 \) was true. Rejecting a true \( H_0 \) is a Type I error; its probability is \( \alpha \). A missed attack (failing to reject a false \( H_0 \)) would be Type II.
Answer: (a) — \( H_0 \) সত্য হওয়া সত্ত্বেও IDS \( H_0 \) reject করেছে ("alarm দিয়েছে")। সত্য \( H_0 \) reject করা হলো Type I error; এর probability \( \alpha \)। Attack miss করা (মিথ্যা \( H_0 \) reject না করা) হতো Type II।
Q5. (IICT MCQ style) A chi-square test of independence uses a contingency table with 3 rows (user role) and 4 columns (type of incident). The degrees of freedom are:
  • (a) 12
  • (b) 11
  • (c) 7
  • (d) 6
Q5. (IICT MCQ style) একটা chi-square test of independence-এ 3টা row (user role) আর 4টা column (incident type)-এর contingency table। Degrees of freedom কত?
  • (a) 12
  • (b) 11
  • (c) 7
  • (d) 6
Show Answerউত্তর দেখুন
Answer: (d) — \( df = (r-1)(c-1) = (3-1)(4-1) = 2 \times 3 = 6 \). Option (a) is the number of cells, and (b) is cells − 1, which is the goodness-of-fit formula — not the right one here.
Answer: (d) — \( df = (r-1)(c-1) = 2 \times 3 = 6 \)। Option (a) হলো cell-এর সংখ্যা, আর (b) হলো cell − 1, যেটা goodness-of-fit-এর formula — এখানে ঠিক না।
Q6. (IICT MCQ style) A test gives p-value = 0.03 with \( \alpha = 0.05 \). Which statement is correct?
  • (a) There is a 3% chance that \( H_0 \) is true.
  • (b) Reject \( H_0 \); if \( H_0 \) were true, data this extreme would appear only 3% of the time.
  • (c) Accept \( H_0 \), because 0.03 is small.
  • (d) There is a 97% chance that \( H_1 \) is true.
Q6. (IICT MCQ style) একটা test-এ p-value = 0.03, \( \alpha = 0.05 \)। কোন কথাটা ঠিক?
  • (a) \( H_0 \) সত্য হওয়ার chance 3%।
  • (b) \( H_0 \) reject; \( H_0 \) সত্য হলে এত extreme data মাত্র 3% সময় আসত।
  • (c) \( H_0 \) accept, কারণ 0.03 ছোট।
  • (d) \( H_1 \) সত্য হওয়ার chance 97%।
Show Answerউত্তর দেখুন
Answer: (b) — p = 0.03 ≤ 0.05, so we reject \( H_0 \). The p-value is P(data this extreme | \( H_0 \) true). It is not P(\( H_0 \) true), so (a) and (d) are the classic wrong readings. (c) is backwards: a small p-value is evidence against \( H_0 \).
Answer: (b) — p = 0.03 ≤ 0.05, তাই \( H_0 \) reject। p-value হলো P(এত extreme data | \( H_0 \) সত্য)। এটা P(\( H_0 \) সত্য) না, তাই (a) আর (d) হলো classic ভুল ব্যাখ্যা। (c) উল্টো: ছোট p-value হলো \( H_0 \)-এর বিরুদ্ধে প্রমাণ।
Q7. (IICT MCQ style) The correlation between the number of open ports and a vulnerability score is \( r = -0.8 \). What fraction of the variation in the score is explained by a simple linear regression on open ports?
  • (a) −80%
  • (b) 64%
  • (c) 80%
  • (d) 89%
Q7. (IICT MCQ style) Open port-এর সংখ্যা আর vulnerability score-এর correlation \( r = -0.8 \)। Open port-এর উপর simple linear regression score-এর variation-এর কত অংশ ব্যাখ্যা করে?
  • (a) −80%
  • (b) 64%
  • (c) 80%
  • (d) 89%
Show Answerউত্তর দেখুন
Answer: (b) — In simple linear regression \( R^2 = r^2 = (-0.8)^2 = 0.64 \), so 64% of the variation is explained. A fraction explained can never be negative, and \( |r| \) itself (80%) is not the explained share. (89% would be \( \sqrt{0.8} \), a wrong move.)
Answer: (b) — Simple linear regression-এ \( R^2 = r^2 = (-0.8)^2 = 0.64 \), তাই variation-এর 64% ব্যাখ্যা হয়। ব্যাখ্যা করা অংশ কখনো negative হয় না, আর \( |r| \) নিজে (80%) explained share না। (89% হলো \( \sqrt{0.8} \), ভুল পদক্ষেপ।)
Q8. (IICT written style) The number of malware alerts per day for 11 days is: 15, 18, 20, 21, 22, 24, 25, 27, 29, 31, 60. Find the five-number summary and the IQR. Use the 1.5 × IQR rule to find any outliers. Sketch the box plot in words.
Q8. (IICT written style) 11 দিনের প্রতিদিনের malware alert সংখ্যা: 15, 18, 20, 21, 22, 24, 25, 27, 29, 31, 60। Five-number summary আর IQR বের করো। 1.5 × IQR rule দিয়ে outlier খোঁজো। Box plot কেমন হবে কথায় বলো।
Show Answerউত্তর দেখুন
Answer: Min 15, Q1 20, Median 24, Q3 29, Max 60; IQR = 9; outlier = 60.
Step 1 — The data is sorted, \( n = 11 \) (odd). Median = 6th value = 24.
Step 2 — Lower half (leave out the median): 15, 18, 20, 21, 22 → Q1 = 20.
Step 3 — Upper half: 25, 27, 29, 31, 60 → Q3 = 29.
Step 4 — IQR = 29 − 20 = 9.
Step 5 — Fences: lower = 20 − 13.5 = 6.5; upper = 29 + 13.5 = 42.5.
Step 6 — 60 > 42.5, so 60 is an outlier. Nothing is below 6.5.
Box plot: box from 20 to 29 with a line at 24; left whisker to 15; right whisker to 31 (largest non-outlier); a separate dot at 60. The data is right-skewed.
Answer: Min 15, Q1 20, Median 24, Q3 29, Max 60; IQR = 9; outlier = 60।
Step 1 — Data sorted, \( n = 11 \) (odd)। Median = 6th value = 24।
Step 2 — নিচের অর্ধেক (median বাদ দিয়ে): 15, 18, 20, 21, 22 → Q1 = 20।
Step 3 — উপরের অর্ধেক: 25, 27, 29, 31, 60 → Q3 = 29।
Step 4 — IQR = 29 − 20 = 9।
Step 5 — Fence: lower = 20 − 13.5 = 6.5; upper = 29 + 13.5 = 42.5।
Step 6 — 60 > 42.5, তাই 60 একটা outlier। 6.5-এর নিচে কিছু নেই।
Box plot: box 20 থেকে 29, ভেতরে 24-এ line; বাম whisker 15 পর্যন্ত; ডান whisker 31 পর্যন্ত (সবচেয়ে বড় non-outlier); 60-এ আলাদা dot। Data right-skewed।
Q9. (IICT written style) Student A scored 72 in a Cryptography exam (mean 65, SD 5). Student B scored 80 in a Networking exam (mean 74, SD 4). Using z-scores, who performed relatively better? If Networking marks are normal, what percentage of students scored below B?
Q9. (IICT written style) Student A Cryptography exam-এ পেয়েছে 72 (mean 65, SD 5)। Student B Networking exam-এ পেয়েছে 80 (mean 74, SD 4)। z-score দিয়ে বলো কে তুলনামূলক ভালো করেছে? Networking marks normal হলে কত শতাংশ student B-এর চেয়ে কম পেয়েছে?
Show Answerউত্তর দেখুন
Answer: B is relatively better (z = 1.5 vs 1.4); about 93.3% scored below B.
Step 1 — \( z_A = \frac{72 - 65}{5} = \frac{7}{5} = 1.4 \).
Step 2 — \( z_B = \frac{80 - 74}{4} = \frac{6}{4} = 1.5 \).
Step 3 — \( 1.5 > 1.4 \), so B did relatively better, being further above the class mean in SD units.
Step 4 — \( P(Z < 1.5) = \Phi(1.5) = 0.9332 \) → about 93.3% of Networking students scored below B.
Answer: B তুলনামূলক ভালো (z = 1.5 বনাম 1.4); প্রায় 93.3% B-এর চেয়ে কম পেয়েছে।
Step 1 — \( z_A = \frac{72 - 65}{5} = 1.4 \)।
Step 2 — \( z_B = \frac{80 - 74}{4} = 1.5 \)।
Step 3 — \( 1.5 > 1.4 \), তাই B তুলনামূলক ভালো করেছে — SD unit-এ class mean থেকে বেশি উপরে।
Step 4 — \( P(Z < 1.5) = \Phi(1.5) = 0.9332 \) → Networking-এর প্রায় 93.3% student B-এর চেয়ে কম পেয়েছে।
Q10. (IICT written style) A system allows random 10-character passwords from lowercase letters and digits (36 symbols). (a) Find the entropy in bits. (b) An attacker tries \( 10^9 \) guesses per second. What is the worst-case time to try every password? (c) Compare with random 8-character passwords from 94 printable characters.
Q10. (IICT written style) একটা system lowercase letter আর digit (36টা symbol) থেকে random 10-character password দেয়। (a) Entropy কত bits? (b) Attacker প্রতি second-এ \( 10^9 \)টা guess করে। সব password try করতে worst-case সময় কত? (c) 94টা printable character-এর random 8-character password-এর সাথে তুলনা করো।
Show Answerউত্তর দেখুন
Answer: (a) 51.7 bits; (b) about 42.3 days; (c) the 94-char, 8-length password is slightly stronger (52.4 bits, about 70.6 days).
(a) \( H = 10 \log_2 36 = 10 \times 5.170 = \mathbf{51.7} \) bits.
(b) Number of passwords \( = 36^{10} \approx 3.656 \times 10^{15} \). Time \( = \frac{3.656 \times 10^{15}}{10^9} = 3.656 \times 10^6 \) s. Divide by 86,400 s/day → ≈ 42.3 days (average ≈ 21.2 days).
(c) \( 8 \log_2 94 = 52.4 \) bits; \( 94^8 \approx 6.10 \times 10^{15} \) → \( 6.10 \times 10^6 \) s ≈ 70.6 days. So 8 characters from a big charset beat 10 characters from a small one here — but only by 0.7 bits. Length and charset size both matter.
Answer: (a) 51.7 bits; (b) প্রায় 42.3 দিন; (c) 94-char, 8-length password একটু বেশি শক্ত (52.4 bits, প্রায় 70.6 দিন)।
(a) \( H = 10 \log_2 36 = 10 \times 5.170 = \mathbf{51.7} \) bits।
(b) Password সংখ্যা \( = 36^{10} \approx 3.656 \times 10^{15} \)। সময় \( = 3.656 \times 10^6 \) s। 86,400 s/দিন দিয়ে ভাগ → ≈ 42.3 দিন (গড়ে ≈ 21.2 দিন)।
(c) \( 8 \log_2 94 = 52.4 \) bits; \( 94^8 \approx 6.10 \times 10^{15} \) → \( 6.10 \times 10^6 \) s ≈ 70.6 দিন। তাই এখানে বড় charset-এর 8 character ছোট charset-এর 10 character-কে হারায় — তবে মাত্র 0.7 bit-এ। Length আর charset size দুটোই গুরুত্বপূর্ণ।
Q11. (IICT written style) Files uploaded to a company server have mean size 2.0 MB and SD 0.5 MB. The size distribution is unknown (probably skewed). A random sample of 100 files is taken. (a) Find the probability that the sample mean is between 1.9 and 2.1 MB. (b) Can you find the probability that a single file is larger than 2.1 MB? Explain.
Q11. (IICT written style) একটা company server-এ upload হওয়া file-এর mean size 2.0 MB আর SD 0.5 MB। Size distribution অজানা (সম্ভবত skewed)। Random 100টা file-এর sample নেওয়া হলো। (a) Sample mean 1.9 থেকে 2.1 MB-এর মধ্যে হওয়ার probability বের করো। (b) একটা file 2.1 MB-এর বড় হওয়ার probability কি বের করা যাবে? ব্যাখ্যা করো।
Show Answerউত্তর দেখুন
Answer: (a) ≈ 0.9545; (b) No.
(a) Step 1 — \( n = 100 \ge 30 \), so by CLT \( \bar{X} \) is about normal.
Step 2 — \( SE = \frac{0.5}{\sqrt{100}} = 0.05 \).
Step 3 — \( z_1 = \frac{1.9 - 2.0}{0.05} = -2 \), \( z_2 = \frac{2.1 - 2.0}{0.05} = 2 \).
Step 4 — \( P = \Phi(2) - \Phi(-2) = 0.9772 - 0.0228 = \mathbf{0.9545} \).
(b) No. CLT is about the mean of many files. One file follows the population distribution, which is unknown and skewed. We cannot use the normal table for a single file.
Answer: (a) ≈ 0.9545; (b) না।
(a) Step 1 — \( n = 100 \ge 30 \), তাই CLT অনুযায়ী \( \bar{X} \) প্রায় normal।
Step 2 — \( SE = \frac{0.5}{10} = 0.05 \)।
Step 3 — \( z_1 = -2 \), \( z_2 = 2 \)।
Step 4 — \( P = \Phi(2) - \Phi(-2) = 0.9772 - 0.0228 = \mathbf{0.9545} \)।
(b) না। CLT অনেক file-এর mean নিয়ে। একটা file population distribution follow করে, যেটা অজানা আর skewed। একটা file-এর জন্য normal table ব্যবহার করা যায় না।
Q12. (IICT written style) A SOC team records the time (minutes) to respond to 9 incidents. The sample mean is 48 and the sample SD is 6. Assume response times are normal. (a) Build a 95% confidence interval for the true mean response time. (b) Management claims the mean is 55 minutes. Does the interval support this claim?
Q12. (IICT written style) একটা SOC team 9টা incident-এ response time (মিনিট) record করল। Sample mean 48, sample SD 6। Response time normal ধরো। (a) আসল mean response time-এর 95% confidence interval বানাও। (b) Management দাবি করে mean 55 মিনিট। Interval কি এই দাবি support করে?
Show Answerউত্তর দেখুন
Answer: (a) (43.39, 52.61) minutes; (b) No.
(a) Step 1 — \( \sigma \) unknown, \( n = 9 \) small → t with \( df = 8 \).
Step 2 — \( t_{0.025,8} = 2.306 \). \( SE = \frac{6}{\sqrt{9}} = 2 \).
Step 3 — \( E = 2.306 \times 2 = 4.612 \).
Step 4 — CI = \( 48 \pm 4.612 = \mathbf{(43.39,\ 52.61)} \).
(b) 55 is outside the interval. So a two-tailed t-test of \( H_0: \mu = 55 \) at \( \alpha = 0.05 \) would reject it. The data does not support the claim — the team seems faster than 55 minutes. (A 95% CI and a two-tailed 5% test always agree like this.)
Answer: (a) (43.39, 52.61) মিনিট; (b) না।
(a) Step 1 — \( \sigma \) অজানা, \( n = 9 \) ছোট → \( df = 8 \) সহ t।
Step 2 — \( t_{0.025,8} = 2.306 \)। \( SE = \frac{6}{3} = 2 \)।
Step 3 — \( E = 2.306 \times 2 = 4.612 \)।
Step 4 — CI = \( 48 \pm 4.612 = \mathbf{(43.39,\ 52.61)} \)।
(b) 55 interval-এর বাইরে। তাই \( \alpha = 0.05 \)-এ \( H_0: \mu = 55 \)-এর two-tailed t-test এটাকে reject করত। Data দাবিটা support করে না — team 55 মিনিটের চেয়ে দ্রুত মনে হচ্ছে। (95% CI আর two-tailed 5% test সবসময় এভাবে মিলে যায়।)
Q13. (IICT written style) A mail gateway scans 500 random emails and finds 60 are spam. (a) Find a 90% confidence interval for the true spam proportion. (b) How many emails should be scanned so that the 90% margin of error is at most 0.02? Use the sample proportion from (a) as the guess.
Q13. (IICT written style) একটা mail gateway random 500টা email scan করে 60টা spam পেল। (a) আসল spam proportion-এর 90% confidence interval বের করো। (b) 90% margin of error সর্বোচ্চ 0.02 রাখতে কতগুলো email scan করা উচিত? (a)-এর sample proportion guess হিসেবে নাও।
Show Answerউত্তর দেখুন
Answer: (a) (0.096, 0.144); (b) 715 emails.
(a) Step 1 — \( \hat{p} = 60/500 = 0.12 \). Check: \( 500 \times 0.12 = 60 \ge 10 \) and \( 500 \times 0.88 = 440 \ge 10 \).
Step 2 — \( SE = \sqrt{\frac{0.12 \times 0.88}{500}} = \sqrt{0.0002112} = 0.01453 \).
Step 3 — 90% → \( z = 1.645 \). \( E = 1.645 \times 0.01453 = 0.0239 \).
Step 4 — CI = \( 0.12 \pm 0.0239 = \mathbf{(0.096,\ 0.144)} \), i.e. 9.6% to 14.4% spam.
(b) \( n = \frac{1.645^2 \times 0.12 \times 0.88}{0.02^2} = \frac{2.706 \times 0.1056}{0.0004} = 714.39 \) → round up → 715.
Answer: (a) (0.096, 0.144); (b) 715টা email।
(a) Step 1 — \( \hat{p} = 60/500 = 0.12 \)। Check: \( 500 \times 0.12 = 60 \ge 10 \), \( 500 \times 0.88 = 440 \ge 10 \)।
Step 2 — \( SE = \sqrt{\frac{0.12 \times 0.88}{500}} = 0.01453 \)।
Step 3 — 90% → \( z = 1.645 \)। \( E = 1.645 \times 0.01453 = 0.0239 \)।
Step 4 — CI = \( 0.12 \pm 0.0239 = \mathbf{(0.096,\ 0.144)} \), মানে 9.6% থেকে 14.4% spam।
(b) \( n = \frac{1.645^2 \times 0.12 \times 0.88}{0.02^2} = \frac{2.706 \times 0.1056}{0.0004} = 714.39 \) → উপরে round → 715।
Q14. (IICT written style) A crypto library claims AES encryption of a 1 MB block takes 50 ms on average, with known \( \sigma = 6 \) ms. You time 36 runs and get \( \bar{x} = 52.1 \) ms. Test whether the true mean differs from 50 ms at \( \alpha = 0.05 \). Find the p-value. Would the decision change at \( \alpha = 0.01 \)?
Q14. (IICT written style) একটা crypto library দাবি করে 1 MB block AES encryption-এ গড়ে 50 ms লাগে, \( \sigma = 6 \) ms জানা। 36 বার time করে পেলে \( \bar{x} = 52.1 \) ms। \( \alpha = 0.05 \)-এ test করো আসল mean 50 ms থেকে আলাদা কিনা। p-value বের করো। \( \alpha = 0.01 \)-এ কি decision বদলাবে?
Show Answerউত্তর দেখুন
Answer: z = 2.1, p ≈ 0.036 → reject at 5%, but fail to reject at 1%.
Step 1: \( H_0: \mu = 50 \), \( H_1: \mu \ne 50 \) ("differs" → two-tailed).
Step 2: \( \alpha = 0.05 \).
Step 3: \( SE = \frac{6}{\sqrt{36}} = 1 \). \( z = \frac{52.1 - 50}{1} = 2.1 \).
Step 4: Critical ±1.96. p-value \( = 2 \times P(Z > 2.1) = 2 \times (1 - 0.9821) = 0.0357 \).
Step 5: \( 2.1 > 1.96 \) and \( 0.036 < 0.05 \) → reject \( H_0 \). The mean encryption time is not 50 ms (it seems slower).
At \( \alpha = 0.01 \): critical ±2.576, and \( 2.1 < 2.576 \) (also \( 0.036 > 0.01 \)) → fail to reject. The evidence is not strong enough at the stricter level.
Answer: z = 2.1, p ≈ 0.036 → 5%-এ reject, কিন্তু 1%-এ fail to reject।
Step 1: \( H_0: \mu = 50 \), \( H_1: \mu \ne 50 \) ("আলাদা" → two-tailed)।
Step 2: \( \alpha = 0.05 \)।
Step 3: \( SE = \frac{6}{6} = 1 \)। \( z = \frac{52.1 - 50}{1} = 2.1 \)।
Step 4: Critical ±1.96। p-value \( = 2 \times (1 - 0.9821) = 0.0357 \)।
Step 5: \( 2.1 > 1.96 \) আর \( 0.036 < 0.05 \) → \( H_0 \) reject। Mean encryption time 50 ms না (আরও ধীর মনে হচ্ছে)।
\( \alpha = 0.01 \)-এ: critical ±2.576, আর \( 2.1 < 2.576 \) → fail to reject। কড়া level-এ প্রমাণ যথেষ্ট শক্ত না।
Q15. (IICT written style) Last year a company got 12 reported phishing emails per day on average. After a new awareness campaign, reports for 8 random days are: 12, 15, 11, 14, 13, 16, 10, 15. At \( \alpha = 0.05 \), is there evidence that the mean number of reports has increased? State your conclusion carefully.
Q15. (IICT written style) গত বছর একটা company-তে দিনে গড়ে 12টা phishing email report হতো। নতুন awareness campaign-এর পর random 8 দিনের report: 12, 15, 11, 14, 13, 16, 10, 15। \( \alpha = 0.05 \)-এ mean report সংখ্যা বেড়েছে — এর কি প্রমাণ আছে? Conclusion সাবধানে লেখো।
Show Answerউত্তর দেখুন
Answer: t = 1.667 < 1.895 → fail to reject \( H_0 \).
Step 1: \( H_0: \mu = 12 \), \( H_1: \mu > 12 \) ("increased" → right-tailed).
Step 2: \( \alpha = 0.05 \).
Step 3: Sum = 106, \( \bar{x} = 13.25 \).
  Squared deviations: 1.5625, 3.0625, 5.0625, 0.5625, 0.0625, 7.5625, 10.5625, 3.0625. Sum = 31.5.
  \( s^2 = 31.5 / 7 = 4.5 \), \( s = 2.121 \). \( SE = 2.121 / \sqrt{8} = 0.75 \).
  \( t = \frac{13.25 - 12}{0.75} = 1.667 \), \( df = 7 \).
Step 4: One-tailed \( t_{0.05,7} = 1.895 \). (Exact p ≈ 0.070.)
Step 5: \( 1.667 < 1.895 \) → fail to reject \( H_0 \). There is not enough evidence at the 5% level that reports increased.
Careful: this does NOT prove the campaign had no effect. The sample mean did go up; with only 8 days, the test has low power. Collect more days.
Answer: t = 1.667 < 1.895 → \( H_0 \) fail to reject।
Step 1: \( H_0: \mu = 12 \), \( H_1: \mu > 12 \) ("বেড়েছে" → right-tailed)।
Step 2: \( \alpha = 0.05 \)।
Step 3: Sum = 106, \( \bar{x} = 13.25 \)।
  Deviation-এর square-এর sum = 31.5।
  \( s^2 = 31.5 / 7 = 4.5 \), \( s = 2.121 \)। \( SE = 2.121 / \sqrt{8} = 0.75 \)।
  \( t = \frac{1.25}{0.75} = 1.667 \), \( df = 7 \)।
Step 4: One-tailed \( t_{0.05,7} = 1.895 \)। (Exact p ≈ 0.070।)
Step 5: \( 1.667 < 1.895 \) → \( H_0 \) fail to reject। 5% level-এ report বেড়েছে বলার মতো যথেষ্ট প্রমাণ নেই।
সাবধান: এটা প্রমাণ করে না যে campaign-এর কোনো effect নেই। Sample mean বেড়েছে ঠিকই; মাত্র 8 দিনে test-এর power কম। আরও দিনের data নাও।
Q16. (IICT written style) An old and a new version of an antivirus scanner are run on the same 5 machines. Full-scan time (minutes):
Old: 30, 28, 35, 32, 27. New: 26, 27, 30, 29, 25.
At \( \alpha = 0.05 \), is there a difference in mean scan time? Why is a paired test correct here?
Q16. (IICT written style) একই 5টা machine-এ antivirus scanner-এর পুরনো আর নতুন version চালানো হলো। Full-scan time (মিনিট):
পুরনো: 30, 28, 35, 32, 27। নতুন: 26, 27, 30, 29, 25।
\( \alpha = 0.05 \)-এ mean scan time-এ কি পার্থক্য আছে? এখানে paired test কেন ঠিক?
Show Answerউত্তর দেখুন
Answer: t = 4.24 > 2.776 → reject \( H_0 \); the new version is faster.
Paired, because the same machines were used for both versions. Each machine's own speed cancels out in the difference.
Step 1: \( d = \) old − new. \( H_0: \mu_d = 0 \), \( H_1: \mu_d \ne 0 \).
Step 2: \( \alpha = 0.05 \).
Step 3: \( d = 4, 1, 5, 3, 2 \). \( \bar{d} = 15/5 = 3 \).
  \( \sum (d - \bar{d})^2 = 1 + 4 + 4 + 0 + 1 = 10 \). \( s_d^2 = 10/4 = 2.5 \), \( s_d = 1.581 \).
  \( SE = 1.581 / \sqrt{5} = 0.707 \). \( t = 3 / 0.707 = 4.24 \), \( df = 4 \).
Step 4: \( t_{0.025,4} = 2.776 \). (Exact p ≈ 0.013.)
Step 5: \( 4.24 > 2.776 \) → reject \( H_0 \). The mean scan times differ; the new version saves about 3 minutes per scan.
Answer: t = 4.24 > 2.776 → \( H_0 \) reject; নতুন version দ্রুত।
Paired, কারণ দুই version-এর জন্য একই machine ব্যবহার হয়েছে। প্রতিটা machine-এর নিজস্ব speed difference-এ কেটে যায়।
Step 1: \( d = \) পুরনো − নতুন। \( H_0: \mu_d = 0 \), \( H_1: \mu_d \ne 0 \)।
Step 2: \( \alpha = 0.05 \)।
Step 3: \( d = 4, 1, 5, 3, 2 \)। \( \bar{d} = 3 \)।
  \( \sum (d - \bar{d})^2 = 10 \)। \( s_d^2 = 2.5 \), \( s_d = 1.581 \)।
  \( SE = 0.707 \)। \( t = 3 / 0.707 = 4.24 \), \( df = 4 \)।
Step 4: \( t_{0.025,4} = 2.776 \)। (Exact p ≈ 0.013।)
Step 5: \( 4.24 > 2.776 \) → \( H_0 \) reject। Mean scan time আলাদা; নতুন version প্রতি scan-এ প্রায় 3 মিনিট বাঁচায়।
Q17. (IICT written style) In a phishing simulation, 100 IT staff and 100 HR staff were tested.
Q17. (IICT written style) একটা phishing simulation-এ 100 জন IT staff আর 100 জন HR staff test করা হলো।
Clicked linkLink-এ click করেছেDid not clickClick করেনিTotalTotal
IT1090100
HR3070100
TotalTotal40160200
At \( \alpha = 0.05 \), is clicking independent of department?
\( \alpha = 0.05 \)-এ click করা কি department-এর উপর independent?
Show Answerউত্তর দেখুন
Answer: \( \chi^2 = 12.5 > 3.841 \) → not independent.
Step 1: \( H_0 \): clicking and department are independent. \( H_1 \): they are related.
Step 2: \( \alpha = 0.05 \).
Step 3: Expected: IT-click = \( \frac{100 \times 40}{200} = 20 \), IT-no = 80, HR-click = 20, HR-no = 80.
  \( \chi^2 = \frac{(10-20)^2}{20} + \frac{(90-80)^2}{80} + \frac{(30-20)^2}{20} + \frac{(70-80)^2}{80} = 5 + 1.25 + 5 + 1.25 = 12.5 \).
Step 4: \( df = (2-1)(2-1) = 1 \); critical = 3.841. (p ≈ 0.0004.)
Step 5: \( 12.5 > 3.841 \) → reject \( H_0 \). Clicking depends on department: HR clicked 30% of the time vs IT 10%. HR needs more awareness training.
Answer: \( \chi^2 = 12.5 > 3.841 \) → independent না।
Step 1: \( H_0 \): click আর department independent। \( H_1 \): এরা সম্পর্কিত।
Step 2: \( \alpha = 0.05 \)।
Step 3: Expected: IT-click = \( \frac{100 \times 40}{200} = 20 \), IT-no = 80, HR-click = 20, HR-no = 80।
  \( \chi^2 = 5 + 1.25 + 5 + 1.25 = 12.5 \)।
Step 4: \( df = 1 \); critical = 3.841। (p ≈ 0.0004।)
Step 5: \( 12.5 > 3.841 \) → \( H_0 \) reject। Click করা department-এর উপর নির্ভর করে: HR 30% বার click করেছে, IT 10%। HR-এর আরও awareness training দরকার।
Q18. (IICT written style) For 5 servers, x = number of open ports and y = risk score:
x: 2, 4, 6, 8, 10    y: 3, 7, 5, 11, 14.
(a) Find Pearson's r. (b) Find the least-squares line \( \hat{y} = a + bx \). (c) Predict the risk score for 7 open ports. (d) Find \( R^2 \) and interpret it.
Q18. (IICT written style) 5টা server-এ x = open port-এর সংখ্যা আর y = risk score:
x: 2, 4, 6, 8, 10    y: 3, 7, 5, 11, 14।
(a) Pearson's r বের করো। (b) Least-squares line \( \hat{y} = a + bx \) বের করো। (c) 7টা open port-এ risk score predict করো। (d) \( R^2 \) বের করে ব্যাখ্যা করো।
Show Answerউত্তর দেখুন
Answer: r ≈ 0.919; \( \hat{y} = 0.2 + 1.3x \); \( \hat{y}(7) = 9.3 \); \( R^2 \approx 0.845 \).
Step 1 — \( \bar{x} = 30/5 = 6 \), \( \bar{y} = 40/5 = 8 \).
Step 2 — \( x - \bar{x} \): −4, −2, 0, 2, 4. \( y - \bar{y} \): −5, −1, −3, 3, 6.
  \( S_{xx} = 16 + 4 + 0 + 4 + 16 = 40 \).
  \( S_{yy} = 25 + 1 + 9 + 9 + 36 = 80 \).
  \( S_{xy} = 20 + 2 + 0 + 6 + 24 = 52 \).
(a) \( r = \frac{52}{\sqrt{40 \times 80}} = \frac{52}{56.57} = \mathbf{0.919} \) — strong positive.
(b) \( b = 52/40 = 1.3 \), \( a = 8 - 1.3 \times 6 = 0.2 \) → \( \hat{y} = 0.2 + 1.3x \).
(c) \( \hat{y}(7) = 0.2 + 9.1 = \mathbf{9.3} \) (x = 7 is inside the data range, so this is interpolation — safe).
(d) \( R^2 = r^2 = 0.845 \). Check with residuals: \( e = 0.2, 1.6, -3.0, 0.4, 0.8 \); SSE = 0.04 + 2.56 + 9 + 0.16 + 0.64 = 12.4; \( R^2 = 1 - 12.4/80 = 0.845 \) ✓. About 84.5% of the variation in risk score is explained by the number of open ports.
Answer: r ≈ 0.919; \( \hat{y} = 0.2 + 1.3x \); \( \hat{y}(7) = 9.3 \); \( R^2 \approx 0.845 \)।
Step 1 — \( \bar{x} = 6 \), \( \bar{y} = 8 \)।
Step 2 — \( x - \bar{x} \): −4, −2, 0, 2, 4। \( y - \bar{y} \): −5, −1, −3, 3, 6।
  \( S_{xx} = 40 \), \( S_{yy} = 80 \), \( S_{xy} = 20 + 2 + 0 + 6 + 24 = 52 \)।
(a) \( r = \frac{52}{\sqrt{3200}} = \frac{52}{56.57} = \mathbf{0.919} \) — strong positive।
(b) \( b = 52/40 = 1.3 \), \( a = 8 - 1.3 \times 6 = 0.2 \) → \( \hat{y} = 0.2 + 1.3x \)।
(c) \( \hat{y}(7) = 0.2 + 9.1 = \mathbf{9.3} \) (x = 7 data range-এর ভেতরে, তাই এটা interpolation — নিরাপদ)।
(d) \( R^2 = r^2 = 0.845 \)। Residual দিয়ে check: \( e = 0.2, 1.6, -3.0, 0.4, 0.8 \); SSE = 12.4; \( R^2 = 1 - 12.4/80 = 0.845 \) ✓। Risk score-এর variation-এর প্রায় 84.5% open port-এর সংখ্যা দিয়ে ব্যাখ্যা হয়।
Q19. (IICT written style) In a network, 2% of connections are malicious. An IDS detects 95% of malicious connections and wrongly flags 5% of normal ones. (a) If the IDS raises an alarm, what is the probability that the connection is really malicious? (b) If the IDS stays quiet, what is the probability the connection is malicious anyway? (c) Keeping detection at 95%, what false-positive rate would make \( P(\text{malicious} \mid \text{alarm}) \ge 0.5 \)?
Q19. (IICT written style) একটা network-এ 2% connection malicious। একটা IDS 95% malicious connection ধরে আর 5% normal connection-কে ভুল করে flag করে। (a) IDS alarm দিলে connection-টা সত্যিই malicious হওয়ার probability কত? (b) IDS চুপ থাকলে তবুও malicious হওয়ার probability কত? (c) Detection 95% রেখে কত false-positive rate হলে \( P(\text{malicious} \mid \text{alarm}) \ge 0.5 \) হবে?
Show Answerউত্তর দেখুন
Answer: (a) ≈ 0.279; (b) ≈ 0.00107; (c) FPR ≤ about 1.94%.
Let \( M \) = malicious. \( P(M) = 0.02 \), \( P(\text{alarm} \mid M) = 0.95 \), \( P(\text{alarm} \mid \neg M) = 0.05 \).
(a) \( P(\text{alarm}) = 0.95 \times 0.02 + 0.05 \times 0.98 = 0.019 + 0.049 = 0.068 \).
  \( P(M \mid \text{alarm}) = \frac{0.019}{0.068} = \mathbf{0.279} \). Only about 28% of alarms are real — base-rate fallacy again.
(b) \( P(\text{quiet} \mid M) = 0.05 \), \( P(\text{quiet} \mid \neg M) = 0.95 \).
  \( P(M \mid \text{quiet}) = \frac{0.05 \times 0.02}{0.05 \times 0.02 + 0.95 \times 0.98} = \frac{0.001}{0.001 + 0.931} = \mathbf{0.00107} \). A quiet IDS is very reassuring.
(c) Need \( \frac{0.019}{0.019 + 0.98 f} \ge 0.5 \) → \( 0.019 \ge 0.5(0.019 + 0.98f) \) → \( 0.0095 \ge 0.49 f \) → \( f \le 0.0194 \). So the FPR must drop from 5% to about 1.94% or less.
Answer: (a) ≈ 0.279; (b) ≈ 0.00107; (c) FPR প্রায় 1.94% বা তার কম।
ধরো \( M \) = malicious। \( P(M) = 0.02 \), \( P(\text{alarm} \mid M) = 0.95 \), \( P(\text{alarm} \mid \neg M) = 0.05 \)।
(a) \( P(\text{alarm}) = 0.019 + 0.049 = 0.068 \)।
  \( P(M \mid \text{alarm}) = \frac{0.019}{0.068} = \mathbf{0.279} \)। মাত্র প্রায় 28% alarm আসল — আবার base-rate fallacy।
(b) \( P(M \mid \text{quiet}) = \frac{0.05 \times 0.02}{0.001 + 0.95 \times 0.98} = \frac{0.001}{0.932} = \mathbf{0.00107} \)। IDS চুপ থাকলে বেশ নিশ্চিন্ত থাকা যায়।
(c) দরকার \( \frac{0.019}{0.019 + 0.98 f} \ge 0.5 \) → \( 0.0095 \ge 0.49 f \) → \( f \le 0.0194 \)। তাই FPR 5% থেকে কমিয়ে প্রায় 1.94% বা তার নিচে আনতে হবে।
Q20. (IICT written style) Packet-processing latency (ms) is measured for three firewall configurations, 4 runs each:
Config A: 10, 12, 11, 13   Config B: 14, 15, 13, 16   Config C: 11, 10, 12, 11.
Use one-way ANOVA at \( \alpha = 0.05 \) (\( F_{0.05}(2, 9) = 4.26 \)) to test whether the mean latencies are equal. Show the ANOVA table.
Q20. (IICT written style) তিনটা firewall configuration-এ packet-processing latency (ms) মাপা হলো, প্রতিটা 4 বার:
Config A: 10, 12, 11, 13   Config B: 14, 15, 13, 16   Config C: 11, 10, 12, 11।
\( \alpha = 0.05 \)-এ (\( F_{0.05}(2, 9) = 4.26 \)) one-way ANOVA দিয়ে test করো mean latency সমান কিনা। ANOVA table দেখাও।
Show Answerউত্তর দেখুন
Answer: F = 10.75 > 4.26 → reject \( H_0 \).
Step 1: \( H_0: \mu_A = \mu_B = \mu_C \); \( H_1 \): at least one mean differs.
Step 2: \( \alpha = 0.05 \).
Step 3: Group means: A = 46/4 = 11.5, B = 58/4 = 14.5, C = 44/4 = 11. Grand mean = 148/12 = 12.333.
  \( SSB = 4[(11.5 - 12.333)^2 + (14.5 - 12.333)^2 + (11 - 12.333)^2] = 4[0.694 + 4.694 + 1.778] = 4 \times 7.167 = 28.667 \).
  \( SSW \): A: 2.25 + 0.25 + 0.25 + 2.25 = 5; B: 0.25 + 0.25 + 2.25 + 2.25 = 5; C: 0 + 1 + 1 + 0 = 2. Total = 12.
  \( MSB = 28.667 / 2 = 14.333 \); \( MSW = 12 / 9 = 1.333 \); \( F = 14.333 / 1.333 = 10.75 \).
Answer: F = 10.75 > 4.26 → \( H_0 \) reject।
Step 1: \( H_0: \mu_A = \mu_B = \mu_C \); \( H_1 \): অন্তত একটা mean আলাদা।
Step 2: \( \alpha = 0.05 \)।
Step 3: Group mean: A = 11.5, B = 14.5, C = 11। Grand mean = 148/12 = 12.333।
  \( SSB = 4[0.694 + 4.694 + 1.778] = 28.667 \)।
  \( SSW \): A: 5; B: 5; C: 2। মোট = 12।
  \( MSB = 14.333 \); \( MSW = 12 / 9 = 1.333 \); \( F = 10.75 \)।
SourceSSdfMSF
Between28.667214.33310.75
Within1291.333
Total40.66711
Step 4: \( df = (k - 1, N - k) = (2, 9) \); critical \( F = 4.26 \). (Exact p ≈ 0.004.)
Step 5: \( 10.75 > 4.26 \) → reject \( H_0 \). The configurations do not all have the same mean latency; Config B looks slowest. A post-hoc test would confirm which pairs differ.
Step 4: \( df = (2, 9) \); critical \( F = 4.26 \)। (Exact p ≈ 0.004।)
Step 5: \( 10.75 > 4.26 \) → \( H_0 \) reject। সব configuration-এর mean latency এক না; Config B সবচেয়ে ধীর মনে হচ্ছে। কোন pair আলাদা, সেটা post-hoc test নিশ্চিত করবে।