System Modeling & Simulation
All Chapters
Chapter 3Exam Weight: Essential Toolkit (Feeds Monte Carlo, Queueing & Midterm 2024/2025 comparisons)Lec 3 Slides 1–90Lec 3 Transcript (Dr. Ayman)Lab 1

Probability & Statistics Review

مراجعة الاحتمالات والإحصاء (Stat 1)

Sample spaces, random variables, expectation & variance algebra, Correlation vs. Causation, the 6 Discrete & 3 Continuous distributions, and empirical displays (Stem-and-leaf, Skewness, Boxplots).

فضاء العينة، المتغيرات العشوائية، حسابات الـ Expectation والـ Variance، الفرق بين الارتباط والسببية (Correlation ≠ Causation)، التوزيعات المتقطعة والمستمرة، والـ Boxplot والـ Skewness.

Chapter Mastery0% (0/3 sections · 0/4 checks)
x
Scope: Assoc. Prof. Ayman Ghoneim (FCAI — Cairo University)
What you'll lock down in this chapter
  • Distinguish Discrete Finite, Discrete Infinite, and Continuous sample spaces.
  • Compute E[X], E[aX+b], Var(X) = E[X²] - (E[X])², and Var(aX₁ + bX₂) including Covariance.
  • Explain Correlation ≠ Causation with confounding variables (Dr. Ayman's ice cream & drowning example).
  • Identify and evaluate Discrete (Uniform, Bernoulli, Binomial, Geometric, Negative Binomial, Poisson) and Continuous (Uniform, Normal, Exponential) distributions.
  • Read Stem-and-leaf plots, Boxplots (Q1, Q2, Q3), and skewness ordering of Mean, Median, and Mode.
Section 3.1High Yield

Random Variables, Expectation, Variance & Confounding

المتغير العشوائي والتوقع والتباين والارتباط والسببية

Core Concept
Random Variable, PMF/CDF & Expectation

المتغير العشوائي وقيمة التوقع E[X]

A Random Variable X is a function mapping outcomes in sample space S to real numbers R. Its CDF F(x) = P(X ≤ x) always rises from 0 to 1, while the Complementary CDF is F_c(x) = 1 - F(x). E[X] is the long-run weighted average—it does NOT have to be a value you can actually observe on one trial!

Worked Example
Dr. Ayman's Coin Game: Head pays 10 EGP, Tail pays 0 EGP. E[X] = 0.5(10) + 0.5(0) = 5 EGP—even though you will NEVER walk away with 5 EGP in your pocket after one toss!
شرح عربي — كلام الدكتور

الـ Random Variable هو دالة بتربط نتايج التجربة بأرقام حقيقية. دالة الـ CDF هي F(x) = P(X ≤ x). خلي بالك إن الـ Expected Value E[X] ده متوسط طويل المدى — مش شرط يطلع رقم ممكن تكسبه في مرة واحدة!

مثال توضيحي:لعبة العملة بتاعة د. أيمن: لو ملك تكسب 10 جنيه، ولو كتابة 0 جنيه. الـ E[X] = 5 جنيه — مع إنك مستحيل تروح في جيبك 5 جنيه من رمية واحدة!
Exam Trap
Why Variance Squares Deviations + Correlation ≠ Causation

ليه بنربّع الانحرافات في Variance؟ والارتباط مش سببية

Deviations (X - μ) cancel to 0 if not squared; squaring gives Var(X) = E[X²] - (E[X])² and penalizes large swings. Covariance Cov(X₁, X₂) and Correlation ρ ∈ [-1, 1] measure linear association only—NEVER causation!

Worked Example
Dr. Ayman's Analogies: (1) Night-out budget 200 EGP: if 5 cancel (195 EGP) you still go; if 80 cancel (120 EGP) the outing collapses—large deviations hurt quadratically! (2) Ice cream sales & drowning deaths rise together in summer because Temperature is a Confounding Variable (or Switzerland suicide rates vs. Egypt ice cream!).
شرح عربي — كلام الدكتور

لو جمعت الفروقات (X - μ) من غير تربيع دايماً بتطلع صفر! التربيع بيخلينا نحس بالخبطات الكبيرة. وأوعى تنسى: الارتباط الإحصائي (Correlation) مش معناه السببية (Causation)!

مثال توضيحي:تشبيهات د. أيمن: (1) خروجة بـ 200 جنيه، لو فرق 5 جنيه عادي، لو 80 جنيه الخروجة بتبوظ — التربيع بيكبّر الضربة الكبيرة. (2) مبيعات الآيس كريم وحالات الغرق بيزيدوا سوا في الصيف بسبب متغير خفي (Confounding variable) وهو درجة الحرارة، مش الآيس كريم اللي بيغرق الناس!
Linear Expectation & Variance
Formula

قوانين التحويل الخطي

Linearity of Expectation
E[aX+b]=a E[X]+bE[aX + b] = a\,E[X] + b
Linear Variance Scaling
Var⁡(aX+b)=a2Var⁡(X)\operatorname{Var}(aX + b) = a^2\operatorname{Var}(X)

When to use: Adding a constant shifts the mean by b but leaves Variance unchanged.

إضافة ثابت b بتزود الـ Mean بس، لكن مبتغيرش الـ Variance خالص!

Variance Shortcut & Sum of Two RVs
Formula

قانون التباين المختصر ومجموع متغيرين

Variance Shortcut
Var⁡(X)=E[X2]−(E[X])2\operatorname{Var}(X) = E[X^2] - (E[X])^2
Weighted Sum Variance
Var⁡(aX1+bX2)=a2Var⁡(X1)+b2Var⁡(X2)+2abCov⁡(X1,X2)\operatorname{Var}(aX_1 + bX_2) = a^2\operatorname{Var}(X_1) + b^2\operatorname{Var}(X_2) + 2ab\operatorname{Cov}(X_1, X_2)
When X₁ and X₂ are independent, Cov(X₁, X₂) = 0, so Var(X₁ - X₂) = Var(X₁) + Var(X₂) (variances ADD even when subtracting!).
Say This, Not That
Don't Say / Trap

Var(X - Y) = Var(X) - Var(Y) for independent X and Y.

Say This Instead

Var(X - Y) = (+1)²Var(X) + (-1)²Var(Y) = Var(X) + Var(Y).

The coefficient b = -1 gets squared to +1, so uncertainty always adds up.

السالب بيتربّع ويبقى موجب! فرق متغيرين مستقلين تشتته مجموع التشتتين مش طرحهم.

Say This, Not ThatLec 3
Don't Say / Trap

High correlation (r = 0.92) proves X causes Y.

Say This Instead

Correlation only shows linear co-movement; check for a Confounding Variable before claiming causation.

الارتباط العالي ممكن سببه متغير تالت (Confounding variable) زي الحرارة مع الآيس كريم والغرق.

Section 3.2Formula Reference

The 6 Discrete & 3 Continuous Distributions

الـ 6 توزيعات المتقطعة والـ 3 توزيعات المستمرة

Discrete Family: Bernoulli → Binomial, Geometric, NegBin, Poisson

التوزيعات المتقطعة والفرق بينها

Every discrete counting model builds on independent Bernoulli(p) trials (except Poisson, which counts rare events over continuous time/space at rate λ).

  • Discrete Uniform(1..k): p = 1/k each.
  • Bernoulli(p): 1 trial; Mean = p, Var = p(1 - p).
  • Binomial(n, p): # successes in n fixed trials; Mean = np, Var = npq.
  • Geometric(p): # trials UNTIL 1st success; P(X=x) = p·q^(x-1); Mean = 1/p, Var = q/p².
  • Negative Binomial(k, p): # trials UNTIL k-th success; Mean = k/p, Var = kq/p².
  • Poisson(λt): # arrivals/flaws in interval t; P(X=x) = e^(-λt)·(λt)^x / x!; Mean = Var = λt (Memoryless arrivals).
شرح عربي — كلام الدكتور

تقريباً كل التوزيعات المتقطعة مبنية على تكرار تجربة Bernoulli(p)، ماعدا الـ Poisson اللي بيعدّ أحداث عشوائية في زمن أو مسافة بمعدل λ.

  • Binomial: عدد النجاحات في n تجربة ثابتة (Mean = np).
  • Geometric: هتستنى كام محاولة لحد أول نجاح (Mean = 1/p).
  • Negative Binomial: هتستنى كام محاولة لحد النجاح رقم k (Mean = k/p).
  • Poisson: عدد الأحداث في فترة زمنية t بمعدل λ (المتوسط = التباين = λt)، زي عيوب سلك النحاس 2.3/mm.
Core Concept
Continuous Family: Uniform, Normal & Exponential

التوزيعات المستمرة (Uniform, Normal, Exponential)

For continuous RVs, P(X = exact point) = 0, and probability equals area under f(x). Exponential(λ) models inter-arrival times between Poisson(λ) events and has the memoryless property.

  • Uniform[a, b]: f(x) = 1/(b-a); Mean = (a+b)/2; Var = (b-a)² / 12.
  • Normal N(μ, σ²): 68% within ±1σ, 95% within ±2σ, 99.7% within ±3σ; standardize Z = (X - μ)/σ.
  • Exponential(λ): f(x) = λ·e^(-λx) for x ≥ 0; CDF F(x) = 1 - e^(-λx); Mean = 1/λ; Var = 1/λ².
شرح عربي — كلام الدكتور

في المتغير المستمر، احتمال قيمة واحدة بالظبط = صفر، والاحتمال هو المساحة تحت المنحنى. توزيع Exponential(λ) بيوصف الوقت بين وصول والتاني في عملية Poisson.

  • Uniform[a,b]: المتوسط (a+b)/2 والتباين (b-a)² / 12.
  • Normal: قاعدة 68-95-99.7% والتحويل القياسي Z = (X - μ)/σ.
  • Exponential(λ): المتوسط 1/λ والتباين 1/λ² والـ CDF هو 1 - e^(-λx).
Poisson PMF (Flaws / Arrivals)
Formula

دالة احتمال بواسون

Poisson($\lambda t$) PMF :: P(X = x) = \frac{e^{-\lambda t}(\lambda t)^x}{x!}, \qquad \mu = \sigma^2 = \lambda t

When to use: Counts arrivals or defects in time/length t given constant rate λ (e.g., 2.3 flaws/mm over 2 mm → λt = 4.6).

بنضرب المعدل λ في الطول أو الزمن t الأول عشان نجيب المتوسط μ = λt.

Continuous Uniform & Exponential
Formula

المتوسط والتباين للـ Uniform و Exponential

Continuous Uniform [a,b][a, b]
E[X]=a+b2,Var⁡(X)=(b−a)212E[X] = \frac{a + b}{2}, \qquad \operatorname{Var}(X) = \frac{(b - a)^2}{12}
Exponential(λ\lambda)
E[X]=1λ,Var⁡(X)=1λ2,F(x)=1−e−λxE[X] = \frac{1}{\lambda}, \quad \operatorname{Var}(X) = \frac{1}{\lambda^2}, \quad F(x) = 1 - e^{-\lambda x}
Section 3.3

Empirical Displays: Skewness & Boxplots

الرسوم الإحصائية: الالتواء (Skewness) والـ Boxplot

Mean vs. Median vs. Mode under Skewness + Boxplot

ترتيب المتوسط والوسيط والمنوال والـ Boxplot

In a symmetric unimodal distribution, Mean = Median = Mode. Long right tail (positive skew, e.g., wealth/wait times) pulls the Mean UP: Mode < Median < Mean. Long left tail (negative skew) pulls the Mean DOWN: Mean < Median < Mode.

  • Stem-and-leaf keeps exact digits visible while showing shape (Lec 3 cardiograms 20-day example).
  • Boxplot marks Min, Q1 (25th), Q2 (Median, 50th), Q3 (75th), and Max; IQR = Q3 - Q1.
شرح عربي — كلام الدكتور

في التوزيع المتماثل (Symmetric): الـ Mean = Median = Mode. الديل اللي على اليمين (Right-skewed) بيشد الـ Mean لفوق فيبقى Mode < Median < Mean. والديل اللي على الشمال (Left-skewed) بيشد الـ Mean لتحت فيبقى Mean < Median < Mode.

  • الـ Stem-and-leaf بيحافظ على الأرقام الأصلية وبيورّيك شكل التوزيع.
  • الـ Boxplot بيعرض 5 أرقام: Min و Q1 و Q2 (الوسيط) و Q3 و Max.
Interactive Simulation LabCh 3–4

Distributions & Monte Carlo Sandbox

التوزيعات الاحتمالية ومحاكاة مونت كارلو

Ch 3–4 Interactive Lab: Distributions & Monte Carlo Sandbox
Tune Binomial, Poisson, Normal, Uniform, and Exponential shapes, then run live Monte Carlo simulations for π, integrals, and profit risk.
Ch 3 & 4
Trials (n)12
Success Prob (p)0.45
Type
Discrete (PMF)
Mean E[X]
5.40
Variance Var(X)
2.97
Instant Micro-Checks0/4 passed

Test your grasp before moving on

Wrong answers are automatically logged to your Weak Topics on the Coverage & Progress dashboard until you pass them.

Check 1
If E[X] = 5 and Var(X) = 4, what are E[2X + 3] and Var(2X + 3)?

لو E[X] = 5 و Var(X) = 4، يبقى E[2X + 3] و Var(2X + 3) بكام؟

Check 2
Inter-arrival times follow Exponential(λ = 0.5/min). What are the mean inter-arrival time and P(X ≤ 3)?

الزمن بين الوصولات Exponential(λ = 0.5). المتوسط كام واحتمال P(X ≤ 3) كام؟

Check 3
Which distribution has Mean = Variance = λt?

أي توزيع فيه المتوسط بيساوي التباين وبيساوي λt؟

Check 4
A histogram of emergency waiting times is strongly skewed to the right (long right tail). Which ordering holds?

توزيع أوقات الانتظار ملتوي لليمين (Right-skewed). إيه الترتيب الصح؟

30-Second Recap
Read these bullets right before entering the exam hall.
  • 1E[aX+b] = aE[X]+b; Var(aX+b) = a²Var(X); Var(X) = E[X²] - (E[X])².
  • 2Correlation ∈ [-1, 1] NEVER proves causation—always look for Confounding Variables.
  • 3Discrete: Binomial (np), Geometric (1/p), NegBin (k/p), Poisson (mean = var = λt).
  • 4Continuous: Uniform[a,b] ((a+b)/2, (b-a)²/12), Normal N(μ,σ²), Exponential(λ) (1/λ, 1/λ², F(x)=1-e^(-λx)).

ملخص ٣٠ ثانية بالعربي:

  • E[aX+b] = aE[X]+b، والـ Var بيتضرب في a² ومش بيتأثر بالـ +b.
  • الارتباط مش سببية — دوّر دايماً على الـ Confounding Variable.
  • في Poisson المتوسط = التباين = λt، وفي Exponential المتوسط = 1/λ والتباين = 1/λ².
  • في Right-skewed دايماً Mode < Median < Mean.
Ready to drill Chapter 3 questions?
10curated concept & written questions for this chapter.