Machine LearningModule 6 · Guide and practice

Module 6 · LDA, mistakes, and thresholds

One picture: two overlapping clouds and a dividing line. LDA models each class’s cloud. A boundary decides the label; the cloud area on the wrong side tells us how often it makes mistakes.

Slides → small steps → practice. Browse the original slides at each topic, or click to enlarge. Keep the formula sheet nearby. Module 5 builds the classification and logistic-regression ideas used here.

1. LDA: which class could have produced this input?

Linear Discriminant Analysis — original slide 3 of 6
Original slides · Linear Discriminant AnalysisOpen PDF ↗
Slide 3 of 6

Start with a story for making the data

Linear discriminant analysis (LDA) imagines two steps:

  1. Pick a class label Y=kY=k. Its prior πk=P(Y=k)\pi_k=P(Y=k) is how common that class is before seeing the input.
  2. Draw the input XX from that class’s bell-shaped, or Gaussian, distribution. Its density is fk(x)f_k(x).

Here xx is the input we observe; kk names a class. LDA uses a separate center for each class but a shared spread. With several inputs, it shares the whole covariance matrix: the spread and how inputs vary together.

Density is curve height; probability is area. For a continuous input, P(X=x)=0P(X=x)=0 at one exact point. We use fk(x)f_k(x) to compare how plausible values near xx are within each class. Areas under fkf_k give probabilities.

Bayes’ rule reverses the story

We observe the input and want the class. The posterior is the updated class probability after seeing xx:

P(Y=k∣X=x)=πkfk(x)∑ℓ=1Kπℓfℓ(x).P(Y=k\mid X=x)= \frac{\pi_k f_k(x)} {\sum_{\ell=1}^{K}\pi_\ell f_\ell(x)}.

KK is the number of classes; ℓ\ell runs through them. The numerator is class frequency × fit to this input. The denominator adds every class’s weight so the answers sum to 1.

Invented example: at one input, suppose priors are π0=0.8\pi_0=0.8, π1=0.2\pi_1=0.2 and densities are f0(x)=0.1f_0(x)=0.1, f1(x)=0.3f_1(x)=0.3.

π0f0(x)=0.8(0.1)=0.08,π1f1(x)=0.2(0.3)=0.06.\begin{aligned} \pi_0f_0(x)&=0.8(0.1)=0.08,\\ \pi_1f_1(x)&=0.2(0.3)=0.06. \end{aligned}

Using total weight 0.08+0.06=0.140.08+0.06=0.14, the posterior for class 1 is 0.06/0.14≈0.4290.06/0.14\approx0.429. Class 0 wins even though class 1’s density is taller: class 0 started much more common.

The classifier only needs the largest weight

With equal costs for mistakes, choose the most probable class:

Y^=C(x)=arg⁡max⁡k{πkfk(x)}.\widehat Y=C(x)=\arg\max_k\{\pi_k f_k(x)\}.

CC is the classification rule; Y^\widehat Y is its predicted label. Arg max means “return the class label with the biggest value.” The shared denominator cannot change which class wins.

This is Bayes optimal when the probabilities are correct: it minimizes the chance of a wrong label. Fitting LDA from data estimates those probabilities, so its quality depends on both the data and its Gaussian, shared-spread assumptions.

2. One input: turn bell curves into straight scores

Univariate LDA — original slide 2 of 7
Original slides · Univariate LDAOpen PDF ↗
Slide 2 of 7

Mean = center; standard deviation = spread

Univariate means one input. Write

X∣Y=k∼N(μk,σ2).X\mid Y=k\sim\mathcal N(\mu_k,\sigma^2).

The class center is μk\mu_k. The second number, σ2\sigma^2, is the variance; its square root σ\sigma is the standard deviation. LDA uses the same positive variance for all classes.

The Gaussian density is

fk(x)=1σ2πexp⁡ ⁣[−(x−μk)22σ2].f_k(x)=\frac{1}{\sigma\sqrt{2\pi}} \exp\!\left[-\frac{(x-\mu_k)^2}{2\sigma^2}\right].

Here π≈3.14159\pi\approx3.14159 is the mathematical constant; πk\pi_k with a subscript is a class prior. Exp means exp⁡(a)=ea\exp(a)=e^a.

Compare a simpler score

Taking logs preserves the ordering of positive weights. After dropping terms shared by all classes, the discriminant score is

δk(x)=μkxσ2−μk22σ2+log⁡πk.\boxed{\delta_k(x)=\frac{\mu_k x}{\sigma^2} -\frac{\mu_k^2}{2\sigma^2}+\log\pi_k.}

log⁡\log is the natural logarithm. Choose the class with the largest δk(x)\delta_k(x). The score is a line in xx: this is where “linear” comes from. The score itself is not a probability.

Slide example: μ1=−1.5\mu_1=-1.5, μ2=1.5\mu_2=1.5, shared σ2=1\sigma^2=1, equal priors 0.50.5. The squared-mean penalty is the same for both classes: μk2/(2σ2)=1.52/[2(1)]=1.125\mu_k^2/(2\sigma^2)=1.5^2/[2(1)]=1.125. To find the boundary, set the two scores equal:

δ1(x)=−1.5x−1.125+log⁡(0.5),δ2(x)=1.5x−1.125+log⁡(0.5).\begin{aligned} \delta_1(x)&=-1.5x-1.125+\log(0.5),\\ \delta_2(x)&=1.5x-1.125+\log(0.5). \end{aligned}

Both constants cancel, leaving −1.5x=1.5x-1.5x=1.5x, so x=0x=0. To the right, class 2’s score is larger.

Equal priors put the boundary halfway between the means

For classes 0 and 1 with μ1>μ0\mu_1>\mu_0, define input boundary γ\gamma:

γ=μ0+μ12+σ2μ1−μ0log⁡ ⁣(π0π1).\boxed{\begin{aligned} \gamma&=\frac{\mu_0+\mu_1}{2}\\ &\quad+\frac{\sigma^2}{\mu_1-\mu_0} \log\!\left(\frac{\pi_0}{\pi_1}\right). \end{aligned}}

Predict 1 when x≥γx\geq\gamma, and 0 otherwise. For equal priors, log⁡(1)=0\log(1)=0, so only the midpoint remains. Increasing class 1’s prior moves the boundary left: it takes less input evidence to choose that class.

Why does the squared input disappear?

Start with the log of the weighted density:

log⁡[πkfk(x)]=log⁡πk−log⁡(σ2π)−(x−μk)22σ2.\begin{aligned} \log[\pi_kf_k(x)]&=\log\pi_k -\log(\sigma\sqrt{2\pi})\\ &\quad-\frac{(x-\mu_k)^2}{2\sigma^2}. \end{aligned}

Expand the square. The pieces −x2/(2σ2)-x^2/(2\sigma^2) and −log⁡(σ2π)-\log(\sigma\sqrt{2\pi}) are identical for every class. Removing them leaves δk(x)\delta_k(x). Shared variance is what makes that cancellation possible.

3. Learn the clouds from data

Usually the centers, spread, and priors are unknown. A hat means estimated from the training data. Let NN count all training observations, KK count classes, and NkN_k count observations whose true label is kk.

Count each class; average within each class

π^k=NkN,μ^k=1Nk∑i:yi=kxi.\widehat\pi_k=\frac{N_k}{N}, \qquad \widehat\mu_k=\frac{1}{N_k}\sum_{i:y_i=k}x_i.

xix_i is observation ii‘s input and yiy_i is its true label. The sum includes only observations in class kk.

Pool the leftover spread

Measure each input from its own class mean, square the differences, then combine them:

σ^2=∑k=1K∑i:yi=k(xi−μ^k)2N−K.\widehat\sigma^2= \frac{\sum_{k=1}^{K}\sum_{i:y_i=k} (x_i-\widehat\mu_k)^2}{N-K}.

The denominator is N−KN-K because we estimated KK separate means. This is the shared pooled variance. If class sample variances sk2s_k^2 are supplied instead:

σ^2=∑k=1K(Nk−1)sk2N−K.\widehat\sigma^2= \frac{\sum_{k=1}^{K}(N_k-1)s_k^2}{N-K}.

Invented training data: class 0 has inputs −2,0-2,0; class 1 has inputs 2,42,4. Thus N=4N=4, K=2K=2, and each Nk=2N_k=2.

  • Priors: use Nk/NN_k/N: both are 2/4=0.52/4=0.5.
  • Centers: use each group’s mean: μ^0=(−2+0)/2=−1\widehat\mu_0=(-2+0)/2=-1 and μ^1=(2+4)/2=3\widehat\mu_1=(2+4)/2=3.
  • Spread: each class’s deviations from its own mean are −1,+1-1,+1. Their squared sum is 1+1+1+1=41+1+1+1=4; hence σ^2=4/(4−2)=2\widehat\sigma^2=4/(4-2)=2.
  • Boundary: equal priors give midpoint γ^=(−1+3)/2=1\widehat\gamma=(-1+3)/2=1.

Several inputs: the same comparison in more directions

Multivariate means several inputs. The input x\mathbf x and class center μk\boldsymbol\mu_k are lists of pp numbers, called vectors. A shared p×pp\times p covariance matrix Σ\Sigma records each input’s variance and which inputs tend to move together.

The clouds become ellipses in two dimensions. LDA still compares prior × density. Its boundaries become straight lines in two dimensions and flat separating surfaces in more dimensions.

For the multivariate Gaussian, write the adjusted squared distance as

uk=x−μk,dk2=ukTΣ−1uk.\mathbf u_k=\mathbf x-\boldsymbol\mu_k, \qquad d_k^2=\mathbf u_k^T\Sigma^{-1}\mathbf u_k.

Then its density is

fk(x)=exp⁡(−dk2/2)(2π)p/2∣Σ∣1/2.f_k(\mathbf x)= \frac{\exp(-d_k^2/2)} {(2\pi)^{p/2}|\Sigma|^{1/2}}.

uk\mathbf u_k is the offset from the class center. TT turns a column into a row; Σ−1\Sigma^{-1} adjusts distance for spread and correlation; ∣Σ∣|\Sigma| is the determinant, which scales the cloud’s volume. Use a nonsingular shared covariance matrix. With p=1p=1, dk2=(x−μk)2/σ2d_k^2=(x-\mu_k)^2/\sigma^2, recovering the one-input formula.

4. Name a mistake before calculating its rate

Classification Errors — original slide 2 of 5
Original slides · Classification ErrorsOpen PDF ↗
Slide 2 of 5

Let positive = class 1, negative = class 0. “Positive” says what the model predicted; “true” or “false” says whether that prediction was correct.

OutcomeActual labelPredicted label
True positive (TP)11
False positive (FP)01
True negative (TN)00
False negative (FN)10

Here TP, FP, TN, and FN stand for counts. With NN evaluated observations:

Error rate=FP+FNN,N=TP+TN+FP+FN.\begin{aligned} \text{Error rate}&=\frac{FP+FN}{N},\\ N&=TP+TN+FP+FN. \end{aligned}

Invented counts: 4 false alarms and 6 missed positives among 100 observations give (4+6)/100=0.10=10%(4+6)/100=0.10=10\% error.

Read the slide's counting notation as on/off switches

An indicator 1{A}\mathbf1\{A\} is 1 when statement AA is true and 0 otherwise. For true label yiy_i and prediction C(xi)C(x_i):

FP=∑i=1N1{C(xi)=1}1{yi=0},FP=\sum_{i=1}^{N} \mathbf1\{C(x_i)=1\}\mathbf1\{y_i=0\}, FN=∑i=1N1{C(xi)=0}1{yi=1}.FN=\sum_{i=1}^{N} \mathbf1\{C(x_i)=0\}\mathbf1\{y_i=1\}.

Multiplying the switches counts a row only when both conditions hold. The slide’s δ(a)\delta(a) is an equality switch: 1 when a=0a=0, otherwise 0. It plays the same counting role here; it is not a Gaussian density or the LDA score δk(x)\delta_k(x).

5. Confusion matrix: always ask “out of which group?”

Confusion Matrix — original slide 3 of 5
Original slides · Confusion MatrixOpen PDF ↗
Slide 3 of 5

A confusion matrix sorts the four counts into a table. The slides put predictions in rows, actual labels in columns. Other tables may swap them: read the labels first.

The supplied Default example evaluates the fitted classifier on its training data and calls default class 1:

PredictionActual 0Actual 1
Predict 0TN = 9644FN = 252
Predict 1FP = 23TP = 81
Actual totals9667333

Use the actual class as the denominator

FPR=FPFP+TN,TNR=TNFP+TN,FNR=FNFN+TP,TPR=TPFN+TP.\begin{aligned} FPR&=\frac{FP}{FP+TN},\\ TNR&=\frac{TN}{FP+TN},\\ FNR&=\frac{FN}{FN+TP},\\ TPR&=\frac{TP}{FN+TP}. \end{aligned}

FPR and TNR divide the actual negatives. FNR and TPR divide the actual positives. Each pair adds to 1:

TNR=1−FPR,TPR=1−FNR.TNR=1-FPR,\qquad TPR=1-FNR.

For the slide’s counts:

  • False positive rate: 23/(23+9644)=23/9667≈0.00238=0.238%23/(23+9644)=23/9667\approx0.00238=0.238\%.
  • False negative rate: 252/(252+81)=252/333≈0.7568=75.68%252/(252+81)=252/333\approx0.7568=75.68\%.
  • True positive rate: 81/(81+252)=81/333≈0.2432=24.32%81/(81+252)=81/333\approx0.2432=24.32\%.
  • Overall training error: (23+252)/10000=0.0275=2.75%(23+252)/10000=0.0275=2.75\%.

The small overall training error hides a large miss rate for actual defaults. Most observations are class 0. Even the null classifier, which always predicts 0, makes only 333/10000=3.33%333/10000=3.33\% errors on these observations, while missing every default. New-data performance requires a separate test set.

FPR is not “out of everything predicted positive.” Its denominator is everything actually negative. Say that group aloud before dividing.

6. Gaussian errors are areas across the boundary

Errors in LDA — original slide 3 of 4
Original slides · Errors in LDAOpen PDF ↗
Slide 3 of 4

Shade the wrong side of each class’s curve

Suppose we predict 1 for x≥γx\geq\gamma and 0 for x<γx<\gamma. Each class density has total area 1:

FPR=P(X≥γ∣Y=0)=∫γ∞f0(x) dx,\begin{aligned} FPR&=P(X\geq\gamma\mid Y=0)\\ &=\int_\gamma^\infty f_0(x)\,dx, \end{aligned} FNR=P(X<γ∣Y=1)=∫−∞γf1(x) dx.\begin{aligned} FNR&=P(X<\gamma\mid Y=1)\\ &=\int_{-\infty}^\gamma f_1(x)\,dx. \end{aligned}

The integral sign means “add up the area.” The first expression shades class 0’s right tail; the second shades class 1’s left tail.

Standardize: how many standard deviations away?

For a normal class with mean μ\mu and standard deviation σ\sigma:

z=γ−μσ.z=\frac{\gamma-\mu}{\sigma}.

Let Φ(z)\Phi(z) be the area to the left of zz under a standard normal curve, whose mean is 0 and standard deviation is 1. With class means μ0,μ1\mu_0,\mu_1 and shared σ\sigma:

FPR=1−Φ ⁣(γ−μ0σ),FPR=1-\Phi\!\left(\frac{\gamma-\mu_0}{\sigma}\right), FNR=Φ ⁣(γ−μ1σ).FNR=\Phi\!\left(\frac{\gamma-\mu_1}{\sigma}\right).

Then TPR=1−FNRTPR=1-FNR.

Invented one-class calculation: if μ0=−2\mu_0=-2, σ=1\sigma=1, and γ=0\gamma=0, the boundary is z=[0−(−2)]/1=2z=[0-(-2)]/1=2 standard deviations above the center. Its right-tail error is 1−Φ(2)≈0.022751-\Phi(2)\approx0.02275.

Whole-population errors need the priors too

Conditional rates answer “among this actual class.” To find a fraction of everyone, multiply by that class’s prior:

Error=π0FPR+π1FNR.\boxed{\text{Error}=\pi_0FPR+\pi_1FNR.}

For NN observations drawn from that population, expected counts are

E[FP]=Nπ0FPR,E[FN]=Nπ1FNR.\begin{aligned} E[FP]&=N\pi_0FPR,\\ E[FN]&=N\pi_1FNR. \end{aligned}

EE means the long-run average over repeated samples. Invented example: N=1000N=1000, π0=0.9\pi_0=0.9, π1=0.1\pi_1=0.1, FPR=0.02FPR=0.02, and FNR=0.20FNR=0.20. Expected FP is 1000(0.9)(0.02)=181000(0.9)(0.02)=18; expected FN is 1000(0.1)(0.20)=201000(0.1)(0.20)=20. Total error is (18+20)/1000=0.038=3.8%(18+20)/1000=0.038=3.8\%.

Adding FPR+FNR=0.22FPR+FNR=0.22 would mix rates with different denominators. Weighting them gives the fraction of all observations that are wrong.

7. Move the threshold; trade false alarms for misses

Receiver Operating Characteristics — original slide 2 of 5
Original slides · Receiver Operating CharacteristicsOpen PDF ↗
Slide 2 of 5

Probability threshold and input boundary are different numbers

Let p1(x)=P(Y=1∣X=x)p_1(x)=P(Y=1\mid X=x) be the posterior for class 1. The probability threshold τ\tau says how sure we must be before predicting 1:

Cτ(x)={1,p1(x)≥τ,0,p1(x)<τ.C_\tau(x)= \begin{cases} 1,&p_1(x)\geq\tau,\\ 0,&p_1(x)<\tau. \end{cases}

Equal mistake costs give the usual τ=0.5\tau=0.5. A lower τ\tau predicts 1 more often: it catches more actual positives (TPR rises, FNR falls) while also flagging more actual negatives (FPR rises). Raising τ\tau reverses that tradeoff. On finite data, rates can stay unchanged between score values.

For the one-input LDA model with μ1>μ0\mu_1>\mu_0, the corresponding input boundary is

γτ=μ0+μ12+σ2μ1−μ0[log⁡π0π1+log⁡τ1−τ].\begin{aligned} \gamma_\tau&=\frac{\mu_0+\mu_1}{2}\\ &\quad+\frac{\sigma^2}{\mu_1-\mu_0} \left[\log\frac{\pi_0}{\pi_1} +\log\frac{\tau}{1-\tau}\right]. \end{aligned}

This formula uses 0<τ<10<\tau<1. τ\tau is a probability; γτ\gamma_\tau is measured in the input’s units. If missing a positive costs more, choose a lower probability threshold to put more emphasis on catching positives.

ROC: show every threshold on one graph

The receiver operating characteristic (ROC) curve plots FPR horizontally and TPR vertically as the threshold changes. Every point is a different tradeoff for the same scoring model.

  • Near (0,0)(0,0): predict almost nobody positive.
  • Near (1,1)(1,1): predict almost everybody positive.
  • Toward (0,1)(0,1): catch positives with few false alarms.

AUC means the area under that ROC curve. Higher AUC summarizes better separation across thresholds; it does not choose the operating threshold or the preferred balance of mistakes. A diagonal curve has AUC 0.50.5; perfect separation has AUC 11.

Try the boundary on the actual practice distributions

Use the Q3 and Q7 presets below. Move the boundary right and watch both TPR and FPR fall. Change a prior and notice why the overall error uses a weighted sum even though the conditional curves still each have area 1.

Move the boundary to see which class areas become false alarms and misses.

8. Shared practice Q3: two Gaussians centered at −3 and +3

View the original practice sheet (includes solutions)
Module 5 and 6 Practice Problems - Solutions — original page 2 of 6
Original practice sheet · Module 5 and 6 Practice Problems - SolutionsOpen PDF ↗
Page 2 of 6

Given: labels y∈{−1,+1}y\in\{-1,+1\}, both priors 0.50.5, and

X∣Y=+1∼N(3,1),X∣Y=−1∼N(−3,1).\begin{aligned} X\mid Y=+1&\sim\mathcal N(3,1),\\ X\mid Y=-1&\sim\mathcal N(-3,1). \end{aligned}

The shared variance is 1, so the standard deviation is 1=1\sqrt1=1. Rules: Bayes and joint densities, LDA boundary, and Gaussian tail errors.

1. Joint density = class density × class prior

Write g(x,y)g(x,y) for the joint density in continuous input xx and discrete label yy. The rule is g(x,y)=fy(x)P(Y=y)g(x,y)=f_y(x)P(Y=y).

Using means 3y3y, variance 1, and prior 1/21/2:

g(x,y)=122πexp⁡ ⁣[−(x−3y)22].\boxed{g(x,y)=\frac{1}{2\sqrt{2\pi}} \exp\!\left[-\frac{(x-3y)^2}{2}\right].}

For y=+1y=+1, the squared term is (x−3)2(x-3)^2; for y=−1y=-1, it is (x+3)2(x+3)^2. Each joint curve has area 1/21/2, because each label occurs half the time. Their two areas add to 1.

2. Draw equal-width curves; split at the midpoint

The conditional densities f−1(x)f_{-1}(x) and f+1(x)f_{+1}(x) have centers −3,+3-3,+3 and each has area 1. Equal priors and equal variance give boundary

γ=−3+32=0.\gamma=\frac{-3+3}{2}=0. C(x)={−1,x<0,+1,x≥0.C(x)=\begin{cases} -1,&x<0,\\ +1,&x\geq0. \end{cases}

At x=0x=0 the two posteriors tie, so either label is valid. A single point has zero probability here. The widget’s Q3 preset draws both curves and the boundary.

3. Find the negative class’s right-tail area

Standardize using boundary 00, negative-class mean −3-3, and standard deviation 11:

z=0−(−3)1=3.z=\frac{0-(-3)}{1}=3.

The 99.7% empirical rule puts approximately 0.997 of a normal curve within three standard deviations. The remaining mass splits equally between the two tails:

P(X≥0∣Y=−1)≈1−0.9972=0.0015.\begin{aligned} P(X\geq0\mid Y=-1) &\approx\frac{1-0.997}{2}\\ &=\boxed{0.0015}. \end{aligned}

This is the practice approximation: 0.15% of actual negatives cross the boundary. An exact normal calculation gives 1−Φ(3)≈0.0013501-\Phi(3)\approx0.001350, or 0.135%0.135\%. The difference is the empirical rule’s rounding.

The answer is a conditional tail area. Multiplying by the negative prior 0.50.5 would instead give the fraction of the entire population that is a false positive.

9. Shared practice Q4: spam is the positive class

Given: a spam detector. Define Y=1Y=1 as actually spam and C(x)=1C(x)=1 as marked spam. Rule: confusion matrix rates.

RatePlain-English questionFormula
FPROf actual nonspam emails, what fraction got marked spam?FP/(FP+TN)FP/(FP+TN)
FNROf actual spam emails, what fraction slipped through as nonspam?FN/(FN+TP)FN/(FN+TP)
TPROf actual spam emails, what fraction got caught?TP/(TP+FN)TP/(TP+FN)

Memory aid: “false” means wrong; “positive” means the predicted spam label. FPR is a false alarm among legitimate emails. FNR is a miss among spam emails. TPR and FNR divide the same actual-spam group, so TPR=1−FNRTPR=1-FNR.

10. Shared practice Q7: decode a noisy 0 or 1

View Q7 on the original practice sheet (includes solutions)
Module 5 and 6 Practice Problems - Solutions — original page 5 of 6
Original practice sheet · Module 5 and 6 Practice Problems - SolutionsOpen PDF ↗
Page 5 of 6

Given: the transmitted bit is Y∈{0,1}Y\in\{0,1\}, each bit occurs half the time, and the received input is

X=2Y+ε,ε∼N(−1,14).X=2Y+\varepsilon, \qquad\varepsilon\sim\mathcal N(-1,\tfrac14).

Treat the channel noise as having this same distribution for either transmitted bit. Its mean is −1-1 and its variance is 1/41/4, so its standard deviation is 1/4=1/2\sqrt{1/4}=1/2.

Rules: shifted Gaussian inputs, LDA boundary, Gaussian tails, and weighted error.

1. Substitute each possible bit

Adding a constant moves a distribution’s mean without changing its variance.

  • If Y=0Y=0, then X=0+εX=0+\varepsilon: mean 2(0)−1=−12(0)-1=-1, variance 1/41/4.
  • If Y=1Y=1, then X=2+εX=2+\varepsilon: mean 2(1)−1=12(1)-1=1, variance 1/41/4.

Thus

X∣Y=0∼N(−1,14),X∣Y=1∼N(1,14).\begin{aligned} X\mid Y=0&\sim\mathcal N(-1,\tfrac14),\\ X\mid Y=1&\sim\mathcal N(1,\tfrac14). \end{aligned}

The supplied 50/50 transmission frequencies give both priors:

π0=12,π1=12.\boxed{\pi_0=\tfrac12,\qquad\pi_1=\tfrac12.}

For k∈{0,1}k\in\{0,1\}, the mean is μk=2k−1\mu_k=2k-1. Substitute this mean and σ2=1/4\sigma^2=1/4 into the normal density. The front factor becomes 1/[(1/2)2π]=2/π1/[(1/2)\sqrt{2\pi}]=\sqrt{2/\pi}; the exponent’s multiplier becomes 1/[2(1/4)]=21/[2(1/4)]=2. Thus

fk(x)=2πexp⁡[−2(x+1−2k)2].f_k(x)=\sqrt{\frac{2}{\pi}} \exp[-2(x+1-2k)^2].

In particular,

f0(x)=2πe−2(x+1)2,f1(x)=2πe−2(x−1)2.\begin{aligned} f_0(x)&=\sqrt{\frac2\pi}e^{-2(x+1)^2},\\ f_1(x)&=\sqrt{\frac2\pi}e^{-2(x-1)^2}. \end{aligned}

These are densities; their areas, rather than individual heights, give probabilities.

2. Use the midpoint because priors and variances match

The LDA rule chooses the larger πkfk(x)\pi_kf_k(x). With equal priors 1/21/2, equal variance 1/41/4, and means −1,+1-1,+1, the boundary is

γ=−1+12=0.\gamma=\frac{-1+1}{2}=0. C(x)={0,x<0,1,x≥0.\boxed{C(x)=\begin{cases} 0,&x<0,\\ 1,&x\geq0. \end{cases}}

3. Compute FPR, then use symmetry for TPR

FPR is among actual zeros. The mean is −1-1, standard deviation 1/21/2, and boundary 00:

z0=0−(−1)1/2=2.z_0=\frac{0-(-1)}{1/2}=2.

Using the practice approximation that 95.4% lies within two standard deviations, the right tail is

FPR≈1−0.9542=0.023.FPR\approx\frac{1-0.954}{2} =\boxed{0.023}.

FNR is among actual ones. This class has mean 11, standard deviation 1/21/2, and boundary 00:

z1=0−11/2=−2.z_1=\frac{0-1}{1/2}=-2.

The equal-width mirrored curve has left-tail mass FNR≈0.023FNR\approx0.023. Therefore

TPR=1−FNR≈1−0.023=0.977.TPR=1-FNR\approx1-0.023 =\boxed{0.977}.

So approximately 2.3% of actual zeros trigger a false 1, while 97.7% of actual ones are correctly received as 1. Exact normal values are FPR=FNR≈0.022750FPR=FNR\approx0.022750 and TPR≈0.977250TPR\approx0.977250.

4. Weight the two kinds of error by how often each bit occurs

Use the total-error rule, the supplied priors π0=π1=0.5\pi_0=\pi_1=0.5, and calculated rates FPR≈FNR≈0.023FPR\approx FNR\approx0.023:

Error=π0FPR+π1FNR≈0.5(0.023)+0.5(0.023)=0.023=2.3%.\begin{aligned} \text{Error}&=\pi_0FPR+\pi_1FNR\\ &\approx0.5(0.023)+0.5(0.023)\\ &=\boxed{0.023=2.3\%}. \end{aligned}

Invented batch-size illustration: for 1000 transmitted bits, expect 500 actual zeros and 500 actual ones. Expected false positives are 500(0.023)=11.5500(0.023)=11.5 and expected false negatives are also 11.5. Thus approximately 23 of the 1000 bits are wrong. Expected counts can be fractional; any one real batch has whole-number counts.

The exact Gaussian total error is about 0.0227500.022750. The practice’s 0.0230.023 uses its two-standard-deviation approximation consistently.

11. Pick the calculation that matches the question

Asked for…First move
Class probability after observing xxPrior × density, then normalize across classes.
Predicted labelCompare πkfk(x)\pi_kf_k(x) or LDA scores δk(x)\delta_k(x).
One-input boundarySet the two scores equal; equal priors give a midpoint.
False positive or negative ratePick the actual class, then shade its wrong-side area.
Overall errorWeight each conditional error rate by its class prior.
A different error tradeoffMove the probability threshold and read the ROC point.

The shared sheet’s Q1, Q2, Q5, and Q6 are in Module 5. Reuse the Module 6 formula sheet when the numbers change.

Module 6 formulas

Open the formula sheet →