Math Matters: Essential Math for Aspiring AI Experts

The journey starts with mastering some essential mathematical concepts! Linear algebra is our toolkit for handling and manipulating data in multiple dimensions. Calculus becomes our guide to understanding how models learn and optimize performance. Probability and statistics are our crystal balls, helping us predict outcomes and discover patterns in the data. Finally, discrete mathematics shapes our ability to design and analyze algorithms. These mathematical foundations enable us to construct, comprehend, and improve advanced AI and ML models.

Math Matters: Essential Math for Aspiring AI Experts

A prehistoric scene set in the stone age, depicting early humans learning basic counting and mathematics in a natural setting.

Image credits: Image generated by DALL-E.

Why Mathematics Matters for AI?

Mathematics is the hidden engine driving the fascinating world of AI and ML. Imagine trying to build a bridge without understanding the principles of physics—that's what AI development would be like without math! The fundamental laws and principles of physics, such as stress, strain, and gravity, are essential for understanding the behavior of physical systems. Similarly, mathematics provides the fundamental tools and techniques for understanding and analyzing complex systems, such as data patterns, probability, and optimization.

Whether we're a math whiz or a curious newbie, the math concept that's been buzzing around in our brain is probably the key to unlocking AI's incredible abilities. From the geometry of self-driving cars to the algebra of language processing, math is the thread that weaves together the complex systems and algorithms of AI.

Unlock the secrets of AI with the ultimate math toolkit! While calculus, linear algebra, optimization, probability, and statistics are the top-tier math subjects for AI implementation, don't worry if you're not a master of them all. Think of it like a recipe for AI success: you only need to know the right ingredients to cook up a masterpiece. Focus on the math topics that spark your curiosity, and you'll be well on your way to creating AI that's the talk of the town!

Depending on the dish we're trying to cook up, we might need to add a pinch of random matrix theory to spice up our machine learning, a dash of graph theory to navigate complex networks, a sprinkle of game theory to beat our opponents, a simmer of differential equations to model real-world phenomena, or a dash of operations research to optimize our workflow. With the right math ingredients, we'll be serving up AI solutions that are the perfect blend of art and science!

By mastering these mathematical concepts, we unlock the true potential of AI and ML, transforming theory into groundbreaking applications. Dive in, and watch as the numbers come alive, powering the future of intelligent technology. Setting out on a journey to understand artificial intelligence (AI) and machine learning (ML) can be both "thrilling" and "daunting"—especially when it comes to the mathematics that support these technologies. If you’re looking to dive into this field of essential mathematics for AI and ML, knowing where to start and how to proceed effectively with your mathematical learning is crucial.

Here’s a structured direction to help you navigate through the essential mathematics for AI and ML:

Starting with: 1. Basic Mathematics (Foundation level)

As part of basic mathematics, we will cover number theory (whole numbers, integers, rational numbers, and irrational numbers).

Next: 2. Algebra (Foundation for Linear Algebra)

Algebra provides the basic skills needed to manipulate numbers, variables, and expressions, which are crucial in linear algebra.

Next: 3. Linear Algebra (Most important)

Linear algebra is the first mathematical toolkit we should arm ourselves with. It forms the foundation of how data is structured and manipulated in AI and ML. Here’s a brief look at how linear algebra contributes to AI and ML:

  • Data Representation
    • Vectors and Matrices: Data in machine learning is often represented as vectors (1D arrays) and matrices (2D arrays). For example, a dataset with n features1 and m samples can be represented as an m x n matrix.
    • Images: Digital images are represented as matrices (2D for grayscale images, 3D for color images with RGB channels).
  • Linear Transformations
    • Feature Transformation: Linear transformations, represented by matrices, are used to change the representation of data. This includes scaling, rotating, and translating data points.
    • Dimensionality Reduction: Techniques like Principal Component Analysis (PCA) use linear algebra to reduce the dimensionality of data, helping to simplify models and visualize high-dimensional data.
  • Optimization Algorithms
    • Gradient Descent: This algorithm, fundamental to training many machine learning models, involves operations on vectors to update parameters iteratively.
    • Convex Optimization: Many optimization problems in machine learning, such as support vector machines, rely on convex functions, where linear algebra helps in finding optimal solutions.
  • Neural Networks
    • Weights and Activations: Neural networks are essentially composed of layers of linear transformations (weights as matrices) followed by non-linear activations. Backpropagation, the algorithm for training neural networks, involves matrix and vector operations.
    • Convolutional Operations: Convolutional neural networks (CNNs) use convolutions, which are linear operations applied to data structured as matrices.

These are only a few examples of how linear algebra contributes to AI and ML, demonstrating its fundamental role in various aspects of these fields.

Key topics:

  • Vectors and matrices
  • Matrix operations
  • Eigenvalues and eigenvectors
  • Singular value decomposition

Next: 4. Calculus (Highly Recommended)

Once we are comfortable with linear algebra, calculus should be our next topic. Calculus, particularly differential calculus, is essential for understanding how algorithms optimize and learn from data. It allows us to understand gradient descent—an optimization algorithm that is fundamental in training deep learning models. By learning about derivatives and integrals, we will be better equipped to understand the dynamics of machine learning algorithms, especially how changes in data affect the learning process.

Key topics:

  • Derivatives and integrals
  • Partial derivatives
  • Multivariable calculus (for advanced learning)

Next: 5. Probability and Statistics

Probability and statistics are crucial for handling and making decisions from data, which is inherently noisy and uncertain. These branches of mathematics help in modeling and evaluating the behavior of algorithms under various conditions. Understanding concepts like probability distributions, statistical tests, and bayesian thinking will empower us to design and evaluate ML models more effectively.

Key topics:

  • Probability rules and distributions
  • Descriptive statistics (mean, median, variance)
  • Hypothesis testing and Bayesian methods

Next: 6. Discrete Mathematics

Discrete mathematics introduces us to the logical and structural aspects of mathematics that are important for algorithm design and analysis. This area enhances our understanding of how algorithms function and their limitations, which is essential for debugging and improving AI models.

Key topics:

  • Logic and set theory
  • Combinatorics
  • Graph theory
  • Information theory

Finally: 7. Optimization Theory (Advance Topic)

Understanding optimization techniques is akin to learning the art of fine-tuning AI models. Optimization in AI is about finding the best configuration of model parameters2 to improve accuracy and performance. Familiarity with concepts like convex optimization and learning various gradient descent methods will serve as your final piece of the puzzle.

Key topics:

  • Linear programming
  • Convex optimization
  • Gradient descent methods

By following this structured path, we not only build a solid foundation in the mathematics necessary for AI and ML but also develop the practical skills to bring our ideas to life. Don't be fooled - this is no sprint3, but a marathon that requires patience, persistence, and dedication.


1. Basic Mathematics

Number Theory

Before we go into detail explaining all these essential mathematics, let’s first know briefly about number theory and why it is important.

Number theory is a branch of mathematics that deals with the properties and relationships of numbers, especially integers. It provides a framework for solving problems related to patterns, relationships, and cryptography, which are critical components of AI and ML.

  • Cryptography: Secure communication relies heavily on number theory, particularly prime numbers and modular arithmetic.
  • Algorithms: Many algorithms in computer science, including those used in AI, are based on number-theoretic principles.
  • Data structures: Efficient data storage and retrieval methods often utilize concepts from number theory.

Here are different number systems:

Natural Numbers

hese are the numbers 1, 2, 3, 4, 5... and so on. Only positive numbers are included here.

Whole Numbers

Whole numbers are non-negative integers, including 0. Whole numbers include all natural numbers, plus zero. The set of whole numbers is: 0, 1, 2, 3, 4, 5,...

Integers

Integers include positive and negative natural numbers as well as 0.

Rational Numbers

A rational number is a number that can be expressed as the ratio of two integers, i.e., a fraction. It is a number that can be written in the form: a/b, where a and b are integers, and b is non-zero.

Irrational Numbers

Irrational numbers cannot be expressed as a fraction. This means they cannot be expressed as a ratio of two integers a/b, where a and b are integers and b is not zero. It's non-repeating and non-terminating decimals. This means, the decimal form of an irrational number goes on forever without repeating. Think of it like this: if we tried to write out an irrational number's decimal places, we could keep writing forever and never find a pattern or reach the end.

Rational numbers (NOT irrational):

  • 0.5 (can be written as 1/2)
  • 0.333333... (can be written as 1/3, has a repeating pattern)
  • 0.75 (can be written as 3/4)

Irrational numbers:

  • π (pi) is 3.14159265... - the digits after the decimal point never end and never fall into a pattern
  • √2 (1.41421356...) - again, the digits keep going forever without repeating

This is why in real-world calculations, we often use approximations of irrational numbers (like using 3.14 for π) since we can't write out their exact value.

Different Number Systems

Figure 1: Different Number Systems.

Complex and Imaginary Numbers

Complex Numbers

In mathematics, complex numbers are numbers that can be expressed in the form: a + bi, where a is a real number (a scalar), b is a real number (a scalar) and i is the imaginary part, which is defined as the square root of -1.

Imaginary Numbers

Imaginary numbers are a subset of complex numbers, and they are numbers that can be expressed in the form: bi. Imaginary numbers are often combined with real numbers to form complex numbers. Imaginary numbers are numbers that, when squared, give a negative result. This is fundamentally different from real numbers, where squaring any real number always gives a positive result.

Imaginary numbers are unique because they allow for the square roots of negative numbers. This extension of the number system is crucial for solving many mathematical and real-world problems that cannot be addressed with real numbers alone. By defining i and using it to form other imaginary numbers, we can square these numbers and always get a negative result, thus expanding our mathematical toolkit.

Data

Qualitative Data vs. Quantitative Data

Qualitative Data (Categorical Data)

  • Qualitative data describes qualities, attributes, or characteristics that are non-numeric and cannot be measured directly.
  • It often involves categories or labels.

Key Characteristics:

  • Descriptive in nature.
  • Cannot perform mathematical operations (e.g., addition, averages).
  • Answers questions like "what kind?" or "which type?"

Examples:

  1. Customer Feedback: "Good," "Bad," "Neutral."
  2. Product Colors: Red, Blue, Green.
  3. Survey Responses: "Satisfied," "Very Satisfied," "Dissatisfied."
  4. Employee Role: Manager, Engineer, Intern.
  5. Country of Origin: USA, UK, India.

When to Use It:

  • To analyze non-numeric trends and patterns.
  • To classify or group data based on categories.

Quantitative Data (Numerical Data)

  • Quantitative data consists of numeric values that can be measured or counted.
  • It involves quantities and allows for mathematical operations.

Key Characteristics:

  • Numerical in nature.
  • Can perform arithmetic operations (e.g., sum, average, range).
  • Answers questions like "how many?" or "how much?"

Types of Quantitative Data:

  • Discrete Data: Countable, whole numbers (e.g., 1, 2, 3…).
  • Continuous Data: Measured values that can take decimals (e.g., 5.5, 7.8).

Examples:

  1. Customer Age: 25, 30, 45.
  2. Monthly Sales: $10,000, $15,000, $20,000.
  3. Temperature: 35.5°C, 20.1°C.
  4. Number of Orders: 150, 200, 500.
  5. Height or Weight: 5.8 feet, 75 kg.

When to Use It:

  • To analyze trends with measurable data.
  • To perform statistical analysis or calculations.

Types of Data

  1. Categorical (Qualitative) Data
    • Nominal Data: Categories with no natural order
      • Color of cars (Red, Blue, Black)
      • Gender (Male, Female, Non-binary)
      • Blood types (A, B, AB, O)
      • Payment methods (Cash, Credit card, Debit card)
    • Ordinal Data: Categories with a natural order/ranking
      • Education level (High school, Bachelor's, Master's, PhD)
      • Customer satisfaction (Very dissatisfied, Dissatisfied, Neutral, Satisfied, Very satisfied)
      • Spicy food preference (Mild, Medium, Hot, Extra hot)
      • T-shirt sizes (XS, S, M, L, XL)
  2. Numerical (Quantitative) Data
    • Discrete Data: Countable values with clear gaps between them
      • Number of children in a family (1, 2, 3...)
      • Number of products sold per day
      • Number of errors in a program
      • Count of website visitors
    • Continuous Data: Measurements that can take any value within a range
      • Height (172.5 cm, 175.3 cm)
      • Temperature (36.8°C, 37.2°C)
      • Time to complete a task (15.7 minutes)
      • Weight (68.3 kg)

Each type of data requires different analysis methods and visualization techniques:

  • Categorical data is often analyzed using frequencies, proportions, and mode
  • Ordinal data can use median and percentiles
  • Numerical data can use mean, standard deviation, range, and more complex statistical measures

Understanding these data types is crucial because it determines:

  • How you can analyze the data
  • What statistical tests you can apply
  • Which visualization methods are most appropriate
  • What kinds of conclusions you can draw from the data

2. Algebra

Before we dive into the world of linear algebra, let's take a step back and understand what algebra actually is.

Definition:

Algebra is a branch of mathematics that uses letters or symbols epresent numbers and quantities in equations and expressions. It helps us to solve problems by finding unknown values. For example, in the equation (x + 3 = 7), x is an unknown number that we can use rules and operations (like addition, subtraction, multiplication, and division) to find the values of those unknowns.

Algebra is a lot like arithmetic10. It follows all the rules of arithmetic, and it uses the same four main operations that arithmetic is built on:

  • Addition
  • Subtraction
  • Multiplication
  • Division

Algebra introduces a new element — the element of the unknown. In arithmetic, we're working with known, specific numbers to find a single unknown answer. Like in the example given: 1 + 2 = ? - everything before the equals sign is known, and we're just calculating the result.

In algebra, we're often working with:

  • Unknown values from the start (like x + 2 = 5)
  • Multiple unknowns at once (like x + y = 10)
  • Variables that could represent many different values (like in the formula for area of a rectangle: A = l × w)

This shift from working with concrete numbers to working with unknowns is what makes algebra more abstract but also more powerful.

It allows us to:

  • Write general formulas that work for any numbers (Take rectangle formula (A = l × w). Instead of writing "2 × 3 = 6" for one rectangle, we can write just one formula: A = l × w. This single formula works for ALL rectangles, no matter how big or small they are)
  • Solve problems where we don't have all the information upfront
  • Describe relationships between quantities that might change

This change from arithmetic to algebra is a big step in how we think about math because it means we have to think about numbers in a different way. Instead of just working with actual numbers like 1, 2, or 3, we now have to imagine numbers that could be anything. It's like moving from counting real objects to thinking about numbers that we can't see yet.

The crucial aspect of algebra is that, when we are unfamiliar with a number, we substitute it with a symbol, typically any letter from the alphabet. A really popular letter to choose is the letter x. So in arithmetic, we would just leave the problem like this: 1 + 2 = "blank", and we'd write in the answer when we did the addition. But in algebra, we'd write it like this: 1 + 2 = x. The x is a placeholder that stands for the number that we don't know yet.

What we have here is a very basic algebraic equation. An equation is just a mathematical statement that two things are equal. An equation says: the things on one side of the equal sign have the same value as the things on the other side of the equal sign. In the 1 + 2 = x case, our equation is telling us that the unknown values on the side (1 + 2) are equal to what's on the other side, which happens to be the unknown value that we are calling x.

Algebraic Equation

Figure 2: Algebraic Equation.

One of the main goals in algebra is to figure out what the unknown values in equations are. We refer to this process as "solving the equations." In this equation, it's pretty straightforward to see that the unknown value is just 3. Simply adding 1 and 2 on the left side of the equation yields 3 = x, which is the same as x = 3. So now we know what x is. It's just a 3.

Let's take a little complex equation: x - 2 = 1. This is exactly the same equation as 1 + 2 = x, but it has been rearranged so that it's not quite as straightforward to tell what x is. To solve x in x - 2 = 1, add 2 to both sides: x - 2 + 2 = 1 + 2, which is equal to x = 3.

So in algebra, solving equations is a lot like a game where we are given mixed-up, complicated equations, and it's our job to simplify them and rearrange them until it's a nice, simple equation (like x = 3) where it's straightforward to tell what the unknown values are.

Now, let's learn some important rules about how symbols can and can't be used in algebraic equations.

Rules

Rule 1: The same symbol/letter can represent different values in different problems

The first rule we need to know is that the same symbol (or letter) can be used in different algebra problems to stand for different unknown values. For example, in the problem (1 + 2 = x where x = 3) we just solved, the letter x was used to stand for the number 3, right?

But x could stand for a different number in a different problem. For instance, we could be asked to solve the equation 5 + x = 10. For the two sides of this equation to be equal, x must have a value of 5, as 5 + 5 equals 10. So x (or any other symbol) can stand for different values in different problems.

Rule 2: A symbol cannot represent different values in the same problem simultaneously

What's NOT okay is for a symbol to stand for different values in the same problem at the same time!

Algebraic Equation

Figure 3: Algebraic Equation.

For example, what if we had the equation: x + x = 10? This equation says that if we add x to x, we will get 10. There are a variety of different numbers that we can add together to get 10.

x + x = 10
6 + 4 = 10

But if we had the first x stand for 6 and the second x stand for 4, then x would stand for two different values at the same time, and things could get really confusing!

Rule 3: Different symbols can be used to represent different values in the same equation

If we wanted symbols to stand for two different numbers at the same time, we need to use two different symbols, like x and y.

x + y = 10
6 + 4 = 10

So in algebra, whenever we see the same symbol repeated more than once in an equation, it's representing the same unknown value. Like if we see a really complicated algebraic equation like the one below (Figure 4), where x is repeated a lot of different times, all of those xs stand for the same value, and it will be our job to figure out what the value is.

Complex Algebraic Equation

Figure 4: Complex Algebraic Equation.

Having said that, for any particular equation, we can't use the same letter or symbol to represent two different numbers at the same time.

Rule 4: Different symbols can represent the same value if that satisfies the equation

Could we use two different letters to represent the same number? Yes! Here is an example of that.

Let's say we have the equation: a + b = 2. What could a and b stand for so that the equation is true? If a was 0 and b was 2, then the equation would be true. If a was 2 and b was 0, the equation would also be true. But there's another possibility: if a was 1 and b was also 1, that would make the equation true, right?

a + b = 2
0 + 2 = 2
2 + 0 = 2
1 + 1 = 2

So, even though a and b are different symbols and would usually be used to represent different numbers, there are times when they might happen to represent the same number. Indeed, this problem can shed light on a crucial aspect of algebraic symbol usage.

Rule 5: Variables in an equation can have different valid values depending on the values of other variables

Did you notice that there were different possible solutions for this equation? In other words, b could have the value 0, 1, or 2 depending on what the value of a was.

If a = 0 then b = 2
if a = 1 then b = 1
if a = 2 then b = 0

Here, b can't have two different values at the same time, but its value can change over time if the value of a changes. In algebra, we refer to b as a variable because its value is subject to variation or change. In this equation, both a and b are variables because their values will change depending on each other's values.

In fact:

  • Letters as Stand-ins:
    • When we say "letters as stand-ins" in algebra, we mean that letters are used to represent numbers or take the place of numbers.
    • In algebra, we often use letters (like x, y, a, b) to represent numbers.
    • These letters can represent different values in different problems.
    • For example: x might be 5 in one problem and 12 in another problem.
  • True Variables:
    • In mathematics, a "variable" specifically refers to a value that can change within the same problem.
    • Like temperature changing throughout the day or the speed of a car during a journey.

So while we casually call any letter in algebra a "variable," technically speaking, a true variable is something that can take different values as part of the same situation or problem.

For example, in the equation x + 5 = 12:

  • Here, x is just standing in for one specific number (7)
  • It's not really "varying" - it has one fixed value in this problem

But in a formula like d = rt (distance = rate × time):

  • Both r and t are true variables because they can take different values in the same problem
  • The speed (rate) might change during the journey
  • Time is constantly changing as you travel

So far, we have learned that algebra is a lot like arithmetic, but that includes unknown values and variables that we can solve for in equations.


3. Linear Algebra

Linear algebra is a branch of mathematics that has revolutionized the way we understand and interact with the world around us.

It deals with:

  • Vectors (list of ordered numbers)
  • Vector Spaces (collections of vectors)
  • linear Transformations (functions that map vectors to other vectors in a specific way)
  • Systems of Linear Equations (sets of equations solved simultaneously)

Understanding the Difference Between Algebra and Linear Algebra

The key difference is that algebra deals with a wider range of equations and mathematical structures, while linear algebra focuses specifically on linear equations, vectors, matrices, and their associated operations. Linear algebra can be considered a specialized subset of algebra. Everything in linear algebra is also algebra, but not everything in algebra is linear algebra.

Algebra: Usually solves for one variable

3x + 4 = 10

Linear Algebra: Handles multiple variables at once

2x + 3y = 8
4x - y = 6

Real-World Applications

  • Algebra:

    • Calculating discounts
    • Finding time for a journey
    • Basic problem solving
  • Linear Algebra:

    • Computer graphics (moving objects in games)
    • Data analysis (handling large datasets)
    • Machine learning (making predictions)

At its core, linear algebra is about understanding and working with lines and planes in higher-dimensional spaces8. At its core, linear algebra is about vectors.

What is a Vector?

A vector is a way to represent data as a list of numbers. It's typically represented as an ordered list of numbers. These numbers represent features or characteristics of something. Think of it like a container holding several values, arranged in a specific order. The order of the numbers matters because each position in the vector corresponds to a specific feature or attribute. Changing the order changes the meaning. Here's why and how:

Customer Data

Let's say a vector represents a customer with three features: age, income, and purchase frequency.

  • Vector 1: [30, 50000, 2] This represents a 30-year-old customer with a $50,000 income and 2 purchases.
  • Vector 2: [50000, 30, 2] This represents something completely different! It implies a customer with an age of $50,000, an income of 30, and 2 purchases. This is nonsensical.

So the order (age, income, and purchase frequency) is crucial for interpretation. Changing it makes the data meaningless.

The power of vectors lies in how easily computers can perform calculations on them. These calculations help in:

  • Similarity Measurements: How similar are two customers? Compare their vectors.
  • Clustering: Group similar data points together based on their vector representations.
  • Prediction: Use vectors as input to models that learn patterns and make predictions.

A vector has two key properties:

  • Magnitude (how much/how big)
  • Direction (which way)

Real-World Examples:

  • Wind:

    • Magnitude: 30 mph (how strong the wind is)
    • Direction: Northeast (which way it's blowing)
    • Vector Representation: [30 mph, Northeast]
  • Driving a car:

    • Magnitude: 40 mph (speed)
    • Direction: North
    • Vector Representation: [40 mph, North]

Having said that, a vector is a mathematical measurement that has both magnitude and direction, often used to represent quantities5. In linear algebra, vectors are often represented as arrows, with the length of the arrow representing the magnitude of the vector and the direction of the arrow representing the direction of the vector.

Think of them as super-powered lists of numbers that can be added, subtracted, multiplied, and combined in countless ways. With vectors, we can represent everything from data points to directions, velocities, and even complex systems. Vectors are a fundamental concept in linear algebra and are used in many areas of mathematics and science. The purpose of the vector is to visually represent a piece of data.

Vector often represented graphically as an arrow. The length of the arrow represents the magnitude, and the arrow's direction represents the vector's direction. We can think of it as a displacement7 or movement from one point to another.

Example:

Imagine a vector v in a two-dimensional space, starting from the origin (0,0) and pointing to the point (3, 6). Graphically, this vector can be represented as:

Vector diagram (3,6)

Figure 5: Shows a vector `v` that moves `3` steps in the horizontal direction and `6` steps in the vertical direction.

In Figure 1, the vector v is shown as an arrow starting at the origin (0,0) and ending at the point (3,6). The arrow indicates the direction and length (magnitude) of the vector.

What is a Vector Space?

A vector space is a collection of vectors that satisfies certain mathematical rules, specifically defined by two fundamental operations:

  1. Vector Addition: When we add any two vectors in the space, the result must be another vector in the same space.
  2. Scalar Multiplication: When we multiply any vector by a real number (scalar), the result must be another vector in the same space.

The term "space" in this context is like a container or environment where vectors live and follow specific for how vectors can behave. It's like a playground specifically designed for vectors where:

  • We can add vectors together.
  • We can multiply vectors by numbers (scalars).
  • The result of these operations stays in the same space.

Like fish need water, vectors need their space.

Effects of Scalar Multiplication and Vector Addition

When we multiply a vector by a scalar, we're changing the vector's magnitude (length) but not its direction. Multiplying a vector by a positive scalar changes only its magnitude; the direction remains the same. However, multiplying by a negative scalar reverses the direction.

Vector addition does change the direction of a resultant vector. When we add two vectors, the resulting vector points in a new direction determined by the vector sum. This new direction is different from the direction of either of the original vectors unless the vectors are collinear (pointing in the same or opposite directions). So, direction changes are primarily a result of vector addition, while scalar multiplication affects only magnitude (with the caveat of direction reversal when the scalar is negative).

Let's illustrate "collinear vectors" and their effect on vector addition with examples:

Scenario 1: Collinear Vectors (Same Direction)

Imagine we're walking 3 miles east (vector A) and then another 2 miles east (vector B). Both vectors are collinear—they point in the same direction (east). The resulting vector (A + B) is 5 miles east. The direction hasn't changed; it's still east.

Scenario 2: Collinear Vectors (Opposite Directions)

Now, imagine walking 3 miles east (vector A) and then 2 miles west (vector B). These vectors are still collinear because they lie on the same line (east-west), but they point in opposite directions. The resultant vector (A + B) is 1 mile east (3 - 2 = 1). The magnitude has changed, but the direction remains along the same east-west line.

Scenario 3: Non-Collinear Vectors

Imagine walking 3 miles east (vector A) and then 2 miles north (vector B). These vectors are not collinear; they point in different directions. The resulting vector (A + B) will point northeast. The direction of the resultant vector is different from both the original vectors A and B. It's a new direction created by the combination of the two.

In short: If vectors are collinear, adding them just changes the length (magnitude) along the same line. If they are not collinear, adding them results in a vector pointing in a completely new direction.

Understanding Vectors vs. Matrices

Now that we've got a solid understanding of what vectors are, let's explore how they differ from matrices. Understanding this difference is crucial for working with data and solving real-world problems. Let's break it down using everyday examples that will make these concepts crystal clear.

Quick Vector Recap

Think of a vector as a single line of information – like our shopping list. It's a collection of numbers arranged in a single row or column.

Real-World Vector Example: Our Daily Fitness Stats:

Imagine tracking our daily exercise routine. Your fitness app might store this information as a vector:

Steps: 8,000
Calories burned: 400
Active minutes: 45

This is a vector because it's a single column of related numbers. Each number represents a different aspect of our fitness for that single day.

What is a Matrix?

Now, imagine expanding that single column into a full spreadsheet. That's essentially what a matrix is – a table of numbers arranged in rows and columns, like a grid.

Real-World Vector Example: Weekly Fitness Tracking:

When we track your fitness data over a week, we create a matrix:

Metrics Monday Tuesday Wednesday Thursday Friday
Steps 8,000 10,000 7,500 9,000 8,500
Calories 400 450 350 425 400
Minutes 45 60 40 50 45

Table 1: Weekly Fitness Activity Tracking.

This is a matrix because it organizes multiple vectors (daily stats) into a structured table, making it easy to compare data across different days.

Feature/Type Vector Matrix
Definition A one-dimensional array of numbers that represents magnitude and direction, arranged in a single row or column. A two-dimensional array of numbers arranged in rows and columns, forming a rectangular grid of values.
Dimensionality One-dimensional (1×n or n×1, where n represents the number of elements or components in the vector) Two-dimensional (m×n, where m and n are the number of rows and columns)
Structure Single row or column of elements Multiple rows and columns forming a grid
Example [3, 4, 5] or
[x]
[y]
[z]
[1 2 3]
[4 5 6]
[7 8 9]
Use Cases Single sets of related data like:
- Position coordinates
- Student's test scores
- Daily weather metrics
Multiple sets of related data like:
- Multiple students' test scores
- Weather data across cities
- Sales data over time
Key Characteristics Simple, ordered list of numbers ideal for representing single instances of data or directions in space. Complex data structure capable of representing relationships between multiple sets of data and performing advanced calculations.

Table 2: Comparison Between Vectors and Matrices.


5. Probability and Statistics

Probability and statistics are two interconnected branches of mathematics that deal with analyzing data and making predictions.

Probability

Probability is the chance or likelihood of something happening. Think of it like predicting the future based on what we know. It ranges from 0 to 1, where 0 means the event will not happen, and 1 means the event will certainly happen.

There are many formulas for calculating probability, depending on what we're trying to calculate. The most basic formula for the probability of an event occurring is:

Basic Probability Formula:

P(Event) = (Number of favorable outcomes) / (Total number of possible outcomes)

Examples:

  • When we flip a coin, the probability of getting heads is 50% (or 1/2 chance) (one favorable outcome / 2 possible outcomes).
  • Rolling a 6 on a die is 1/6 (one favorable outcome / six possible outcomes).
  • If we have a bag with 3 red marbles and 1 blue marble, the probability of randomly picking a red marble is 75% (or 3/4) - Probability = Number of favorable outcomes / Total number of possible outcomes; Number of favorable red marbles = 3 and Total number of marbles = 4. So, probability = 3/4 = = 0.75 = 75%.

Addition Rule for Mutually Exclusive Events:

If events A and B cannot happen at the same time:

P(A or B) = P(A) + P(B)

Examples:

  • Coin Toss (Single Coin)
    • In this case, we cannot get both heads and tails at the same time on a single flip of the coin.
    • Event A: Getting heads when flipping a coin - P(Heads) = 1/2 = 0.5 = 50%
    • Event B: Getting tails when flipping the same coin - P(Tails) = 1/2 = 0.5 = 50%
    • P(Heads or Tails) = 1/2 + 1/2 = 1 = 100%

Addition Rule for Non-Mutually Exclusive Events:

If events A and B can happen at the same time:

P(A or B) = P(A) + P(B) - P(A and B)

Multiplication Rule (for independent events):

If the occurrence of one event doesn't affect the probability of the other:

P(A and B) = P(A) * P(B)

Multiplication Rule (for dependent events):

If the events are dependent:

P(A and B) = P(A) * P(B|A)

Population

In statistics and data analysis, a population refers to the total set of all possible observations or elements or items that are relevant to our analysis or experiment. In other words, a population refers to the entire set of possible items that we're interested in studying.

For example:

  • In analyzing customer behavior, the population would be all possible customers (past, present, and potential future).
  • All students enrolled in a particular university.
  • All products manufactured by a company in the last year.
  • All voters in a certain election.

Contrast with Sample

A population is often contrasted with a sample, which is a subset of the population. In many practical scenarios, it is not feasible to collect or analyze data from the entire population, so researchers select samples to estimate population characteristics (like means, proportions, etc.).

So, studying an entire population is often:

  • Impractical (imagine surveying every single customer)
  • Too expensive (testing every single product)
  • Sometimes impossible (like when studying future customers)

This is why we typically collect data from a smaller subset of the population, called a sample, and use statistical methods to make informed inferences about the entire population.

Population vs. Sample

  • Population: The complete group of interest.
  • Sample: A smaller, representative group drawn from the population that is used to make conclusions about the population.
  • For example, we might survey 1,000 customers (sample) to understand the satisfaction level of 10 million customers (population).

Central Tendency

Central tendency is a core concept within probability and statistics that helps us understand how a set of numbers is clustered around a middle value. It refers to the central value around which data points tend to cluster. Simply put, it's the value where most of the data points are gathered around.

It gives an idea of the "average" or "typical" value in a dataset. Think of it like a big group of people standing in a line, and we want to know where most of them are standing.

In math, central tendency is measured by three main values:

  • Mean: It's an average of a set of values. It is calculated by adding up all the values and dividing by the number of values. It's a common measure for normally distributed data. Because the calculation includes all values, including the outliers, the mean is sensitive to extreme values (outliers).

  • Median: It's the middle value in a dataset when the values are arranged in ascending or descending order. It's less sensitive to outliers and skewed data than the mean. It provides a better measure of central tendency for skewed distributions or datasets with outliers. Imagine a line that divides the group in half, and the median is the value that most people are standing on. For an odd number of values, the median is the value at the $ (n+1)/2th $ position. For an even number of values, the median is the average of the values at the $ n/2th $ and $ (n/2) + 1th $ positions.

  • Mode: The most common value that appears most frequently in a dataset. It's not affected by outliers. It's useful for categorical data and to identify the most common value in a dataset. Note that mode is not a good representation of the typical value because it's influenced by the frequency of the values. Imagine a big crowd of people, and the mode is the value that most people are standing on.

These three values help us understand how the group is clustered around a middle value. For example:

  • If the mean is 10, it means that if we add up all the numbers and divide by the number of people, we get 10.
  • If the median is 10, it means that half the people are standing on one side of the line and half are standing on the other side, with 10 being the middle value.
  • If the mode is 10, it means that most people are standing on the value 10.

Central tendency is important in math because it helps us:

  • Understand patterns and trends in data
  • Make predictions and forecasts
  • Compare different groups of data
  • Identify outliers (numbers that are far away from the rest of the group)

So, in simple terms, central tendency is like finding the "average" or "middle" value of a group of numbers. It helps us understand how the numbers are clustered and what the typical value is.

Mean, Median, Variance, Standard Deviation, Mode, Range, Interquartile Range (IQR), and Skewness

Mean

The mean, also known as the average, is a measure of the central tendencyCT of a dataset. It's calculated by adding up all the values and dividing by the number of values.

The formula is:

Mean = (Sum of all values) / (Number of values)

For example, if we have the values 2, 4, 6, 8, and 10, the mean would be:

Mean = (2 + 4 + 6 + 8 + 10) / 5 = 30 / 5 = 6

Median

The median is another measure of central tendencyCT. It's the middle value of a dataset when it's sorted in order. If the dataset has an odd number of values, the median is the middle value. If the dataset has an even number of values, the median is the average of the two middle values.

For example, if we have the values 1, 3, 5, 7, 9, the median would be 5.

Variance

The variance is a measure of how spread out a dataset is. It's calculated by subtracting the mean from each value, squaring the result, and then averaging those squared differences.

Variance = (Sum of (xi - mean)^2) / (Number of values - 1)

where xi is each value in the dataset.

For example, if we have the values 2, 4, 6, 8, 10, the variance would be:

Variance = ((2 - 6)^2 + (4 - 6)^2 + (6 - 6)^2 + (8 - 6)^2 + (10 - 6)^2) / (5 - 1) = 8 / 4 = 2

Standard Deviation

The standard deviation is the square root of the variance. It's a measure of how spread out a dataset is, but it's on the same scale as the original values.

Standard Deviation = √Variance

For example, if the variance is 2, the standard deviation would be:

Standard Deviation = √2 ≈ 1.41

Mode

The mode is the value that appears most frequently in a dataset.

Consider the following set of numbers: 2, 4, 4, 4, 5, 6, 6, 7

To find the mode:

  • Count the frequency of each number:

    • 2 appears 1 time
    • 4 appears 3 times
    • 5 appears 1 time
    • 6 appears 2 times
    • 7 appears 1 time
  • Identify the number with the highest frequency:

    • The number 4 appears the most frequently (3 times).

So, the mode of this data set is 4, as it is the number that occurs most often.

Range

The range is the difference between the largest and smallest values in a dataset. The range is a measure of how spread out the values in a data set are. It is calculated by subtracting the smallest value from the largest value.

Consider the following set of numbers: 3, 7, 2, 9, 5

To find the range:

  1. Identify the smallest value: The smallest value is 2.
  2. Identify the largest value: The largest value is 9.
  3. Subtract the smallest value from the largest value: Range = Largest value - Smallest value = 9 - 2 = 7

So, the range of this data set is 7.

The range provides a simple way to understand the spread of the data by showing the difference between the highest and lowest values.

Interquartile Range (IQR)

Interquartile range is a way to measure how spread out the middle part of a set of numbers is. It helps us understand the range where the middle half of the numbers lie, ignoring the highest and lowest values which might be outliers. It's widely used in statistics and data analysis to understand the spread and variability of a data set.

Explanation:

  1. Imagine we have a list of numbers: Like scores from a test.
  2. Arrange the numbers in order: From smallest to largest.
  3. Find the middle number: This is called the "median". If there are an odd number of numbers, the median is the one right in the middle. If there are an even number, it’s the average of the two middle numbers.
  4. Split the list into two halves:
  • The lower half (below the median).
  • The upper half (above the median).
  1. Find the median of the lower half: This is called the first quartile (Q1).
  2. Find the median of the upper half: This is called the third quartile (Q3).
  3. Calculate the IQR: Subtract the first quartile (Q1) from the third quartile (Q3).

Example:

Let’s say we have these test scores: 70, 55, 90, 65, 60, 75, 80, 95, 85

  1. Arrange the scores: 55, 60, 65, 70, 75, 80, 85, 90, 95
  2. Find the overall median: 75 (the middle score).
  3. Split into lower and upper halves:
  • Lower half: 55, 60, 65, 70
  • Upper half: 80, 85, 90, 95
  1. Find Q1 (median of lower half): 62.5 (average of 60 and 65).
  2. Find Q3 (median of upper half): 87.5 (average of 85 and 90).
  3. Calculate the IQR: Q3 - Q1 = 87.5 - 62.5 = 25

So, the IQR is 25, meaning the middle 50% of the test scores lie within a range of 25 points. This helps us understand the spread of the main body of scores, ignoring the extreme highs and lows.

Uses of IQR:

  1. Identifying Outliers
  2. Summarizing Data: Summary of the middle 50% of the data, offering a sense of where the bulk of the values lie. This is particularly useful for skewed distributions where the mean might not provide a clear picture of the central tendencyCT.
  3. Comparing Variability: IQR is used to compare the spread of different data sets. By comparing the IQRs, we can understand which data set has more variability in the middle 50% of its values.
  4. Robust Measure of Spread: IQR is a robust measure of statistical dispersion because it is not affected by extreme values or outliers. This makes it more reliable for understanding the spread of data than the range or the standard deviation in cases where the data contains outliers.

In summary, the IQR is a valuable tool in statistics and data analysis for understanding and summarizing the spread of a data set, especially when dealing with outliers and skewed distributions.

Skewness

Skewness describes how a set of numbers is not evenly distributed around the average (mean). It tells us if the numbers are leaning more to one side of the average or if they are balanced.

Types of skewness:

  1. Positive Skewness (Right-Skewed): Most numbers are smaller, but a few are much larger. For example, imagine a neighborhood where most houses cost between USD 100,000 and USD 300,000, but a few mansions cost over USD 1,000,000. Most house prices are on the lower side, but those few very expensive houses make the distribution lean to the right.
  2. Negative Skewness (Left-Skewed): Most numbers are larger, but a few are much smaller. For example, Think about a class where most students score between 70 and 100 on a test, but a few students score below 40. Most scores are on the higher side, but those few very low scores make the distribution lean to the left.
  3. Zero Skewness (Symmetrical Distribution): Numbers are evenly spread around the average. For example, if we roll a fair die many times, we would expect each number (1 through 6) to come up about the same number of times. The distribution of outcomes is balanced.

Why it matters?

  • Understanding Data: Skewness helps us see if the data is balanced or if there are extreme values that are pulling the average in one direction. For instance, in a business, if sales data is positively skewed, it means there are a few very high sales that are significantly affecting the overall average.
  • Making Decisions: Knowing about skewness can help in decision-making. For example, if a school notices that test scores are negatively skewed, they might want to provide extra help to the few students with very low scores.

In simple terms, skewness tells us if our data has a lean or tilt towards higher or lower values, or if it is evenly spread out. This can be very helpful in understanding and interpreting the data better.

[Work in progress]


Notes and References

  1. 1. Feature: In ML, a feature is a measurable property or variable of the data that is used to train a model. Features are the inputs used by models to make predictions. In other words, features are the attributes or variables that describe the data, such as: Numerical values (e.g., age, temperature), categorical values (e.g., gender, color), textual data (e.g., words, sentences), and image data (e.g., pixels, shapes). They play a crucial role in determining the performance and accuracy of a model. A good feature set can help the model learn meaningful patterns and relationships in the data, leading to better predictions and decision-making.
  2. 2. Model's parameters are the variables within the model that are adjusted during the training process to minimize the error between the model’s predictions and the actual outcomes. Parameters are learned from the data. They are internal variables within a machine learning model that are adjusted during the training process. These parameters define the model’s structure and behavior, influencing how it maps input data to output predictions. The primary goal of training a model is to optimize these parameters to minimize the error between the model’s predictions and the actual target values.
  3. 3. Sprint: Unlike marathon, sprint is short distance and quick run. Sprint vs. marathon is meant to convey that learning mathematics for AI and ML is not a quick or easy task. It requires a sustained effort over a long period, with patience, persistence, and dedication being essential qualities for success.
  4. 4. Euler’s number: Euler's number, denoted by e, is a mathematical constant that is approximately equal to 2.71828. It is named after the Swiss mathematician Leonhard Euler and is widely used in mathematics, particularly in calculus and complex analysis. It is an irrational number, meaning its decimal representation goes on forever without repeating. It's crucial in describing processes that exhibit exponential growth or decay, such as population growth, radioactive decay, and compound interest.
  5. 5. Quantities in this context refer to measurable properties or attributes that have both size (magnitude) and orientation (direction).
  6. 6. Orientation refers to the direction in which the vector is pointing. Think of it like the direction an arrow is pointing. For example, if you have a vector representing the direction from New York to Los Angeles, the orientation of the vector would be the direction from east to west.
  7. 7. Displacement refers to the difference between an object's initial and final positions. It's a measure of how far and in what direction an object has changed its position.
  8. 8. Higher-dimensional spaces refers to mathematical spaces that have more than three dimensions. While we are familiar with one-dimensional (lines), two-dimensional (planes), and three-dimensional (volumes) spaces, higher dimensions extend beyond these familiar concepts.
  9. 9. A coefficient is the number that multiplies a variable in an equation. Examples: In 2x: 2 is the coefficient of x; in -5y: -5 is the coefficient of y; in x: 1 is the coefficient (when no number is shown); in 0x: 0 is the coefficient.
  10. 10. Arithmetic is the branch of mathematics dealing with basic numerical operations: addition, subtraction, multiplication, and division.