Notes, summaries, assignments, exams, and problems for Mathematics

Sort by
Subject
Level

R Programming Fundamentals, SQL, and Advanced Clustering Methods

Posted by Anonymous and classified in Mathematics

Written on in with a size of 238.95 KB

Section A: R Basics and Data Types (Weeks 1-4)

Model Questions and Answers

Q: Create a vector v (3, NA, Inf, -Inf). Explain adding 5 to v.

A: The operation is element-wise. Missing values (NA) propagate, resulting in NA. Infinite values (Inf, -Inf) remain infinite.

v <- c(3, NA, Inf, -Inf)
print(v + 5)
# Output: [1]  8 NA Inf -Inf

Q: Given vector a, write code to count and replace NAs.

A: Assuming a <- c(10, 15, NA, 20).

  • Count NAs: sum(is.na(a)) → 1.
  • Replace NAs (e.g., with 0): a[is.na(a)] <- 0.

Q: Explain the difference between a[a > 12] and a[which(a > 12)].

A: Both select elements greater than 12 (15, 20). However:

  • a[a > 12][1] 15 NA (Uses logical indexing; preserves the position of NA in the original vector as NA).
  • a[which(
... Continue reading "R Programming Fundamentals, SQL, and Advanced Clustering Methods" »

Intervalos de confianza y pruebas estadísticas para muestras

Classified in Mathematics

Written on in with a size of 4.24 KB

Problema 1: Intervalo para la media (σ conocido)

PROBLEM 1

Nos dan normal distribution.

Desviación estándar σ = 24

Muestra aleatoria simple de 8 — ignorar.

Luego los datos:

185, 180, 167, 162, 176, 170, 181, 192

La pregunta es: confidence interval for the population mean, with a confidence level of...

Paso 1: srs1 = c(185, 180, 162, etc...)

Pregunta (A) — 90%

Ejecutar:

z.test(x = srs1, sigma = 24, conf.level = 0.9)

Pregunta (B) — 95%

Ejecutar:

z.test(x = srs1, sigma = 24, conf.level = 0.95)

Pregunta (C) — 99%

Ejecutar:

z.test(x = srs1, sigma = 24, conf.level = 0.99)

Problema 2: Intervalo para media, varianza y desviación

PROBLEM 2

Te dan números: 45297, 51012, 41764, 41799, 42408, 28543

Normal distribution.

Nivel de significancia = 2% y necesito el

... Continue reading "Intervalos de confianza y pruebas estadísticas para muestras" »

Two-State Actuarial Modeling: Principles and Applications

Posted by Anonymous and classified in Mathematics

Written on in with a size of 3.27 KB

Two-State Actuarial Model

The Two-State Model (also known as the Dead-Alive or Binary Model) is a fundamental actuarial framework used to represent processes that exist in one of two possible states, such as Alive/Dead or Working/Retired. It is widely utilized in life insurance and pension modeling to estimate the probability of transition between states. The model assumes that at any given time, an individual occupies only one state, allowing actuaries to calculate premiums, reserves, and expected present values by simplifying complex uncertainties into binary outcomes.

Core Assumptions

  • Binary States: The system exists in only one of two states at any time.
  • Markov Property: Transitions depend solely on the current state.
  • Constant Probabilities:
... Continue reading "Two-State Actuarial Modeling: Principles and Applications" »

Understanding Financial Formulas and Calculations

Classified in Mathematics

Written on in with a size of 3.51 KB

Tutorial 1

If you get a positive value times a number,

You need to shift the decimal to the right as many times as the number specified.

If negative, move it to the right.

Simple interest formula = S = FV = P(1 + iK)

Compound interest formula = Sk = P(1 + i)^k

Sn = P(1 + I/T)^n
where I is interest
T is frequency of compounding per year
K is the number of years
N is the total number of periods - K T or TK

Depreciation Formula = Vo or P = Initial value,
Vk = P(1 - d)^k

Tutorial 2

1. 5 years 1 + r = (FV/PV)^(1/5)
(i) r = 10.38%
(ii) r = 10.47%
(iii) r = 10.51%
(iv) r = 10.52%
(v) r = 10.52%
2. 1 + r = (1 + 0.06/12)^8 ∙ (1 + 0.072/12)^4
1 + r = (1.005)^8 ∙ (1.006)^4
1 + r = (1.0407) ∙ (1.0242) = 1.06591
r = 6.59%

For an initial outlay of $1000, the net return is

... Continue reading "Understanding Financial Formulas and Calculations" »

Optimal Estimators, Dice Posterior & Statistical Problems

Posted by Anonymous and classified in Mathematics

Written on in with a size of 63.89 KB

Combine Independent Unbiased Estimators

Let d1 and d2 be independent unbiased estimators of θ with variances σ12 and σ22, respectively:

  • E[di] = θ for i = 1,2.
  • Var(di) = σi2.

Any estimator of the form d = λ d1 + (1 - λ) d2 is also unbiased for any constant λ.

The variance (mean square error for an unbiased estimator) is
Var(d) = λ2σ12 + (1 - λ)2σ22.

To minimize Var(d) with respect to λ, differentiate and set to zero:

d/dλ Var(d) = 2λσ12 - 2(1 - λ)σ22 = 0.

Solving gives the optimal weight

λ* = σ22 / (σ12 + σ22).


Question 1: Posterior PMF for a Third Dice Roll

Assume there are five dice with sides {4, 6, 8, 12, 20}. One of these five dice is selected uniformly at random (probability 1/5) and rolled twice. The two observed results are... Continue reading "Optimal Estimators, Dice Posterior & Statistical Problems" »

Statistical Learning and Linear Regression Essentials

Posted by Anonymous and classified in Mathematics

Written on in with a size of 7.23 KB

Introduction to Statistical Learning

Key Notation

  • Y: Response (dependent/output) variable - quantitative or qualitative
  • X₁,...,Xₚ: Predictors (features/covariates/independent variables)
  • p: Number of predictors
  • n: Number of observations
  • i: Subject index (i = 1,...,n)
  • j: Variable index (j = 1,...,p)
  • Data: (Yᵢ, Xᵢ), i = 1,...,n

Types of Learning

  • Supervised learning: Have both Y and X (prediction or inference) - PRIMARY FOCUS
  • Unsupervised learning: Have X but no Y

Model for Data

Yᵢ = f(Xᵢ) + εᵢ, i = 1,...,n
Assumptions: E(εᵢ) = 0, var(εᵢ) = σ², εᵢ are mutually independent
Properties: E(Yᵢ|Xᵢ) = f(Xᵢ), var(Yᵢ|Xᵢ) = σ²

Prediction vs Inference

PredictionInference
ˆY = ˆf(X)Understand relationship between Y and X
ˆf can be black
... Continue reading "Statistical Learning and Linear Regression Essentials" »

Essential Machine Learning Algorithms and Metrics

Classified in Mathematics

Written on in with a size of 106.59 KB

Evaluation Metrics for ML Models

  • Accuracy: The ratio of correctly predicted instances.

  • Precision: Correct positive predictions divided by total predicted positives.

  • Recall: Correct positive predictions divided by actual positives.

  • F1 Score: The harmonic mean of precision and recall.

    AF4gf7O8RoPFAAAAAElFTkSuQmCC

K-Nearest Neighbors (KNN) Algorithm

  • A classification algorithm that works by finding the 'k' closest training examples to a data point.

  • Strengths: Simple to understand, effective for smaller datasets.

  • Weaknesses: Sensitive to irrelevant features and the scale of the data.

  • Applications: Image recognition, recommendation systems.

Ensemble Learning Techniques

  • Combines multiple models to improve predictive performance.

  • Methods:

    • Bagging (e.g., Random Forests)
    • Boosting (e.g., AdaBoost)
... Continue reading "Essential Machine Learning Algorithms and Metrics" »

Theory of Computation: Automata, Grammars, and Turing Machines

Posted by Anonymous and classified in Mathematics

Written on in with a size of 2.37 KB

(a) Alphabet, String, and Language Definitions

  • Alphabet (Σ): A finite, non-empty set of symbols. Example: Σ = {0, 1} or Σ = {a, b}.
  • String: A finite sequence of symbols chosen from an alphabet. Example: 0110, abba.
  • Language (L): A set of strings over an alphabet Σ. Example: L = {a, ab, aab, aaab, ...} = a⁺b over Σ = {a, b}. ε denotes the empty string (length 0).

(b) DFA vs. NFA

  • DFA: For each state and input symbol, exactly one next state is defined. No ε-transitions are allowed.
  • NFA: For each state and input symbol, zero, one, or more next states are possible. ε-transitions are allowed.
  • Power: Both accept the same class of languages (Regular Languages). Every NFA can be converted to an equivalent DFA.
  • Design: DFA usually has more states;
... Continue reading "Theory of Computation: Automata, Grammars, and Turing Machines" »

Year 9 Algebra Essentials: Linear Equations Mastery

Posted by Anonymous and classified in Mathematics

Written on in with a size of 3.63 KB


1. Simplifying Algebraic Expressions

How to Simplify Algebraic Expressions

  • Multiply numbers and letters together.
  • Combine like terms (terms with the same letters and powers).

Example:
−2ac × 4bd = −8abcd

Example:
5ab − 8b²a + ba = 5ab − 8ab² + ab = −8ab² + 6ab


2. Expanding Brackets (Distributive Law)

How to Expand Brackets

  • Multiply everything inside the bracket by what is outside.

Example:
−4(x + 7) = −4x − 28

Example:
5(x − 3) + 2(6 − x) = 5x − 15 + 12 − 2x = 3x − 3


3. Solving Equations

How to Solve Equations

  • Get all variables (e.g., x's) on one side and numbers on the other.
  • Perform the same operation on both sides of the equation.

Example:
3x + 2 = 17
3x = 15
x = 5

Example:
9x − 8 = 4x + 7
5x = 15
x = 3


4. Solving Inequalities

How

... Continue reading "Year 9 Algebra Essentials: Linear Equations Mastery" »

Python Inheritance: Reusing Code with Parent and Child Classes

Posted by Anonymous and classified in Mathematics

Written on in with a size of 3.34 KB

Understanding Inheritance in Python

Inheritance allows a class to use and extend the properties and methods of another class. It promotes code reusability and reduces duplication. Think of it as “child learns from parent.” 👨‍👦‍💻

Code Duplication: Program Without Inheritance

When classes share common attributes or methods (such as first_name, last_name, and get_age), implementing them separately leads to redundant code, as shown below:

import datetime

class TennisPlayer:
    def __init__(self, fname, lname, birth_year):
        self.first_name = fname
        self.last_name = lname
        self.birth_year = birth_year
        self.aces = []

    def get_age(self):
        now = datetime.datetime.now()
        return now.year -
... Continue reading "Python Inheritance: Reusing Code with Parent and Child Classes" »