🤖 AI Math Unit 1 — Vectors & Geometric EmbeddingsApplied STEM · Vector spaces & column vectors · L1 (Manhattan) and L2 (Euclidean) norms · Dot products & vector projections · Cosine similarity in NLP & vector search · Word and token embeddings (Word2Vec / Transformer)
In Artificial Intelligence and Natural Language Processing, text, images, and audio are mapped to high-dimensional numerical vectors called embeddings. We explore vector geometry, norms, and distance metrics used in modern vector databases.In Artificial Intelligence and Natural Language Processing, text, images, and audio are mapped to high-dimensional numerical المتجهات called embeddings. We explore المتجه الهندسة, norms, and distance metrics used in modern المتجه databases.
📊 Math for AI & Data Science — Exam Blueprint & Domain Weighting
Vectors & Embeddings
~25%MATHAI
Matrices & Neural Layers
~25%MATHAI
Gradient Descent & Loss
~25%MATHAI
Probability, Bayes & PCA
~25%MATHAI
Official curriculum weighting and examination domain distribution for Math for AI & Data Science.
For a vector x=[x1,x2,…,xn]T∈Rn: 1. Euclidean (L2) Norm:∥x∥2=∑i=1nxi2=xTx. Measures straight-line geometric distance. 2. Manhattan (L1) Norm:∥x∥1=∑i=1n∣xi∣. Used in Lasso regularization (L1 sparsity). 3. Max (L∞) Norm:∥x∥∞=maxi∣xi∣. Used in adversarial robustness attacks (FGSM).
For a المتجه x=[x1,x2,…,xn]T∈Rn: 1. Euclidean (L2) Norm:∥x∥2=∑i=1nxi2=xTx. Measures straight-line geometric distance. 2. Manhattan (L1) Norm:∥x∥1=∑i=1n∣xi∣. Used in Lasso regularization (L1 sparsity). 3. Max (L∞) Norm:∥x∥∞=maxi∣xi∣. Used in adversarial robustness attacks (FGSM).
Linear Structure, Inner Products & Geometric Transformations: In Rn, the dot product u⋅v=∥u∥∥v∥cosθ=∑i=1nuivi encodes orthogonality (u⊥v⟺u⋅v=0) and orthogonal projection projvu=∥v∥2u⋅vv. For a matrix transformation A∈Rn×n, ∣det(A)∣ measures the local volume scaling factor, and A is invertible if and only if det(A)=0 (equivalently, all eigenvalues λi=0).
الفضاءات المتجهية والتحويلات الخطية: يقيس الضرب القياسي u⋅v الزاوية والتعامد بين المتجهات، بينما يقيس محدد المصفوفة ∣det(A)∣ معامل تغير المساحة أو الحجم.
Coordinate grid showing geometric action of a linear transformation mapping △ABC to its image △A'B'C'.تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس المتجهات والمسافات المعيارية والتمثيل الشعاعي (Embeddings).
⊙ Explorer · Embedding Space: Cosine Similarity cosθ & L1 vs. L2 Norm Balls⊙ مستكشف تفاعلي · فضاء التضمينات: تشابه جيب التمام cos θ وكرات معيار L₁ و L₂
interactive
Live numerical table for Embedding Space: Cosine Similarity cosθ & L1 vs. L2 Norm Ballsجدول القيم العددية لـ ⊙ مستكشف تفاعلي · فضاء التضمينات: تشابه جيب التمام cos θ وكرات معيار L₁ و L₂
Parameter / Metricالمتغير / المعيار
Valueالقيمة
Drag to rotate, scroll to zoom · loads a small 3D library on first use
Compare two embedding vectors u and v on the unit L2 circle (indigo) and unit L1 diamond (dashed gray), tracking their dot-product cosine similarity cos(θu−θv).قارن بين متجهي التضمين u و v على دائرة معيار L₂ ومعين معيار L₁ مع حساب تشابه جيب التمام cos(θ_u − θ_v).
Vectors, Norms & High-Dimensional Embeddings — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Vectors, Norms & High-Dimensional Embeddings.رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس المتجهات والمسافات المعيارية والتمثيل الشعاعي (Embeddings).
◆ Why It Works — First-Principles Derivation (Vectors, Norms & High-Dimensional Embeddings)◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (المتجهات والمسافات المعيارية والتمثيل الشعاعي (Embeddings))
Why Orthogonal Projection & Eigenvalue Characteristic Equations Work: Decompose u=cv+w where w⊥v. Taking the dot product with v uses w⋅v=0 to isolate c:
u⋅v=c(v⋅v)+0⟹c=∥v∥2u⋅v
For eigenvalues, Av=λv with v=0 is equivalent to (A−λI)v=0. A homogeneous linear system has a non-trivial nullspace vector v=0 if and only if the matrix A−λI is singular, yielding the characteristic polynomial det(A−λI)=0.
برهان صيغة المسقط العمودي والمعادلة المميزة للقيم الذاتية: من شرط التعامد (u−cv)⋅v=0 ينتج c=∥v∥2u⋅v. وشرط وجود متجه ذاتي غير صفري (A−λI)v=0 يكافئ انعدام المحدد det(A−λI)=0.
Worked Example 1.A — Cosine Similarity Between Word Embeddingsمثال محلول 1.A — Cosine Similarity Between Word Embeddings
In an NLP embedding model, the word vectors for 'king' and 'queen' in a 3-dimensional subspace are u=[0.8,0.6,0.0]T and v=[0.6,0.8,0.0]T. An unrelated word 'apple' has vector w=[0.0,0.1,0.99]T. Calculate the cosine similarity between 'king' and 'queen', and between 'king' and 'apple'.
Solution: 1. Norm of u: ∥u∥=0.82+0.62+02=0.64+0.36=1.0. 2. Norm of v: ∥v∥=0.62+0.82+02=1.0. 3. Dot product: u⋅v=(0.8)(0.6)+(0.6)(0.8)+(0)(0)=0.48+0.48=0.96. Cosine similarity: cosθuv=(1.0)(1.0)0.96=0.96 (very high semantic similarity!).
4. Now check 'king' and 'apple': u⋅w=(0.8)(0)+(0.6)(0.1)+(0)(0.99)=0.06. Norm ∥w∥=02+0.01+0.9801=0.9901≈0.995. Cosine similarity: cosθuw=(1.0)(0.995)0.06≈0.0603 (near orthogonal, no semantic relation). Answer:cosθuv=0.96; cosθuw≈0.060.
In an NLP embedding model, the word المتجهات for 'king' and 'queen' in a 3-dimensional subspace are u=[0.8,0.6,0.0]T and v=[0.6,0.8,0.0]T. An unrelated word 'apple' has المتجه w=[0.0,0.1,0.99]T. احسب cosine similarity between 'king' and 'queen', and between 'king' and 'apple'.
Solution: 1. Norm of u: ∥u∥=0.82+0.62+02=0.64+0.36=1.0. 2. Norm of v: ∥v∥=0.62+0.82+02=1.0. 3. Dot product: u⋅v=(0.8)(0.6)+(0.6)(0.8)+(0)(0)=0.48+0.48=0.96. Cosine similarity: cosθuv=(1.0)(1.0)0.96=0.96 (very high semantic similarity!).
4. Now check 'king' and 'apple': u⋅w=(0.8)(0)+(0.6)(0.1)+(0)(0.99)=0.06. Norm ∥w∥=02+0.01+0.9801=0.9901≈0.995. Cosine similarity: cosθuw=(1.0)(0.995)0.06≈0.0603 (near orthogonal, no semantic relation). Answer:cosθuv=0.96; cosθuw≈0.060.
Worked Example B — Vectors, Norms & High-Dimensional Embeddings (Easy Application)مثال محلول B — المتجهات والمسافات المعيارية والتمثيل الشعاعي (Embeddings) (تطبيق Easy)
Problem (Easy): Consider a simple logistic regression model where the decision boundary is defined by the equation 3x+4y−12=0. This equation represents a linear boundary in a 2D feature space. What is the y-intercept of this decision boundary?
Step-by-Step Solution: The equation of the decision boundary is given by 3x+4y−12=0. To find the y-intercept, we set x=0 and solve for y. \nSubstituting x=0 into the equation: \n3(0)+4y−12=04y−12=04y=12y=412y=3
Therefore, the y-intercept of the decision boundary is 3.
مسألة (Easy): Consider a simple logistic regression model where the decision boundary is defined by the equation 3x+4y−12=0. This equation represents a linear boundary in a 2D feature space. What is the y-intercept of this decision boundary?
الحل خطوة بخطوة: The equation of the decision boundary is given by 3x+4y−12=0. To find the y-intercept, we set x=0 and solve for y. \nSubstituting x=0 into the equation: \n3(0)+4y−12=04y−12=04y=12y=412y=3
Therefore, the y-intercept of the decision boundary is 3.
Worked Example C — Vectors, Norms & High-Dimensional Embeddings (Medium Application)مثال محلول C — المتجهات والمسافات المعيارية والتمثيل الشعاعي (Embeddings) (تطبيق Medium)
Problem (Medium): A linear transformation is defined by the matrix M=(2314). If an input vector is v=(x1), and the output vector after the transformation is w=(57), what is the value of x?
Step-by-Step Solution: The linear transformation is given by w=Mv. Substituting the given matrices and vectors, we have:
(37)=(2314)(x1)
Performing the matrix multiplication on the right side gives:
(37)=(2x+1(1)3x+4(1))=(2x+13x+4)
Equating the corresponding components of the vectors, we get two equations:
1. 3=2x+1
2. 7=3x+4
Solving the first equation for x:
3−1=2x2=2xx=22x=1
Solving the second equation for x:
7−4=3x3=3xx=33x=1
Both equations yield x=1. Therefore, the value of x is 1.
مسألة (Medium): A linear transformation is defined by the matrix M=(2314). If an input vector is v=(x1), and the output vector after the transformation is w=(57), what is the value of x?
الحل خطوة بخطوة: The linear transformation is given by w=Mv. Substituting the given matrices and vectors, we have:
(37)=(2314)(x1)
Performing the matrix multiplication on the right side gives:
(37)=(2x+1(1)3x+4(1))=(2x+13x+4)
Equating the corresponding components of the vectors, we get two equations:
1. 3=2x+1
2. 7=3x+4
Solving the first equation for x:
3−1=2x2=2xx=22x=1
Solving the second equation for x:
7−4=3x3=3xx=33x=1
Both equations yield x=1. Therefore, the value of x is 1.
Worked Example D — Vectors, Norms & High-Dimensional Embeddings (Hard Application)مثال محلول D — المتجهات والمسافات المعيارية والتمثيل الشعاعي (Embeddings) (تطبيق Hard)
Problem (Hard): Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
Step-by-Step Solution: To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
مسألة (Hard): Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
الحل خطوة بخطوة: To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
1. Non-Commutativity of Matrix Multiplication & Cross Products: On Mathematics for Artificial Intelligence & Machine Learning, assuming AB=BA (so expanding (A+B)2 as A2+2AB+B2 instead of A2+AB+BA+B2) or forgetting u×v=−(v×u) invalidates matrix proofs.
2. Using Position Vectors Instead of Direction Vectors for Angles: To find the angle at vertex B of triangle ABC, you must use tail-to-tail vectors BA and BC, never AB⋅BC (which finds the exterior supplementary angle 180∘−B).
1. عدم إبدالية ضرب المصفوفات: حاصل الضرب AB لا يساوي BA عموماً، وعند حساب الزاوية عند الرأس B يجب استخدام المتجهين المنطلقين من B وهما BA و BC.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Vectors, Norms & High-Dimensional Embeddings)تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (المتجهات والمسافات المعيارية والتمثيل الشعاعي (Embeddings))
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Computing angle at B using AB⋅BCالخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Vectors are head-to-tail instead of tail-to-tail, giving 180∘−θ.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Reverse AB so both emanate from B: use BA⋅BC.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Using the same parameter t for two intersecting 3D lines r1(t)=r2(t)الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Tests for a simultaneous collision at time t rather than geometric intersection of paths.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Assign distinct parameters λ and μ to the two lines before equating components.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Assuming (AB)−1=A−1B−1الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Multiplying (AB)(A−1B−1) does not cancel inner factors when AB=BA.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Use the shoe-sock reversal law: (AB)−1=B−1A−1.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Fast Matrix & Vector Verification (Mathematics for Artificial Intelligence & Machine Learning): Check every 2×2 or 3×3 eigenvalue computation using the trace and determinant invariants: ∑λi=tr(A) (sum of diagonal entries) and ∏λi=det(A).
فحص سريع للقيم الذاتية: تحقق دائماً من أن مجموع القيم الذاتية يساوي أثر المصفوفة tr(A) وحاصل ضربها يساوي المحدد det(A).
[Practice 1 · Easy] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?[تدريب 1 · Easy] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
💡 Hint 1 of 3
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
💡 Hint 2 of 3
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
💡 Hint 3 of 3
Therefore, the resulting vector is [510].
Therefore, the resulting vector is [510].
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
[Practice 2 · Medium] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?[تدريب 2 · Medium] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
💡 Hint 1 of 3
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
💡 Hint 2 of 3
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
💡 Hint 3 of 3
Therefore, the resulting vector is [510].
Therefore, the resulting vector is [510].
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
[Practice 3 · Hard] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?[تدريب 3 · Hard] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
💡 Hint 1 of 3
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
💡 Hint 2 of 3
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
💡 Hint 3 of 3
Therefore, the resulting vector is [510].
Therefore, the resulting vector is [510].
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
[Practice 4 · Easy] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?[تدريب 4 · Easy] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
💡 Hint 1 of 3
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
💡 Hint 2 of 3
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
💡 Hint 3 of 3
Therefore, the resulting vector is [510].
Therefore, the resulting vector is [510].
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
[Practice 5 · Medium] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?[تدريب 5 · Medium] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
💡 Hint 1 of 3
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
💡 Hint 2 of 3
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
💡 Hint 3 of 3
Therefore, the resulting vector is [510].
Therefore, the resulting vector is [510].
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
Matrices, Linear Layers & Activation Functionsالمصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط
🤖 AI Math Unit 2 — Neural Matrix OperationsApplied STEM · Matrix multiplication as linear transformation · Dense layer forward pass y = Wx + b · Dimensions, shapes & batching · Non-linear activations: ReLU, Sigmoid, Softmax · Universal approximation theorem intuition
Deep neural networks are sequences of matrix multiplications alternated with non-linear activation functions. Here we formulate the algebraic forward pass of dense feedforward neural layers.Deep neural networks are المتتاليات of المصفوفة multiplications alternated with non-linear activation الدوال. Here we formulate the algebraic forward pass of dense feedforward neural layers.
A fully connected (dense) neural network layer with nin inputs and nout neurons computes an affine linear transformation followed by an element-wise activation σ: z=Wx+b,a=σ(z) where W∈Rnout×nin is the weight matrix, x∈Rnin is the input vector, b∈Rnout is the bias vector, and a∈Rnout is the layer activation vector.
A fully connected (dense) neural network layer with nin inputs and nout neurons computes an affine linear transformation followed by an element-wise activation σ: z=Wx+b,a=σ(z) where W∈Rnout×nin is the weight المصفوفة, x∈Rnin is the input المتجه, b∈Rnout is the bias المتجه, and a∈Rnout is the layer activation المتجه.
● Deep Conceptual Intuition — Matrices, Linear Layers & Activation Functions● الفهم المفاهيمي العميق — المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط
Linear Structure, Inner Products & Geometric Transformations: In Rn, the dot product u⋅v=∥u∥∥v∥cosθ=∑i=1nuivi encodes orthogonality (u⊥v⟺u⋅v=0) and orthogonal projection projvu=∥v∥2u⋅vv. For a matrix transformation A∈Rn×n, ∣det(A)∣ measures the local volume scaling factor, and A is invertible if and only if det(A)=0 (equivalently, all eigenvalues λi=0).
الفضاءات المتجهية والتحويلات الخطية: يقيس الضرب القياسي u⋅v الزاوية والتعامد بين المتجهات، بينما يقيس محدد المصفوفة ∣det(A)∣ معامل تغير المساحة أو الحجم.
Coordinate grid showing geometric action of a linear transformation mapping △ABC to its image △A'B'C'.تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط.
Active Linear RegimeActive Linear Regime2 Active Hinges
See how a hidden layer combining piecewise-linear ReLU activations max(0,wi⋅x+bi) creates hinged bends capable of approximating nonlinear functions.شاهد كيف تشكل وحدات تفعيل ReLU المتعددة انكسارات خطية قادرة على تقريب الدوال غير الخطية.
Matrices, Linear Layers & Activation Functions — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Matrices, Linear Layers & Activation Functions.رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط.
ReLUReLU (المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط)
ReLU(z)=max(0,z)ReLU(z)=max(0,z)
SigmoidSigmoid (المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط)
σ(z)=1+e−z1∈(0,1)σ(z)=1+e−z1∈(0,1)
SoftmaxSoftmax (المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط)
◆ Why It Works — First-Principles Derivation (Matrices, Linear Layers & Activation Functions)◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط)
Why Orthogonal Projection & Eigenvalue Characteristic Equations Work: Decompose u=cv+w where w⊥v. Taking the dot product with v uses w⋅v=0 to isolate c:
u⋅v=c(v⋅v)+0⟹c=∥v∥2u⋅v
For eigenvalues, Av=λv with v=0 is equivalent to (A−λI)v=0. A homogeneous linear system has a non-trivial nullspace vector v=0 if and only if the matrix A−λI is singular, yielding the characteristic polynomial det(A−λI)=0.
برهان صيغة المسقط العمودي والمعادلة المميزة للقيم الذاتية: من شرط التعامد (u−cv)⋅v=0 ينتج c=∥v∥2u⋅v. وشرط وجود متجه ذاتي غير صفري (A−λI)v=0 يكافئ انعدام المحدد det(A−λI)=0.
Worked Example 2.A — Manual Feedforward Neural Layerمثال محلول 2.A — Manual Feedforward Neural Layer
A neural network layer has 2 inputs and 3 neurons with weights and biases: W=20.5−1−131,b=1−20.5 For the input x=(32), compute the pre-activation z and the activated output a using the ReLU function.
A neural network layer has 2 inputs and 3 neurons with weights and biases: W=20.5−1−131,b=1−20.5 For the input x=(32), compute the pre-activation z and the activated output a using the ReLU الدالة.
Worked Example B — Matrices, Linear Layers & Activation Functions (Medium Application)مثال محلول B — المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط (تطبيق Medium)
Problem (Medium): In a multiple linear regression model, the Sum of Squared Errors is SSE=100 and the Total Sum of Squares is SST=500. What is the coefficient of determination R2?
Step-by-Step Solution: The coefficient of determination measures the proportion of variance explained: R2=1−SSTSSE=1−500100=1−0.20=0.80.
مسألة (Medium): In a multiple linear regression model, the Sum of Squared Errors is SSE=100 and the Total Sum of Squares is SST=500. What is the coefficient of determination R2?
الحل خطوة بخطوة: The coefficient of determination measures the proportion of variance explained: R2=1−SSTSSE=1−500100=1−0.20=0.80.
Worked Example C — Matrices, Linear Layers & Activation Functions (Hard Application)مثال محلول C — المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط (تطبيق Hard)
Problem (Hard): A centered feature matrix X has shape N×38. What is the size and symmetry property of the sample covariance matrix Σ=N−11XTX?
Step-by-Step Solution: Since X has 38 columns, XT is 38×N and XTX is 38×38. Furthermore, (XTX)T=XT(XT)T=XTX, proving it is always symmetric.
مسألة (Hard): A centered feature matrix X has shape N×38. What is the size and symmetry property of the sample covariance matrix Σ=N−11XTX?
الحل خطوة بخطوة: Since X has 38 columns, XT is 38×N and XTX is 38×38. Furthermore, (XTX)T=XT(XT)T=XTX, proving it is always symmetric.
Worked Example D — Matrices, Linear Layers & Activation Functions (Easy Application)مثال محلول D — المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط (تطبيق Easy)
Problem (Easy): Consider a linear layer with a weight matrix W and an input vector x. If W=(1324) and x=(56), compute the output vector y=Wx.
Step-by-Step Solution: The output vector y is computed by multiplying the weight matrix W by the input vector x. This is a standard matrix-vector multiplication. \\ \\ y=Wx=(1324)(56)\\\ \\ To compute the first element of y, we take the dot product of the first row of W with x: (1)(5)+(2)(6)=5+12=17.\\ \\ To compute the second element of y, we take the dot product of the second row of W with x: (3)(5)+(4)(6)=15+24=39.\\ \\ Therefore, the output vector is y=(1739).
مسألة (Easy): Consider a linear layer with a weight matrix W and an input vector x. If W=(1324) and x=(56), compute the output vector y=Wx.
الحل خطوة بخطوة: The output vector y is computed by multiplying the weight matrix W by the input vector x. This is a standard matrix-vector multiplication. \\ \\ y=Wx=(1324)(56)\\\ \\ To compute the first element of y, we take the dot product of the first row of W with x: (1)(5)+(2)(6)=5+12=17.\\ \\ To compute the second element of y, we take the dot product of the second row of W with x: (3)(5)+(4)(6)=15+24=39.\\ \\ Therefore, the output vector is y=(1739).
⚠️ Common Exam Traps — Matrices, Linear Layers & Activation Functions⚠️ أخطاء شائعة في الاختبار — المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط
1. Non-Commutativity of Matrix Multiplication & Cross Products: On Mathematics for Artificial Intelligence & Machine Learning, assuming AB=BA (so expanding (A+B)2 as A2+2AB+B2 instead of A2+AB+BA+B2) or forgetting u×v=−(v×u) invalidates matrix proofs.
2. Using Position Vectors Instead of Direction Vectors for Angles: To find the angle at vertex B of triangle ABC, you must use tail-to-tail vectors BA and BC, never AB⋅BC (which finds the exterior supplementary angle 180∘−B).
1. عدم إبدالية ضرب المصفوفات: حاصل الضرب AB لا يساوي BA عموماً، وعند حساب الزاوية عند الرأس B يجب استخدام المتجهين المنطلقين من B وهما BA و BC.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Matrices, Linear Layers & Activation Functions)تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط)
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Computing angle at B using AB⋅BCالخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Vectors are head-to-tail instead of tail-to-tail, giving 180∘−θ.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Reverse AB so both emanate from B: use BA⋅BC.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Using the same parameter t for two intersecting 3D lines r1(t)=r2(t)الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Tests for a simultaneous collision at time t rather than geometric intersection of paths.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Assign distinct parameters λ and μ to the two lines before equating components.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Assuming (AB)−1=A−1B−1الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Multiplying (AB)(A−1B−1) does not cancel inner factors when AB=BA.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Use the shoe-sock reversal law: (AB)−1=B−1A−1.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
▲ Exam Pacing & Verification Strategy — Matrices, Linear Layers & Activation Functions▲ استراتيجية الحل السريع والتحقق — المصفوفات والطبقات الخطية في الشبكات العصبية ودوال التنشيط
Fast Matrix & Vector Verification (Mathematics for Artificial Intelligence & Machine Learning): Check every 2×2 or 3×3 eigenvalue computation using the trace and determinant invariants: ∑λi=tr(A) (sum of diagonal entries) and ∏λi=det(A).
فحص سريع للقيم الذاتية: تحقق دائماً من أن مجموع القيم الذاتية يساوي أثر المصفوفة tr(A) وحاصل ضربها يساوي المحدد det(A).
[Practice 1 · Medium] A 3D dataset has covariance matrix eigenvalues λ1=62, λ2=24, and λ3=14. What percentage of total variance is explained by the first principal component PC1?[تدريب 1 · Medium] A 3D dataset has covariance matrix eigenvalues λ1=62, λ2=24, and λ3=14. What percentage of total variance is explained by the first principal component PC1?
💡 Hint 1 of 3
Total variance is ∑λi=62+24+14.
Total variance is ∑λi=62+24+14.
💡 Hint 2 of 3
The proportion explained by PC1 is: ∑λiλ1. Rewrite and substitute: ∑λiλ1=10062.
The proportion explained by PC1 is: ∑λiλ1. Rewrite and substitute: ∑λiλ1=10062.
💡 Hint 3 of 3
Evaluate 10062 to obtain the final answer.
Evaluate 10062 to obtain the final answer.
Total variance is ∑λi=62+24+14=100. The proportion explained by PC1 is ∑λiλ1=10062=62.0%.Total variance is ∑λi=62+24+14=100. The proportion explained by PC1 is ∑λiλ1=10062=62.0%.
[Practice 2 · Hard] Consider a dataset with two features, X1 and X2. The covariance matrix for this dataset is given by:
Σ=(105520)
What is the variance of the first feature, X1?[تدريب 2 · Hard] Consider a dataset with two features, X1 and X2. The covariance matrix for this dataset is given by:
Σ=(105520)
What is the variance of the first feature, X1?
💡 Hint 1 of 3
The covariance matrix Σ for a dataset with two features X1 and X2 is structured as follows: Σ=(Cov(X1,X1)Cov(X2,X1)Cov(X1,X2)Cov(X2,X2)).
The covariance matrix Σ for a dataset with two features X1 and X2 is structured as follows: Σ=(Cov(X1,X1)Cov(X2,X1)Cov(X1,X2)Cov(X2,X2)).
💡 Hint 2 of 3
By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1) and Var(X2)=Cov(X2,X2). In the given covariance matrix: Σ=(105520).
By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1) and Var(X2)=Cov(X2,X2). In the given covariance matrix: Σ=(105520).
💡 Hint 3 of 3
Thus, the variance of X1 is 10. The covariance between X1 and X2 is 5, and the variance of X2 is 20.
Thus, the variance of X1 is 10. The covariance between X1 and X2 is 5, and the variance of X2 is 20.
The covariance matrix Σ for a dataset with two features X1 and X2 is structured as follows:
Σ=(Cov(X1,X1)Cov(X2,X1)Cov(X1,X2)Cov(X2,X2))
By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1) and Var(X2)=Cov(X2,X2).
In the given covariance matrix:
Σ=(105520)
The element in the first row and first column represents Cov(X1,X1), which is the variance of X1.
Thus, the variance of X1 is 10. The covariance between X1 and X2 is 5, and the variance of X2 is 20.The covariance matrix Σ for a dataset with two features X1 and X2 is structured as follows:
Σ=(Cov(X1,X1)Cov(X2,X1)Cov(X1,X2)Cov(X2,X2))
By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1) and Var(X2)=Cov(X2,X2).
In the given covariance matrix:
Σ=(105520)
The element in the first row and first column represents Cov(X1,X1), which is the variance of X1.
Thus, the variance of X1 is 10. The covariance between X1 and X2 is 5, and the variance of X2 is 20.
[Practice 3 · Easy] Principal Component Analysis (PCA) projects a dataset from R50 onto its top 6 principal components. What is the dimension of each transformed data point?[تدريب 3 · Easy] Principal Component Analysis (PCA) projects a dataset from R50 onto its top 6 principal components. What is the dimension of each transformed data point?
💡 Hint 1 of 3
PCA projection onto k eigenvectors transforms each sample vector from RD to Rk.
PCA projection onto k eigenvectors transforms each sample vector from RD to Rk.
💡 Hint 2 of 3
Here k=6.
Here k=6.
💡 Hint 3 of 3
So the reduced dimension is 6.
So the reduced dimension is 6.
PCA projection onto k eigenvectors transforms each sample vector from RD to Rk. Here k=6, so the reduced dimension is 6.PCA projection onto k eigenvectors transforms each sample vector from RD to Rk. Here k=6, so the reduced dimension is 6.
[Practice 4 · Medium] A vector v is transformed into a new vector v′ by a linear transformation represented by the matrix M. We are given that v=(23) and v′=(711). The transformation matrix is of the form M=(a14b). Determine the value of a and b.[تدريب 4 · Medium] A vector v is transformed into a new vector v′ by a linear transformation represented by the matrix M. We are given that v=(23) and v′=(711). The transformation matrix is of the form M=(a14b). Determine the value of a and b.
💡 Hint 1 of 3
The transformation is defined by v′=Mv. Substituting the given vectors and matrix form: (711)=(a14b)(23).
The transformation is defined by v′=Mv. Substituting the given vectors and matrix form: (711)=(a14b)(23).
💡 Hint 2 of 3
Performing the matrix multiplication: (711)=(2a+38+3b) Equating the corresponding components, we get a system of two linear equations: 1) 2a+3=7.
Performing the matrix multiplication: (711)=(2a+38+3b) Equating the corresponding components, we get a system of two linear equations: 1) 2a+3=7.
💡 Hint 3 of 3
Solving the second equation for b: 3b=11−8.
Solving the second equation for b: 3b=11−8.
The transformation is defined by v′=Mv. Substituting the given vectors and matrix form:
(711)=(a14b)(23)
Performing the matrix multiplication:
(711)=(2a+38+3b)
Equating the corresponding components, we get a system of two linear equations:
1) 2a+3=7
2) 8+3b=11
Solving the first equation for a:
2a=7−32a=4a=2
Solving the second equation for b:
3b=11−83b=3b=1
Thus, a=2 and b=1.The transformation is defined by v′=Mv. Substituting the given vectors and matrix form:
(711)=(a14b)(23)
Performing the matrix multiplication:
(711)=(2a+38+3b)
Equating the corresponding components, we get a system of two linear equations:
1) 2a+3=7
2) 8+3b=11
Solving the first equation for a:
2a=7−32a=4a=2
Solving the second equation for b:
3b=11−83b=3b=1
Thus, a=2 and b=1.
[Practice 5 · Hard] A medical test for a rare disease has a 99\% accuracy rate in detecting the disease when it is present (True Positive Rate) and a 95\% accuracy rate in identifying individuals without the disease (True Negative Rate). If the prevalence of the disease in the population is 0.5\%, what is the probability that a person who tests positive actually has the disease?[تدريب 5 · Hard] A medical test for a rare disease has a 99\% accuracy rate in detecting the disease when it is present (True Positive Rate) and a 95\% accuracy rate in identifying individuals without the disease (True Negative Rate). If the prevalence of the disease in the population is 0.5\%, what is the probability that a person who tests positive actually has the disease?
💡 Hint 1 of 3
Let D be the event that a person has the disease, and P be the event that the person tests positive.
Let D be the event that a person has the disease, and P be the event that the person tests positive.
💡 Hint 2 of 3
We are given: P(P|D) = 0.99 (True Positive Rate) P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate).
We are given: P(P|D) = 0.99 (True Positive Rate) P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate).
💡 Hint 3 of 3
Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.
Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.
Let D be the event that a person has the disease, and P be the event that the person tests positive.
We are given:
P(P|D) = 0.99 (True Positive Rate)
P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate)
P(D) = 0.005 (Prevalence of the disease)
From P(D), we know P(not D) = 1 - P(D) = 1 - 0.005 = 0.995.
We want to find P(D|P), the probability that a person has the disease given a positive test result.
Using Bayes' Theorem:
P(D|P) = [P(P|D) * P(D)] / P(P)
To find P(P), we use the law of total probability:
P(P) = P(P|D) * P(D) + P(P|not D) * P(not D)
P(P) = (0.99 * 0.005) + (0.05 * 0.995)
P(P) = 0.00495 + 0.04975
P(P) = 0.0547
Now, substitute this back into Bayes' Theorem:
P(D|P) = (0.99 * 0.005) / 0.0547
P(D|P) = 0.00495 / 0.0547
P(D|P) \approx 0.09049
Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.Let D be the event that a person has the disease, and P be the event that the person tests positive.
We are given:
P(P|D) = 0.99 (True Positive Rate)
P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate)
P(D) = 0.005 (Prevalence of the disease)
From P(D), we know P(not D) = 1 - P(D) = 1 - 0.005 = 0.995.
We want to find P(D|P), the probability that a person has the disease given a positive test result.
Using Bayes' Theorem:
P(D|P) = [P(P|D) * P(D)] / P(P)
To find P(P), we use the law of total probability:
P(P) = P(P|D) * P(D) + P(P|not D) * P(not D)
P(P) = (0.99 * 0.005) + (0.05 * 0.995)
P(P) = 0.00495 + 0.04975
P(P) = 0.0547
Now, substitute this back into Bayes' Theorem:
P(D|P) = (0.99 * 0.005) / 0.0547
P(D|P) = 0.00495 / 0.0547
P(D|P) \approx 0.09049
Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.
Loss Functions, Gradients & Optimizationدوال الخسارة والانحدار التدريجي والتحسين الرياضي
🤖 AI Math Unit 3 — Gradient Descent OptimizationApplied STEM · Loss functions: Mean Squared Error (MSE) · Partial derivatives & the gradient vector ∇L · Learning rate η and convergence · Gradient descent update rule w ← w - η ∇L · Convex vs non-convex loss landscapes
Machine learning models learn by minimizing a loss function via gradient descent. Calculus provides the directional derivative pointing toward the steepest descent in parameter space.Machine learning models learn by minimizing a loss الدالة via gradient descent. التفاضل والتكامل provides the directional المشتقة pointing toward the steepest descent in المعامل space.
Let L(w) be a differentiable loss function over weight parameters w. The gradient ∇L(w)=[∂w1∂L,…,∂wd∂L]T points in the direction of greatest rate of increase. To minimize loss, parameter updates step in the opposite direction scaled by learning rate η>0: wt+1=wt−η∇L(wt)
Let L(w) be a differentiable loss الدالة over weight المعاملات w. The gradient ∇L(w)=[∂w1∂L,…,∂wd∂L]T points in the direction of greatest rate of increase. To minimize loss, المعامل updates step in the opposite direction scaled by learning rate η>0: wt+1=wt−η∇L(wt)
● Deep Conceptual Intuition — Loss Functions, Gradients & Optimization● الفهم المفاهيمي العميق — دوال الخسارة والانحدار التدريجي والتحسين الرياضي
Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔxΔy, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1, a2x+b2y=c2 has a unique intersection if a2a1=b2b1, no solution (parallel lines) if a2a1=b2b1=c2c1, and infinitely many solutions if all three ratios coincide.
البنية الخطية والنمذجة الكمية: يعتمد حل الأنظمة والمعادلات على ثبات معدل التغير m=ΔxΔy وتحليل نسب المعاملات لتحديد عدد الحلول بدقة.
Coordinate intersection of linear system y=2x+1 and y=−x+7 at unique equilibrium point (2,5).تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس دوال الخسارة والانحدار التدريجي والتحسين الرياضي.
Trace 6 steps of gradient descent w_{t+1} = wt−η⋅2(wt−1) on the convex loss bowl L(w)=(w−1)2+0.5. Notice how η>0.5 overshoots the minimum and η≥1.0 diverges!تتبع 6 خطوات من الانحدار التدريجي على دالة الخسارة المحدبة L(w) = (w − 1)² + 0.5 مع تغير معدل التعلم η.
Loss Functions, Gradients & Optimization — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Loss Functions, Gradients & Optimization.رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس دوال الخسارة والانحدار التدريجي والتحسين الرياضي.
MSE LossMSE Loss (دوال الخسارة والانحدار التدريجي والتحسين الرياضي)
Updates weights on mini-batches of size B≪N.Updates weights on mini-batches of size B≪N. (دوال الخسارة والانحدار التدريجي والتحسين الرياضي)
◆ Why It Works — First-Principles Derivation (Loss Functions, Gradients & Optimization)◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (دوال الخسارة والانحدار التدريجي والتحسين الرياضي)
Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0 undergoes a percentage change p% followed by q%, the compound multiplier is the product of individual scale factors:
Notice the cross term 10000pq: an increase of p% followed by a decrease of p% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).
برهان النسب المتتالية والسرعة المتوسطة التوافقية: عند زيادة مقدار بنسبة p% ثم خفضه بنسبة p% يكون الناتج \(Q_0(1 - (p/100)^2) < Q_0\)، والسرعة المتوسطة لرحلتين متساويتين في المسافة هي الوسط التوافقي \(\frac{2v_1 v_2}{v_1 + v_2}\).
Worked Example 3.A — Single Step of Gradient Descentمثال محلول 3.A — Single Step of Gradient Descent
Consider a simple linear model y^=wx with squared loss for a single data point (x,y)=(2,8): L(w)=(y−wx)2=(8−2w)2 If the current weight is w0=1.0 and the learning rate is η=0.05, compute the gradient dwdL and the updated weight w1.
Solution: Apply the chain rule to differentiate L(w): dwdL=2(8−2w)⋅(−2)=−4(8−2w)=−32+8w Evaluate at w0=1.0: dwdLw=1.0=−32+8(1)=−24 Apply gradient descent update: w1=w0−η(dwdL)=1.0−(0.05)(−24)=1.0+1.2=2.2. Notice that with w0=1.0, prediction y^=2 was too low (target was 8). The gradient step increased w to 2.2, giving y^=4.4, moving closer to 8. Answer: Gradient = −24; updated weight w1=2.2.
الشرح الرياضي (دوال الخسارة والانحدار التدريجي والتحسين الرياضي):
Consider a simple linear model y^=wx with squared loss for a single data point (x,y)=(2,8): L(w)=(y−wx)2=(8−2w)2 If the current weight is w0=1.0 and the learning rate is η=0.05, compute the gradient dwdL and the updated weight w1.
Solution: Apply the chain rule to differentiate L(w): dwdL=2(8−2w)⋅(−2)=−4(8−2w)=−32+8w Evaluate at w0=1.0: dwdLw=1.0=−32+8(1)=−24 Apply gradient descent update: w1=w0−η(dwdL)=1.0−(0.05)(−24)=1.0+1.2=2.2. Notice that with w0=1.0, prediction y^=2 was too low (target was 8). The gradient step increased w to 2.2, giving y^=4.4, moving closer to 8. Answer: Gradient = −24; updated weight w1=2.2.
Worked Example B — Loss Functions, Gradients & Optimization (Medium Application)مثال محلول B — دوال الخسارة والانحدار التدريجي والتحسين الرياضي (تطبيق Medium)
Problem (Medium): Consider a univariate regression model where the predicted output y^ is given by y^=ax+b. The loss function is the Mean Squared Error (MSE), defined as L=n1∑i=1n(yi−y^i)2. For a single data point (x1,y1)=(2,5), the loss is L=(5−(2a+b))2. The gradient of the loss function with respect to a is ∂a∂L=−2(5−(2a+b))⋅2. If during gradient descent, with a learning rate of η=0.1, the parameters a and b are updated from aold=1 and bold=1, to anew=0.8 and bnew=0.8, what is the value of b that would have resulted in ∂b∂L=0 for this single data point, assuming a=1 and b=1 were the values *before* the gradient calculation that led to the update to anew=0.8,bnew=0.8?
Step-by-Step Solution: The loss function for a single data point is L=(y1−(ax1+b))2. Given (x1,y1)=(2,5), so L=(5−(2a+b))2. The gradient of the loss with respect to b is ∂b∂L=2(5−(2a+b))⋅(−1)=−2(5−2a−b). We are asked to find the value of b for which ∂b∂L=0, assuming a=1 and b=1 were the parameters *before* the update step that led to anew=0.8,bnew=0.8. This means we evaluate the gradient at a=1 and the *unknown* value of b. Setting ∂b∂L=0: −2(5−2(1)−b)=05−2−b=03−b=0b=3. The provided gradient update information ∂a∂L=−2(5−(2a+b))⋅2 and the learning rate η=0.1 are distractors. The question specifically asks for the value of b that makes ∂b∂L=0 *at the point where a=1*. The update rule to anew=0.8,bnew=0.8 implies that the gradient of a was ηaold−anew=0.11−0.8=2, and the gradient of b was ηbold−bnew=0.11−0.8=2. Let's verify: If a=1 and b=3, then ∂b∂L=−2(5−2(1)−3)=−2(5−2−3)=−2(0)=0. If a=1 and b=3, ∂a∂L=−2(5−2(1)−3)⋅2=−2(0)⋅2=0. This scenario implies that the point a=1,b=3 is a minimum for the loss function, but the question is about finding the value of b that makes the gradient of b zero at a=1, which is b=3. The provided update anew=0.8,bnew=0.8 from aold=1,bold=1 is a different step in the optimization process and is not directly used to find the value of b that makes the gradient of b zero at a=1.
مسألة (Medium): Consider a univariate regression model where the predicted output y^ is given by y^=ax+b. The loss function is the Mean Squared Error (MSE), defined as L=n1∑i=1n(yi−y^i)2. For a single data point (x1,y1)=(2,5), the loss is L=(5−(2a+b))2. The gradient of the loss function with respect to a is ∂a∂L=−2(5−(2a+b))⋅2. If during gradient descent, with a learning rate of η=0.1, the parameters a and b are updated from aold=1 and bold=1, to anew=0.8 and bnew=0.8, what is the value of b that would have resulted in ∂b∂L=0 for this single data point, assuming a=1 and b=1 were the values *before* the gradient calculation that led to the update to anew=0.8,bnew=0.8?
الحل خطوة بخطوة: The loss function for a single data point is L=(y1−(ax1+b))2. Given (x1,y1)=(2,5), so L=(5−(2a+b))2. The gradient of the loss with respect to b is ∂b∂L=2(5−(2a+b))⋅(−1)=−2(5−2a−b). We are asked to find the value of b for which ∂b∂L=0, assuming a=1 and b=1 were the parameters *before* the update step that led to anew=0.8,bnew=0.8. This means we evaluate the gradient at a=1 and the *unknown* value of b. Setting ∂b∂L=0: −2(5−2(1)−b)=05−2−b=03−b=0b=3. The provided gradient update information ∂a∂L=−2(5−(2a+b))⋅2 and the learning rate η=0.1 are distractors. The question specifically asks for the value of b that makes ∂b∂L=0 *at the point where a=1*. The update rule to anew=0.8,bnew=0.8 implies that the gradient of a was ηaold−anew=0.11−0.8=2, and the gradient of b was ηbold−bnew=0.11−0.8=2. Let's verify: If a=1 and b=3, then ∂b∂L=−2(5−2(1)−3)=−2(5−2−3)=−2(0)=0. If a=1 and b=3, ∂a∂L=−2(5−2(1)−3)⋅2=−2(0)⋅2=0. This scenario implies that the point a=1,b=3 is a minimum for the loss function, but the question is about finding the value of b that makes the gradient of b zero at a=1, which is b=3. The provided update anew=0.8,bnew=0.8 from aold=1,bold=1 is a different step in the optimization process and is not directly used to find the value of b that makes the gradient of b zero at a=1.
Worked Example C — Loss Functions, Gradients & Optimization (Hard Application)مثال محلول C — دوال الخسارة والانحدار التدريجي والتحسين الرياضي (تطبيق Hard)
Problem (Hard): Consider the following quadratic loss function for a regression problem: L(y,y^)=(y−y^)2. If the predicted value y^=5 and the true value y=3, what is the value of the loss function?
Step-by-Step Solution: The quadratic loss function is defined as L(y,y^)=(y−y^)2. Given the true value y=3 and the predicted value y^=5, we substitute these values into the loss function:
L(3,5)=(3−5)2L(3,5)=(−2)2L(3,5)=4
Therefore, the value of the loss function is 4.
مسألة (Hard): Consider the following quadratic loss function for a regression problem: L(y,y^)=(y−y^)2. If the predicted value y^=5 and the true value y=3, what is the value of the loss function?
الحل خطوة بخطوة: The quadratic loss function is defined as L(y,y^)=(y−y^)2. Given the true value y=3 and the predicted value y^=5, we substitute these values into the loss function:
L(3,5)=(3−5)2L(3,5)=(−2)2L(3,5)=4
Therefore, the value of the loss function is 4.
Worked Example D — Loss Functions, Gradients & Optimization (Easy Application)مثال محلول D — دوال الخسارة والانحدار التدريجي والتحسين الرياضي (تطبيق Easy)
Problem (Easy): Consider the quadratic loss function L(w)=w2−4w+3. Find the value of w where the function reaches its minimum.
Step-by-Step Solution: The given loss function is a quadratic function L(w)=w2−4w+3. This represents a parabola opening upwards. The minimum value of a quadratic function of the form aw2+bw+c occurs at w=−2ab. In this case, a=1 and b=−4. Therefore, the minimum occurs at w=−2(1)−4=24=2. Alternatively, we can find the minimum by taking the derivative and setting it to zero: L′(w)=2w−4. Setting L′(w)=0 gives 2w−4=0, which implies 2w=4, so w=2.
مسألة (Easy): Consider the quadratic loss function L(w)=w2−4w+3. Find the value of w where the function reaches its minimum.
الحل خطوة بخطوة: The given loss function is a quadratic function L(w)=w2−4w+3. This represents a parabola opening upwards. The minimum value of a quadratic function of the form aw2+bw+c occurs at w=−2ab. In this case, a=1 and b=−4. Therefore, the minimum occurs at w=−2(1)−4=24=2. Alternatively, we can find the minimum by taking the derivative and setting it to zero: L′(w)=2w−4. Setting L′(w)=0 gives 2w−4=0, which implies 2w=4, so w=2.
⚠️ Common Exam Traps — Loss Functions, Gradients & Optimization⚠️ أخطاء شائعة في الاختبار — دوال الخسارة والانحدار التدريجي والتحسين الرياضي
1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20% discount followed by a 20% increase gives 0.80×1.20=0.96 (a net 4% loss, not 0%). Likewise, average speed for a round trip at 40 and 60 km/h is 1002(40)(60)=48 km/h, never 50 km/h.
2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −3x+5≤8, dividing by −3 strictly reverses ≤ to ≥.
1. جمع النسب المئوية المتتالية أو حساب المتوسط الحسابي للسرعات: الزيادة ثم الخصم بنفس النسبة تنقص القيمة الأصلية دائماً، وعند القسمة على عدد سالب في المتباينات يجب قلب رمز المتباينة فوراً.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Loss Functions, Gradients & Optimization)تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (دوال الخسارة والانحدار التدريجي والتحسين الرياضي)
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Claiming +25% followed by −25% returns to 100%الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
The 25% reduction applies to the larger base 1.25Q0, not Q0.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Multiply scale factors: 1.25×0.75=0.9375 (a 6.25% net decrease).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Solving −3x>12 as x>−4الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Dividing by a negative number reverses order on the real number line.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Computing round-trip average speed as 2v1+v2الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Time spent at the slower speed is longer than time spent at the faster speed.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Use total distance over total time: vavg=v1+v22v1v2.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
▲ Exam Pacing & Verification Strategy — Loss Functions, Gradients & Optimization▲ استراتيجية الحل السريع والتحقق — دوال الخسارة والانحدار التدريجي والتحسين الرياضي
High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y rather than x and y individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.
اختصار ذهني سريع: عندما يطلب السؤال مقداراً مركباً مثل x+y في نظام معادلتين، اجمع المعادلتين أو اطرحهما مباشرةً بدلاً من إيجاد كل متغير على حدة.
[Practice 1 · Medium] Consider the following quadratic loss function: L(w)=3w2−12w+10. What is the value of w that minimizes this loss function?[تدريب 1 · Medium] Consider the following quadratic loss function: L(w)=3w2−12w+10. What is the value of w that minimizes this loss function?
💡 Hint 1 of 3
To find the minimum of the quadratic loss function L(w)=3w2−12w+10, we can find the derivative with respect to w and set it to zero.
To find the minimum of the quadratic loss function L(w)=3w2−12w+10, we can find the derivative with respect to w and set it to zero.
💡 Hint 2 of 3
The derivative of L(w) with respect to w is: dwdL=6w−12. Setting the derivative to zero to find the critical point: 6w−12=06w=12w=612w=2.
The derivative of L(w) with respect to w is: dwdL=6w−12. Setting the derivative to zero to find the critical point: 6w−12=06w=12w=612w=2.
💡 Hint 3 of 3
The second derivative is dw2d2L=6, which is positive, confirming that w corresponds to a minimum.
The second derivative is dw2d2L=6, which is positive, confirming that w corresponds to a minimum.
To find the minimum of the quadratic loss function L(w)=3w2−12w+10, we can find the derivative with respect to w and set it to zero. The derivative of L(w) with respect to w is: dwdL=6w−12. Setting the derivative to zero to find the critical point: 6w−12=06w=12w=612w=2. The second derivative is dw2d2L=6, which is positive, confirming that w=2 corresponds to a minimum.To find the minimum of the quadratic loss function L(w)=3w2−12w+10, we can find the derivative with respect to w and set it to zero. The derivative of L(w) with respect to w is: dwdL=6w−12. Setting the derivative to zero to find the critical point: 6w−12=06w=12w=612w=2. The second derivative is dw2d2L=6, which is positive, confirming that w=2 corresponds to a minimum.
[Practice 2 · Hard] Evaluate the output of the standard ReLU activation function f(z)=max(0,z) for inputs z1=−4 and z2=6.[تدريب 2 · Hard] Evaluate the output of the standard ReLU activation function f(z)=max(0,z) for inputs z1=−4 and z2=6.
💡 Hint 1 of 3
By definition of the Rectified Linear Unit: ReLU(z)=z if z>0.
By definition of the Rectified Linear Unit: ReLU(z)=z if z>0.
💡 Hint 2 of 3
And 0 if z≤0.
And 0 if z≤0.
💡 Hint 3 of 3
Thus f(−4)=0 and f(6).
Thus f(−4)=0 and f(6).
By definition of the Rectified Linear Unit: ReLU(z)=z if z>0, and 0 if z≤0. Thus f(−4)=0 and f(6)=6.By definition of the Rectified Linear Unit: ReLU(z)=z if z>0, and 0 if z≤0. Thus f(−4)=0 and f(6)=6.
[Practice 3 · Easy] In gradient descent, a weight currently has value w=60. If the gradient of the loss is ∂w∂L=24 and the learning rate is η=0.6, find the updated weight w′.[تدريب 3 · Easy] In gradient descent, a weight currently has value w=60. If the gradient of the loss is ∂w∂L=24 and the learning rate is η=0.6, find the updated weight w′.
💡 Hint 1 of 3
Using the gradient descent update rule: w′=w−η∂w∂L.
Using the gradient descent update rule: w′=w−η∂w∂L.
💡 Hint 2 of 3
Substitute and simplify: w′=60−(0.6)(24).
Substitute and simplify: w′=60−(0.6)(24).
💡 Hint 3 of 3
Compute the final value from: 60−14.40.
Compute the final value from: 60−14.40.
Using the gradient descent update rule: w′=w−η∂w∂L=60−(0.6)(24)=60−14.40=45.60.Using the gradient descent update rule: w′=w−η∂w∂L=60−(0.6)(24)=60−14.40=45.60.
[Practice 4 · Medium] Consider the scalar loss function L(w)=5w2−8w+5. Find the analytical gradient ∇L(w) evaluated at w=8.[تدريب 4 · Medium] Consider the scalar loss function L(w)=5w2−8w+5. Find the analytical gradient ∇L(w) evaluated at w=8.
💡 Hint 1 of 3
Differentiate with respect to w: dwdL=2(5)w−8=10w−8.
Differentiate with respect to w: dwdL=2(5)w−8=10w−8.
💡 Hint 2 of 3
At w=8: ∇L=10(8)−8. Substitute and simplify: ∇L=80−8.
At w=8: ∇L=10(8)−8. Substitute and simplify: ∇L=80−8.
💡 Hint 3 of 3
Compute the final value from: 80−8.
Compute the final value from: 80−8.
Differentiate with respect to w: dwdL=2(5)w−8=10w−8. At w=8: ∇L=10(8)−8=80−8=72.Differentiate with respect to w: dwdL=2(5)w−8=10w−8. At w=8: ∇L=10(8)−8=80−8=72.
[Practice 5 · Hard] Two document embeddings a=[6,12]T and b=[12,6]T are compared. If ∥a∥=∥b∥=180, calculate their exact cosine similarity.[تدريب 5 · Hard] Two document embeddings a=[6,12]T and b=[12,6]T are compared. If ∥a∥=∥b∥=180, calculate their exact cosine similarity.
🤖 AI Math Unit 4 — Probabilistic Machine LearningApplied STEM · Joint and conditional probability P(A|B) · Bayes' Theorem: Prior, Likelihood, Posterior · Total probability theorem · Naive Bayes independence assumption · Text spam filtering & medical diagnostics
Uncertainty is omnipresent in real-world data. Bayes' Theorem provides the mathematical framework for updating beliefs when observing new evidence, forming the core of Bayesian machine learning and Naive Bayes classifiers.Uncertainty is omnipresent in real-world data. Bayes' مبرهنة provides the mathematical framework for updating beliefs عندما observing new evidence, forming the core of Bayesian machine learning and Naive Bayes classifiers.
▲ Theorem 4.1 — Bayes' Theorem in Machine Learning▲ مبرهنة 4.1 — Bayes' مبرهنة in Machine Learning
For hypothesis (class) C and observed evidence (features) x: P(C∣x)=P(x)P(x∣C)P(C) Where: • P(C) is the Prior probability of class C. • P(x∣C) is the Likelihood of observing features x given class C. • P(x)=∑kP(x∣Ck)P(Ck) is the Marginal probability (Evidence). • P(C∣x) is the Posterior probability.
For hypothesis (class) C and observed evidence (features) x: P(C∣x)=P(x)P(x∣C)P(C) Where: • P(C) is the Prior probability of class C. • P(x∣C) is the Likelihood of observing features x المعطيات class C. • P(x)=∑kP(x∣Ck)P(Ck) is the Marginal الاحتمال (Evidence). • P(C∣x) is the Posterior probability.
Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔxΔy, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1, a2x+b2y=c2 has a unique intersection if a2a1=b2b1, no solution (parallel lines) if a2a1=b2b1=c2c1, and infinitely many solutions if all three ratios coincide.
البنية الخطية والنمذجة الكمية: يعتمد حل الأنظمة والمعادلات على ثبات معدل التغير m=ΔxΔy وتحليل نسب المعاملات لتحديد عدد الحلول بدقة.
Coordinate intersection of linear system y=2x+1 and y=−x+7 at unique equilibrium point (2,5).تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس الاحتمال الشرطي وقاعدة بايز ومصنفات الذكاء الاصطناعي.
⊙ Explorer · Bayes' Theorem Classifier: Prior Base Rate vs. Posterior P(C1∣+)⊙ مستكشف تفاعلي · مصنف نظرية بايز: الاحتمال القبلي مقابل الاحتمال البعدي P(C₁ | +)
interactive
Live numerical table for Bayes' Theorem Classifier: Prior Base Rate vs. Posterior P(C1∣+)جدول القيم العددية لـ ⊙ مستكشف تفاعلي · مصنف نظرية بايز: الاحتمال القبلي مقابل الاحتمال البعدي P(C₁ | +)
With fixed sensitivity P(+∣C1)=0.90, see how a low base rate P(C1) or high false-positive rate P(+∣C0) dramatically reduces the posterior probability P(C1∣+).لاحظ كيف يؤثر معدل الانتشار الأساسي P(C₁) ومعدل الإيجابيات الكاذبة P(+ | C₀) على الدقة البعدية P(C₁ | +).
Conditional Probability, Bayes' Rule & Classifiers — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Conditional Probability, Bayes' Rule & Classifiers.رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس الاحتمال الشرطي وقاعدة بايز ومصنفات الذكاء الاصطناعي.
Prevents zero probability: total+∣V∣count+1Prevents zero الاحتمال: total+∣V∣count+1
◆ Why It Works — First-Principles Derivation (Conditional Probability, Bayes' Rule & Classifiers)◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (الاحتمال الشرطي وقاعدة بايز ومصنفات الذكاء الاصطناعي)
Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0 undergoes a percentage change p% followed by q%, the compound multiplier is the product of individual scale factors:
Notice the cross term 10000pq: an increase of p% followed by a decrease of p% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).
برهان النسب المتتالية والسرعة المتوسطة التوافقية: عند زيادة مقدار بنسبة p% ثم خفضه بنسبة p% يكون الناتج \(Q_0(1 - (p/100)^2) < Q_0\)، والسرعة المتوسطة لرحلتين متساويتين في المسافة هي الوسط التوافقي \(\frac{2v_1 v_2}{v_1 + v_2}\).
Worked Example 4.A — Bayesian Spam Classificationمثال محلول 4.A — Bayesian Spam Classification
An email filter processes emails where 20% are spam (P(S)=0.20) and 80% are legitimate (P(L)=0.80). The word 'lottery' appears in 60% of spam emails (P(W∣S)=0.60) and in 1% of legitimate emails (P(W∣L)=0.01). If an incoming email contains the word 'lottery', what is the probability that it is spam?
Solution: By Bayes' Theorem: P(S∣W)=P(W)P(W∣S)P(S) Calculate total probability P(W): P(W)=P(W∣S)P(S)+P(W∣L)P(L)=(0.60)(0.20)+(0.01)(0.80)=0.12+0.008=0.128 Compute posterior: P(S∣W)=0.1280.12=128120=1615=0.9375. Despite only 20% of all emails being spam initially, observing the word 'lottery' raises the probability to 93.75%. Answer:93.75% (or 0.938).
An email filter processes emails حيث 20% are spam (P(S)=0.20) and 80% are legitimate (P(L)=0.80). The word 'lottery' appears in 60% of spam emails (P(W∣S)=0.60) and in 1% of legitimate emails (P(W∣L)=0.01). If an incoming email contains the word 'lottery', what is the الاحتمال that it is spam?
Solution: By Bayes' مبرهنة: P(S∣W)=P(W)P(W∣S)P(S) Calculate total الاحتمال P(W): P(W)=P(W∣S)P(S)+P(W∣L)P(L)=(0.60)(0.20)+(0.01)(0.80)=0.12+0.008=0.128 Compute posterior: P(S∣W)=0.1280.12=128120=1615=0.9375. Despite only 20% of all emails being spam initially, observing the word 'lottery' raises the الاحتمال to 93.75%. Answer:93.75% (or 0.938).
Worked Example B — Conditional Probability, Bayes' Rule & Classifiers (Medium Application)مثال محلول B — الاحتمال الشرطي وقاعدة بايز ومصنفات الذكاء الاصطناعي (تطبيق Medium)
Problem (Medium): Given n=4 independent observations from a normal distribution with sum ∑i=14xi=12, what is the Maximum Likelihood Estimate (MLE) μ^MLE?
Step-by-Step Solution: The log-likelihood lnL(μ)=−2nln(2πσ2)−2σ21∑(xi−μ)2. Setting ∂μ∂lnL=0 yields the sample mean μ^=n1∑xi=412=3.
مسألة (Medium): Given n=4 independent observations from a normal distribution with sum ∑i=14xi=12, what is the Maximum Likelihood Estimate (MLE) μ^MLE?
الحل خطوة بخطوة: The log-likelihood lnL(μ)=−2nln(2πσ2)−2σ21∑(xi−μ)2. Setting ∂μ∂lnL=0 yields the sample mean μ^=n1∑xi=412=3.
Worked Example C — Conditional Probability, Bayes' Rule & Classifiers (Hard Application)مثال محلول C — الاحتمال الشرطي وقاعدة بايز ومصنفات الذكاء الاصطناعي (تطبيق Hard)
Problem (Hard): A logistic regression model produces a class probability p=P(y=1∣x)=0.40. Compute the corresponding log-odds (logit) ln(1−pp).
Step-by-Step Solution: Odds are 1−pp=0.600.40=0.6667. Taking natural logarithm: ln(0.6667)=−0.405.
مسألة (Hard): A logistic regression model produces a class probability p=P(y=1∣x)=0.40. Compute the corresponding log-odds (logit) ln(1−pp).
الحل خطوة بخطوة: Odds are 1−pp=0.600.40=0.6667. Taking natural logarithm: ln(0.6667)=−0.405.
Worked Example D — Conditional Probability, Bayes' Rule & Classifiers (Easy Application)مثال محلول D — الاحتمال الشرطي وقاعدة بايز ومصنفات الذكاء الاصطناعي (تطبيق Easy)
Problem (Easy): A medical diagnostic test for a rare disease is designed to be highly sensitive and specific. The disease affects 1 in every 1000 individuals in the population. The test has a sensitivity of 99\% (meaning it correctly identifies 99\% of individuals who have the disease) and a specificity of 95\% (meaning it correctly identifies 95\% of individuals who do not have the disease). If a randomly selected individual from the population tests positive, what is the probability that they actually have the disease?
Step-by-Step Solution: Let D be the event that an individual has the disease, and P be the event that the individual tests positive.
We are given the following probabilities:
- Prior probability of having the disease: P(D)=10001=0.001
- Prior probability of not having the disease: P(Dc)=1−P(D)=1−0.001=0.999
- Sensitivity (true positive rate): P(P∣D)=0.99
- Specificity (true negative rate): P(Pc∣Dc)=0.95
From specificity, we can derive the false positive rate: P(P∣Dc)=1−P(Pc∣Dc)=1−0.95=0.05.
We want to find the probability that an individual actually has the disease given a positive test result, which is P(D∣P). We can use Bayes' Theorem:
P(D∣P)=P(P)P(P∣D)P(D)
To find P(P), the overall probability of testing positive, we can use the law of total probability:
P(P)=P(P∣D)P(D)+P(P∣Dc)P(Dc)
Substitute the given values:
P(P)=(0.99)(0.001)+(0.05)(0.999)P(P)=0.00099+0.04995P(P)=0.05094
Now, substitute P(P) back into Bayes' Theorem:
P(D∣P)=0.05094(0.99)(0.001)P(D∣P)=0.050940.00099P(D∣P)≈0.0194346
Therefore, the probability that a person who tests positive actually has the disease is approximately 0.0194, which is closest to 0.019.
مسألة (Easy): A medical diagnostic test for a rare disease is designed to be highly sensitive and specific. The disease affects 1 in every 1000 individuals in the population. The test has a sensitivity of 99\% (meaning it correctly identifies 99\% of individuals who have the disease) and a specificity of 95\% (meaning it correctly identifies 95\% of individuals who do not have the disease). If a randomly selected individual from the population tests positive, what is the probability that they actually have the disease?
الحل خطوة بخطوة: Let D be the event that an individual has the disease, and P be the event that the individual tests positive.
We are given the following probabilities:
- Prior probability of having the disease: P(D)=10001=0.001
- Prior probability of not having the disease: P(Dc)=1−P(D)=1−0.001=0.999
- Sensitivity (true positive rate): P(P∣D)=0.99
- Specificity (true negative rate): P(Pc∣Dc)=0.95
From specificity, we can derive the false positive rate: P(P∣Dc)=1−P(Pc∣Dc)=1−0.95=0.05.
We want to find the probability that an individual actually has the disease given a positive test result, which is P(D∣P). We can use Bayes' Theorem:
P(D∣P)=P(P)P(P∣D)P(D)
To find P(P), the overall probability of testing positive, we can use the law of total probability:
P(P)=P(P∣D)P(D)+P(P∣Dc)P(Dc)
Substitute the given values:
P(P)=(0.99)(0.001)+(0.05)(0.999)P(P)=0.00099+0.04995P(P)=0.05094
Now, substitute P(P) back into Bayes' Theorem:
P(D∣P)=0.05094(0.99)(0.001)P(D∣P)=0.050940.00099P(D∣P)≈0.0194346
Therefore, the probability that a person who tests positive actually has the disease is approximately 0.0194, which is closest to 0.019.
1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20% discount followed by a 20% increase gives 0.80×1.20=0.96 (a net 4% loss, not 0%). Likewise, average speed for a round trip at 40 and 60 km/h is 1002(40)(60)=48 km/h, never 50 km/h.
2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −5x+7≤12, dividing by −5 strictly reverses ≤ to ≥.
1. جمع النسب المئوية المتتالية أو حساب المتوسط الحسابي للسرعات: الزيادة ثم الخصم بنفس النسبة تنقص القيمة الأصلية دائماً، وعند القسمة على عدد سالب في المتباينات يجب قلب رمز المتباينة فوراً.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Conditional Probability, Bayes' Rule & Classifiers)تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (الاحتمال الشرطي وقاعدة بايز ومصنفات الذكاء الاصطناعي)
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Claiming +25% followed by −25% returns to 100%الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
The 25% reduction applies to the larger base 1.25Q0, not Q0.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Multiply scale factors: 1.25×0.75=0.9375 (a 6.25% net decrease).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Solving −3x>12 as x>−4الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Dividing by a negative number reverses order on the real number line.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Computing round-trip average speed as 2v1+v2الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Time spent at the slower speed is longer than time spent at the faster speed.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Use total distance over total time: vavg=v1+v22v1v2.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y rather than x and y individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.
اختصار ذهني سريع: عندما يطلب السؤال مقداراً مركباً مثل x+y في نظام معادلتين، اجمع المعادلتين أو اطرحهما مباشرةً بدلاً من إيجاد كل متغير على حدة.
[Practice 1 · Medium] A spam classification model identifies TP=30 genuine spam emails and FP=10 legitimate emails falsely flagged as spam. What is the precision of this model?[تدريب 1 · Medium] A spam classification model identifies TP=30 genuine spam emails and FP=10 legitimate emails falsely flagged as spam. What is the precision of this model?
💡 Hint 1 of 3
Precision is the fraction of predicted positive instances that are truly positive: Precision=TP+FPTP.
Precision is the fraction of predicted positive instances that are truly positive: Precision=TP+FPTP.
💡 Hint 2 of 3
Substitute and simplify: Precision=30+1030.
Substitute and simplify: Precision=30+1030.
💡 Hint 3 of 3
Compute the final value from: 30+1030.
Compute the final value from: 30+1030.
Precision is the fraction of predicted positive instances that are truly positive: Precision=TP+FPTP=30+1030=4030=75.0%.Precision is the fraction of predicted positive instances that are truly positive: Precision=TP+FPTP=30+1030=4030=75.0%.
[Practice 2 · Hard] Compute the Manhattan (L1) norm and Euclidean (L2) norm of the word vector w=[10,−15]T.[تدريب 2 · Hard] Compute the Manhattan (L1) norm and Euclidean (L2) norm of the word vector w=[10,−15]T.
💡 Hint 1 of 3
Set up the initial relation: L1 norm is the sum of absolute values: ∣10∣+∣−15∣=25.
Set up the initial relation: L1 norm is the sum of absolute values: ∣10∣+∣−15∣=25.
💡 Hint 2 of 3
Rewrite and simplify to obtain: L2 norm is the square root of sum of squares: (10)2+(−15)2. Rewrite and substitute: (10)2+(−15)2=100+225.
Rewrite and simplify to obtain: L2 norm is the square root of sum of squares: (10)2+(−15)2. Rewrite and substitute: (10)2+(−15)2=100+225.
💡 Hint 3 of 3
Evaluate 100+225 to obtain the final answer.
Evaluate 100+225 to obtain the final answer.
L1 norm is the sum of absolute values: ∣10∣+∣−15∣=25. L2 norm is the square root of sum of squares: (10)2+(−15)2=100+225=325.L1 norm is the sum of absolute values: ∣10∣+∣−15∣=25. L2 norm is the square root of sum of squares: (10)2+(−15)2=100+225=325.
[Practice 3 · Easy] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?[تدريب 3 · Easy] Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?
💡 Hint 1 of 3
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
💡 Hint 2 of 3
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
Now, we subtract v from 2u: 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2].
💡 Hint 3 of 3
Therefore, the resulting vector is [510].
Therefore, the resulting vector is [510].
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
[Practice 4 · Medium] Consider a dataset of n observations (xi,yi) for i=1,…,n, where xi are scalar predictor variables and yi are scalar response variables. The ordinary least squares (OLS) estimates for the intercept β0 and the slope β1 of the linear model y=β0+β1x+ϵ are given by β^1=∑i=1n(xi−xˉ)2∑i=1n(xi−xˉ)(yi−yˉ) and β^0=yˉ−β^1xˉ. Suppose we have a dataset where n=5, ∑xi=15, ∑yi=30, ∑xi2=55, ∑yi2=210, and ∑xiyi=105. A new data point (x6,y6) is added to the dataset. If the new regression line that minimizes the sum of squared errors for the n+1=6 points is parallel to the original regression line (i.e., β^1new=β^1old), what is the value of y6 in terms of x6?[تدريب 4 · Medium] Consider a dataset of n observations (xi,yi) for i=1,…,n, where xi are scalar predictor variables and yi are scalar response variables. The ordinary least squares (OLS) estimates for the intercept β0 and the slope β1 of the linear model y=β0+β1x+ϵ are given by β^1=∑i=1n(xi−xˉ)2∑i=1n(xi−xˉ)(yi−yˉ) and β^0=yˉ−β^1xˉ. Suppose we have a dataset where n=5, ∑xi=15, ∑yi=30, ∑xi2=55, ∑yi2=210, and ∑xiyi=105. A new data point (x6,y6) is added to the dataset. If the new regression line that minimizes the sum of squared errors for the n+1=6 points is parallel to the original regression line (i.e., β^1new=β^1old), what is the value of y6 in terms of x6?
💡 Hint 1 of 3
For the original n=5 observations, xˉ=515=3 and yˉ=530.
For the original n=5 observations, xˉ=515=3 and yˉ=530.
💡 Hint 2 of 3
The sums of squares are Sxx=55−5(32)=10 and Sxy=105−5(3)(6)=15, giving slope β^1=1015=1.5 and intercept β^0=6−1.5(3).
The sums of squares are Sxx=55−5(32)=10 and Sxy=105−5(3)(6)=15, giving slope β^1=1015=1.5 and intercept β^0=6−1.5(3).
💡 Hint 3 of 3
When a 6th point (x6,y6) lying on the existing regression line y6=1.5x6+1.5 is added, the residual is zero and the OLS slope remains unchanged at 1.5.
When a 6th point (x6,y6) lying on the existing regression line y6=1.5x6+1.5 is added, the residual is zero and the OLS slope remains unchanged at 1.5.
For the original n=5 observations, xˉ=515=3 and yˉ=530=6. The sums of squares are Sxx=55−5(32)=10 and Sxy=105−5(3)(6)=15, giving slope β^1=1015=1.5 and intercept β^0=6−1.5(3)=1.5. When a 6th point (x6,y6) lying on the existing regression line y6=1.5x6+1.5 is added, the residual is zero and the OLS slope remains unchanged at 1.5.For the original n=5 observations, xˉ=515=3 and yˉ=530=6. The sums of squares are Sxx=55−5(32)=10 and Sxy=105−5(3)(6)=15, giving slope β^1=1015=1.5 and intercept β^0=6−1.5(3)=1.5. When a 6th point (x6,y6) lying on the existing regression line y6=1.5x6+1.5 is added, the residual is zero and the OLS slope remains unchanged at 1.5.
[Practice 5 · Hard] Consider a dataset of n data points, where each data point is a vector in RD. A non-linear dimensionality reduction technique maps these data points to a lower-dimensional space Rd. The mapping function for a single data point x∈RD is given by f(x)=ϕ(x), where ϕ:RD→Rd is a function designed to preserve local neighborhood structures. Suppose the mapping ϕ is defined by an explicit feature map ϕ(x)=[xTx,xTx,…,xTx]T where the vector x∈R10 and d is the dimension of the embedded space. If the goal is to embed these points into a space such that pairwise Euclidean distances are preserved as closely as possible under a specific distortion, and it is found that d=15 yields optimal results for this mapping under a certain constraint, determine the effective rank of the feature map's image space.[تدريب 5 · Hard] Consider a dataset of n data points, where each data point is a vector in RD. A non-linear dimensionality reduction technique maps these data points to a lower-dimensional space Rd. The mapping function for a single data point x∈RD is given by f(x)=ϕ(x), where ϕ:RD→Rd is a function designed to preserve local neighborhood structures. Suppose the mapping ϕ is defined by an explicit feature map ϕ(x)=[xTx,xTx,…,xTx]T where the vector x∈R10 and d is the dimension of the embedded space. If the goal is to embed these points into a space such that pairwise Euclidean distances are preserved as closely as possible under a specific distortion, and it is found that d=15 yields optimal results for this mapping under a certain constraint, determine the effective rank of the feature map's image space.
💡 Hint 1 of 3
The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T, where x∈R10.
The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T, where x∈R10.
💡 Hint 2 of 3
The term xTx is the squared Euclidean norm of x, denoted as ∥x∥2. This is a scalar value.
The term xTx is the squared Euclidean norm of x, denoted as ∥x∥2. This is a scalar value.
💡 Hint 3 of 3
The problem states that d, but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.
The problem states that d, but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.
The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T, where x∈R10. The term xTx is the squared Euclidean norm of x, denoted as ∥x∥2. This is a scalar value. Thus, the mapping ϕ produces a vector where each component is the same scalar value, ∥x∥2. Let k=∥x∥2. Then ϕ(x)=[k,k,…,k]T in Rd. This means that the image of the mapping ϕ is a subspace spanned by a single vector. For example, if d=15, then ϕ(x)=[k,k,…,k]T which can be written as k⋅[1,1,…,1]T. The vector [1,1,…,1]T forms a basis for the image space. Therefore, the dimension of the image space, which is equivalent to its rank, is 1, regardless of the value of d (as long as d≥1). The problem states that d=15, but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T, where x∈R10. The term xTx is the squared Euclidean norm of x, denoted as ∥x∥2. This is a scalar value. Thus, the mapping ϕ produces a vector where each component is the same scalar value, ∥x∥2. Let k=∥x∥2. Then ϕ(x)=[k,k,…,k]T in Rd. This means that the image of the mapping ϕ is a subspace spanned by a single vector. For example, if d=15, then ϕ(x)=[k,k,…,k]T which can be written as k⋅[1,1,…,1]T. The vector [1,1,…,1]T forms a basis for the image space. Therefore, the dimension of the image space, which is equivalent to its rank, is 1, regardless of the value of d (as long as d≥1). The problem states that d=15, but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.
Probability Distributions & Maximum Likelihood (MLE)التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE)
🤖 AI Math Unit 5 — Distributions & EstimationApplied STEM · Gaussian / Normal distribution N(μ, σ²) · Bernoulli & Binomial distributions for classification · Likelihood function L(θ | data) · Log-Likelihood log L(θ) and differentiation · MLE parameter derivation for Gaussian mean and variance
Data in AI is modeled using probability distributions. Maximum Likelihood Estimation (MLE) is the statistical method used to find the model parameters that make the observed training data most probable.Data in AI is modeled using الاحتمال distributions. Maximum Likelihood Estimation (MLE) is the statistical method used to أوجد model المعاملات that make the observed training data most probable.
● Definition 5.1 — Maximum Likelihood Estimation (MLE)● تعريف 5.1 — Maximum Likelihood Estimation (MLE)
Given independent and identically distributed (i.i.d.) observations X={x1,x2,…,xN} from a distribution parameterized by θ: 1. Likelihood:L(θ)=∏i=1Np(xi∣θ). 2. Log-Likelihood:ℓ(θ)=lnL(θ)=∑i=1Nlnp(xi∣θ). Taking the logarithm converts products into sums without shifting the maximizing argument. 3. MLE Estimator:θ^MLE=argmaxθℓ(θ), solved by setting ∂θ∂ℓ=0.
المعطيات independent and identically distributed (i.i.d.) observations X={x1,x2,…,xN} from a distribution parameterized by θ: 1. Likelihood:L(θ)=∏i=1Np(xi∣θ). 2. Log-Likelihood:ℓ(θ)=lnL(θ)=∑i=1Nlnp(xi∣θ). Taking the logarithm converts products into sums without shifting the maximizing argument. 3. MLE Estimator:θ^MLE=argmaxθℓ(θ), solved by setting ∂θ∂ℓ=0.
● Deep Conceptual Intuition — Probability Distributions & Maximum Likelihood (MLE)● الفهم المفاهيمي العميق — التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE)
Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔxΔy, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1, a2x+b2y=c2 has a unique intersection if a2a1=b2b1, no solution (parallel lines) if a2a1=b2b1=c2c1, and infinitely many solutions if all three ratios coincide.
البنية الخطية والنمذجة الكمية: يعتمد حل الأنظمة والمعادلات على ثبات معدل التغير m=ΔxΔy وتحليل نسب المعاملات لتحديد عدد الحلول بدقة.
Coordinate intersection of linear system y=2x+1 and y=−x+7 at unique equilibrium point (2,5).تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE).
Given 5 observed data points on the horizontal axis, slide candidate mean μ to align the Gaussian bell (indigo) with the data and maximize the log-likelihood curve ℓ(μ) (amber).حرك المتوسط المرشح μ لمحاذاة منحنى جاوس مع نقاط البيانات المرصودة وتعظيم دالة الإمكان اللوغاريتمية ℓ(μ).
Probability Distributions & Maximum Likelihood (MLE) — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Probability Distributions & Maximum Likelihood (MLE).رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE).
Gaussian PDFGaussian PDF (التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE))
p(x)=σ2π1e−2σ2(x−μ)2p(x)=σ2π1e−2σ2(x−μ)2
Gaussian Mean MLEGaussian Mean MLE (التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE))
p^MLE=Nk (fraction of positive trials)p^MLE=Nk (fraction of positive trials) (التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE))
◆ Why It Works — First-Principles Derivation (Probability Distributions & Maximum Likelihood (MLE))◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE))
Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0 undergoes a percentage change p% followed by q%, the compound multiplier is the product of individual scale factors:
Notice the cross term 10000pq: an increase of p% followed by a decrease of p% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).
برهان النسب المتتالية والسرعة المتوسطة التوافقية: عند زيادة مقدار بنسبة p% ثم خفضه بنسبة p% يكون الناتج \(Q_0(1 - (p/100)^2) < Q_0\)، والسرعة المتوسطة لرحلتين متساويتين في المسافة هي الوسط التوافقي \(\frac{2v_1 v_2}{v_1 + v_2}\).
Worked Example 5.A — Deriving the MLE of a Bernoulli Parameterمثال محلول 5.A — Deriving the MLE of a Bernoulli المعامل
Let x1,x2,…,xN∈{0,1} be N binary outcomes from a coin toss with unknown bias p. Deriving the MLE estimator for p.
Solution: The probability of single outcome is P(xi)=pxi(1−p)1−xi. The likelihood for N i.i.d. observations is: L(p)=i=1∏Npxi(1−p)1−xi=p∑xi(1−p)N−∑xi Let k=∑i=1Nxi be the total number of successes. Log-likelihood: ℓ(p)=lnL(p)=klnp+(N−k)ln(1−p) Differentiate with respect to p and set to 0: dpdℓ=pk−1−pN−k=0⟹pk=1−pN−k k(1−p)=p(N−k)⟹k−kp=Np−kp⟹Np=k⟹p^MLE=Nk. Checking second derivative: \( \frac{d^2\ell}{dp^2} = -\frac{k}{p^2} - \frac{N-k}{(1-p)^2} < 0 \), confirming a maximum. Answer:p^MLE=N1∑i=1Nxi.
Let x1,x2,…,xN∈{0,1} be N binary outcomes from a coin toss with unknown bias p. Deriving the MLE estimator for p.
Solution: The الاحتمال of single outcome is P(xi)=pxi(1−p)1−xi. The likelihood for N i.i.d. observations is: L(p)=i=1∏Npxi(1−p)1−xi=p∑xi(1−p)N−∑xi Let k=∑i=1Nxi be the total number of successes. Log-likelihood: ℓ(p)=lnL(p)=klnp+(N−k)ln(1−p) Differentiate بالنسبة إلى p and set to 0: dpdℓ=pk−1−pN−k=0⟹pk=1−pN−k k(1−p)=p(N−k)⟹k−kp=Np−kp⟹Np=k⟹p^MLE=Nk. Checking second المشتقة: \( \frac{d^2\ell}{dp^2} = -\frac{k}{p^2} - \frac{N-k}{(1-p)^2} < 0 \), confirming a maximum. Answer:p^MLE=N1∑i=1Nxi.
Worked Example B — Probability Distributions & Maximum Likelihood (MLE) (Medium Application)مثال محلول B — التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE) (تطبيق Medium)
Problem (Medium): Principal Component Analysis on covariance matrix ΣA yields eigenvalues λ1=51 and λ2=49. Determine the percentage of variance fx explained by the first principal component.
Step-by-Step Solution: The percentage explained is 51+4951×100%=51%.
مسألة (Medium): Principal Component Analysis on covariance matrix ΣA yields eigenvalues λ1=51 and λ2=49. Determine the percentage of variance fx explained by the first principal component.
الحل خطوة بخطوة: The percentage explained is 51+4951×100%=51%.
Worked Example C — Probability Distributions & Maximum Likelihood (MLE) (Hard Application)مثال محلول C — التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE) (تطبيق Hard)
Problem (Hard): Consider an i.i.d. sample x1,x2,…,xn from a Poisson distribution with probability mass function P(X=k;θ)=k!θke−θ for k=0,1,2,…, where θ>0. Given a sample of size n=5 with sample sum ∑i=15xi=15, find the maximum likelihood estimate (MLE) θ^ of θ.
Step-by-Step Solution: The log-likelihood function for n i.i.d. Poisson(\/θ) observations is:
ℓ(θ)=i=1∑nxilnθ−nθ−i=1∑nln(xi!).
Setting the derivative with respect to θ equal to zero gives:
dθdℓ=θ∑i=1nxi−n=0⟹θ^=n1i=1∑nxi=515=3.
مسألة (Hard): Consider an i.i.d. sample x1,x2,…,xn from a Poisson distribution with probability mass function P(X=k;θ)=k!θke−θ for k=0,1,2,…, where θ>0. Given a sample of size n=5 with sample sum ∑i=15xi=15, find the maximum likelihood estimate (MLE) θ^ of θ.
الحل خطوة بخطوة: The log-likelihood function for n i.i.d. Poisson(\/θ) observations is:
ℓ(θ)=i=1∑nxilnθ−nθ−i=1∑nln(xi!).
Setting the derivative with respect to θ equal to zero gives:
dθdℓ=θ∑i=1nxi−n=0⟹θ^=n1i=1∑nxi=515=3.
Worked Example D — Probability Distributions & Maximum Likelihood (MLE) (Easy Application)مثال محلول D — التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE) (تطبيق Easy)
Problem (Easy): Consider a discrete random variable X with the following probability mass function (PMF): P(X=x)=10x for x∈{1,2,3,4}. What is the value of P(X≤2)?
Step-by-Step Solution: The probability mass function is given by P(X=x)=10x for x∈{1,2,3,4}. We need to find P(X≤2). This is the sum of probabilities for X=1 and X=2. P(X≤2)=P(X=1)+P(X=2). P(X=1)=101 and P(X=2)=102. Therefore, P(X≤2)=101+102=103.
مسألة (Easy): Consider a discrete random variable X with the following probability mass function (PMF): P(X=x)=10x for x∈{1,2,3,4}. What is the value of P(X≤2)?
الحل خطوة بخطوة: The probability mass function is given by P(X=x)=10x for x∈{1,2,3,4}. We need to find P(X≤2). This is the sum of probabilities for X=1 and X=2. P(X≤2)=P(X=1)+P(X=2). P(X=1)=101 and P(X=2)=102. Therefore, P(X≤2)=101+102=103.
⚠️ Common Exam Traps — Probability Distributions & Maximum Likelihood (MLE)⚠️ أخطاء شائعة في الاختبار — التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE)
1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20% discount followed by a 20% increase gives 0.80×1.20=0.96 (a net 4% loss, not 0%). Likewise, average speed for a round trip at 40 and 60 km/h is 1002(40)(60)=48 km/h, never 50 km/h.
2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −3x+3≤6, dividing by −3 strictly reverses ≤ to ≥.
1. جمع النسب المئوية المتتالية أو حساب المتوسط الحسابي للسرعات: الزيادة ثم الخصم بنفس النسبة تنقص القيمة الأصلية دائماً، وعند القسمة على عدد سالب في المتباينات يجب قلب رمز المتباينة فوراً.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Probability Distributions & Maximum Likelihood (MLE))تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE))
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Claiming +25% followed by −25% returns to 100%الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
The 25% reduction applies to the larger base 1.25Q0, not Q0.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Multiply scale factors: 1.25×0.75=0.9375 (a 6.25% net decrease).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Solving −3x>12 as x>−4الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Dividing by a negative number reverses order on the real number line.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Computing round-trip average speed as 2v1+v2الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Time spent at the slower speed is longer than time spent at the faster speed.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Use total distance over total time: vavg=v1+v22v1v2.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
▲ Exam Pacing & Verification Strategy — Probability Distributions & Maximum Likelihood (MLE)▲ استراتيجية الحل السريع والتحقق — التوزيعات الاحتمالية وتقدير الاحتمال الأقصى (MLE)
High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y rather than x and y individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.
اختصار ذهني سريع: عندما يطلب السؤال مقداراً مركباً مثل x+y في نظام معادلتين، اجمع المعادلتين أو اطرحهما مباشرةً بدلاً من إيجاد كل متغير على حدة.
[Practice 1 · Medium] A dataset consists of observations x1,x2,…,xn that are assumed to be drawn independently from a Bernoulli distribution with parameter p. The probability mass function is given by P(X=k;p)=pk(1−p)1−k for k∈{0,1}. The following bar chart shows the frequency distribution of these observations, where n=50.
{
"type": "bar",
"labels": ["0", "1"],
"data": [20, 30],
"title": "Frequency Distribution of Bernoulli Observations"
}
Using the method of Maximum Likelihood Estimation (MLE), determine the estimated value of p for this distribution.[تدريب 1 · Medium] A dataset consists of observations x1,x2,…,xn that are assumed to be drawn independently from a Bernoulli distribution with parameter p. The probability mass function is given by P(X=k;p)=pk(1−p)1−k for k∈{0,1}. The following bar chart shows the frequency distribution of these observations, where n=50.
{
"type": "bar",
"labels": ["0", "1"],
"data": [20, 30],
"title": "Frequency Distribution of Bernoulli Observations"
}
Using the method of Maximum Likelihood Estimation (MLE), determine the estimated value of p for this distribution.
💡 Hint 1 of 3
The Bernoulli distribution has the probability mass function P(X=k;p)=pk(1−p)1−k. The likelihood function for n independent observations is L(p;x1,…,xn)=∏i=1npxi(1−p)1−xi. This can be rewritten as L(p)=p∑xi(1−p)n−∑xi.
The Bernoulli distribution has the probability mass function P(X=k;p)=pk(1−p)1−k. The likelihood function for n independent observations is L(p;x1,…,xn)=∏i=1npxi(1−p)1−xi. This can be rewritten as L(p)=p∑xi(1−p)n−∑xi.
💡 Hint 2 of 3
Rewrite and simplify to obtain: ∑xi=np.
Rewrite and simplify to obtain: ∑xi=np.
💡 Hint 3 of 3
Therefore, the MLE for p is: p^MLE=5030.
Therefore, the MLE for p is: p^MLE=5030.
The Bernoulli distribution has the probability mass function P(X=k;p)=pk(1−p)1−k. The likelihood function for n independent observations is L(p;x1,…,xn)=∏i=1npxi(1−p)1−xi. This can be rewritten as L(p)=p∑xi(1−p)n−∑xi.
The log-likelihood function is lnL(p)=(∑xi)lnp+(n−∑xi)ln(1−p).
To find the maximum likelihood estimate (MLE) of p, we take the derivative of the log-likelihood with respect to p and set it to zero:
dpdlnL(p)=p∑xi−1−pn−∑xi
Setting the derivative to zero:
p∑xi=1−pn−∑xi(∑xi)(1−p)=p(n−∑xi)∑xi−p∑xi=np−p∑xi∑xi=npp^MLE=n∑xi
This means the MLE for p is the sample mean.
From the bar chart, the frequency of observations equal to 0 is 20, and the frequency of observations equal to 1 is 30. The total number of observations is n=50.
The sum of the observations ∑xi is calculated as:
∑xi=(20×0)+(30×1)=0+30=30
Therefore, the MLE for p is:
p^MLE=5030=53
Common algebraic traps: Students might incorrectly calculate the sample mean, or confuse the counts of 0s and 1s. The option 52 would arise from incorrectly using 5020 which represents 1−p. The option 21 might arise from assuming equal probabilities without considering the data. The option 23 is not a valid probability.The Bernoulli distribution has the probability mass function P(X=k;p)=pk(1−p)1−k. The likelihood function for n independent observations is L(p;x1,…,xn)=∏i=1npxi(1−p)1−xi. This can be rewritten as L(p)=p∑xi(1−p)n−∑xi.
The log-likelihood function is lnL(p)=(∑xi)lnp+(n−∑xi)ln(1−p).
To find the maximum likelihood estimate (MLE) of p, we take the derivative of the log-likelihood with respect to p and set it to zero:
dpdlnL(p)=p∑xi−1−pn−∑xi
Setting the derivative to zero:
p∑xi=1−pn−∑xi(∑xi)(1−p)=p(n−∑xi)∑xi−p∑xi=np−p∑xi∑xi=npp^MLE=n∑xi
This means the MLE for p is the sample mean.
From the bar chart, the frequency of observations equal to 0 is 20, and the frequency of observations equal to 1 is 30. The total number of observations is n=50.
The sum of the observations ∑xi is calculated as:
∑xi=(20×0)+(30×1)=0+30=30
Therefore, the MLE for p is:
p^MLE=5030=53
Common algebraic traps: Students might incorrectly calculate the sample mean, or confuse the counts of 0s and 1s. The option 52 would arise from incorrectly using 5020 which represents 1−p. The option 21 might arise from assuming equal probabilities without considering the data. The option 23 is not a valid probability.
[Practice 2 · Hard] Consider a sequence of n independent Bernoulli trials, where the probability of success in each trial is p. Let X be the random variable representing the number of successes in these n trials. Thus, X∼Binomial(n,p). We are given a dataset of N observed values {x1,x2,…,xN} for X, where each xi is an observed count of successes from n trials. The observed data are: [3, 4, 2, 5, 4, 3, 2, 4, 5, 3]. If we assume that n=5 (the number of trials for each observation is fixed at 5), find the value of p that maximizes the likelihood of observing this dataset. Then, compute the maximum likelihood estimate (MLE) of the probability of success, p, and round your answer to two decimal places.[تدريب 2 · Hard] Consider a sequence of n independent Bernoulli trials, where the probability of success in each trial is p. Let X be the random variable representing the number of successes in these n trials. Thus, X∼Binomial(n,p). We are given a dataset of N observed values {x1,x2,…,xN} for X, where each xi is an observed count of successes from n trials. The observed data are: [3, 4, 2, 5, 4, 3, 2, 4, 5, 3]. If we assume that n=5 (the number of trials for each observation is fixed at 5), find the value of p that maximizes the likelihood of observing this dataset. Then, compute the maximum likelihood estimate (MLE) of the probability of success, p, and round your answer to two decimal places.
💡 Hint 1 of 3
The random variable X follows a Binomial distribution: X∼Binomial(n,p). The probability mass function (PMF) of the Binomial distribution is given by P(X=k∣n,p)=(kn)pk(1−p)n−k, where k is the number of successes.
The random variable X follows a Binomial distribution: X∼Binomial(n,p). The probability mass function (PMF) of the Binomial distribution is given by P(X=k∣n,p)=(kn)pk(1−p)n−k, where k is the number of successes.
💡 Hint 2 of 3
Rewrite and simplify to obtain: pS=1−pT.
Rewrite and simplify to obtain: pS=1−pT.
💡 Hint 3 of 3
Let's check the second derivative to confirm it's a maximum: dp2d2ℓ=−p2S−(1−p)2T. Since S>0, T>0, p∈(0,1), the second derivative is negative, confirming a maximum.
Let's check the second derivative to confirm it's a maximum: dp2d2ℓ=−p2S−(1−p)2T. Since S>0, T>0, p∈(0,1), the second derivative is negative, confirming a maximum.
The random variable X follows a Binomial distribution: X∼Binomial(n,p). The probability mass function (PMF) of the Binomial distribution is given by P(X=k∣n,p)=(kn)pk(1−p)n−k, where k is the number of successes.
We are given n=5 and a dataset of N=10 observations: {x1,x2,…,x10}={3,4,2,5,4,3,2,4,5,3}.
The likelihood function for this dataset, given p, is the product of the PMFs for each observation:
L(p∣{xi})=∏i=1NP(X=xi∣n,p)=∏i=110(xi5)pxi(1−p)5−xi
To find the MLE of p, we typically work with the log-likelihood function, which simplifies the product into a sum:
ℓ(p)=logL(p)=∑i=110log((xi5)pxi(1−p)5−xi)ℓ(p)=∑i=110(log(xi5)+xilogp+(5−xi)log(1−p))ℓ(p)=∑i=110log(xi5)+(∑i=110xi)logp+(∑i=110(5−xi))log(1−p)
The term ∑i=110log(xi5) is a constant with respect to p and can be ignored for maximization.
Let S=∑i=110xi be the total number of successes in the dataset, and T=∑i=110(5−xi)=10×5−∑i=110xi=50−S be the total number of failures.
So, ℓ(p)≈Slogp+Tlog(1−p).
To find the MLE, we take the derivative of ℓ(p) with respect to p and set it to zero:
dpdℓ=pS−1−pT=0pS=1−pTS(1−p)=TpS−Sp=TpS=Tp+SpS=p(T+S)p=T+SS
We know that T+S=∑i=110(5−xi)+∑i=110xi=∑i=110(5−xi+xi)=∑i=1105=10×5=50.
Now, let's calculate S, the sum of the observed successes:
S=3+4+2+5+4+3+2+4+5+3=35.
Therefore, the MLE of p is:
p^=nNS=5×1035=5035=107=0.70.
The maximum likelihood estimate of p is 0.70.
Let's check the second derivative to confirm it's a maximum:
dp2d2ℓ=−p2S−(1−p)2T. Since S>0, T>0, p∈(0,1), the second derivative is negative, confirming a maximum.
Common Misconception:
A common mistake might be to incorrectly calculate the sum of successes or failures, or to use the wrong formula for the MLE of a binomial proportion, such as simply averaging the proportions of successes in each trial (which is not applicable here as n is fixed). For example, if one made an arithmetic error and got S=30, then p^=30/50=0.60. If S=37.5 (an impossible sum, but for illustration of error), p^=37.5/50=0.75. If S=30, p^=30/50=0.6. If S=33.5, p^=33.5/50=0.67.The random variable X follows a Binomial distribution: X∼Binomial(n,p). The probability mass function (PMF) of the Binomial distribution is given by P(X=k∣n,p)=(kn)pk(1−p)n−k, where k is the number of successes.
We are given n=5 and a dataset of N=10 observations: {x1,x2,…,x10}={3,4,2,5,4,3,2,4,5,3}.
The likelihood function for this dataset, given p, is the product of the PMFs for each observation:
L(p∣{xi})=∏i=1NP(X=xi∣n,p)=∏i=110(xi5)pxi(1−p)5−xi
To find the MLE of p, we typically work with the log-likelihood function, which simplifies the product into a sum:
ℓ(p)=logL(p)=∑i=110log((xi5)pxi(1−p)5−xi)ℓ(p)=∑i=110(log(xi5)+xilogp+(5−xi)log(1−p))ℓ(p)=∑i=110log(xi5)+(∑i=110xi)logp+(∑i=110(5−xi))log(1−p)
The term ∑i=110log(xi5) is a constant with respect to p and can be ignored for maximization.
Let S=∑i=110xi be the total number of successes in the dataset, and T=∑i=110(5−xi)=10×5−∑i=110xi=50−S be the total number of failures.
So, ℓ(p)≈Slogp+Tlog(1−p).
To find the MLE, we take the derivative of ℓ(p) with respect to p and set it to zero:
dpdℓ=pS−1−pT=0pS=1−pTS(1−p)=TpS−Sp=TpS=Tp+SpS=p(T+S)p=T+SS
We know that T+S=∑i=110(5−xi)+∑i=110xi=∑i=110(5−xi+xi)=∑i=1105=10×5=50.
Now, let's calculate S, the sum of the observed successes:
S=3+4+2+5+4+3+2+4+5+3=35.
Therefore, the MLE of p is:
p^=nNS=5×1035=5035=107=0.70.
The maximum likelihood estimate of p is 0.70.
Let's check the second derivative to confirm it's a maximum:
dp2d2ℓ=−p2S−(1−p)2T. Since S>0, T>0, p∈(0,1), the second derivative is negative, confirming a maximum.
Common Misconception:
A common mistake might be to incorrectly calculate the sum of successes or failures, or to use the wrong formula for the MLE of a binomial proportion, such as simply averaging the proportions of successes in each trial (which is not applicable here as n is fixed). For example, if one made an arithmetic error and got S=30, then p^=30/50=0.60. If S=37.5 (an impossible sum, but for illustration of error), p^=37.5/50=0.75. If S=30, p^=30/50=0.6. If S=33.5, p^=33.5/50=0.67.
[Practice 3 · Easy] Consider a dataset where the number of defective items produced by a machine per hour, Y, follows a Poisson distribution with a rate parameter λ=3. The probability mass function (PMF) for a Poisson distribution is given by P(Y=k)=k!λke−λ for k=0,1,2,…. What is the value of λ in this scenario?[تدريب 3 · Easy] Consider a dataset where the number of defective items produced by a machine per hour, Y, follows a Poisson distribution with a rate parameter λ=3. The probability mass function (PMF) for a Poisson distribution is given by P(Y=k)=k!λke−λ for k=0,1,2,…. What is the value of λ in this scenario?
💡 Hint 1 of 3
The problem statement explicitly defines that the number of defective items, Y, follows a Poisson distribution with a rate parameter λ=3.
The problem statement explicitly defines that the number of defective items, Y, follows a Poisson distribution with a rate parameter λ=3.
💡 Hint 2 of 3
The rate parameter λ is a direct characteristic of the Poisson distribution that determines its mean and variance.
The rate parameter λ is a direct characteristic of the Poisson distribution that determines its mean and variance.
💡 Hint 3 of 3
Therefore, the value of λ is directly given as 3.
Therefore, the value of λ is directly given as 3.
The problem statement explicitly defines that the number of defective items, Y, follows a Poisson distribution with a rate parameter λ=3. The rate parameter λ is a direct characteristic of the Poisson distribution that determines its mean and variance. Therefore, the value of λ is directly given as 3.The problem statement explicitly defines that the number of defective items, Y, follows a Poisson distribution with a rate parameter λ=3. The rate parameter λ is a direct characteristic of the Poisson distribution that determines its mean and variance. Therefore, the value of λ is directly given as 3.
[Practice 4 · Easy] A feature in an AI vision model follows a normal distribution X∼N(25,36). What is the mean μ and variance σ2 of this feature?[تدريب 4 · Easy] A feature in an AI vision model follows a normal distribution X∼N(25,36). What is the mean μ and variance σ2 of this feature?
💡 Hint 1 of 3
Start by examining the given mathematical expression in the problem: X∼N(25,36).
Start by examining the given mathematical expression in the problem: X∼N(25,36).
💡 Hint 2 of 3
The notation N(μ,σ2) directly specifies the mean μ=25 and variance σ2=36 (with standard deviation σ).
The notation N(μ,σ2) directly specifies the mean μ=25 and variance σ2=36 (with standard deviation σ).
💡 Hint 3 of 3
Apply this step to σ and simplify to determine the final result.
Apply this step to σ and simplify to determine the final result.
The notation N(μ,σ2) directly specifies the mean μ=25 and variance σ2=36 (with standard deviation σ=6).The notation N(μ,σ2) directly specifies the mean μ=25 and variance σ2=36 (with standard deviation σ=6).
[Practice 5 · Medium] A dataset consists of three independent observations X1,X2,X3 drawn from a Poisson distribution with parameter λ. The observed values are x1=3,x2=5,x3=4. We want to find the Maximum Likelihood Estimate (MLE) for λ. The log-likelihood function for a Poisson distribution is given by ℓ(λ)=∑i=1n(xilog(λ)−log(xi!)−λ).
Part 1: Derive the expression for the derivative of the log-likelihood function with respect to λ.
Part 2: Set the derivative to zero to find the MLE of λ.[تدريب 5 · Medium] A dataset consists of three independent observations X1,X2,X3 drawn from a Poisson distribution with parameter λ. The observed values are x1=3,x2=5,x3=4. We want to find the Maximum Likelihood Estimate (MLE) for λ. The log-likelihood function for a Poisson distribution is given by ℓ(λ)=∑i=1n(xilog(λ)−log(xi!)−λ).
Part 1: Derive the expression for the derivative of the log-likelihood function with respect to λ.
Part 2: Set the derivative to zero to find the MLE of λ.
💡 Hint 1 of 3
The log-likelihood function for n=3 observations is ℓ(λ)=(x1log(λ)−log(x1!)−λ)+(x2log(λ)−log(x2!)−λ)+(x3log(λ)−log(x3!)−λ).
The log-likelihood function for n=3 observations is ℓ(λ)=(x1log(λ)−log(x1!)−λ)+(x2log(λ)−log(x2!)−λ)+(x3log(λ)−log(x3!)−λ).
💡 Hint 2 of 3
Rewrite and simplify to obtain: λx1+x2+x3−3=0.
Rewrite and simplify to obtain: λx1+x2+x3−3=0.
💡 Hint 3 of 3
Substituting the observed values x1=3,x2=5,x3: λ^=33+5+4.
Substituting the observed values x1=3,x2=5,x3: λ^=33+5+4.
The log-likelihood function for n=3 observations is ℓ(λ)=(x1log(λ)−log(x1!)−λ)+(x2log(λ)−log(x2!)−λ)+(x3log(λ)−log(x3!)−λ).
Part 1: The derivative of the log-likelihood function with respect to λ is:
dλdℓ=∑i=13(λxi−1)=(λx1−1)+(λx2−1)+(λx3−1).
Part 2: To find the MLE, we set the derivative to zero:
λx1−1+λx2−1+λx3−1=0λx1+x2+x3−3=0λx1+x2+x3=3λ^=3x1+x2+x3.
Substituting the observed values x1=3,x2=5,x3=4:
λ^=33+5+4=312=4.
Common algebraic traps include incorrectly differentiating the log-likelihood or making errors in solving for λ. For example, forgetting the −1 term from the derivative of −λ leads to an incorrect denominator. Choice B is incorrect as it includes e which is not part of the Poisson MLE derivation. Choice C is an incomplete and incorrect expression. Choice D is only correct if the sum of observations was 12, but the formula for λ^ is the sample mean. Therefore, the MLE is λ^=4.The log-likelihood function for n=3 observations is ℓ(λ)=(x1log(λ)−log(x1!)−λ)+(x2log(λ)−log(x2!)−λ)+(x3log(λ)−log(x3!)−λ).
Part 1: The derivative of the log-likelihood function with respect to λ is:
dλdℓ=∑i=13(λxi−1)=(λx1−1)+(λx2−1)+(λx3−1).
Part 2: To find the MLE, we set the derivative to zero:
λx1−1+λx2−1+λx3−1=0λx1+x2+x3−3=0λx1+x2+x3=3λ^=3x1+x2+x3.
Substituting the observed values x1=3,x2=5,x3=4:
λ^=33+5+4=312=4.
Common algebraic traps include incorrectly differentiating the log-likelihood or making errors in solving for λ. For example, forgetting the −1 term from the derivative of −λ leads to an incorrect denominator. Choice B is incorrect as it includes e which is not part of the Poisson MLE derivation. Choice C is an incomplete and incorrect expression. Choice D is only correct if the sum of observations was 12, but the formula for λ^ is the sample mean. Therefore, the MLE is λ^=4.
Linear Regression & Ordinary Least Squaresالانحدار الخطي وطريقة المربعات الصغرى (OLS)
🤖 AI Math Unit 6 — Linear Models & OLSApplied STEM · Simple linear regression: y = mx + b · Matrix formulation Y = Xw + ε · Ordinary Least Squares (OLS) closed form · Normal equation w = (XᵀX)⁻¹ Xᵀ y · Residuals, MSE and R² coefficient of determination
Linear regression is the foundational predictive model in data science. We explore both algebraic least-squares minimization and the closed-form matrix Normal Equation used across analytics libraries.Linear regression is the foundational predictive model in data science. We explore both algebraic least-squares minimization and the closed-form المصفوفة Normal المعادلة used across analytics libraries.
▲ Theorem 6.1 — The Matrix Normal Equation▲ مبرهنة 6.1 — The المصفوفة Normal المعادلة
For a linear model y=Xw where X∈RN×(d+1) is the design matrix (including a column of ones for intercept), the weight vector w that minimizes the sum of squared errors ∥y−Xw∥2 satisfies: XTXw=XTy⟹w=(XTX)−1XTy provided XTX is invertible (non-singular).
For a linear model y=Xw حيث X∈RN×(d+1) is the design المصفوفة (including a column of ones for المقطع), the weight المتجه w that minimizes the sum of squared errors ∥y−Xw∥2 satisfies: XTXw=XTy⟹w=(XTX)−1XTy provided XTX is invertible (non-singular).
● Deep Conceptual Intuition — Linear Regression & Ordinary Least Squares● الفهم المفاهيمي العميق — الانحدار الخطي وطريقة المربعات الصغرى (OLS)
Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔxΔy, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1, a2x+b2y=c2 has a unique intersection if a2a1=b2b1, no solution (parallel lines) if a2a1=b2b1=c2c1, and infinitely many solutions if all three ratios coincide.
البنية الخطية والنمذجة الكمية: يعتمد حل الأنظمة والمعادلات على ثبات معدل التغير m=ΔxΔy وتحليل نسب المعاملات لتحديد عدد الحلول بدقة.
Coordinate intersection of linear system y=2x+1 and y=−x+7 at unique equilibrium point (2,5).تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس الانحدار الخطي وطريقة المربعات الصغرى (OLS).
⊙ Explorer · Ordinary Least Squares (OLS) Regression Line & Residual MSE⊙ مستكشف تفاعلي · الانحدار الخطي والمربعات الصغرى الاعتيادية (OLS) ومربعات البواقي
interactive
Live numerical table for Ordinary Least Squares (OLS) Regression Line & Residual MSEجدول القيم العددية لـ ⊙ مستكشف تفاعلي · الانحدار الخطي والمربعات الصغرى الاعتيادية (OLS) ومربعات البواقي
Parameter / Metricالمتغير / المعيار
Valueالقيمة
Mean Squared Error MSE(w,b)Mean Squared Error MSE(w, b)MSE = 0.124
Coefficient of Determination R2Coefficient of Determination R²R2=0.943
Vertical amber segments show the residuals ei=yi−(w⋅xi+b) for each training point. Minimizing Σ e_i2 yields the dashed ordinary least squares line.القطع الرأسية الكهرمانية تمثل البواقي e_i = y_i − (w·x_i + b)؛ تقليل مجموع مربعاتها يعطي خط المربعات الصغرى الأمثل.
Regression Line and Observations — illustrating key geometric and analytical relationships in Linear Regression & Ordinary Least Squares.رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس الانحدار الخطي وطريقة المربعات الصغرى (OLS).
◆ Why It Works — First-Principles Derivation (Linear Regression & Ordinary Least Squares)◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (الانحدار الخطي وطريقة المربعات الصغرى (OLS))
Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0 undergoes a percentage change p% followed by q%, the compound multiplier is the product of individual scale factors:
Notice the cross term 10000pq: an increase of p% followed by a decrease of p% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).
برهان النسب المتتالية والسرعة المتوسطة التوافقية: عند زيادة مقدار بنسبة p% ثم خفضه بنسبة p% يكون الناتج \(Q_0(1 - (p/100)^2) < Q_0\)، والسرعة المتوسطة لرحلتين متساويتين في المسافة هي الوسط التوافقي \(\frac{2v_1 v_2}{v_1 + v_2}\).
Worked Example 6.A — Closed-Form Matrix Normal Equationمثال محلول 6.A — Closed-Form المصفوفة Normal المعادلة
Fit a line y=w1x+w0 to three points: (1,2), (2,3), and (3,5) using the Normal Equation.
Solution: 1. Set up design matrix X (with bias column) and target y: X=123111,y=235 2. Compute XTX: XTX=(112131)123111=(1+4+91+2+31+2+31+1+1)=(14663) 3. Invert XTX: det=(14)(3)−(6)(6)=42−36=6. (XTX)−1=61(3−6−614) 4. Compute XTy: XTy=(112131)235=(2+6+152+3+5)=(2310) 5. Compute w=(XTX)−1(XTy): w=61(3(23)−6(10)−6(23)+14(10))=61(69−60−138+140)=61(92)=(1.50.333) Line equation: y^=1.5x+31. Answer: Slope w1=1.5, Intercept w0=31.
Fit a line y=w1x+w0 to three points: (1,2), (2,3), and (3,5) using the Normal المعادلة.
Solution: 1. Set up design المصفوفة X (with bias column) and target y: X=123111,y=235 2. Compute XTX: XTX=(112131)123111=(1+4+91+2+31+2+31+1+1)=(14663) 3. Invert XTX: det=(14)(3)−(6)(6)=42−36=6. (XTX)−1=61(3−6−614) 4. Compute XTy: XTy=(112131)235=(2+6+152+3+5)=(2310) 5. Compute w=(XTX)−1(XTy): w=61(3(23)−6(10)−6(23)+14(10))=61(69−60−138+140)=61(92)=(1.50.333) Line المعادلة: y^=1.5x+31. Answer: الميل w1=1.5, المقطع w0=31.
Worked Example B — Linear Regression & Ordinary Least Squares (Hard Application)مثال محلول B — الانحدار الخطي وطريقة المربعات الصغرى (OLS) (تطبيق Hard)
Problem (Hard): A simple linear regression model has been fitted to a dataset. The model equation is given by y^=ax+b. The regression line passes through the points (2,10) and (5,22) in the feature-target space. Determine the value of the intercept b.
Step-by-Step Solution: The problem states that the linear regression line y^=ax+b passes through two points: (x1,y1)=(2,10) and (x2,y2)=(5,22).
We can use these two points to form a system of linear equations to solve for the unknown parameters a (the slope) and b (the intercept).
Substituting the first point (2,10) into the equation y^=ax+b gives:
10=a(2)+b (Equation 1)
Substituting the second point (5,22) into the equation y^=ax+b gives:
22=a(5)+b (Equation 2)
To find the slope a, we can subtract Equation 1 from Equation 2:
(22−10)=(5a−2a)+(b−b)12=3aa=312=4
Now that we have the value of a, we can substitute it back into either Equation 1 or Equation 2 to solve for b. Let's use Equation 1:
10=4(2)+b10=8+bb=10−8b=2
Let's verify with Equation 2:
22=4(5)+b22=20+bb=22−20b=2
Both equations yield b=2. Therefore, the intercept b is 2.
Common algebraic traps include incorrectly calculating the slope or making sign errors when substituting values back into the equations. For instance, if one incorrectly calculated the slope as 123 or made a sign error in 10−8, they might arrive at an incorrect intercept.
مسألة (Hard): A simple linear regression model has been fitted to a dataset. The model equation is given by y^=ax+b. The regression line passes through the points (2,10) and (5,22) in the feature-target space. Determine the value of the intercept b.
الحل خطوة بخطوة: The problem states that the linear regression line y^=ax+b passes through two points: (x1,y1)=(2,10) and (x2,y2)=(5,22).
We can use these two points to form a system of linear equations to solve for the unknown parameters a (the slope) and b (the intercept).
Substituting the first point (2,10) into the equation y^=ax+b gives:
10=a(2)+b (Equation 1)
Substituting the second point (5,22) into the equation y^=ax+b gives:
22=a(5)+b (Equation 2)
To find the slope a, we can subtract Equation 1 from Equation 2:
(22−10)=(5a−2a)+(b−b)12=3aa=312=4
Now that we have the value of a, we can substitute it back into either Equation 1 or Equation 2 to solve for b. Let's use Equation 1:
10=4(2)+b10=8+bb=10−8b=2
Let's verify with Equation 2:
22=4(5)+b22=20+bb=22−20b=2
Both equations yield b=2. Therefore, the intercept b is 2.
Common algebraic traps include incorrectly calculating the slope or making sign errors when substituting values back into the equations. For instance, if one incorrectly calculated the slope as 123 or made a sign error in 10−8, they might arrive at an incorrect intercept.
Worked Example C — Linear Regression & Ordinary Least Squares (Easy Application)مثال محلول C — الانحدار الخطي وطريقة المربعات الصغرى (OLS) (تطبيق Easy)
Problem (Easy): In gradient descent on loss f(x), parameter x0=30 is updated with learning rate η=0.1 and gradient ∇f(x0)=20. Determine the updated parameter x1=x0−η∇f(x0).
مسألة (Easy): In gradient descent on loss f(x), parameter x0=30 is updated with learning rate η=0.1 and gradient ∇f(x0)=20. Determine the updated parameter x1=x0−η∇f(x0).
الحل خطوة بخطوة: Computing x1=30−0.1(20)=28.
Worked Example D — Linear Regression & Ordinary Least Squares (Medium Application)مثال محلول D — الانحدار الخطي وطريقة المربعات الصغرى (OLS) (تطبيق Medium)
Problem (Medium): Consider a simple linear regression model where the predicted value y^ is related to the independent variable x by the equation y^=mx+c. If the line of best fit passes through the points (1,5) and (3,11), what is the slope m of this line?
Step-by-Step Solution: The slope m of a line passing through two points (x1,y1) and (x2,y2) is given by the formula m=x2−x1y2−y1. Given the points (1,5) and (3,11), we have x1=1, y1=5, x2=3, and y2=11. Plugging these values into the formula, we get m=3−111−5=26=3. Therefore, the slope of the line of best fit is 3.
مسألة (Medium): Consider a simple linear regression model where the predicted value y^ is related to the independent variable x by the equation y^=mx+c. If the line of best fit passes through the points (1,5) and (3,11), what is the slope m of this line?
الحل خطوة بخطوة: The slope m of a line passing through two points (x1,y1) and (x2,y2) is given by the formula m=x2−x1y2−y1. Given the points (1,5) and (3,11), we have x1=1, y1=5, x2=3, and y2=11. Plugging these values into the formula, we get m=3−111−5=26=3. Therefore, the slope of the line of best fit is 3.
⚠️ Common Exam Traps — Linear Regression & Ordinary Least Squares⚠️ أخطاء شائعة في الاختبار — الانحدار الخطي وطريقة المربعات الصغرى (OLS)
1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20% discount followed by a 20% increase gives 0.80×1.20=0.96 (a net 4% loss, not 0%). Likewise, average speed for a round trip at 40 and 60 km/h is 1002(40)(60)=48 km/h, never 50 km/h.
2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −2x+5≤7, dividing by −2 strictly reverses ≤ to ≥.
1. جمع النسب المئوية المتتالية أو حساب المتوسط الحسابي للسرعات: الزيادة ثم الخصم بنفس النسبة تنقص القيمة الأصلية دائماً، وعند القسمة على عدد سالب في المتباينات يجب قلب رمز المتباينة فوراً.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Linear Regression & Ordinary Least Squares)تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (الانحدار الخطي وطريقة المربعات الصغرى (OLS))
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Claiming +25% followed by −25% returns to 100%الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
The 25% reduction applies to the larger base 1.25Q0, not Q0.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Multiply scale factors: 1.25×0.75=0.9375 (a 6.25% net decrease).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Solving −3x>12 as x>−4الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Dividing by a negative number reverses order on the real number line.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Computing round-trip average speed as 2v1+v2الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Time spent at the slower speed is longer than time spent at the faster speed.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Use total distance over total time: vavg=v1+v22v1v2.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
▲ Exam Pacing & Verification Strategy — Linear Regression & Ordinary Least Squares▲ استراتيجية الحل السريع والتحقق — الانحدار الخطي وطريقة المربعات الصغرى (OLS)
High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y rather than x and y individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.
اختصار ذهني سريع: عندما يطلب السؤال مقداراً مركباً مثل x+y في نظام معادلتين، اجمع المعادلتين أو اطرحهما مباشرةً بدلاً من إيجاد كل متغير على حدة.
[Practice 1 · Hard] A 2D loss surface is defined as L(w1,w2)=4w12+7w22. Find the gradient vector ∇L at the point (w1,w2)=(2,−1).[تدريب 1 · Hard] A 2D loss surface is defined as L(w1,w2)=4w12+7w22. Find the gradient vector ∇L at the point (w1,w2)=(2,−1).
[Practice 2 · Easy] A fully-connected dense layer maps an input x∈R50 to y∈R25 using y=Wx+b. How many total learnable parameters are in this layer?[تدريب 2 · Easy] A fully-connected dense layer maps an input x∈R50 to y∈R25 using y=Wx+b. How many total learnable parameters are in this layer?
💡 Hint 1 of 3
The weight matrix W has shape 25×50, giving 1250 weights.
The weight matrix W has shape 25×50, giving 1250 weights.
💡 Hint 2 of 3
The bias vector b has 25 parameters.
The bias vector b has 25 parameters.
💡 Hint 3 of 3
Substitute the result from the previous step into the governing relation and verify the problem condition to find the final answer.
Substitute the result from the previous step into the governing relation and verify the problem condition to find the final answer.
The weight matrix W has shape 25×50, giving 1250 weights. The bias vector b has 25 parameters. Total = 1250+25=1275.The weight matrix W has shape 25×50, giving 1250 weights. The bias vector b has 25 parameters. Total = 1250+25=1275.
[Practice 3 · Easy] In a dataset, the prior probability of class C1 is P(C1)=0.10. What is the probability of the complement class P(¬C1)?[تدريب 3 · Easy] In a dataset, the prior probability of class C1 is P(C1)=0.10. What is the probability of the complement class P(¬C1)?
💡 Hint 1 of 3
By the complement rule of probability: P(egC1)=1−P(C1).
By the complement rule of probability: P(egC1)=1−P(C1).
💡 Hint 2 of 3
Substitute and simplify: P(egC1)=1−0.10.
Substitute and simplify: P(egC1)=1−0.10.
💡 Hint 3 of 3
Compute the final value from: 1−0.10.
Compute the final value from: 1−0.10.
By the complement rule of probability: P(egC1)=1−P(C1)=1−0.10=0.90.By the complement rule of probability: P(egC1)=1−P(C1)=1−0.10=0.90.
[Practice 4 · Medium] Consider a simple linear regression model where a dependent variable y is predicted from an independent variable x. The model is given by the equation y=β0+β1x+ϵ, where ϵ is the error term. Suppose we have estimated the regression line to be y^=3+2x. If we observe an independent variable value of x=4, what is the predicted value y^ for the dependent variable?[تدريب 4 · Medium] Consider a simple linear regression model where a dependent variable y is predicted from an independent variable x. The model is given by the equation y=β0+β1x+ϵ, where ϵ is the error term. Suppose we have estimated the regression line to be y^=3+2x. If we observe an independent variable value of x=4, what is the predicted value y^ for the dependent variable?
💡 Hint 1 of 3
The problem asks for the predicted value y^ given an independent variable value x=4 and a linear regression equation y^=3+2x. We substitute the value of x into the equation: y^=3+2(4).
The problem asks for the predicted value y^ given an independent variable value x=4 and a linear regression equation y^=3+2x. We substitute the value of x into the equation: y^=3+2(4).
💡 Hint 2 of 3
Rewrite and simplify to obtain: y^=3+8y^=11.
Rewrite and simplify to obtain: y^=3+8y^=11.
💡 Hint 3 of 3
Therefore, the predicted value for the dependent variable is 11.
Therefore, the predicted value for the dependent variable is 11.
The problem asks for the predicted value y^ given an independent variable value x=4 and a linear regression equation y^=3+2x. We substitute the value of x into the equation:
y^=3+2(4)y^=3+8y^=11
Therefore, the predicted value for the dependent variable is 11. Common errors might involve incorrectly multiplying 2 by 4 or incorrectly adding 3 to 8.The problem asks for the predicted value y^ given an independent variable value x=4 and a linear regression equation y^=3+2x. We substitute the value of x into the equation:
y^=3+2(4)y^=3+8y^=11
Therefore, the predicted value for the dependent variable is 11. Common errors might involve incorrectly multiplying 2 by 4 or incorrectly adding 3 to 8.
[Practice 5 · Hard] In anomaly detection, anomaly prior P(A)=0.10, detection sensitivity P(+∣A)=0.95, and false alarm rate P(+∣¬A)=0.05. By Bayes' theorem, what is the posterior probability P(A∣+) that an alarm is a true anomaly?[تدريب 5 · Hard] In anomaly detection, anomaly prior P(A)=0.10, detection sensitivity P(+∣A)=0.95, and false alarm rate P(+∣¬A)=0.05. By Bayes' theorem, what is the posterior probability P(A∣+) that an alarm is a true anomaly?
💡 Hint 1 of 3
By Bayes' Rule: P(A∣+)=P(+∣A)P(A)+P(+∣egA)P(egA)P(+∣A)P(A).
By Bayes' Rule: P(A∣+)=P(+∣A)P(A)+P(+∣egA)P(egA)P(+∣A)P(A).
💡 Hint 2 of 3
Substitute and simplify: P(A∣+)=0.95(0.10)+0.05(0.90)0.95×0.10.
Substitute and simplify: P(A∣+)=0.95(0.10)+0.05(0.90)0.95×0.10.
💡 Hint 3 of 3
Compute the final value from: 0.14000.0950.
Compute the final value from: 0.14000.0950.
By Bayes' Rule: P(A∣+)=P(+∣A)P(A)+P(+∣egA)P(egA)P(+∣A)P(A)=0.95(0.10)+0.05(0.90)0.95×0.10=0.14000.0950=0.679.By Bayes' Rule: P(A∣+)=P(+∣A)P(A)+P(+∣egA)P(egA)P(+∣A)P(A)=0.95(0.10)+0.05(0.90)0.95×0.10=0.14000.0950=0.679.
🤖 AI Math Unit 7 — Logistic ClassificationApplied STEM · Binary classification & probabilities · The Sigmoid function σ(z) = 1 / (1 + e⁻ᶻ) · Log-odds (Logit) transformation · Binary Cross-Entropy (Log Loss) function · Linear decision boundaries and threshold tuning
When the target variable is categorical (0 or 1, positive or negative), standard linear regression fails. Logistic regression maps continuous linear combinations to calibrated probabilities using the Sigmoid curve.عندما the target المتغير is categorical (0 or 1, positive or negative), standard linear regression fails. Logistic regression maps continuous linear combinations to calibrated probabilities using the Sigmoid curve.
Accumulation, Antiderivatives & Differential Flows: By the Fundamental Theorem of Calculus, the accumulation function A(x)=∫axf(t)dt satisfies A′(x)=f(x), linking instantaneous rates of change to net signed area. In first-order differential equations dxdy=g(x)h(y), separation of variables ∫h(y)1dy=∫g(x)dx+C reconstructs the family of integral curves across the slope field.
التراكم والتكامل والمعادلات التفاضلية: تربط النظرية الأساسية للتفاضل والتكامل بين المشتقة والمساحة الموجهة dxd∫axf(t)dt=f(x).
Slope field for dxdy=x−y with the integral curve passing through initial condition (0,1).تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس الانحدار اللوجستي والحدود الفاصلة للتصنيف.
⊙ Explorer · Logistic Regression Sigmoid σ(wx + b) & Decision Boundary⊙ مستكشف تفاعلي · الانحدار اللوجستي ودالة السيجمويد σ(wx + b) وحد القرار
interactive
Live numerical table for Logistic Regression Sigmoid σ(wx + b) & Decision Boundaryجدول القيم العددية لـ ⊙ مستكشف تفاعلي · الانحدار اللوجستي ودالة السيجمويد σ(wx + b) وحد القرار
Class 0 (indigo dots at y=0) and Class 1 (amber dots at y=1) are separated by the sigmoid curve P(y=1∣x)=1/(1 + e^(−(wx+b))), which crosses 0.5 at x* = −b/w.يفصل منحنى السيجمويد P(y=1|x) = 1/(1 + e^(−(wx+b))) بين الفئة 0 والفئة 1 عند حد القرار الرأسي x* = −b/w.
Binary Classification Contingency Table
Pred Positive
Pred Negative
Actual Positive
45
10
Actual Negative
10
40
Binary Classification Contingency Table — illustrating key geometric and analytical relationships in Logistic Regression & Classification Boundaries.رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس الانحدار اللوجستي والحدود الفاصلة للتصنيف.
Odds RatioOdds Ratio (الانحدار اللوجستي والحدود الفاصلة للتصنيف)
◆ Why It Works — First-Principles Derivation (Logistic Regression & Classification Boundaries)◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (الانحدار اللوجستي والحدود الفاصلة للتصنيف)
Why Integration by Parts & Integrating Factors Work: Differentiating a product u(x)v(x) gives (uv)′=u′v+uv′. Integrating both sides and rearranging yields the Integration by Parts formula:
∫udxdvdx=uv−∫vdxdudx
Similarly, for a linear first-order ODE y′+P(x)y=Q(x), multiplying by the integrating factor μ(x)=e∫P(x)dx (which satisfies μ′(x)=P(x)μ(x)) collapses the left-hand side into an exact product derivative: dxd[μ(x)y]=μ(x)Q(x).
برهان التكامل بالتجزيء وعامل التكامل: من قاعدة مشتقة الضرب (uv)′=u′v+uv′ نحصل بتكامل الطرفين على ∫udv=uv−∫vdu. وبضرب المعادلة الخطية في μ(x)=e∫P(x)dx يتحول الطرف الأيسر إلى dxd[μ(x)y].
Worked Example 7.A — Probability & Cross-Entropy Calculationمثال محلول 7.A — الاحتمال & Cross-Entropy Calculation
A medical AI model has learned weights w=0.8 and bias b=−2.4 for predicting whether a tumor is malignant (y=1) based on diameter x in cm: z=0.8x−2.4,y^=σ(z) (a) Find the predicted malignancy probability for a tumor of diameter x=4.5 cm. (b) If the actual diagnosis was malignant (y=1), calculate the binary cross-entropy loss L.
Solution: (a) Compute logit z: z=0.8(4.5)−2.4=3.6−2.4=1.2. Compute probability via Sigmoid: y^=σ(1.2)=1+e−1.21=1+0.30121=1.30121≈0.7685 (76.85% probability).
(b) Binary cross-entropy with y=1: L=−[1⋅ln(0.7685)+0⋅ln(1−0.7685)]=−ln(0.7685)≈−(−0.2633)=0.2633. Answer: (a) y^≈0.769 (76.9%), (b) Loss L≈0.263.
A medical AI model has learned weights w=0.8 and bias b=−2.4 for predicting whether a tumor is malignant (y=1) based on القطر x in cm: z=0.8x−2.4,y^=σ(z) (a) أوجد predicted malignancy الاحتمال for a tumor of القطر x=4.5 cm. (b) If the actual diagnosis was malignant (y=1), احسب binary cross-entropy loss L.
(b) Binary cross-entropy with y=1: L=−[1⋅ln(0.7685)+0⋅ln(1−0.7685)]=−ln(0.7685)≈−(−0.2633)=0.2633. Answer: (a) y^≈0.769 (76.9%), (b) Loss L≈0.263.
Worked Example B — Logistic Regression & Classification Boundaries (Hard Application)مثال محلول B — الانحدار اللوجستي والحدود الفاصلة للتصنيف (تطبيق Hard)
Problem (Hard): Consider a binary classification problem where the decision boundary is defined by the logistic function p(x)=1+e−(β0+β1x1+β2x2)1, which represents the probability of a data point x=(x1,x2) belonging to class 1. The estimated model parameters are β0=−3, β1=1, and β2=−2. We are interested in the geometric shape of the classification boundary. The classification boundary occurs where p(x)=0.5. Find the equation of this boundary in the x1x2-plane.
Step-by-Step Solution: The logistic regression model gives the probability of belonging to class 1 as p(x)=1+e−(β0+β1x1+β2x2)1. The classification boundary is the set of points where p(x)=0.5.
Setting p(x)=0.5, we have:
0.5=1+e−(β0+β1x1+β2x2)1
This implies:
1+e−(β0+β1x1+β2x2)=2
Therefore:
e−(β0+β1x1+β2x2)=1
Taking the natural logarithm of both sides:
−(β0+β1x1+β2x2)=ln(1)
Since ln(1)=0, we get:
β0+β1x1+β2x2=0
This is the equation of the linear decision boundary.
Substitute the given parameter values: β0=−3, β1=1, and β2=−2.
−3+x1+(−2)⋅x2=0−3+x1−2x2=0
We need to express this in the form x2=f(x1).
2x2=x1−3x2=21x1−23
This matches choice A.
مسألة (Hard): Consider a binary classification problem where the decision boundary is defined by the logistic function p(x)=1+e−(β0+β1x1+β2x2)1, which represents the probability of a data point x=(x1,x2) belonging to class 1. The estimated model parameters are β0=−3, β1=1, and β2=−2. We are interested in the geometric shape of the classification boundary. The classification boundary occurs where p(x)=0.5. Find the equation of this boundary in the x1x2-plane.
الحل خطوة بخطوة: The logistic regression model gives the probability of belonging to class 1 as p(x)=1+e−(β0+β1x1+β2x2)1. The classification boundary is the set of points where p(x)=0.5.
Setting p(x)=0.5, we have:
0.5=1+e−(β0+β1x1+β2x2)1
This implies:
1+e−(β0+β1x1+β2x2)=2
Therefore:
e−(β0+β1x1+β2x2)=1
Taking the natural logarithm of both sides:
−(β0+β1x1+β2x2)=ln(1)
Since ln(1)=0, we get:
β0+β1x1+β2x2=0
This is the equation of the linear decision boundary.
Substitute the given parameter values: β0=−3, β1=1, and β2=−2.
−3+x1+(−2)⋅x2=0−3+x1−2x2=0
We need to express this in the form x2=f(x1).
2x2=x1−3x2=21x1−23
This matches choice A.
Worked Example C — Logistic Regression & Classification Boundaries (Easy Application)مثال محلول C — الانحدار اللوجستي والحدود الفاصلة للتصنيف (تطبيق Easy)
Problem (Easy): Consider a simple logistic regression model where the decision boundary is defined by the linear equation w1x1+w2x2+b=0. If the weights are w1=2 and w2=3, and the bias is b=−7, what is the equation of the decision boundary?
Step-by-Step Solution: The decision boundary in a logistic regression model is defined by the equation where the log-odds are zero. This corresponds to a linear combination of the input features and weights, plus the bias, being equal to zero. Given the weights w1=2 and w2=3, and the bias b=−7, the equation of the decision boundary is w1x1+w2x2+b=0. Substituting the given values, we get 2x1+3x2+(−7)=0, which simplifies to 2x1+3x2−7=0.
مسألة (Easy): Consider a simple logistic regression model where the decision boundary is defined by the linear equation w1x1+w2x2+b=0. If the weights are w1=2 and w2=3, and the bias is b=−7, what is the equation of the decision boundary?
الحل خطوة بخطوة: The decision boundary in a logistic regression model is defined by the equation where the log-odds are zero. This corresponds to a linear combination of the input features and weights, plus the bias, being equal to zero. Given the weights w1=2 and w2=3, and the bias b=−7, the equation of the decision boundary is w1x1+w2x2+b=0. Substituting the given values, we get 2x1+3x2+(−7)=0, which simplifies to 2x1+3x2−7=0.
Worked Example D — Logistic Regression & Classification Boundaries (Medium Application)مثال محلول D — الانحدار اللوجستي والحدود الفاصلة للتصنيف (تطبيق Medium)
Problem (Medium): Consider a simple logistic regression model where the decision boundary is defined by the equation −1.5x1+2x2+5=0. For a data point (x1,x2), if \( -1.5x_1 + 2x_2 + 5 < 0 \), it is classified into Class 0. Otherwise, it is classified into Class 1. Which of the following points lies on the decision boundary?
Step-by-Step Solution: The decision boundary is defined by the equation −1.5x1+2x2+5=0. To find which point lies on the boundary, we substitute the coordinates of each point into the equation. For point (−1,1): −1.5(−1)+2(1)+5=1.5+2+5=8.5, which is not 0. For point (2,−2): −1.5(2)+2(−2)+5=−3−4+5=−2, which is not 0. For point (0,−2.5): −1.5(0)+2(−2.5)+5=0−5+5=0. This point lies on the boundary. For point (3,0.5): −1.5(3)+2(0.5)+5=−4.5+1+5=1.5, which is not 0. Therefore, the point (0,−2.5) lies on the decision boundary.
مسألة (Medium): Consider a simple logistic regression model where the decision boundary is defined by the equation −1.5x1+2x2+5=0. For a data point (x1,x2), if \( -1.5x_1 + 2x_2 + 5 < 0 \), it is classified into Class 0. Otherwise, it is classified into Class 1. Which of the following points lies on the decision boundary?
الحل خطوة بخطوة: The decision boundary is defined by the equation −1.5x1+2x2+5=0. To find which point lies on the boundary, we substitute the coordinates of each point into the equation. For point (−1,1): −1.5(−1)+2(1)+5=1.5+2+5=8.5, which is not 0. For point (2,−2): −1.5(2)+2(−2)+5=−3−4+5=−2, which is not 0. For point (0,−2.5): −1.5(0)+2(−2.5)+5=0−5+5=0. This point lies on the boundary. For point (3,0.5): −1.5(3)+2(0.5)+5=−4.5+1+5=1.5, which is not 0. Therefore, the point (0,−2.5) lies on the decision boundary.
⚠️ Common Exam Traps — Logistic Regression & Classification Boundaries⚠️ أخطاء شائعة في الاختبار — الانحدار اللوجستي والحدود الفاصلة للتصنيف
1. Adding +C Only After Exponentiating in Separable ODEs: In dxdy=3xy, integrating gives ln∣y∣=23x2+C⟹y=Ae3x2/2 where A=±eC. Writing y=e3x2/2+C is a fatal algebraic error that forfeits all follow-up marks on Mathematics for Artificial Intelligence & Machine Learning.
2. Forgetting to Transform Limits in u-Substitution: In definite integrals ∫abf(g(x))g′(x)dx, you must replace the limits x=a,b with u=g(a),g(b) immediately.
1. خطأ إضافة ثابت التكامل بعد أخذ الدالة الأسية: في المعادلة ln∣y∣=g(x)+C يصبح الحل y=Aeg(x) وليس y=eg(x)+C.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Logistic Regression & Classification Boundaries)تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (الانحدار اللوجستي والحدود الفاصلة للتصنيف)
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Writing ln∣y∣=x2+C⟹y=ex2+Cالخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Exponentiation distributes over addition as multiplication (ea+b=eaeb), not addition.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Write y=ex2+C=Aex2 and solve for A using the initial condition.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Leaving original x-limits on a u-substituted definite integralالخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Evaluates the antiderivative F(u) at x-values instead of u(x)-values.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Convert bounds immediately: ulow=u(a) and uhigh=u(b).تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Computing total distance as ∫t1t2v(t)dtالخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Cancels forward and backward motion (net displacement) instead of accumulating total path length.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Split the integral at every root where v(t)=0 and integrate ∣v(t)∣.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Quick Verification Trick (Mathematics for Artificial Intelligence & Machine Learning): For any indefinite integral ∫f(x)dx=F(x)+C, differentiate your answer F′(x) mentally—especially the coefficient 1/k from chain-rule reversal ∫ekxdx=k1ekx+C—before moving on.
فحص سريع للتكامل: اشتق الناتج النهائي ذهنياً للتأكد من صحة المعامل العكسي 1/k الناتج عن قاعدة السلسلة.
[Practice 1 · Hard] The sigmoid activation function is σ(z)=1+e−z1. If σ(z0)=0.40, what is the value of the derivative σ′(z0)?[تدريب 1 · Hard] The sigmoid activation function is σ(z)=1+e−z1. If σ(z0)=0.40, what is the value of the derivative σ′(z0)?
💡 Hint 1 of 3
The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)).
The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)).
💡 Hint 2 of 3
Substituting σ(z0)=0.40: σ′(z0)=(0.40)(1−0.40). Substitute and simplify: σ′(z0)=(0.40)(0.60).
Substituting σ(z0)=0.40: σ′(z0)=(0.40)(1−0.40). Substitute and simplify: σ′(z0)=(0.40)(0.60).
💡 Hint 3 of 3
Compute the final value from: (0.40)(0.60).
Compute the final value from: (0.40)(0.60).
The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)). Substituting σ(z0)=0.40: σ′(z0)=(0.40)(1−0.40)=(0.40)(0.60)=0.2400.The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)). Substituting σ(z0)=0.40: σ′(z0)=(0.40)(1−0.40)=(0.40)(0.60)=0.2400.
[Practice 2 · Easy] A fitted simple linear regression model is y^=7x+18. What is the predicted target value y^ when the input feature is x=4?[تدريب 2 · Easy] A fitted simple linear regression model is y^=7x+18. What is the predicted target value y^ when the input feature is x=4?
💡 Hint 1 of 3
Substitute x=4 into the regression equation: y^=7(4)+18.
Substitute x=4 into the regression equation: y^=7(4)+18.
💡 Hint 2 of 3
Substitute and simplify: y^=28+18.
Substitute and simplify: y^=28+18.
💡 Hint 3 of 3
Compute the final value from: 28+18.
Compute the final value from: 28+18.
Substitute x=4 into the regression equation: y^=7(4)+18=28+18=46.Substitute x=4 into the regression equation: y^=7(4)+18=28+18=46.
[Practice 3 · Medium] A binary classification model uses a logistic sigmoid function σ(z)=1+e−z1. The decision boundary is defined by σ(z)=0.5, where z=w1x1+w0. For a dataset with two features x1 and x2, the model's linear component is z=2x1−x2+b. If the classification boundary passes through the point (x1,x2)=(3,1), what is the value of the bias b?[تدريب 3 · Medium] A binary classification model uses a logistic sigmoid function σ(z)=1+e−z1. The decision boundary is defined by σ(z)=0.5, where z=w1x1+w0. For a dataset with two features x1 and x2, the model's linear component is z=2x1−x2+b. If the classification boundary passes through the point (x1,x2)=(3,1), what is the value of the bias b?
💡 Hint 1 of 3
The logistic sigmoid function is σ(z)=1+e−z1. The decision boundary is where σ(z)=0.5. Setting σ(z)=0.5 gives 1+e−z1=0.5, which implies 1=0.5(1+e−z), so 2=1+e−z, and e−z=1. This occurs when −z=0, or z=0. Therefore, the decision boundary is defined by z=0.
The logistic sigmoid function is σ(z)=1+e−z1. The decision boundary is where σ(z)=0.5. Setting σ(z)=0.5 gives 1+e−z1=0.5, which implies 1=0.5(1+e−z), so 2=1+e−z, and e−z=1. This occurs when −z=0, or z=0. Therefore, the decision boundary is defined by z=0.
💡 Hint 2 of 3
The linear component of the model is given by z=w1x1+w2x2+b. In this problem, z=2x1−x2+b. Since the decision boundary is z=0, we have 2x1−x2+b=0.
The linear component of the model is given by z=w1x1+w2x2+b. In this problem, z=2x1−x2+b. Since the decision boundary is z=0, we have 2x1−x2+b=0.
💡 Hint 3 of 3
Use the resulting form to finish: 5+b.
Use the resulting form to finish: 5+b.
The logistic sigmoid function is σ(z)=1+e−z1. The decision boundary is where σ(z)=0.5. Setting σ(z)=0.5 gives 1+e−z1=0.5, which implies 1=0.5(1+e−z), so 2=1+e−z, and e−z=1. This occurs when −z=0, or z=0. Therefore, the decision boundary is defined by z=0.
The linear component of the model is given by z=w1x1+w2x2+b. In this problem, z=2x1−x2+b.
Since the decision boundary is z=0, we have 2x1−x2+b=0.
The classification boundary passes through the point (x1,x2)=(3,1). Substituting these values into the equation for the decision boundary:
2(3)−1+b=06−1+b=05+b=0b=−5The logistic sigmoid function is σ(z)=1+e−z1. The decision boundary is where σ(z)=0.5. Setting σ(z)=0.5 gives 1+e−z1=0.5, which implies 1=0.5(1+e−z), so 2=1+e−z, and e−z=1. This occurs when −z=0, or z=0. Therefore, the decision boundary is defined by z=0.
The linear component of the model is given by z=w1x1+w2x2+b. In this problem, z=2x1−x2+b.
Since the decision boundary is z=0, we have 2x1−x2+b=0.
The classification boundary passes through the point (x1,x2)=(3,1). Substituting these values into the equation for the decision boundary:
2(3)−1+b=06−1+b=05+b=0b=−5
[Practice 4 · Hard] For a bivariate feature dataset, Cov(x,y)=24, Var(x)=8, xˉ=5, and yˉ=30. Compute the OLS regression slope β^1 and intercept β^0.[تدريب 4 · Hard] For a bivariate feature dataset, Cov(x,y)=24, Var(x)=8, xˉ=5, and yˉ=30. Compute the OLS regression slope β^1 and intercept β^0.
💡 Hint 1 of 3
The OLS slope is β^1=Var(x)Cov(x,y)=824.
The OLS slope is β^1=Var(x)Cov(x,y)=824.
💡 Hint 2 of 3
The intercept is: β^0=yˉ−β^1xˉ. Substitute and simplify: β^0=30−(3)(5).
The intercept is: β^0=yˉ−β^1xˉ. Substitute and simplify: β^0=30−(3)(5).
💡 Hint 3 of 3
Compute the final value from: 30−15.
Compute the final value from: 30−15.
The OLS slope is β^1=Var(x)Cov(x,y)=824=3. The intercept is β^0=yˉ−β^1xˉ=30−(3)(5)=30−15=15.The OLS slope is β^1=Var(x)Cov(x,y)=824=3. The intercept is β^0=yˉ−β^1xˉ=30−(3)(5)=30−15=15.
[Practice 5 · Easy] In evaluating a binary classifier, the confusion matrix shows TP=45, TN=40, FP=10, and FN=10. Compute the overall classification accuracy.[تدريب 5 · Easy] In evaluating a binary classifier, the confusion matrix shows TP=45, TN=40, FP=10, and FN=10. Compute the overall classification accuracy.
💡 Hint 1 of 3
Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TN+FP+FNTP+TN.
Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TN+FP+FNTP+TN.
💡 Hint 2 of 3
Substitute and simplify: Accuracy=10545+40.
Substitute and simplify: Accuracy=10545+40.
💡 Hint 3 of 3
Compute the final value from: 10545+40.
Compute the final value from: 10545+40.
Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TN+FP+FNTP+TN=10545+40=10585=81.0%.Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TN+FP+FNTP+TN=10545+40=10585=81.0%.
🤖 AI Math Unit 8 — Dimensionality Reduction & PCAApplied STEM · Curse of dimensionality in high-dimensional data · Sample covariance matrix Σ · Eigenvalues λ and Eigenvectors v · Principal Component Analysis (PCA) projection · Explained variance ratio and data compression
Real datasets frequently have hundreds or thousands of correlated features. Principal Component Analysis (PCA) identifies the orthogonal axes of maximum variance, compressing high-dimensional data while preserving essential information.
الشرح الرياضي (تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA)):
Real datasets frequently have hundreds or thousands of correlated features. Principal Component Analysis (PCA) identifies the orthogonal axes of maximum variance, compressing high-dimensional data while preserving essential information.
▲ Theorem 8.1 — PCA via Spectral Decomposition▲ مبرهنة 8.1 — PCA via Spectral Decomposition
Let X∈RN×d be a zero-centered data matrix (mean xˉ=0). 1. The empirical covariance matrix is Σ=N−11XTX∈Rd×d. 2. Because Σ is symmetric positive semi-definite, it admits an orthonormal eigen-decomposition: Σvi=λivi,λ1≥λ2≥⋯≥λd≥0 3. The first principal component v1 is the unit eigenvector associated with the largest eigenvalue λ1, maximizing the variance of the projected data.
Let X∈RN×d be a zero-centered data المصفوفة (mean xˉ=0). 1. The empirical covariance المصفوفة is Σ=N−11XTX∈Rd×d. 2. Because Σ is symmetric positive semi-definite, it admits an orthonormal eigen-decomposition: Σvi=λivi,λ1≥λ2≥⋯≥λd≥0 3. The first principal component v1 is the unit eigenvector associated with the largest eigenvalue λ1, maximizing the variance of the projected data.
Linear Structure, Inner Products & Geometric Transformations: In Rn, the dot product u⋅v=∥u∥∥v∥cosθ=∑i=1nuivi encodes orthogonality (u⊥v⟺u⋅v=0) and orthogonal projection projvu=∥v∥2u⋅vv. For a matrix transformation A∈Rn×n, ∣det(A)∣ measures the local volume scaling factor, and A is invertible if and only if det(A)=0 (equivalently, all eigenvalues λi=0).
الفضاءات المتجهية والتحويلات الخطية: يقيس الضرب القياسي u⋅v الزاوية والتعامد بين المتجهات، بينما يقيس محدد المصفوفة ∣det(A)∣ معامل تغير المساحة أو الحجم.
Coordinate grid showing geometric action of a linear transformation mapping △ABC to its image △A'B'C'.تمثيل هندسي وبياني يوضح العلاقات الأساسية في درس تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA).
⊙ Explorer · PCA: Covariance Point Cloud, Principal Axis v1 & Projections⊙ مستكشف تفاعلي · تحليل المركبات الأساسية (PCA): المحور الرئيسي v₁ والإسقاطات المتعامدة
interactive
Live numerical table for PCA: Covariance Point Cloud, Principal Axis v1 & Projectionsجدول القيم العددية لـ ⊙ مستكشف تفاعلي · تحليل المركبات الأساسية (PCA): المحور الرئيسي v₁ والإسقاطات المتعامدة
Parameter / Metricالمتغير / المعيار
Valueالقيمة
Projected Variance along u(θ)Projected Variance along u(θ)Var_θ=1.752
Optimal First Eigenvector θ*Optimal First Eigenvector θ*θ∗=45.0∘
Rotate unit direction vector u(θ) through the centered 2D data cloud. PCA chooses the angle θ* that maximizes the variance of the orthogonal projections (and minimizes perpendicular reconstruction error).أدر متجه الاتجاه u(θ) عبر سحابة البيانات لاكتشاف الزاوية θ* التي تعظم تباين الإسقاطات المتعامدة.
Dimensionality Reduction, Covariance & PCA — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Dimensionality Reduction, Covariance & PCA.رسم توضيحي يبيّن العلاقات الرياضية والهندسية في درس تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA).
◆ Why It Works — First-Principles Derivation (Dimensionality Reduction, Covariance & PCA)◆ لماذا تعمل هذه القاعدة — الاشتقاق الرياضي (تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA))
Why Orthogonal Projection & Eigenvalue Characteristic Equations Work: Decompose u=cv+w where w⊥v. Taking the dot product with v uses w⋅v=0 to isolate c:
u⋅v=c(v⋅v)+0⟹c=∥v∥2u⋅v
For eigenvalues, Av=λv with v=0 is equivalent to (A−λI)v=0. A homogeneous linear system has a non-trivial nullspace vector v=0 if and only if the matrix A−λI is singular, yielding the characteristic polynomial det(A−λI)=0.
برهان صيغة المسقط العمودي والمعادلة المميزة للقيم الذاتية: من شرط التعامد (u−cv)⋅v=0 ينتج c=∥v∥2u⋅v. وشرط وجود متجه ذاتي غير صفري (A−λI)v=0 يكافئ انعدام المحدد det(A−λI)=0.
Worked Example 8.A — Finding Principal Components of 2D Dataمثال محلول 8.A — Finding Principal Components of 2D Data
A 2D centered dataset has sample covariance matrix: Σ=(4221) (a) Find the eigenvalues λ1 and λ2. (b) Find the unit eigenvector v1 corresponding to the principal component. (c) What percentage of total variance is explained by the first principal component?
Solution: (a) Characteristic equation det(Σ−λI)=0: det(4−λ221−λ)=(4−λ)(1−λ)−(2)(2)=0 λ2−5λ+4−4=0⟹λ2−5λ=0⟹λ(λ−5)=0. Eigenvalues are λ1=5 and λ2=0.
(b) For λ1=5: (Σ−5I)v=(−122−4)(v1v2)=(00)⟹−v1+2v2=0⟹v1=2v2. A directional vector is (21). Normalizing to unit length: ∥v∥=22+12=5⟹v1=51(21)=(2/51/5)≈(0.8940.447).
(c) Total variance = λ1+λ2=5+0=5. Percentage explained = 55=100%. (The data lies perfectly along a 1D line in 2D space!). Answer:λ1=5,λ2=0; v1=[0.894,0.447]T; 100% variance explained.
A 2D centered dataset has sample covariance المصفوفة: Σ=(4221) (a) أوجد القيم الذاتية λ1 and λ2. (b) أوجد unit eigenvector v1 corresponding to the principal component. (c) What percentage of total variance is explained by the first principal component?
Solution: (a) Characteristic المعادلة det(Σ−λI)=0: det(4−λ221−λ)=(4−λ)(1−λ)−(2)(2)=0 λ2−5λ+4−4=0⟹λ2−5λ=0⟹λ(λ−5)=0. Eigenvalues are λ1=5 and λ2=0.
(b) For λ1=5: (Σ−5I)v=(−122−4)(v1v2)=(00)⟹−v1+2v2=0⟹v1=2v2. A directional المتجه is (21). Normalizing to unit length: ∥v∥=22+12=5⟹v1=51(21)=(2/51/5)≈(0.8940.447).
(c) Total variance = λ1+λ2=5+0=5. Percentage explained = 55=100%. (The data lies perfectly along a 1D line in 2D space!). Answer:λ1=5,λ2=0; v1=[0.894,0.447]T; 100% variance explained.
Worked Example B — Dimensionality Reduction, Covariance & PCA (Easy Application)مثال محلول B — تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA) (تطبيق Easy)
Problem (Easy): Consider a 2D data point v=[3−4]. What is the squared Euclidean norm (or squared magnitude) of this vector?
Step-by-Step Solution: The squared Euclidean norm of a vector v=[v1v2] is given by ∥v∥2=v12+v22. For the given vector v=[3−4], the squared Euclidean norm is (3)2+(−4)2=9+16=25.
مسألة (Easy): Consider a 2D data point v=[3−4]. What is the squared Euclidean norm (or squared magnitude) of this vector?
الحل خطوة بخطوة: The squared Euclidean norm of a vector v=[v1v2] is given by ∥v∥2=v12+v22. For the given vector v=[3−4], the squared Euclidean norm is (3)2+(−4)2=9+16=25.
Worked Example C — Dimensionality Reduction, Covariance & PCA (Medium Application)مثال محلول C — تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA) (تطبيق Medium)
Problem (Medium): A binary classifier p(t) produces the confusion matrix below with TP=68, FP=10, FN=48, and TN=80. Determine the total number of correct classifications q=TP+TN.
Step-by-Step Solution: Summing TP+TN=68+80=148.
مسألة (Medium): A binary classifier p(t) produces the confusion matrix below with TP=68, FP=10, FN=48, and TN=80. Determine the total number of correct classifications q=TP+TN.
الحل خطوة بخطوة: Summing TP+TN=68+80=148.
Worked Example D — Dimensionality Reduction, Covariance & PCA (Hard Application)مثال محلول D — تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA) (تطبيق Hard)
Problem (Hard): Consider a 2D dataset represented by the points A=(1,2), B=(4,2), and C=(2,5). If this dataset undergoes a linear transformation represented by the matrix M=(2001), what are the coordinates of the transformed points A′, B′, and C′?
Step-by-Step Solution: The transformation of a point x by a matrix M is given by Mx. We apply the matrix M=(2001) to each point:
For point A=(1,2), the transformed point A′ is:
(2001)(12)=(2×1+0×20×1+1×2)=(22) So, A′=(2,2).
For point B=(4,2), the transformed point B′ is:
(2001)(42)=(22) So, B′=(8,2).
For point C=(2,5), the transformed point C′ is:
(2001)(25)=(2×2+0×50×2+1×5)=(45) So, C′=(4,5).
Therefore, the transformed points are A′=(2,2), B′=(8,2), and C′=(4,5).
مسألة (Hard): Consider a 2D dataset represented by the points A=(1,2), B=(4,2), and C=(2,5). If this dataset undergoes a linear transformation represented by the matrix M=(2001), what are the coordinates of the transformed points A′, B′, and C′?
الحل خطوة بخطوة: The transformation of a point x by a matrix M is given by Mx. We apply the matrix M=(2001) to each point:
For point A=(1,2), the transformed point A′ is:
(2001)(12)=(2×1+0×20×1+1×2)=(22) So, A′=(2,2).
For point B=(4,2), the transformed point B′ is:
(2001)(42)=(22) So, B′=(8,2).
For point C=(2,5), the transformed point C′ is:
(2001)(25)=(2×2+0×50×2+1×5)=(45) So, C′=(4,5).
Therefore, the transformed points are A′=(2,2), B′=(8,2), and C′=(4,5).
⚠️ Common Exam Traps — Dimensionality Reduction, Covariance & PCA⚠️ أخطاء شائعة في الاختبار — تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA)
1. Non-Commutativity of Matrix Multiplication & Cross Products: On Mathematics for Artificial Intelligence & Machine Learning, assuming AB=BA (so expanding (A+B)2 as A2+2AB+B2 instead of A2+AB+BA+B2) or forgetting u×v=−(v×u) invalidates matrix proofs.
2. Using Position Vectors Instead of Direction Vectors for Angles: To find the angle at vertex B of triangle ABC, you must use tail-to-tail vectors BA and BC, never AB⋅BC (which finds the exterior supplementary angle 180∘−B).
1. عدم إبدالية ضرب المصفوفات: حاصل الضرب AB لا يساوي BA عموماً، وعند حساب الزاوية عند الرأس B يجب استخدام المتجهين المنطلقين من B وهما BA و BC.
Error Diagnosis — Common Student Traps vs. Exam-Board Method (Dimensionality Reduction, Covariance & PCA)تشخيص الأخطاء — مقارنة الخطأ الشائع بالطريقة الصحيحة (تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA))
Common Student Trapالخطأ الشائع للطالب
Why It Fails Mathematicallyالسبب الرياضي للخطأ
Correct Exam-Board Methodالطريقة الصحيحة المعتمدة
Computing angle at B using AB⋅BCالخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Vectors are head-to-tail instead of tail-to-tail, giving 180∘−θ.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Reverse AB so both emanate from B: use BA⋅BC.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Using the same parameter t for two intersecting 3D lines r1(t)=r2(t)الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Tests for a simultaneous collision at time t rather than geometric intersection of paths.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Assign distinct parameters λ and μ to the two lines before equating components.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Assuming (AB)−1=A−1B−1الخطأ الشائع في تطبيق القاعدة الجبرية أو الهندسية دون التحقق من شروط المجال.
Multiplying (AB)(A−1B−1) does not cancel inner factors when AB=BA.يؤدي إلى فقدان جذور صحيحة أو إدخال جذور دخيلة لا تحقق المعادلة الأصلية.
Use the shoe-sock reversal law: (AB)−1=B−1A−1.تطبيق القانون الأساسي خطوة بخطوة مع التحقق من القيود والإشارات.
Fast Matrix & Vector Verification (Mathematics for Artificial Intelligence & Machine Learning): Check every 2×2 or 3×3 eigenvalue computation using the trace and determinant invariants: ∑λi=tr(A) (sum of diagonal entries) and ∏λi=det(A).
فحص سريع للقيم الذاتية: تحقق دائماً من أن مجموع القيم الذاتية يساوي أثر المصفوفة tr(A) وحاصل ضربها يساوي المحدد det(A).
[Practice 1 · Easy] Consider a dataset of observations {xi}i=1n where each xi is a 2-dimensional vector. The sample covariance matrix for this dataset is given by:
S=(4−2−21)
Principal Component Analysis (PCA) is applied to this dataset. The first principal component corresponds to the direction with the largest variance. Let the direction vector of the first principal component be v1=(ab). The variance explained by this principal component is given by the corresponding eigenvalue λ1.
If v1 is a unit vector, what is the value of a2+b2?[تدريب 1 · Easy] Consider a dataset of observations {xi}i=1n where each xi is a 2-dimensional vector. The sample covariance matrix for this dataset is given by:
S=(4−2−21)
Principal Component Analysis (PCA) is applied to this dataset. The first principal component corresponds to the direction with the largest variance. Let the direction vector of the first principal component be v1=(ab). The variance explained by this principal component is given by the corresponding eigenvalue λ1.
If v1 is a unit vector, what is the value of a2+b2?
💡 Hint 1 of 3
The first principal component direction vector v1 is an eigenvector of the covariance matrix S.
The first principal component direction vector v1 is an eigenvector of the covariance matrix S.
💡 Hint 2 of 3
The variance explained by this component is the corresponding eigenvalue λ1. The problem states that v1=(ab) is a unit vector.
The variance explained by this component is the corresponding eigenvalue λ1. The problem states that v1=(ab) is a unit vector.
💡 Hint 3 of 3
The specific values of a and b and the eigenvalues of S are not needed to answer this question, as it directly asks for the property of a unit vector.
The specific values of a and b and the eigenvalues of S are not needed to answer this question, as it directly asks for the property of a unit vector.
The first principal component direction vector v1 is an eigenvector of the covariance matrix S. The variance explained by this component is the corresponding eigenvalue λ1. The problem states that v1=(ab) is a unit vector. By definition, a unit vector has a magnitude of 1. The squared magnitude of a vector (ab) is a2+b2. Therefore, if v1 is a unit vector, its squared magnitude must be 1, which means a2+b2=1. The specific values of a and b and the eigenvalues of S are not needed to answer this question, as it directly asks for the property of a unit vector.The first principal component direction vector v1 is an eigenvector of the covariance matrix S. The variance explained by this component is the corresponding eigenvalue λ1. The problem states that v1=(ab) is a unit vector. By definition, a unit vector has a magnitude of 1. The squared magnitude of a vector (ab) is a2+b2. Therefore, if v1 is a unit vector, its squared magnitude must be 1, which means a2+b2=1. The specific values of a and b and the eigenvalues of S are not needed to answer this question, as it directly asks for the property of a unit vector.
[Practice 2 · Medium] Consider a dataset of n data points, each residing in RD. We are performing Principal Component Analysis (PCA) to reduce the dimensionality. The first three principal components capture 70% of the total variance, the first six capture 85%, and the first ten capture 92%. You are tasked with selecting a subset of principal components for a downstream machine learning model. If the model requires that at least 90% of the original variance be retained, and you want to use the minimum possible number of principal components, what is the dimensionality of the transformed data?[تدريب 2 · Medium] Consider a dataset of n data points, each residing in RD. We are performing Principal Component Analysis (PCA) to reduce the dimensionality. The first three principal components capture 70% of the total variance, the first six capture 85%, and the first ten capture 92%. You are tasked with selecting a subset of principal components for a downstream machine learning model. If the model requires that at least 90% of the original variance be retained, and you want to use the minimum possible number of principal components, what is the dimensionality of the transformed data?
💡 Hint 1 of 3
The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90%. The provided information states: - The first 3 principal components capture 70% of the variance.
The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90%. The provided information states: - The first 3 principal components capture 70% of the variance.
💡 Hint 2 of 3
- The first 6 principal components capture 85% of the variance. - The first 10 principal components capture 92% of the variance.
- The first 6 principal components capture 85% of the variance. - The first 10 principal components capture 92% of the variance.
💡 Hint 3 of 3
Therefore, the minimum number of principal components required to retain at least 90% of the variance is 10. When PCA reduces the dimensionality of data from RD to Rk using the top k principal components, the dimension of each transformed data point is k. In this case, k.
Therefore, the minimum number of principal components required to retain at least 90% of the variance is 10. When PCA reduces the dimensionality of data from RD to Rk using the top k principal components, the dimension of each transformed data point is k. In this case, k.
The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90%. The provided information states:
- The first 3 principal components capture 70% of the variance.
- The first 6 principal components capture 85% of the variance.
- The first 10 principal components capture 92% of the variance.
We need to find the smallest k such that the cumulative variance captured by the first k principal components is ≥90%.
Checking the given values:
- For k=3, variance captured = 70%, which is less than 90%.
- For k=6, variance captured = 85%, which is less than 90%.
- For k=10, variance captured = 92%, which is greater than or equal to 90%.
Therefore, the minimum number of principal components required to retain at least 90% of the variance is 10. When PCA reduces the dimensionality of data from RD to Rk using the top k principal components, the dimension of each transformed data point is k. In this case, k=10.The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90%. The provided information states:
- The first 3 principal components capture 70% of the variance.
- The first 6 principal components capture 85% of the variance.
- The first 10 principal components capture 92% of the variance.
We need to find the smallest k such that the cumulative variance captured by the first k principal components is ≥90%.
Checking the given values:
- For k=3, variance captured = 70%, which is less than 90%.
- For k=6, variance captured = 85%, which is less than 90%.
- For k=10, variance captured = 92%, which is greater than or equal to 90%.
Therefore, the minimum number of principal components required to retain at least 90% of the variance is 10. When PCA reduces the dimensionality of data from RD to Rk using the top k principal components, the dimension of each transformed data point is k. In this case, k=10.
[Practice 3 · Hard] In training a language model token predictor, a binary token occurs k=6 times across n=20 independent trials. What is the Maximum Likelihood Estimate p^MLE of the token probability?[تدريب 3 · Hard] In training a language model token predictor, a binary token occurs k=6 times across n=20 independent trials. What is the Maximum Likelihood Estimate p^MLE of the token probability?
💡 Hint 1 of 3
For a Bernoulli likelihood L(p)=pk(1−p)n−k, the log-likelihood is lnL=klnp+(n−k)ln(1−p).
For a Bernoulli likelihood L(p)=pk(1−p)n−k, the log-likelihood is lnL=klnp+(n−k)ln(1−p).
💡 Hint 2 of 3
Setting derivative to zero: pk−1−pn−k=0. Substitute and simplify: p^=nk.
Setting derivative to zero: pk−1−pn−k=0. Substitute and simplify: p^=nk.
💡 Hint 3 of 3
Evaluate the simplified expression: p^=206.
Evaluate the simplified expression: p^=206.
For a Bernoulli likelihood L(p)=pk(1−p)n−k, the log-likelihood is lnL=klnp+(n−k)ln(1−p). Setting derivative to zero: pk−1−pn−k=0⟹p^=nk=206=0.300.For a Bernoulli likelihood L(p)=pk(1−p)n−k, the log-likelihood is lnL=klnp+(n−k)ln(1−p). Setting derivative to zero: pk−1−pn−k=0⟹p^=nk=206=0.300.
[Practice 4 · Easy] An Ordinary Least Squares linear model p^(t)=2t+11 is evaluated at t=3. Determine the predicted response p^(3).[تدريب 4 · Easy] An Ordinary Least Squares linear model p^(t)=2t+11 is evaluated at t=3. Determine the predicted response p^(3).
💡 Hint 1 of 3
Start from the given mathematical expression in the prompt: p^(t)=2t+11.
Start from the given mathematical expression in the prompt: p^(t)=2t+11.
💡 Hint 2 of 3
Write out the unsimplified expression: 2(3)+11.
Write out the unsimplified expression: 2(3)+11.
💡 Hint 3 of 3
Perform the arithmetic in 2(3)+11 to find the final value.
Perform the arithmetic in 2(3)+11 to find the final value.
Evaluating 2(3)+11=17.Evaluating 2(3)+11=17.
[Practice 5 · Medium] A machine learning diagnostic test has sensitivity P(Positive∣Defect)=0.90. If the defect rate in production is P(Defect)=0.10, find the joint probability of a defect and a positive test result P(Defect∩Positive).[تدريب 5 · Medium] A machine learning diagnostic test has sensitivity P(Positive∣Defect)=0.90. If the defect rate in production is P(Defect)=0.10, find the joint probability of a defect and a positive test result P(Defect∩Positive).
💡 Hint 1 of 3
By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect).
By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect).
💡 Hint 2 of 3
Substitute and simplify: P(Defect∩Positive)=0.10×0.90.
Substitute and simplify: P(Defect∩Positive)=0.10×0.90.
💡 Hint 3 of 3
Compute the final value from: 0.10×0.90.
Compute the final value from: 0.10×0.90.
By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect)=0.10×0.90=0.0900.By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect)=0.10×0.90=0.0900.
Fifty applied mathematics problems for AI & Data Science spanning high-dimensional vectors and cosine similarity, neural layer matrix transformations, multivariable calculus and gradient descent optimization, conditional probability and Bayes' theorem, probability distributions and maximum likelihood estimation (MLE), ordinary least squares linear regression, logistic regression and cross-entropy loss, and covariance matrices and Principal Component Analysis (PCA).
1
In anomaly detection, anomaly prior P(A)=0.02, detection sensitivity P(+∣A)=0.95, and false alarm rate P(+∣¬A)=0.05. By Bayes' theorem, what is the posterior probability P(A∣+) that an alarm is a true anomaly?In anomaly detection, anomaly prior P(A)=0.02, detection sensitivity P(+∣A)=0.95, و false alarm rate P(+∣¬A)=0.05. By Bayes' theorem, what is the posterior probability P(A∣+) that an alarm is a true anomaly?
Advanced
By Bayes' Rule: P(A∣+)=P(+∣A)P(A)+P(+∣¬A)P(¬A)P(+∣A)P(A)=0.95(0.02)+0.05(0.98)0.95×0.02=0.06800.0190=0.279.
Final Answer:0.279
By Bayes' Rule: P(A∣+)=P(+∣A)P(A)+P(+∣¬A)P(¬A)P(+∣A)P(A)=0.95(0.02)+0.05(0.98)0.95×0.02=0.06800.0190=0.279.
الإجابة النهائية:0.279
2
Consider a dataset of n data points, each residing in RD. We are performing Principal Component Analysis (PCA) to reduce the dimensionality. The first three principal components capture 70% of the total variance, the first six capture 85%, and the first ten capture 92%. You are tasked with selecting a subset of principal components for a downstream machine learning model. If the model requires that at least 90% of the original variance be retained, and you want to use the minimum possible number of principal components, what is the dimensionality of the transformed data?Consider a dataset of n data points, each residing in RD. We are performing Principal Component Analysis (PCA) to reduce the dimensionality. The first three principal components capture 70% of the total variance, the first six capture 85%, و the first ten capture 92%. You are tasked with selecting a subset of principal components for a downstream machine learning model. إذا كان the model requires that at least 90% of the original variance be retained, و you want to use the minimum possible number of principal components, what is the dimensionality of the transformed data?
Advanced
The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90%. The provided information states:
- The first 3 principal components capture 70% of the variance. - The first 6 principal components capture 85% of the variance. - The first 10 principal components capture 92% of the variance.
We need to find the smallest k such that the cumulative variance captured by the first k principal components is ≥90%.
Checking the given values: - For k=3, variance captured = 70%, which is less than 90%. - For k=6, variance captured = 85%, which is less than 90%. - For k=10, variance captured = 92%, which is greater than or equal to 90%.
Therefore, the minimum number of principal components required to retain at least 90% of the variance is 10. When PCA reduces the dimensionality of data from RD to Rk using the top k principal components, the dimension of each transformed data point is k. In this case, k=10.
The problem requires us to أوجد minimum number of principal components such that the cumulative explained variance is at least 90%. The provided information states:
- The first 3 principal components capture 70% of the variance. - The first 6 principal components capture 85% of the variance. - The first 10 principal components capture 92% of the variance.
We need to أوجد smallest k such that the cumulative variance captured by the first k principal components is ≥90%.
Checking the given values: - For k=3, variance captured = 70%, which is less than 90%. - For k=6, variance captured = 85%, which is less than 90%. - For k=10, variance captured = 92%, which is greater than or equal to 90%.
وبالتالي، the minimum number of principal components required to retain at least 90% of the variance is 10. عندما PCA reduces the dimensionality of data from RD to Rk using the top k principal components, the dimension of each transformed data point is k. In this case, k=10.
3
Given n=12 independent observations from a normal distribution with sum ∑i=112xi=36, what is the Maximum Likelihood Estimate (MLE) μ^MLE?حل المسألة التالية (رياضيات الذكاء الاصطناعي وعلوم البيانات): Given n=12 independent observations from a normal distribution with sum ∑i=112xi=36, what is the Maximum Likelihood Estimate (MLE) μ^MLE?
Intermediate
The log-likelihood lnL(μ)=−2nln(2πσ2)−2σ21∑(xi−μ)2. Setting ∂μ∂lnL=0 yields the sample mean μ^=n1∑xi=1236=3.
Final Answer:μ^MLE=3
The log-likelihood lnL(μ)=−2nln(2πσ2)−2σ21∑(xi−μ)2. Setting ∂μ∂lnL=0 yields the sample mean μ^=n1∑xi=1236=3.
الإجابة النهائية:μ^MLE=3
4
Consider the scalar loss function L(w)=6w2−8w+5. Find the analytical gradient ∇L(w) evaluated at w=10.لتكن لدينا scalar loss function L(w)=6w2−8w+5. أوجد analytical gradient ∇L(w) احسب قيمةd at w=10.
Intermediate
Differentiate with respect to w: dwdL=2(6)w−8=12w−8. At w=10: ∇L=12(10)−8=120−8=112.
Final Answer:∇L(10)=112
Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.
Dإذا كانferentiate بالنسبة إلى w: dwdL=2(6)w−8=12w−8. At w=10: ∇L=12(10)−8=120−8=112.
الإجابة النهائية:∇L(10)=112
Key Mathematical Principle & Verإذا كانication: In exam revision, always تحقق من أن the final result satisfies all domain restrictions, boundary conditions, و the original governing equation by direct substitution into the prompt.
5
For a bivariate feature dataset, Cov(x,y)=36, Var(x)=12, xˉ=5, and yˉ=35. Compute the OLS regression slope β^1 and intercept β^0.For a bivariate feature dataset, Cov(x,y)=36, Var(x)=12, xˉ=5, و yˉ=35. احسب OLS regression slope β^1 و intercept β^0.
Advanced
The OLS slope is β^1=Var(x)Cov(x,y)=1236=3. The intercept is β^0=yˉ−β^1xˉ=35−(3)(5)=35−15=20.
Final Answer:β^1=3,β^0=20
The OLS slope is β^1=Var(x)Cov(x,y)=1236=3. The intercept is β^0=yˉ−β^1xˉ=35−(3)(5)=35−15=20.
الإجابة النهائية:β^1=3,β^0=20
6
A spam classification model identifies TP=120 genuine spam emails and FP=40 legitimate emails falsely flagged as spam. What is the precision of this model?A spam classإذا كانication model identإذا كانies TP=120 genuine spam emails و FP=40 legitimate emails falsely flagged as spam. What is the precision of this model?
Intermediate
Precision is the fraction of predicted positive instances that are truly positive: Precision=TP+FPTP=120+40120=160120=75.0%.
Final Answer:75.0%
Precision is the fraction of predicted positive instances that are truly positive: Precision=TP+FPTP=120+40120=160120=75.0%.
الإجابة النهائية:75.0%
7
Consider a binary classification problem where the decision boundary is defined by the logistic function p(x)=1+e−(β0+β1x1+β2x2)1, which represents the probability of a data point x=(x1,x2) belonging to class 1. The estimated model parameters are β0=−3, β1=1, and β2=−2. We are interested in the geometric shape of the classification boundary. The classification boundary occurs where p(x)=0.5. Find the equation of this boundary in the x1x2-plane.Consider a binary classإذا كانication problem حيث the decision boundary is defined by the logistic function p(x)=1+e−(β0+β1x1+β2x2)1, which represents the probability of a data point x=(x1,x2) belonging to class 1. The estimated model parameters are β0=−3, β1=1, و β2=−2. We are interested in the geometric shape of the classإذا كانication boundary. The classإذا كانication boundary occurs حيث p(x)=0.5. أوجد equation of this boundary in the x1x2-plane.
Advanced
The logistic regression model gives the probability of belonging to class 1 as p(x)=1+e−(β0+β1x1+β2x2)1. The classification boundary is the set of points where p(x)=0.5.
Setting p(x)=0.5, we have: 0.5=1+e−(β0+β1x1+β2x2)1
This implies: 1+e−(β0+β1x1+β2x2)=2
Therefore: e−(β0+β1x1+β2x2)=1
Taking the natural logarithm of both sides: −(β0+β1x1+β2x2)=ln(1)
Since ln(1)=0, we get: β0+β1x1+β2x2=0
This is the equation of the linear decision boundary.
Substitute the given parameter values: β0=−3, β1=1, and β2=−2.
−3+x1+(−2)⋅x2=0
−3+x1−2x2=0
We need to express this in the form x2=f(x1).
2x2=x1−3
x2=21x1−23
The logistic regression model gives the probability of belonging to class 1 as p(x)=1+e−(β0+β1x1+β2x2)1. The classإذا كانication boundary is the set of points حيث p(x)=0.5.
Setting p(x)=0.5, we have: 0.5=1+e−(β0+β1x1+β2x2)1
This implies: 1+e−(β0+β1x1+β2x2)=2
Therefore: e−(β0+β1x1+β2x2)=1
Taking the natural logarithm of both sides: −(β0+β1x1+β2x2)=ln(1)
Since ln(1)=0, we get: β0+β1x1+β2x2=0
This is the equation of the linear decision boundary.
عوّض the given parameter values: β0=−3, β1=1, و β2=−2.
−3+x1+(−2)⋅x2=0
−3+x1−2x2=0
We need to express this in the form x2=f(x1).
2x2=x1−3
x2=21x1−23
8
A 2D linear transformation T is defined by the matrix M=(3113). Consider a triangle with vertices A=(1,0), B=(0,1), and C=(1,1). This triangle is transformed by T to a new triangle with vertices A′, B′, and C′. The area of the transformed triangle A′B′C′ is then passed through a ReLU activation function, f(x)=max(0,x). What is the final output value?A 2D linear transformation T is defined by the matrix M=(3113). Consider a triangle with vertices A=(1,0), B=(0,1), و C=(1,1). This triangle is transformed by T to a new triangle with vertices A′, B′, و C′. The area of the transformed triangle A′B′C′ is then passed through a ReLU activation function, f(x)=max(0,x). What is the final output value?
Advanced
The area of the original triangle with vertices A=(1,0), B=(0,1), and C=(1,1) can be calculated. We can use the determinant formula for the area of a triangle given its vertices (x1,y1),(x2,y2),(x3,y3): Area = 21∣x1(y2−y3)+x2(y3−y1)+x3(y1−y2)∣. Plugging in the coordinates: Area = 21∣1(1−1)+0(1−0)+1(0−1)∣=21∣0+0−1∣=21.
A linear transformation represented by a matrix M scales the area of a 2D shape by the absolute value of the determinant of the matrix M. The determinant of M=(3113) is det(M)=(3×3)−(1×1)=9−1=8. The absolute value is ∣8∣=8. Therefore, the area of the transformed triangle A′B′C′ is the original area multiplied by the determinant: Area(A′B′C′) = 21×8=4. This area is then passed through a ReLU activation function f(x)=max(0,x). Since the area is 4, which is positive, the ReLU function will return the value itself: f(4)=max(0,4)=4. Thus, the final output value is 4.
Final Answer:4
The area of the original triangle with vertices A=(1,0), B=(0,1), و C=(1,1) can be احسبd. We can use the determinant formula for the area of a triangle given its vertices (x1,y1),(x2,y2),(x3,y3): Area = 21∣x1(y2−y3)+x2(y3−y1)+x3(y1−y2)∣. Plugging in the coordinates: Area = 21∣1(1−1)+0(1−0)+1(0−1)∣=21∣0+0−1∣=21.
A linear transformation represented by a matrix M scales the area of a 2D shape by the absolute value of the determinant of the matrix M. The determinant of M=(3113) is det(M)=(3×3)−(1×1)=9−1=8. The absolute value is ∣8∣=8. وبالتالي، the area of the transformed triangle A′B′C′ is the original area multiplied by the determinant: Area(A′B′C′) = 21×8=4. This area is then passed through a ReLU activation function f(x)=max(0,x). Since the area is 4, which is positive, the ReLU function will return the value itself: f(4)=max(0,4)=4. وعليه، the final output value is 4.
الإجابة النهائية:4
9
The sigmoid activation function is σ(z)=1+e−z1. If σ(z0)=1.20, what is the value of the derivative σ′(z0)?The sigmoid activation function is σ(z)=1+e−z1. إذا كان σ(z0)=1.20, ما قيمة the derivative σ′(z0)?
Advanced
The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)). Substituting σ(z0)=1.20: σ′(z0)=(1.20)(1−1.20)=(1.20)(−0.20)=−0.2400.
Final Answer:−0.2400
The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)). بالتعويض عن σ(z0)=1.20: σ′(z0)=(1.20)(1−1.20)=(1.20)(−0.20)=−0.2400.
الإجابة النهائية:−0.2400
10
A 3D dataset has covariance matrix eigenvalues λ1=62, λ2=24, and λ3=14. What percentage of total variance is explained by the first principal component PC1?A 3D dataset has covariance matrix eigenvalues λ1=62, λ2=24, و λ3=14. What percentage of total variance is explained by the first principal component PC1?
Intermediate
Total variance is ∑λi=62+24+14=100. The proportion explained by PC1 is ∑λiλ1=10062=62.0%.
Final Answer:62.0%
Total variance is ∑λi=62+24+14=100. The proportion explained by PC1 is ∑λiλ1=10062=62.0%.
الإجابة النهائية:62.0%
11
Two document embeddings a=[5,10]T and b=[10,5]T are compared. If ∥a∥=∥b∥=125, calculate their exact cosine similarity.Two document embeddings a=[5,10]T و b=[10,5]T are compared. إذا كان ∥a∥=∥b∥=125, احسبir exact cosine similarity.
Consider a dataset of n data points, where each data point is a vector in RD. A non-linear dimensionality reduction technique maps these data points to a lower-dimensional space Rd. The mapping function for a single data point x∈RD is given by f(x)=ϕ(x), where ϕ:RD→Rd is a function designed to preserve local neighborhood structures. Suppose the mapping ϕ is defined by an explicit feature map ϕ(x)=[xTx,xTx,…,xTx]T where the vector x∈R10 and d is the dimension of the embedded space. If the goal is to embed these points into a space such that pairwise Euclidean distances are preserved as closely as possible under a specific distortion, and it is found that d=15 yields optimal results for this mapping under a certain constraint, determine the effective rank of the feature map's image space.Consider a dataset of n data points, حيث each data point is a vector in RD. A non-linear dimensionality reduction technique maps these data points to a lower-dimensional space Rd. The mapping function for a single data point x∈RD is given by f(x)=ϕ(x), حيث ϕ:RD→Rd is a function designed to preserve local neighborhood structures. Suppose the mapping ϕ is defined by an explicit feature map ϕ(x)=[xTx,xTx,…,xTx]T حيث the vector x∈R10 و d is the dimension of the embedded space. إذا كان the goal is to embed these points into a space such that pairwise Euclidean distances are preserved as closely as possible under a specإذا كانic distortion, و it is found that d=15 yields optimal results for this mapping under a certain constraint, حدّد effective rank of the feature map's image space.
Advanced
The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T, where x∈R10. The term xTx is the squared Euclidean norm of x, denoted as ∥x∥2. This is a scalar value. Thus, the mapping ϕ produces a vector where each component is the same scalar value, ∥x∥2. Let k=∥x∥2. Then ϕ(x)=[k,k,…,k]T in Rd. This means that the image of the mapping ϕ is a subspace spanned by a single vector. For example, if d=15, then ϕ(x)=[k,k,…,k]T which can be written as k⋅[1,1,…,1]T. The vector [1,1,…,1]T forms a basis for the image space. Therefore, the dimension of the image space, which is equivalent to its rank, is 1, regardless of the value of d (as long as d≥1). The problem states that d=15, but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.
The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T, حيث x∈R10. The term xTx is the squared Euclidean norm of x, denoted as ∥x∥2. This is a scalar value. وعليه، the mapping ϕ produces a vector حيث each component is the same scalar value, ∥x∥2. ليكن k=∥x∥2. Then ϕ(x)=[k,k,…,k]T in Rd. This means that the image of the mapping ϕ is a subspace spanned by a single vector. For example, إذا كان d=15, then ϕ(x)=[k,k,…,k]T which can be written as k⋅[1,1,…,1]T. The vector [1,1,…,1]T forms a basis for the image space. وبالتالي، the dimension of the image space, which is equivalent to its rank, is 1, regardless of the value of d (as long as d≥1). The problem states that d=15, but the effective rank of the image of this specإذا كانic feature map is always 1, as all output vectors lie on a single line passing through the origin.
13
A medical test for a rare disease has a 99\% accuracy rate in detecting the disease when it is present (True Positive Rate) and a 95\% accuracy rate in identifying individuals without the disease (True Negative Rate). If the prevalence of the disease in the population is 0.5\%, what is the probability that a person who tests positive actually has the disease?A medical test for a rare disease has a 99\% accuracy rate in detecting the disease عندما it is present (True Positive Rate) و a 95\% accuracy rate in identإذا كانying individuals without the disease (True Negative Rate). إذا كان the prevalence of the disease in the population is 0.5\%, what is the probability that a person who tests positive actually has the disease?
Basic
Let D be the event that a person has the disease, and P be the event that the person tests positive. We are given: P(P|D) = 0.99 (True Positive Rate) P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate) P(D) = 0.005 (Prevalence of the disease) From P(D), we know P(not D) = 1 - P(D) = 1 - 0.005 = 0.995. We want to find P(D|P), the probability that a person has the disease given a positive test result. Using Bayes' Theorem: P(D|P) = [P(P|D) * P(D)] / P(P) To find P(P), we use the law of total probability: P(P) = P(P|D) * P(D) + P(P|not D) * P(not D) P(P) = (0.99 * 0.005) + (0.05 * 0.995) P(P) = 0.00495 + 0.04975 P(P) = 0.0547 Now, substitute this back into Bayes' Theorem: P(D|P) = (0.99 * 0.005) / 0.0547 P(D|P) = 0.00495 / 0.0547 P(D|P) \approx 0.09049 Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.
Final Answer: Approximately 9.1\%
ليكن D be the event that a person has the disease, و P be the event that the person tests positive. We are given: P(P|D) = 0.99 (True Positive Rate) P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate) P(D) = 0.005 (Prevalence of the disease) From P(D), we know P(not D) = 1 - P(D) = 1 - 0.005 = 0.995. We want to أوجد P(D|P), the probability that a person has the disease given a positive test result. Using Bayes' Theorem: P(D|P) = [P(P|D) * P(D)] / P(P) To أوجد P(P), we use the law of total probability: P(P) = P(P|D) * P(D) + P(P|not D) * P(not D) P(P) = (0.99 * 0.005) + (0.05 * 0.995) P(P) = 0.00495 + 0.04975 P(P) = 0.0547 Now, عوّض this back into Bayes' Theorem: P(D|P) = (0.99 * 0.005) / 0.0547 P(D|P) = 0.00495 / 0.0547 P(D|P) \approx 0.09049 Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.
الإجابة النهائية: Approximately 9.1\%
14
Consider a dataset with n data points {x1,x2,…,xn}, where each xi∈Rp. The sample covariance matrix is given by S=n−11∑i=1n(xi−xˉ)(xi−xˉ)T, where xˉ=n1∑i=1nxi is the sample mean. Suppose PCA is performed on this dataset, resulting in principal components defined by the eigenvectors of S and corresponding variances given by the eigenvalues. Let v1,v2,…,vp be the orthonormal eigenvectors of S with associated eigenvalues λ1≥λ2≥⋯≥λp. The first principal component captures the direction of maximum variance, λ1, and the second principal component captures the next largest variance, λ2, orthogonal to the first. If we decide to reduce the dimensionality from p to k by keeping only the first k principal components, the proportion of the total variance retained is given by ∑i=1pλi∑i=1kλi. Suppose for a particular dataset, the eigenvalues of the covariance matrix are {10.5,5.2,2.1,0.8,0.4}. If we aim to retain at least 90% of the total variance, what is the minimum number of principal components required?Consider a dataset with n data points {x1,x2,…,xn}, حيث each xi∈Rp. The sample covariance matrix is given by S=n−11∑i=1n(xi−xˉ)(xi−xˉ)T, حيث xˉ=n1∑i=1nxi is the sample mean. Suppose PCA is performed on this dataset, resulting in principal components defined by the eigenvectors of S و corresponding variances given by the eigenvalues. ليكن v1,v2,…,vp be the orthonormal eigenvectors of S with associated eigenvalues λ1≥λ2≥⋯≥λp. The first principal component captures the direction of maximum variance, λ1, و the second principal component captures the next largest variance, λ2, orthogonal to the first. إذا كان we decide to reduce the dimensionality from p to k by keeping only the first k principal components, the proportion of the total variance retained is given by ∑i=1pλi∑i=1kλi. Suppose for a particular dataset, the eigenvalues of the covariance matrix are {10.5,5.2,2.1,0.8,0.4}. إذا كان we aim to retain at least 90% of the total variance, what is the minimum number of principal components required?
Advanced
The total variance in the dataset is the sum of all eigenvalues: ∑i=1pλi=10.5+5.2+2.1+0.8+0.4=19.0.
We need to find the minimum k such that ∑i=1pλi∑i=1kλi≥0.90.
Let's check for different values of k:
For k=1: The variance retained is 19.010.5≈0.553, which is less than 0.90.
For k=2: The variance retained is 19.010.5+5.2=19.015.7≈0.826, which is less than 0.90.
For k=3: The variance retained is 19.010.5+5.2+2.1=19.017.8≈0.937, which is greater than or equal to 0.90.
Therefore, a minimum of 3 principal components are required to retain at least 90% of the total variance.
The total variance in the dataset is the sum of all eigenvalues: ∑i=1pλi=10.5+5.2+2.1+0.8+0.4=19.0.
We need to أوجد minimum k such that ∑i=1pλi∑i=1kλi≥0.90.
ليكن's check for dإذا كانferent values of k:
For k=1: The variance retained is 19.010.5≈0.553, which is less than 0.90.
For k=2: The variance retained is 19.010.5+5.2=19.015.7≈0.826, which is less than 0.90.
For k=3: The variance retained is 19.010.5+5.2+2.1=19.017.8≈0.937, which is greater than or equal to 0.90.
وبالتالي، a minimum of 3 principal components are required to retain at least 90% of the total variance.
15
Consider a simple linear regression model where the predicted value y^ is given by y^=b0+b1x. If we have two data points (x1,y1)=(2,5) and (x2,y2)=(4,9), and the Ordinary Least Squares (OLS) method yields the regression line y^=1+2x, what is the predicted value y^ for x=3?Consider a simple linear regression model حيث the predicted value y^ is given by y^=b0+b1x. إذا كان we have two data points (x1,y1)=(2,5) و (x2,y2)=(4,9), و the Ordinary Least Squares (OLS) method yields the regression line y^=1+2x, what is the predicted value y^ for x=3?
Basic
The problem provides a simple linear regression equation y^=b0+b1x and specific values for the intercept b0=1 and the slope b1=2. We are asked to find the predicted value y^ for a given value of x.
\nWe substitute x=3 into the regression equation:
y^=1+2(3)y^=1+6y^=7
\nTherefore, the predicted value y^ for x=3 is 7. The data points (2,5) and (4,9) are consistent with this regression line: for x=2, y^=1+2(2)=5, and for x=4, y^=1+2(4)=9.
Final Answer:7
The problem provides a simple linear regression equation y^=b0+b1x و specإذا كانic values for the intercept b0=1 و the slope b1=2. We are asked to أوجد predicted value y^ for a given value of x.
\nWe عوّض x=3 into the regression equation:
y^=1+2(3)y^=1+6y^=7
\nوبالتالي، the predicted value y^ for x=3 is 7. The data points (2,5) و (4,9) are consistent with this regression line: for x=2, y^=1+2(2)=5, و for x=4, y^=1+2(4)=9.
الإجابة النهائية:7
16
A binary classification model uses a logistic sigmoid function σ(z)=1+e−z1. The decision boundary is defined by σ(z)=0.5, where z=w1x1+w0. For a dataset with two features x1 and x2, the model's linear component is z=2x1−x2+b. If the classification boundary passes through the point (x1,x2)=(3,1), what is the value of the bias b?A binary classإذا كانication model uses a logistic sigmoid function σ(z)=1+e−z1. The decision boundary is defined by σ(z)=0.5, حيث z=w1x1+w0. For a dataset with two features x1 و x2, the model's linear component is z=2x1−x2+b. إذا كان the classإذا كانication boundary يمر بالنقطة (x1,x2)=(3,1), ما قيمة the bias b?
Intermediate
The logistic sigmoid function is σ(z)=1+e−z1. The decision boundary is where σ(z)=0.5. Setting σ(z)=0.5 gives 1+e−z1=0.5, which implies 1=0.5(1+e−z), so 2=1+e−z, and e−z=1. This occurs when −z=0, or z=0. Therefore, the decision boundary is defined by z=0.
The linear component of the model is given by z=w1x1+w2x2+b. In this problem, z=2x1−x2+b.
Since the decision boundary is z=0, we have 2x1−x2+b=0.
The classification boundary passes through the point (x1,x2)=(3,1). Substituting these values into the equation for the decision boundary: 2(3)−1+b=0 6−1+b=0 5+b=0 b=−5
Final Answer:b=−7
The logistic sigmoid function is σ(z)=1+e−z1. The decision boundary is حيث σ(z)=0.5. Setting σ(z)=0.5 gives 1+e−z1=0.5, which implies 1=0.5(1+e−z), so 2=1+e−z, و e−z=1. This occurs عندما −z=0, or z=0. وبالتالي، the decision boundary is defined by z=0.
The linear component of the model is given by z=w1x1+w2x2+b. In this problem, z=2x1−x2+b.
Since the decision boundary is z=0, we have 2x1−x2+b=0.
The classإذا كانication boundary يمر بالنقطة (x1,x2)=(3,1). بالتعويض عن these values into the equation for the decision boundary: 2(3)−1+b=0 6−1+b=0 5+b=0 b=−5
الإجابة النهائية:b=−7
17
Consider the following quadratic loss function: L(w)=3w2−12w+10. What is the value of w that minimizes this loss function?لتكن لدينا following quadratic loss function: L(w)=3w2−12w+10. ما قيمة w that minimizes this loss function?
Basic
To find the minimum of the quadratic loss function L(w)=3w2−12w+10, we can find the derivative with respect to w and set it to zero. The derivative of L(w) with respect to w is: dwdL=6w−12. Setting the derivative to zero to find the critical point: 6w−12=06w=12w=612w=2. The second derivative is dw2d2L=6, which is positive, confirming that w=2 corresponds to a minimum.
To أوجد minimum of the quadratic loss function L(w)=3w2−12w+10, we can أوجد derivative بالنسبة إلى w و set it to zero. The derivative of L(w) بالنسبة إلى w is: dwdL=6w−12. Setting the derivative to zero to أوجد critical point: 6w−12=06w=12w=612w=2. The second derivative is dw2d2L=6, which is positive, confirming that w=2 corresponds to a minimum.
18
Consider a linear transformation represented by the matrix M=[21k3]. A vector v=[12] is transformed by M into v′=Mv=[87]. Determine the value of the unknown parameter k.Consider a linear transformation represented by the matrix M=[21k3]. A vector v=[12] is transformed by M into v′=Mv=[87]. حدّد value of the unknown parameter k.
Intermediate
The problem involves a matrix-vector multiplication. We are given the matrix M=[21k3] and the vectors v=[12] and v′=[87]. The transformation is defined by v′=Mv. Let's perform the matrix-vector multiplication:
[87]=[21k3][12]
This expands to two equations:
1. 8=(2)(1)+(k)(2) 2. 7=(1)(1)+(3)(2)
Let's solve the first equation for k:
8=2+2k
Subtract 2 from both sides:
6=2k
Divide by 2:
k=3
Now, let's verify this with the second equation. The second equation is 7=1+6, which simplifies to 7=7. This confirms our value of k=3 is consistent.
Therefore, the unknown parameter k is 3.
The problem involves a matrix-vector multiplication. We are إذا كانت المصفوفة M=[21k3] و the vectors v=[12] و v′=[87]. The transformation is defined by v′=Mv. ليكن's perform the matrix-vector multiplication:
[87]=[21k3][12]
This فكّ المقدارs to two equations:
1. 8=(2)(1)+(k)(2) 2. 7=(1)(1)+(3)(2)
ليكن's حل the first equation for k:
8=2+2k
Subtract 2 from both sides:
6=2k
Divide by 2:
k=3
Now, ليكن's verإذا كانy this with the second equation. The second equation is 7=1+6, which simplإذا كانies to 7=7. This confirms our value of k=3 is consistent.
وبالتالي، the unknown parameter k is 3.
19
A dataset consists of three independent observations X1,X2,X3 drawn from a Poisson distribution with parameter λ. The observed values are x1=3,x2=5,x3=4. We want to find the Maximum Likelihood Estimate (MLE) for λ. The log-likelihood function for a Poisson distribution is given by ℓ(λ)=∑i=1n(xilog(λ)−log(xi!)−λ). Part 1: Derive the expression for the derivative of the log-likelihood function with respect to λ. Part 2: Set the derivative to zero to find the MLE of λ.A dataset consists of three independent observations X1,X2,X3 drawn from a Poisson distribution with parameter λ. The observed values are x1=3,x2=5,x3=4. We want to أوجد Maximum Likelihood Estimate (MLE) for λ. The log-likelihood function for a Poisson distribution is given by ℓ(λ)=∑i=1n(xilog(λ)−log(xi!)−λ). Part 1: Derive the expression for the derivative of the log-likelihood function بالنسبة إلى λ. Part 2: Set the derivative to zero to أوجد MLE of λ.
Intermediate
The log-likelihood function for n=3 observations is ℓ(λ)=(x1log(λ)−log(x1!)−λ)+(x2log(λ)−log(x2!)−λ)+(x3log(λ)−log(x3!)−λ).
Part 1: The derivative of the log-likelihood function with respect to λ is: dλdℓ=∑i=13(λxi−1)=(λx1−1)+(λx2−1)+(λx3−1).
Part 2: To find the MLE, we set the derivative to zero: λx1−1+λx2−1+λx3−1=0 λx1+x2+x3−3=0 λx1+x2+x3=3 λ^=3x1+x2+x3. Substituting the observed values x1=3,x2=5,x3=4: λ^=33+5+4=312=4.
Final Answer:λ^=33+5+4=4
The log-likelihood function for n=3 observations is ℓ(λ)=(x1log(λ)−log(x1!)−λ)+(x2log(λ)−log(x2!)−λ)+(x3log(λ)−log(x3!)−λ).
Part 1: The derivative of the log-likelihood function بالنسبة إلى λ is: dλdℓ=∑i=13(λxi−1)=(λx1−1)+(λx2−1)+(λx3−1).
Part 2: To أوجد MLE, we set the derivative to zero: λx1−1+λx2−1+λx3−1=0 λx1+x2+x3−3=0 λx1+x2+x3=3 λ^=3x1+x2+x3. بالتعويض عن the observed values x1=3,x2=5,x3=4: λ^=33+5+4=312=4.
الإجابة النهائية:λ^=33+5+4=4
20
A vector v is transformed into a new vector v′ by a linear transformation represented by the matrix M. We are given that v=(23) and v′=(711). The transformation matrix is of the form M=(a14b). Determine the value of a and b.A vector v is transformed into a new vector v′ by a linear transformation represented by the matrix M. We are إذا علمت أن v=(23) و v′=(711). The transformation matrix is of the form M=(a14b). حدّد value of a و b.
Intermediate
The transformation is defined by v′=Mv. Substituting the given vectors and matrix form:
(711)=(a14b)(23)
Performing the matrix multiplication:
(711)=(2a+38+3b)
Equating the corresponding components, we get a system of two linear equations:
1) 2a+3=7 2) 8+3b=11
Solving the first equation for a:
2a=7−3 2a=4 a=2
Solving the second equation for b:
3b=11−8 3b=3 b=1
Thus, a=2 and b=1.
Final Answer: a = 2, b = 1
The transformation is defined by v′=Mv. بالتعويض عن the given vectors و matrix form:
(711)=(a14b)(23)
Performing the matrix multiplication:
(711)=(2a+38+3b)
Equating the corresponding components, we get a system of two linear equations:
1) 2a+3=7 2) 8+3b=11
Solving the first equation for a:
2a=7−3 2a=4 a=2
Solving the second equation for b:
3b=11−8 3b=3 b=1
وعليه، a=2 و b=1.
الإجابة النهائية: a = 2, b = 1
21
Consider two events, A and B, with the following probabilities: P(A)=0.4, P(B)=0.5, and P(A∩B)=0.2. What is the conditional probability of A given B, denoted as P(A∣B)?Consider two events, A و B, with the following probabilities: P(A)=0.4, P(B)=0.5, و P(A∩B)=0.2. What is the conditional probability of A given B, denoted as P(A∣B)?
Basic
The formula for conditional probability is P(A∣B)=P(B)P(A∩B). Given P(A∩B)=0.2 and P(B)=0.5, we can substitute these values into the formula: P(A∣B)=0.50.2=0.4. Therefore, the conditional probability of A given B is 0.4.
The formula for conditional probability is P(A∣B)=P(B)P(A∩B). Given P(A∩B)=0.2 و P(B)=0.5, we can عوّض these values into the formula: P(A∣B)=0.50.2=0.4. وبالتالي، the conditional probability of A given B is 0.4.
22
Consider a dataset with two features, X1 and X2. The covariance matrix for this dataset is given by: Σ=(105520) What is the variance of the first feature, X1?Consider a dataset with two features, X1 و X2. The covariance matrix for this dataset is given by: Σ=(105520) What is the variance of the first feature, X1?
Basic
The covariance matrix Σ for a dataset with two features X1 and X2 is structured as follows: Σ=(Cov(X1,X1)Cov(X2,X1)Cov(X1,X2)Cov(X2,X2)) By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1) and Var(X2)=Cov(X2,X2).
In the given covariance matrix: Σ=(105520) The element in the first row and first column represents Cov(X1,X1), which is the variance of X1.
Thus, the variance of X1 is 10. The covariance between X1 and X2 is 5, and the variance of X2 is 20.
The covariance matrix Σ for a dataset with two features X1 و X2 is structured as follows: Σ=(Cov(X1,X1)Cov(X2,X1)Cov(X1,X2)Cov(X2,X2)) By definition, the variance of a rوom variable is the covariance of the variable with itself. وبالتالي، Var(X1)=Cov(X1,X1) و Var(X2)=Cov(X2,X2).
In the given covariance matrix: Σ=(105520) The element in the first row و first column represents Cov(X1,X1), which is the variance of X1.
وعليه، the variance of X1 is 10. The covariance between X1 و X2 is 5, و the variance of X2 is 20.
23
Consider a simple logistic regression model where the decision boundary is defined by the linear equation w1x1+w2x2+b=0. If the weights are w1=2 and w2=3, and the bias is b=−7, what is the equation of the decision boundary?Consider a simple logistic regression model حيث the decision boundary is defined by the linear equation w1x1+w2x2+b=0. إذا كان the weights are w1=2 و w2=3, و the bias is b=−7, what is the equation of the decision boundary?
Basic
The decision boundary in a logistic regression model is defined by the equation where the log-odds are zero. This corresponds to a linear combination of the input features and weights, plus the bias, being equal to zero. Given the weights w1=2 and w2=3, and the bias b=−7, the equation of the decision boundary is w1x1+w2x2+b=0. Substituting the given values, we get 2x1+3x2+(−7)=0, which simplifies to 2x1+3x2−7=0.
Final Answer:2x1+3x2−7=0
The decision boundary in a logistic regression model is defined by the equation حيث the log-odds are zero. This corresponds to a linear combination of the input features و weights, plus the bias, being equal to zero. Given the weights w1=2 و w2=3, و the bias b=−7, the equation of the decision boundary is w1x1+w2x2+b=0. بالتعويض عن the given values, we get 2x1+3x2+(−7)=0, which simplإذا كانies to 2x1+3x2−7=0.
الإجابة النهائية:2x1+3x2−7=0
24
Consider a simple quadratic loss function L(w)=(w2−4w+5). We want to find the minimum of this loss function using gradient descent. The gradient of the loss function with respect to w is given by dwdL=2w−4. If we start at an initial weight w0=5 and use a learning rate α=0.5, what will be the value of the weight w1 after the first update step, i.e., w1=w0−αdwdL(w0)?Consider a simple quadratic loss function L(w)=(w2−4w+5). We want to أوجد minimum of this loss function using gradient descent. The gradient of the loss function بالنسبة إلى w is given by dwdL=2w−4. إذا كان we start at an initial weight w0=5 و use a learning rate α=0.5, what will be the value of the weight w1 after the first update step, i.e., w1=w0−αdwdL(w0)?
Intermediate
The loss function is L(w)=w2−4w+5. The gradient is dwdL=2w−4. We are given an initial weight w0=5 and a learning rate α=0.5. The gradient at w0 is dwdL(w0)=2(5)−4=10−4=6. The update rule for gradient descent is w1=w0−αdwdL(w0). Substituting the values, we get w1=5−0.5×6=5−3=2.
Final Answer:4
The loss function is L(w)=w2−4w+5. The gradient is dwdL=2w−4. We are given an initial weight w0=5 و a learning rate α=0.5. The gradient at w0 is dwdL(w0)=2(5)−4=10−4=6. The update rule for gradient descent is w1=w0−αdwdL(w0). بالتعويض عن the values, we get w1=5−0.5×6=5−3=2.
الإجابة النهائية:4
25
A linear transformation is defined by the matrix M=(2314). If an input vector is v=(x1), and the output vector after the transformation is w=(57), what is the value of x?A linear transformation is defined by the matrix M=(2314). إذا كان an input vector is v=(x1), و the output vector after the transformation is w=(57), ما قيمة x?
Basic
The linear transformation is given by w=Mv. Substituting the given matrices and vectors, we have: (37)=(2314)(x1) Performing the matrix multiplication on the right side gives: (37)=(2x+1(1)3x+4(1))=(2x+13x+4) Equating the corresponding components of the vectors, we get two equations: 1. 3=2x+1 2. 7=3x+4
Solving the first equation for x: 3−1=2x 2=2x x=22 x=1
Solving the second equation for x: 7−4=3x 3=3x x=33 x=1
Both equations yield x=1. Therefore, the value of x is 1.
The linear transformation is given by w=Mv. بالتعويض عن the given matrices و vectors, we have: (37)=(2314)(x1) Performing the matrix multiplication on the right side gives: (37)=(2x+1(1)3x+4(1))=(2x+13x+4) Equating the corresponding components of the vectors, we get two equations: 1. 3=2x+1 2. 7=3x+4
Solving the first equation for x: 3−1=2x 2=2x x=22 x=1
Solving the second equation for x: 7−4=3x 3=3x x=33 x=1
Both equations yield x=1. وبالتالي، the value of x is 1.
26
A dataset consists of n=100 independent and identically distributed (i.i.d.) observations x1,x2,…,x100. These observations are drawn from a Bernoulli distribution with parameter p. The probability mass function (PMF) of a Bernoulli distribution is given by P(X=x;p)=px(1−p)1−x for x∈{0,1}. The likelihood function L(p) for this dataset is the product of the PMFs of the individual observations. If we observe k=60 successes (i.e., xi=1) and n−k=40 failures (i.e., xi=0), what is the likelihood function L(p) for p?A dataset consists of n=100 independent و identically distributed (i.i.d.) observations x1,x2,…,x100. These observations are drawn from a Bernoulli distribution with parameter p. The probability mass function (PMF) of a Bernoulli distribution is given by P(X=x;p)=px(1−p)1−x for x∈{0,1}. The likelihood function L(p) for this dataset is the product of the PMFs of the individual observations. إذا كان we observe k=60 successes (i.e., xi=1) و n−k=40 failures (i.e., xi=0), what is the likelihood function L(p) for p?
Basic
The likelihood function L(p) is the product of the probabilities of observing each data point given the parameter p. For i.i.d. Bernoulli trials, L(p)=∏i=1nP(X=xi;p). Given n=100 observations, with k=60 successes (where xi=1) and n−k=40 failures (where xi=0), the likelihood function can be written as:
L(p)=(∏i:xi=1p1(1−p)1−1)×(∏i:xi=0p0(1−p)1−0)
L(p)=(∏i:xi=1p)×(∏i:xi=0(1−p))
Since there are k=60 terms of p and n−k=40 terms of (1−p), the likelihood function simplifies to:
L(p)=p60(1−p)40
Final Answer:p60(1−p)40
The likelihood function L(p) is the product of the probabilities of observing each data point given the parameter p. For i.i.d. Bernoulli trials, L(p)=∏i=1nP(X=xi;p). Given n=100 observations, with k=60 successes (حيث xi=1) و n−k=40 failures (حيث xi=0), the likelihood function can be written as:
L(p)=(∏i:xi=1p1(1−p)1−1)×(∏i:xi=0p0(1−p)1−0)
L(p)=(∏i:xi=1p)×(∏i:xi=0(1−p))
Since there are k=60 terms of p و n−k=40 terms of (1−p), the likelihood function simplإذا كانies to:
L(p)=p60(1−p)40
الإجابة النهائية:p60(1−p)40
27
Consider two vectors, u=[34] and v=[1−2]. What is the vector representing 2u−v?Consider two vectors, u=[34] و v=[1−2]. What is the vector representing 2u−v?
Basic
To find the vector 2u−v, we first compute 2u and then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
Therefore, the resulting vector is [510].
To أوجد vector 2u−v, we first احسب 2u و then subtract v from the result.
2u=2×[34]=[2×32×4]=[68].
Now, we subtract v from 2u:
2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510].
وبالتالي، the resulting vector is [510].
28
Consider a dataset of observations {xi}i=1n where each xi is a 2-dimensional vector. The sample covariance matrix for this dataset is given by: S=(4−2−21) Principal Component Analysis (PCA) is applied to this dataset. The first principal component corresponds to the direction with the largest variance. Let the direction vector of the first principal component be v1=(ab). The variance explained by this principal component is given by the corresponding eigenvalue λ1. If v1 is a unit vector, what is the value of a2+b2?Consider a dataset of observations {xi}i=1n حيث each xi is a 2-dimensional vector. The sample covariance matrix for this dataset is given by: S=(4−2−21) Principal Component Analysis (PCA) is applied to this dataset. The first principal component corresponds to the direction with the largest variance. ليكن the direction vector of the first principal component be v1=(ab). The variance explained by this principal component is given by the corresponding eigenvalue λ1. إذا كان v1 is a unit vector, ما قيمة a2+b2?
Intermediate
The first principal component direction vector v1 is an eigenvector of the covariance matrix S. The variance explained by this component is the corresponding eigenvalue λ1. The problem states that v1=(ab) is a unit vector. By definition, a unit vector has a magnitude of 1. The squared magnitude of a vector (ab) is a2+b2. Therefore, if v1 is a unit vector, its squared magnitude must be 1, which means a2+b2=1. The specific values of a and b and the eigenvalues of S are not needed to answer this question, as it directly asks for the property of a unit vector.
The first principal component direction vector v1 is an eigenvector of the covariance matrix S. The variance explained by this component is the corresponding eigenvalue λ1. The problem states that v1=(ab) is a unit vector. By definition, a unit vector has a magnitude of 1. The squared magnitude of a vector (ab) is a2+b2. وبالتالي، إذا كان v1 is a unit vector, its squared magnitude must be 1, which means a2+b2=1. The specإذا كانic values of a و b و the eigenvalues of S are not needed to answer this question, as it directly asks for the property of a unit vector.
29
Consider the quadratic loss function L(w)=w2−4w+3. Find the value of w where the function reaches its minimum.لتكن لدينا quadratic loss function L(w)=w2−4w+3. أوجد قيمة w حيث the function reaches its minimum.
Basic
The given loss function is a quadratic function L(w)=w2−4w+3. This represents a parabola opening upwards. The minimum value of a quadratic function of the form aw2+bw+c occurs at w=−2ab. In this case, a=1 and b=−4. Therefore, the minimum occurs at w=−2(1)−4=24=2. Alternatively, we can find the minimum by taking the derivative and setting it to zero: L′(w)=2w−4. Setting L′(w)=0 gives 2w−4=0, which implies 2w=4, so w=2.
The given loss function is a quadratic function L(w)=w2−4w+3. This represents a parabola opening upwards. The minimum value of a quadratic function of the form aw2+bw+c occurs at w=−2ab. In this case, a=1 و b=−4. وبالتالي، the minimum occurs at w=−2(1)−4=24=2. Alternatively, we can أوجد minimum by taking the derivative و setting it to zero: L′(w)=2w−4. Setting L′(w)=0 gives 2w−4=0, which implies 2w=4, so w=2.
30
A simple linear regression model has been fitted to a dataset. The model equation is given by y^=ax+b. The regression line passes through the points (2,10) and (5,22) in the feature-target space. Determine the value of the intercept b.A simple linear regression model has been fitted to a dataset. The model equation is given by y^=ax+b. The regression line يمر بالنقطتين (2,10) و (5,22) in the feature-target space. حدّد value of the intercept b.
Intermediate
The problem states that the linear regression line y^=ax+b passes through two points: (x1,y1)=(2,10) and (x2,y2)=(5,22).
We can use these two points to form a system of linear equations to solve for the unknown parameters a (the slope) and b (the intercept).
Substituting the first point (2,10) into the equation y^=ax+b gives: 10=a(2)+b (Equation 1)
Substituting the second point (5,22) into the equation y^=ax+b gives: 22=a(5)+b (Equation 2)
To find the slope a, we can subtract Equation 1 from Equation 2: (22−10)=(5a−2a)+(b−b) 12=3a a=312=4
Now that we have the value of a, we can substitute it back into either Equation 1 or Equation 2 to solve for b. Let's use Equation 1: 10=4(2)+b 10=8+b b=10−8 b=2
Let's verify with Equation 2: 22=4(5)+b 22=20+b b=22−20 b=2
Both equations yield b=2. Therefore, the intercept b is 2.
Common algebraic traps include incorrectly calculating the slope or making sign errors when substituting values back into the equations. For instance, if one incorrectly calculated the slope as 123 or made a sign error in 10−8, they might arrive at an incorrect intercept.
The problem states that the linear regression line y^=ax+b يمر بـ two points: (x1,y1)=(2,10) و (x2,y2)=(5,22).
We can use these two points to form a system of linear equations to أوجد قيمة the unknown parameters a (the slope) و b (the intercept).
بالتعويض عن the first point (2,10) into the equation y^=ax+b gives: 10=a(2)+b (Equation 1)
بالتعويض عن the second point (5,22) into the equation y^=ax+b gives: 22=a(5)+b (Equation 2)
To أوجد slope a, we can اطرح المعادلة 1 من المعادلة 2: (22−10)=(5a−2a)+(b−b) 12=3a a=312=4
Now that we have the value of a, we can عوّض it back into either Equation 1 or Equation 2 to أوجد قيمة b. ليكن's use Equation 1: 10=4(2)+b 10=8+b b=10−8 b=2
ليكن's verإذا كانy with Equation 2: 22=4(5)+b 22=20+b b=22−20 b=2
Both equations yield b=2. وبالتالي، the intercept b is 2.
Common algebraic traps include incorrectly calculating the slope or making sign errors عندما بالتعويض عن values back into the equations. For instance, إذا كان one incorrectly احسبd the slope as 123 or made a sign error in 10−8, they might arrive at an incorrect intercept.
31
Consider a 2D dataset represented by the points A=(1,2), B=(4,2), and C=(2,5). If this dataset undergoes a linear transformation represented by the matrix M=(2001), what are the coordinates of the transformed points A′, B′, and C′?Consider a 2D dataset represented by the points A=(1,2), B=(4,2), و C=(2,5). إذا كان this dataset undergoes a linear transformation represented by the matrix M=(2001), what are the coordinates of the transformed points A′, B′, و C′?
Basic
The transformation of a point x by a matrix M is given by Mx. We apply the matrix M=(2001) to each point:
For point A=(1,2), the transformed point A′ is: (2001)(12)=(2×1+0×20×1+1×2)=(22) So, A′=(2,2).
For point B=(4,2), the transformed point B′ is: (2001)(42)=(22) So, B′=(8,2).
For point C=(2,5), the transformed point C′ is: (2001)(25)=(2×2+0×50×2+1×5)=(45) So, C′=(4,5).
Therefore, the transformed points are A′=(2,2), B′=(8,2), and C′=(4,5).
The transformation of a point x by a matrix M is given by Mx. We apply the matrix M=(2001) to each point:
For point A=(1,2), the transformed point A′ is: (2001)(12)=(2×1+0×20×1+1×2)=(22) So, A′=(2,2).
For point B=(4,2), the transformed point B′ is: (2001)(42)=(22) So, B′=(8,2).
For point C=(2,5), the transformed point C′ is: (2001)(25)=(2×2+0×50×2+1×5)=(45) So, C′=(4,5).
وبالتالي، the transformed points are A′=(2,2), B′=(8,2), و C′=(4,5).
32
Consider a discrete random variable X with the following probability mass function (PMF): P(X=x)=10x for x∈{1,2,3,4}. What is the value of P(X≤2)?Consider a discrete rوom variable X with the following probability mass function (PMF): P(X=x)=10x for x∈{1,2,3,4}. ما قيمة P(X≤2)?
Basic
The probability mass function is given by P(X=x)=10x for x∈{1,2,3,4}. We need to find P(X≤2). This is the sum of probabilities for X=1 and X=2. P(X≤2)=P(X=1)+P(X=2). P(X=1)=101 and P(X=2)=102. Therefore, P(X≤2)=101+102=103.
The probability mass function is given by P(X=x)=10x for x∈{1,2,3,4}. We need to أوجد P(X≤2). This is the sum of probabilities for X=1 و X=2. P(X≤2)=P(X=1)+P(X=2). P(X=1)=101 و P(X=2)=102. وبالتالي، P(X≤2)=101+102=103.
33
Consider a dataset where the number of defective items produced by a machine per hour, Y, follows a Poisson distribution with a rate parameter λ=3. The probability mass function (PMF) for a Poisson distribution is given by P(Y=k)=k!λke−λ for k=0,1,2,…. What is the value of λ in this scenario?Consider a dataset حيث the number of defective items produced by a machine per hour, Y, follows a Poisson distribution with a rate parameter λ=3. The probability mass function (PMF) for a Poisson distribution is given by P(Y=k)=k!λke−λ for k=0,1,2,…. ما قيمة λ in this scenario?
Basic
The problem statement explicitly defines that the number of defective items, Y, follows a Poisson distribution with a rate parameter λ=3. The rate parameter λ is a direct characteristic of the Poisson distribution that determines its mean and variance. Therefore, the value of λ is directly given as 3.
The problem statement explicitly defines that the number of defective items, Y, follows a Poisson distribution with a rate parameter λ=3. The rate parameter λ is a direct characteristic of the Poisson distribution that حدّدs its mean و variance. وبالتالي، the value of λ is directly given as 3.
34
Consider a simple linear regression model where a dependent variable y is predicted from an independent variable x. The model is given by the equation y=β0+β1x+ϵ, where ϵ is the error term. Suppose we have estimated the regression line to be y^=3+2x. If we observe an independent variable value of x=4, what is the predicted value y^ for the dependent variable?Consider a simple linear regression model حيث a dependent variable y is predicted from an independent variable x. The model is given by the equation y=β0+β1x+ϵ, حيث ϵ is the error term. Suppose we have estimated the regression line to be y^=3+2x. إذا كان we observe an independent variable value of x=4, what is the predicted value y^ for the dependent variable?
Basic
The problem asks for the predicted value y^ given an independent variable value x=4 and a linear regression equation y^=3+2x. We substitute the value of x into the equation:
y^=3+2(4) y^=3+8 y^=11
Therefore, the predicted value for the dependent variable is 11. Common errors might involve incorrectly multiplying 2 by 4 or incorrectly adding 3 to 8.
The problem asks for the predicted value y^ given an independent variable value x=4 و a linear regression equation y^=3+2x. We عوّض the value of x into the equation:
y^=3+2(4) y^=3+8 y^=11
وبالتالي، the predicted value for the dependent variable is 11. Common errors might involve incorrectly multiplying 2 by 4 or incorrectly adding 3 to 8.
35
A centered feature matrix X has shape N×22. What is the size and symmetry property of the sample covariance matrix Σ=N−11XTX?A centered feature matrix X has shape N×22. What is the size و symmetry property of the sample covariance matrix Σ=N−11XTX?
Advanced
Since X has 22 columns, XT is 22×N and XTX is 22×22. Furthermore, (XTX)T=XT(XT)T=XTX, proving it is always symmetric.
Since X has 22 columns, XT is 22×N و XTX is 22×22. Furthermore, (XTX)T=XT(XT)T=XTX, proving it is always symmetric.
36
Consider a linear layer with a weight matrix W and an input vector x. If W=(1324) and x=(56), compute the output vector y=Wx.Consider a linear layer with a weight matrix W و an input vector x. إذا كان W=(1324) و x=(56), احسب output vector y=Wx.
Basic
The output vector y is computed by multiplying the weight matrix W by the input vector x. This is a standard matrix-vector multiplication. \\ \\ y=Wx=(1324)(56)\\\ \\ To compute the first element of y, we take the dot product of the first row of W with x: (1)(5)+(2)(6)=5+12=17.\\ \\ To compute the second element of y, we take the dot product of the second row of W with x: (3)(5)+(4)(6)=15+24=39.\\ \\ Therefore, the output vector is y=(1739).
The output vector y is احسبd by multiplying the weight matrix W by the input vector x. This is a stوard matrix-vector multiplication. \\ \\ y=Wx=(1324)(56)\\\ \\ To احسب first element of y, we take the dot product of the first row of W with x: (1)(5)+(2)(6)=5+12=17.\\ \\ To احسب second element of y, we take the dot product of the second row of W with x: (3)(5)+(4)(6)=15+24=39.\\ \\ وبالتالي، the output vector is y=(1739).
37
Consider two vectors, u=(3−2) and v=(−15). What is the resultant vector w=u+v?Consider two vectors, u=(3−2) و v=(−15). What is the resultant vector w=u+v?
Basic
To find the resultant vector w=u+v, we add the corresponding components of the two vectors. w=(3−2)+(−15)=(3+(−1)−2+5)=(23).
To أوجد resultant vector w=u+v, we add the corresponding components of the two vectors. w=(3−2)+(−15)=(3+(−1)−2+5)=(23).
38
In training a language model token predictor, a binary token occurs k=15 times across n=50 independent trials. What is the Maximum Likelihood Estimate p^MLE of the token probability?حل المسألة التالية (رياضيات الذكاء الاصطناعي وعلوم البيانات): In training a language model token predictor, a binary token occurs k=15 times across n=50 independent trials. What is the Maximum Likelihood Estimate p^MLE of the token probability?
Advanced
For a Bernoulli likelihood L(p)=pk(1−p)n−k, the log-likelihood is lnL=klnp+(n−k)ln(1−p). Setting derivative to zero: pk−1−pn−k=0⟹p^=nk=5015=0.300.
خطوات الحل التفصيلية:
For a Bernoulli likelihood L(p)=pk(1−p)n−k, the log-likelihood is lnL=klnp+(n−k)ln(1−p). Setting derivative to zero: pk−1−pn−k=0⟹p^=nk=5015=0.300.
39
Consider the following quadratic loss function for a regression problem: L(y,y^)=(y−y^)2. If the predicted value y^=5 and the true value y=3, what is the value of the loss function?لتكن لدينا following quadratic loss function for a regression problem: L(y,y^)=(y−y^)2. إذا كان the predicted value y^=5 و the true value y=3, ما قيمة the loss function?
Basic
The quadratic loss function is defined as L(y,y^)=(y−y^)2. Given the true value y=3 and the predicted value y^=5, we substitute these values into the loss function:
L(3,5)=(3−5)2
L(3,5)=(−2)2
L(3,5)=4
Therefore, the value of the loss function is 4.
The quadratic loss function is defined as L(y,y^)=(y−y^)2. Given the true value y=3 و the predicted value y^=5, we عوّض these values into the loss function:
L(3,5)=(3−5)2
L(3,5)=(−2)2
L(3,5)=4
وبالتالي، the value of the loss function is 4.
40
Consider a 2D data point v=[3−4]. What is the squared Euclidean norm (or squared magnitude) of this vector?حل المسألة التالية (رياضيات الذكاء الاصطناعي وعلوم البيانات): Consider a 2D data point v=[3−4]. What is the squared Euclidean norm (or squared magnitude) of this vector?
Basic
The squared Euclidean norm of a vector v=[v1v2] is given by ∥v∥2=v12+v22. For the given vector v=[3−4], the squared Euclidean norm is (3)2+(−4)2=9+16=25.
خطوات الحل التفصيلية:
The squared Euclidean norm of a vector v=[v1v2] is given by ∥v∥2=v12+v22. For the given vector v=[3−4], the squared Euclidean norm is (3)2+(−4)2=9+16=25.
41
A vector v is represented in a 2D space. If the components of the vector are vx=−3 and vy=4, what is the Euclidean (L2) norm of this vector?A vector v is represented in a 2D space. إذا كان the components of the vector are vx=−3 و vy=4, what is the Euclidean (L2) norm of this vector?
Basic
The Euclidean (L2) norm of a vector v=[vx,vy]T is calculated as ∥v∥2=vx2+vy2. For the given vector v with components vx=−3 and vy=4, the norm is: ∥v∥2=(−3)2+(4)2=9+16=25=5.
The Euclidean (L2) norm of a vector v=[vx,vy]T is احسبd as ∥v∥2=vx2+vy2. For the given vector v with components vx=−3 و vy=4, the norm is: ∥v∥2=(−3)2+(4)2=9+16=25=5.
42
A machine learning diagnostic test has sensitivity P(Positive∣Defect)=0.90. If the defect rate in production is P(Defect)=0.25, find the joint probability of a defect and a positive test result P(Defect∩Positive).A machine learning diagnostic test has sensitivity P(Positive∣Defect)=0.90. إذا كان the defect rate in production is P(Defect)=0.25, أوجد joint probability of a defect و a positive test result P(Defect∩Positive).
Intermediate
By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect)=0.25×0.90=0.2250.
خطوات الحل التفصيلية:
By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect)=0.25×0.90=0.2250.
43
A 2D loss surface is defined as L(w1,w2)=2w12+3w22. Find the gradient vector ∇L at the point (w1,w2)=(2,−1).A 2D loss surface is defined as L(w1,w2)=2w12+3w22. أوجد gradient vector ∇L عند النقطة (w1,w2)=(2,−1).
A medical diagnostic test for a rare disease is designed to be highly sensitive and specific. The disease affects 1 in every 1000 individuals in the population. The test has a sensitivity of 99\% (meaning it correctly identifies 99\% of individuals who have the disease) and a specificity of 95\% (meaning it correctly identifies 95\% of individuals who do not have the disease). If a randomly selected individual from the population tests positive, what is the probability that they actually have the disease?A medical diagnostic test for a rare disease is designed to be highly sensitive و specإذا كانic. The disease affects 1 in every 1000 individuals in the population. The test has a sensitivity of 99\% (meaning it correctly identإذا كانies 99\% of individuals who have the disease) و a specإذا كانicity of 95\% (meaning it correctly identإذا كانies 95\% of individuals who do not have the disease). إذا كان a rوomly selected individual from the population tests positive, what is the probability that they actually have the disease?
Advanced
Let D be the event that an individual has the disease, and P be the event that the individual tests positive. We are given the following probabilities: - Prior probability of having the disease: P(D)=10001=0.001 - Prior probability of not having the disease: P(Dc)=1−P(D)=1−0.001=0.999 - Sensitivity (true positive rate): P(P∣D)=0.99 - Specificity (true negative rate): P(Pc∣Dc)=0.95 From specificity, we can derive the false positive rate: P(P∣Dc)=1−P(Pc∣Dc)=1−0.95=0.05.
We want to find the probability that an individual actually has the disease given a positive test result, which is P(D∣P). We can use Bayes' Theorem:
P(D∣P)=P(P)P(P∣D)P(D)
To find P(P), the overall probability of testing positive, we can use the law of total probability:
Therefore, the probability that a person who tests positive actually has the disease is approximately 0.0194, which is closest to 0.019.
ليكن D be the event that an individual has the disease, و P be the event that the individual tests positive. We are given the following probabilities: - Prior probability of having the disease: P(D)=10001=0.001 - Prior probability of not having the disease: P(Dc)=1−P(D)=1−0.001=0.999 - Sensitivity (true positive rate): P(P∣D)=0.99 - Specإذا كانicity (true negative rate): P(Pc∣Dc)=0.95 From specإذا كانicity, we can derive the false positive rate: P(P∣Dc)=1−P(Pc∣Dc)=1−0.95=0.05.
We want to أوجد احتمال أن an individual actually has the disease given a positive test result, which is P(D∣P). We can use Bayes' Theorem:
P(D∣P)=P(P)P(P∣D)P(D)
To أوجد P(P), the overall probability of testing positive, we can use the law of total probability:
وبالتالي، the probability that a person who tests positive actually has the disease is approximately 0.0194, which is closest to 0.019.
45
Compute the Manhattan (L1) norm and Euclidean (L2) norm of the word vector w=[10,−15]T.احسب Manhattan (L1) norm و Euclidean (L2) norm of the word vector w=[10,−15]T.
Intermediate
L1 norm is the sum of absolute values: ∣10∣+∣−15∣=25. L2 norm is the square root of sum of squares: (10)2+(−15)2=100+225=325.
خطوات الحل التفصيلية:
L1 norm is the sum of absolute values: ∣10∣+∣−15∣=25. L2 norm is the square root of sum of squares: (10)2+(−15)2=100+225=325.
46
In a multiple linear regression model, the Sum of Squared Errors is SSE=20 and the Total Sum of Squares is SST=100. What is the coefficient of determination R2?In a multiple linear regression model, the Sum of Squared Errors is SSE=20 و the Total Sum of Squares is SST=100. What is the coefficient of determination R2?
Intermediate
The coefficient of determination measures the proportion of variance explained: R2=1−SSTSSE=1−10020=1−0.20=0.80.
Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.
The coefficient of determination measures the proportion of variance explained: R2=1−SSTSSE=1−10020=1−0.20=0.80.
Key Mathematical Principle & Verإذا كانication: In exam revision, always تحقق من أن the final result satisfies all domain restrictions, boundary conditions, و the original governing equation by direct substitution into the prompt.
47
In evaluating a binary classifier, the confusion matrix shows TP=70, TN=40, FP=10, and FN=10. Compute the overall classification accuracy.In evaluating a binary classإذا كانier, the confusion matrix shows TP=70, TN=40, FP=10, و FN=10. احسب overall classإذا كانication accuracy.
Basic
Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TN+FP+FNTP+TN=13070+40=130110=84.6%.
Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.
Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TN+FP+FNTP+TN=13070+40=130110=84.6%.
Key Mathematical Principle & Verإذا كانication: In exam revision, always تحقق من أن the final result satisfies all domain restrictions, boundary conditions, و the original governing equation by direct substitution into the prompt.
48
A fully-connected dense layer maps an input x∈R50 to y∈R25 using y=Wx+b. How many total learnable parameters are in this layer?حل المسألة التالية (رياضيات الذكاء الاصطناعي وعلوم البيانات): A fully-connected dense layer maps an input x∈R50 to y∈R25 using y=Wx+b. How many total learnable parameters are in this layer?
Basic
The weight matrix W has shape 25×50, giving 1250 weights. The bias vector b has 25 parameters. Total = 1250+25=1275.
Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.
The weight matrix W has shape 25×50, giving 1250 weights. The bias vector b has 25 parameters. Total = 1250+25=1275.
Key Mathematical Principle & Verإذا كانication: In exam revision, always تحقق من أن the final result satisfies all domain restrictions, boundary conditions, و the original governing equation by direct substitution into the prompt.
49
A logistic regression model produces a class probability p=P(y=1∣x)=0.30. Compute the corresponding log-odds (logit) ln(1−pp).A logistic regression model produces a class probability p=P(y=1∣x)=0.30. احسب corresponding log-odds (logit) ln(1−pp).
Advanced
Odds are 1−pp=0.700.30=0.4286. Taking natural logarithm: ln(0.4286)=−0.847.
Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.
Odds are 1−pp=0.700.30=0.4286. Taking natural logarithm: ln(0.4286)=−0.847.
Key Mathematical Principle & Verإذا كانication: In exam revision, always تحقق من أن the final result satisfies all domain restrictions, boundary conditions, و the original governing equation by direct substitution into the prompt.
50
Evaluate the output of the standard ReLU activation function f(z)=max(0,z) for inputs z1=−4 and z2=6.احسب قيمة the output of the stوard ReLU activation function f(z)=max(0,z) for inputs z1=−4 و z2=6.
Intermediate
By definition of the Rectified Linear Unit: ReLU(z)=z if z>0, and 0 if z≤0. Thus f(−4)=0 and f(6)=6.
Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.
By definition of the Rectإذا كانied Linear Unit: ReLU(z)=z إذا كان z>0, و 0 إذا كان z≤0. Thus f(−4)=0 و f(6)=6.
Key Mathematical Principle & Verإذا كانication: In exam revision, always تحقق من أن the final result satisfies all domain restrictions, boundary conditions, و the original governing equation by direct substitution into the prompt.
AI-assisted, human-reviewed: Questions and walkthroughs are developed with AI assistance and reviewed by senior educators.Report an error here ↗
Generate an authentic assessment covering vector embeddings, neural feedforward calculations, gradient descent optimization, and classification metrics.توليد اختبار الرياضيات للذكاء الاصطناعي وتعلم الآلة (Math for AI) الكامل ↻
Full official exam paperورقة اختبار رسمي كامل
Comprehensive 100-mark assessment covering the mathematical foundations required for modern Machine Learning, Deep Learning, and Data Science.الرياضيات للذكاء الاصطناعي وتعلم الآلة (Math for AI) — Comprehensive 100-mark assessment covering the mathematical foundations required for modern Machine Learning, Deep Learning, and Data Science.
AI-assisted, human-reviewed: Questions and walkthroughs are developed with AI assistance and reviewed by senior educators.Report an error here ↗
↓
Downloadsالتنزيلات
Study Math for AI & Data Science offline. Download comprehensive cheat sheets on neural layer matrix operations, gradient updates, Bayes rules, and dimensionality reduction.الرياضيات للذكاء الاصطناعي وتعلم الآلة (Math for AI) — Study Math for AI & Data Science offline. Download comprehensive cheat sheets on neural layer matrix operations, gradient updates, Bayes rules, and dimensionality reduction.
PDF · ready now
Math for AI & Data Science Handbookالرياضيات للذكاء الاصطناعي وتعلم الآلة (Math for AI) — Math for AI & Data Science Handbook
Eight foundational chapters covering high-dimensional geometry, gradient descent, loss landscapes, and probabilistic modeling.الرياضيات للذكاء الاصطناعي وتعلم الآلة (Math for AI) — Eight foundational chapters covering high-dimensional geometry, gradient descent, loss landscapes, and probabilistic modeling.
DOCX · on request
Native Word packet
Editable .docx problem sets with complete formulas and step-by-step mathematical proofs.ملف وورد (.docx) قابل للتعديل بمعادلات رياضية أصلية (OMML) — جاهز لأوراق العمل أو الاختبارات القصيرة.
Official · Past Papers
Past Papers & Official Tests
Officially released exams and mark schemes from the examining body.
Curated collection of applied AI math drills, vector similarity exercises, and loss optimization challenges.مجموعة شاملة من أوراق العمل التدريبية مع نماذج الإجابة الكاملة مرتبة حسب الوحدات — مجانية للتنزيل والطباعة.
Loading worksheet library…
🍪We use essential browser storage for your math progress and settings. With your consent, we also load cookies for advertising and analytics to support free access to ClipSAT.Privacy Policy
Privacy Policy
Last updated October 16, 2026
ClipSAT is an educational mathematics platform founded by Mr. Mohamed Abdallah, serving students preparing for Saudi national examinations (GAT Qudrat, SAAT Tahsili) and international curricula (AP, Cambridge IGCSE/A-Level, IB, SAT, ACT, and university mathematics). We believe in privacy by design, minimal data collection, and full transparency. This policy explains what data exists, how it is processed, and your rights, in compliance with applicable standards including the Saudi Personal Data Protection Law (PDPL) and international data privacy best practices.
1. What's Stored Locally on Your Device
Study Progress & Preferences: Your completed chapters, accuracy statistics, streak counts, mistake log, flashcard review schedule, and dark-mode setting are stored directly in your browser's local storage (localStorage). This data remains on your device by default and is never transmitted to our servers without your explicit action.
Clearing Local Data: You can reset your local study data at any time from within the platform (via the Progress or Mistake reset buttons) or by clearing your browser's site data.
2. User Accounts, Cloud Sync & Third-Party Processors
To enable cross-device synchronization between your phone, tablet, and computer, ClipSAT offers an optional account system (ClipSAT Free and ClipSAT Plus) powered by Supabase Inc.:
Authentication: Sign-in uses passwordless email magic links or one-time verification codes, or Google OAuth sign-in. We do not store plaintext passwords.
Database & Row Level Security: Synchronized study records (such as completed lessons, mistake items, and spaced repetition schedules) are stored in a managed PostgreSQL database hosted by Supabase. Access is governed by strict database Row Level Security (RLS) policies, ensuring only your authenticated session can access or modify your personal records.
Infrastructure & IP Logging: When your device connects to our cloud infrastructure or APIs (such as Supabase or Cloudflare), servers process your device's IP address and standard HTTP request headers as an inherent technical requirement of internet routing. These logs are maintained by our hosting processors strictly for security auditing, DDoS mitigation, and rate limiting, and are routinely purged after operational retention periods (typically up to 30 days). ClipSAT does not sell or cross-track IP logs.
Account & Data Deletion: You can request full deletion of your cloud account and all associated synchronized records at any time by emailing support@clipsat.org. Deletion requests are fulfilled within 30 days.
3. ClipSAT AI Tutor & Practice Generation
When you interact with the ClipSAT AI Tutor or generate AI practice questions:
Server-Side Proxy: All requests route through a secure server proxy (Supabase Edge Functions). Model provider API keys (Groq / OpenAI) are secured server-side and never exposed to the client.
Data Protection & Rate Limits: Requests are gated behind authenticated user sessions, with server-side quotas, per-IP rate limiting, character length limits, and automated content safety filters to prevent abuse and protect student safety.
Pedagogical Purpose Limitation: Prompts and math questions are processed solely to generate pedagogical explanations and tailored practice exercises. Your questions are not used to train public foundation models without consent.
AI Disclaimer: Explanations are AI-generated and may occasionally contain inaccuracies. The AI Tutor is a supplemental study aid, not a human tutor or a substitute for teacher instruction.
4. Google Forms Integration & Google Drive Permissions
Teachers can optionally connect a Google account to export ClipSAT quizzes and worksheets into Google Forms for use in Google Classroom or other learning management systems. This integration is entirely opt-in:
Minimal Scope: ClipSAT requests only the permissions necessary to create Google Forms, read responses for the created form, and save question diagrams to the teacher's own Google Drive (scoped strictly via drive.file to files ClipSAT itself creates). ClipSAT cannot see, read, or modify any other files in your Google Drive or access student rosters.
Restricted Sharing by Default: Uploaded question diagrams are saved with restricted permissions by default (accessible only by the teacher). Because Google Forms requires image URLs to be publicly fetchable by Google's servers to render diagrams to students, ClipSAT requires explicit teacher consent before enabling link-sharing for uploaded diagrams.
Client-Side Operation: The Google integration operates directly in your browser. No Google OAuth tokens or quiz responses pass through or are saved on any ClipSAT server.
ClipSAT uses essential browser storage to save your learning progress. With your permission via our cookie consent banner, third-party advertising cookies (such as Google Ads) or analytics scripts may be loaded to support free access to our curriculum:
Opt-In Consent: Non-essential advertising and tracking scripts are blocked until you click "Accept All" on the cookie consent banner. If you choose "Essential Only", only necessary local storage is utilized.
Changing Consent: You can change or revoke your cookie choices at any time by clicking in the site footer.
You may also manage personalized advertising preferences directly at Google Ads Settings.
6. Saudi Personal Data Protection Law (PDPL) Compliance
For users in the Kingdom of Saudi Arabia, ClipSAT complies with the principles of the Personal Data Protection Law (Royal Decree No. M/19 and amended by Royal Decree No. M/148):
Fair and Lawful Processing: Personal data is processed fairly, lawfully, and transparently based on user consent.
Purpose Limitation: We collect and process data solely for providing educational content, tracking study progress, and powering interactive learning tools.
Data Minimization: We restrict collection to the minimum data strictly required to deliver our educational services.
User Rights: Under the PDPL, you have the right to be informed about the data collected, access your data, request corrections, request destruction or erasure of your data, and withdraw consent at any time.
7. Visitor Counter & Cookieless Analytics
The home page displays an aggregate, live visit count stored in our Supabase database. Each browser tab increments the shared counter at most once per session using session storage. ClipSAT also uses privacy-first analytics to record aggregate educational interactions (such as diagnostic test completions and feature usage) without tracking personal browsing histories across other sites.
8. Contact & Privacy Requests
If you have any questions about this privacy policy, data practices, or wish to exercise your data rights under the Saudi PDPL or GDPR, please contact our support team at support@clipsat.org. You may also contact us via WhatsApp (+966 59 768 8647) or Telegram (@ClipSAT22).
By accessing or using ClipSAT ("the Platform"), you agree to these Terms of Service. If you do not agree, please do not use the Platform.
1. Core Content & Free-Tier Promise
ClipSAT provides free access to foundational mathematics lessons, proofs, formula sheets, question banks, and interactive visualizers across all 26 curriculum tracks. Under our Free-Tier Promise, content that is free today will remain free and will never be moved behind a paywall.
2. ClipSAT Plus Subscriptions, Billing & 14-Day Refund Policy
ClipSAT Plus is an optional convenience tier offering cross-device cloud synchronization, automated spaced-repetition scheduling, and unlimited AI tutor access.
Billing: Subscriptions are billed in Saudi Riyals (SAR) on an annual (75 SAR/year) or monthly (15 SAR/month) basis.
14-Day Money-Back Guarantee: If you are not completely satisfied with ClipSAT Plus, you may cancel your subscription within fourteen (14) days of your initial purchase or renewal to receive a full refund, no questions asked. To request a refund, contact support@clipsat.org with your purchase details.
Cancellation & Reversion: You may cancel your subscription at any time. Upon expiration, your account seamlessly reverts to the permanent free tier with all your local progress intact.
3. ClipSAT AI Tutor Disclaimer
The "ClipSAT AI Tutor" is an automated artificial intelligence assistant, not Mr. Mohamed Abdallah or a licensed human tutor. AI-generated explanations and math solutions may occasionally contain inaccuracies or omissions. The AI tutor is provided solely as a supplementary learning tool; you should independently verify important derivation steps, formulas, and final answers.
4. Acceptable Use of Content & Copyright
Study notes, dynamic explorers, and practice problems are provided for personal academic use and classroom teaching. Downloaded packets and worksheets may be printed for personal study or non-commercial classroom distribution; commercial resale or unauthorized redistribution is strictly prohibited.
5. Educational Study Aid & No Guarantee of Scores
ClipSAT is an educational study aid designed to reinforce mathematical understanding. Use of the platform does not guarantee any specific examination score or percentile. Users should consult official exam bodies (Cambridge International, College Board, ACT, IB, or Qiyas) for authoritative syllabi and regulations.