Skip to content

Commit

Permalink
fix math equations in lists
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedOsamaMath committed Dec 12, 2024
1 parent 7a22b39 commit dace4db
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 105 deletions.
12 changes: 3 additions & 9 deletions 03. Probability/1. Probability Basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,18 @@ Based on intuition, personal judgment, or experience.
1. **Range**:
Probability always lies between 0 and 1:

$$
0 \leq P(A) \leq 1
$$
$$0 \leq P(A) \leq 1$$

2. **Sum of Probabilities**:

The sum of probabilities of all possible outcomes equals 1:

$$
\sum P(A_i) = 1
$$
$$\sum P(A_i) = 1$$

3. **Complement Rule**:
The probability of an event not happening is:

$$
P(\text{Not A}) = 1 - P(A)
$$
$$P(\text{Not A}) = 1 - P(A)$$

**Example**: If $P(A) = 0.7$, then $P(\text{Not A}) = 0.3$.

Expand Down
4 changes: 1 addition & 3 deletions 04. Inferential Statistics/3. Hypothesis Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ A company claims the average lifetime of its batteries is 300 hours. A random sa

3. **Calculate the Test Statistic**:

$$
t = \frac{\bar{x} - \mu}{\frac{s}{\sqrt{n}}} = \frac{290 - 300}{\frac{20}{\sqrt{25}}} = \frac{-10}{4} = -2.5
$$
$$t = \frac{\bar{x} - \mu}{\frac{s}{\sqrt{n}}} = \frac{290 - 300}{\frac{20}{\sqrt{25}}} = \frac{-10}{4} = -2.5$$

4. **Find the Critical Value or P-Value**:
From $t$-distribution tables, critical $t$-value at $\alpha = 0.05$ (two-tailed, $df = 24$) is approximately $\pm 2.064$.
Expand Down
28 changes: 7 additions & 21 deletions 05. Regression Analysis/1. Simple Linear Regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

4. **Equation of the Regression Line**:

$$
Y = \beta_0 + \beta_1X + \epsilon
$$
$$Y = \beta_0 + \beta_1X + \epsilon$$

Where:

Expand Down Expand Up @@ -85,45 +83,33 @@ A researcher wants to study the relationship between study hours ($X$) and test

1. **Equation of Regression Line**:

$$
Y = \beta_0 + \beta_1X
$$
$$Y = \beta_0 + \beta_1X$$

2. **Calculate Coefficients**:

Using the least squares method:

- Slope ($\beta_1$):

$$
\beta_1 = \frac{\text{Cov}(X, Y)}{\text{Var}(X)}
$$
$$\beta_1 = \frac{\text{Cov}(X, Y)}{\text{Var}(X)}$$

- Intercept ($\beta_0$):

$$
\beta_0 = \bar{Y} - \beta_1\bar{X}
$$
$$\beta_0 = \bar{Y} - \beta_1\bar{X}$$

After calculations:

$$
\beta_1 = 3.5, \quad \beta_0 = 46
$$
$$\beta_1 = 3.5, \quad \beta_0 = 46$$

3. **Regression Equation**:

$$
Y = 46 + 3.5X
$$
$$Y = 46 + 3.5X$$

4. **Predicted Values**:

For $X = 6$:

$$
Y = 46 + 3.5(6) = 67
$$
$$Y = 46 + 3.5(6) = 67$$

---

Expand Down
16 changes: 4 additions & 12 deletions 05. Regression Analysis/2. Multiple Regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

3. **Regression Equation**:

$$
Y = \beta_0 + \beta_1X_1 + \beta_2X_2 + \dots + \beta_kX_k + \epsilon
$$
$$Y = \beta_0 + \beta_1X_1 + \beta_2X_2 + \dots + \beta_kX_k + \epsilon$$

Where:

Expand Down Expand Up @@ -80,9 +78,7 @@ A company wants to predict employee salaries ($Y$) based on years of experience

1. **Regression Equation**:

$$
Y = \beta_0 + \beta_1X_1 + \beta_2X_2
$$
$$Y = \beta_0 + \beta_1X_1 + \beta_2X_2$$

2. **Fit the Model**:

Expand All @@ -94,17 +90,13 @@ A company wants to predict employee salaries ($Y$) based on years of experience

3. **Regression Equation**:

$$
Y = 40,000 + 5,000X_1 + 10,000X_2
$$
$$Y = 40,000 + 5,000X_1 + 10,000X_2$$

4. **Prediction**:

For an employee with 7 years of experience ($X_1 = 7$) and education level 2 ($X_2 = 2$):

$$
Y = 40,000 + 5,000(7) + 10,000(2) = 40,000 + 35,000 + 20,000 = 95,000
$$
$$Y = 40,000 + 5,000(7) + 10,000(2) = 40,000 + 35,000 + 20,000 = 95,000$$

---

Expand Down
44 changes: 11 additions & 33 deletions 05. Regression Analysis/3. Logistic Regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@
3. **Logistic Function (Sigmoid Function)**:
Converts the linear combination of inputs into probabilities between 0 and 1.

$$
P(Y=1 \mid X) = \frac{1}{1 + e^{-(\beta_0 + \beta_1X_1 + \beta_2X_2 + \dots + \beta_kX_k)}}
$$
$$P(Y=1 \mid X) = \frac{1}{1 + e^{-(\beta_0 + \beta_1X_1 + \beta_2X_2 + \dots + \beta_kX_k)}}$$

4. **Log-Odds Transformation**:
The logistic model estimates the log-odds of the probability:

$$
\text{Log-Odds} = \ln\left(\frac{P}{1-P}\right) = \beta_0 + \beta_1X_1 + \beta_2X_2 + \dots + \beta_kX_k
$$
$$\text{Log-Odds} = \ln\left(\frac{P}{1-P}\right) = \beta_0 + \beta_1X_1 + \beta_2X_2 + \dots + \beta_kX_k$$

---

Expand Down Expand Up @@ -97,34 +93,22 @@ A bank wants to predict whether a loan applicant will default ($Y = 1$) or not (

1. **Logistic Model**:

$$
P(Y=1 \mid X_1, X_2) = \frac{1}{1 + e^{-(\beta_0 + \beta_1X_1 + \beta_2X_2)}}
$$
$$P(Y=1 \mid X_1, X_2) = \frac{1}{1 + e^{-(\beta_0 + \beta_1X_1 + \beta_2X_2)}}$$

2. **Estimated Coefficients**:

$$
\beta_0 = -10
$$
$$\beta_0 = -10$$

$$
\beta_1 = 0.0001
$$
$$\beta_1 = 0.0001$$

$$
\beta_2 = 0.02
$$
$$\beta_2 = 0.02$$

3. **Prediction for New Applicant**:
Applicant with income $X_1 = 65,000$ and credit score $X_2 = 720$:

$$
\text{Log-Odds} = -10 + 0.0001(65,000) + 0.02(720) = -10 + 6.5 + 14.4 = 10.9
$$
$$\text{Log-Odds} = -10 + 0.0001(65,000) + 0.02(720) = -10 + 6.5 + 14.4 = 10.9$$

$$
P(Y=1) = \frac{1}{1 + e^{-10.9}} \approx 0.999
$$
$$P(Y=1) = \frac{1}{1 + e^{-10.9}} \approx 0.999$$

The applicant is very likely to default.

Expand All @@ -140,21 +124,15 @@ A bank wants to predict whether a loan applicant will default ($Y = 1$) or not (

2. **Accuracy**:

$$
\text{Accuracy} = \frac{\text{TP} + \text{TN}}{\text{Total Observations}}
$$
$$\text{Accuracy} = \frac{\text{TP} + \text{TN}}{\text{Total Observations}}$$

3. **Precision**:

$$
\text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}}
$$
$$\text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}}$$

4. **Recall**:

$$
\text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}}
$$
$$\text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}}$$

5. **AUC-ROC**:
Measures the model's ability to distinguish between classes. A higher value indicates better performance.
Expand Down
4 changes: 1 addition & 3 deletions 06. Advanced Topics/1. ANOVA and MANOVA.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ ANOVA tests whether there are statistically significant differences between the
4. **F-Test**:
The test statistic is the ratio of between-group variance to within-group variance.

$$
F = \frac{\text{Variance Between Groups}}{\text{Variance Within Groups}}
$$
$$F = \frac{\text{Variance Between Groups}}{\text{Variance Within Groups}}$$

---

Expand Down
16 changes: 4 additions & 12 deletions 06. Advanced Topics/2. Time Series Analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,19 @@ Forecast sales for Jan 2023.

1. **Mean Absolute Error (MAE)**:

$$
MAE = \frac{1}{n} \sum_{i=1}^{n} |y_i - \hat{y}_i|
$$
$$MAE = \frac{1}{n} \sum_{i=1}^{n} |y_i - \hat{y}_i|$$

2. **Mean Squared Error (MSE)**:

$$
MSE = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2
$$
$$MSE = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2$$

3. **Root Mean Squared Error (RMSE)**:

$$
RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2}
$$
$$RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2}$$

4. **Mean Absolute Percentage Error (MAPE)**:

$$
MAPE = \frac{1}{n} \sum_{i=1}^{n} \left|\frac{y_i - \hat{y}_i}{y_i}\right| \times 100
$$
$$MAPE = \frac{1}{n} \sum_{i=1}^{n} \left|\frac{y_i - \hat{y}_i}{y_i}\right| \times 100$$

---

Expand Down
16 changes: 4 additions & 12 deletions 06. Advanced Topics/3. Bayesian Statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
4. **Bayes’ Theorem**:
The mathematical formula for updating probabilities:

$$
P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)}
$$
$$P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)}$$

Where:

Expand Down Expand Up @@ -72,19 +70,13 @@ The prevalence of the disease is 1% in the population. What is the probability t

3. **Calculate Evidence ($P(B)$)**:

$$
P(B) = P(B \mid A) \cdot P(A) + P(B \mid \text{Not } A) \cdot P(\text{Not } A)
$$
$$P(B) = P(B \mid A) \cdot P(A) + P(B \mid \text{Not } A) \cdot P(\text{Not } A)$$

$$
P(B) = (0.95 \cdot 0.01) + (0.10 \cdot 0.99) = 0.0095 + 0.099 = 0.1085
$$
$$P(B) = (0.95 \cdot 0.01) + (0.10 \cdot 0.99) = 0.0095 + 0.099 = 0.1085$$

4. **Apply Bayes’ Theorem**:

$$
P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)} = \frac{0.95 \cdot 0.01}{0.1085} \approx 0.0876
$$
$$P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)} = \frac{0.95 \cdot 0.01}{0.1085} \approx 0.0876$$

### Interpretation:

Expand Down

0 comments on commit dace4db

Please sign in to comment.