15 IoT Mathematics: Linear Algebra and Probability
15.1 Start With the Decision
Several sensor values form a vector, while noise makes each value unsure. Matrices and probability keep those facts visible.
15.2 Route Overview
This is part 1 of 2. Continue with IoT Mathematics: Fusion and Sampling Decisions.
15.3 Part Objectives
- Use vectors and matrices to combine sensor state.
- Represent sensor uncertainty with probability and variance.
15.4 Start With the Situation
A single formula can bound change, accumulation, or signal scale, but many IoT decisions combine several measurements and uncertain events. The team now needs vectors, matrices, and probability to fuse evidence without hiding assumptions.
15.5 Overview
This route builds linear-algebra and probability tools, then applies them to cryptography, radio links, sensors, power, and capstone calculations.
This is part 2 of 2. Review IoT Mathematics: Calculus, Exponents, and Logs when you need the first route.
15.6 Learning Objectives
By the end of this chapter, you will be able to:
- use vectors and matrices to represent multi-sensor systems
- apply probability and statistics to uncertain IoT evidence
- build bounded RF, sensor, cryptography, and battery calculations
15.7 Chapter Roadmap
- Start With the Situation
- Overview
- C. Linear Algebra Basics
- The Core Idea
- Interactive Calculator: 3D Vector Magnitude
- The Core Idea
- Quick Rule
- D. Probability and Statistics
- The Core Idea
- The Core Idea
- Interactive Calculator: Sensor Fusion
- Try It: Write a Sensor Uncertainty Assumption Check
- Checkpoint: State and Uncertainty
- E. Modular Arithmetic for Cryptography
- The Core Idea
- F. Complex Numbers for Signal Processing
- The Core Idea
- G. Information Theory Basics
- The Core Idea
- Checkpoint: Security and Signals
- H. Quick Reference Card
- Visual Reference Gallery
- Kalman Filter Visualization
- Signal Processing Pipeline
- Common Pitfalls
- 1. Skipping the units when applying IoT formulas
- 2. Confusing linear and logarithmic scales for signal measurements
- 3. Applying normal distribution assumptions to real IoT sensor noise
- Label the Diagram
- Code Challenge
- Summary
15.8 C. Linear Algebra Basics
15.8.1 C.1 Vectors
A vector is an ordered list of numbers representing multiple related quantities. In IoT, sensors often produce vector outputs (e.g., 3-axis accelerometer gives [x, y, z]).
Notation: or simply
IoT Applications:
| Data Type | Vector Representation |
|---|---|
| 3-axis accelerometer | in g-force |
| GPS position | |
| RGB color | values 0-255 |
| IMU (9-axis) |
Vector Operations:
Magnitude (Length): How “big” is the vector?
Example: Accelerometer reads
This tells us the total acceleration magnitude (useful for fall detection).
15.8.2 C.2 Matrices
A matrix is a 2D array of numbers. Matrices transform vectors - rotate them, scale them, or combine multiple measurements.
Notation:
IoT Applications:
1. Coordinate Transformation:
Rotating sensor data to align with a reference frame:
2. Kalman Filter State:
State vector might be :
State transition predicts next state:
3. Covariance Matrix:
Describes uncertainty in measurements:
Diagonal elements: Variance (uncertainty) in each variable Off-diagonal: How variables correlate (change together)
15.8.3 C.3 Matrix Multiplication
To multiply matrix A (m by n) by matrix B (n by p), the inner dimensions must match. Result is m by p.
Example: Transforming a 3D point
This scales the vector by 2 in all directions.
15.9 D. Probability and Statistics
15.9.1 D.1 Basic Probability
Probability quantifies uncertainty. In IoT, sensor readings are never perfect - probability helps us reason about noise, errors, and reliability.
Key Concepts:
| Term | Definition | IoT Example |
|---|---|---|
| Probability P(A) | Chance of event A (0 to 1) | P(packet loss) = 0.02 |
| Expected Value E[X] | Average outcome | Average sensor reading |
| Variance Var(X) | Spread around average | Noise level |
| Standard Deviation sigma | sqrt(variance) | +/- 1 sigma covers 68% of readings |
Practical Example - Sensor Reliability:
If a sensor has 99.9% uptime:
- P(working) = 0.999
- P(failure) = 0.001
For 100 sensors, expected failures = 100 x 0.001 = 0.1 per unit time
15.9.2 D.2 Gaussian (Normal) Distribution
The Gaussian distribution (bell curve) describes random noise in most physical systems. It’s characterized by mean (mu) and standard deviation (sigma).
Properties:
- 68% of values within mu +/- 1 sigma
- 95% of values within mu +/- 2 sigma
- 99.7% of values within mu +/- 3 sigma
IoT Application - Sensor Noise:
A temperature sensor with:
- Mean reading: mu = 25.0 C
- Noise: sigma = 0.5 C
95% of readings will be between 24.0 C and 26.0 C.
15.9.3 D.3 Sensor Fusion: Combining Measurements
When you have two noisy measurements of the same thing, the optimal combination is:
Intuition: Weight each measurement inversely by its uncertainty. Trust the more precise sensor more.
Example:
- GPS says position is 100m (sigma = 10m)
- Accelerometer integration says 95m (sigma = 5m)
The combined estimate is closer to the accelerometer (more precise).
Before using a fused sensor estimate in a capstone decision, write one short assumption check:
Decision: what action will use the estimate, such as triggering an alert, logging a location, or changing actuator output. Inputs: each sensor value, its stated or measured , and the time window used to collect samples. Assumption: why a Gaussian model is reasonable here, or which evidence shows that outliers, drift, or saturation need a different model. Rule: the numeric threshold that separates accept, warn, and reject states, including units. Recalculation condition: the condition that forces a new estimate, such as a new enclosure, different sample rate, firmware filter change, or field noise pattern.
Accept the estimate only when the decision, units, uncertainty source, and recalculation condition are all explicit.
Checkpoint: State and Uncertainty
You now know:
- A vector can hold a multi-axis sensor reading such as [0.5, 0.3, 0.8]g, whose magnitude is about 0.99g.
- A matrix can rotate, scale, or update state vectors, including Kalman filter state such as position, velocity, and acceleration.
- Probability makes fusion reviewable: a 10m GPS estimate and a 5m accelerometer estimate should not be averaged blindly; the more precise estimate carries more weight.
15.10 E. Modular Arithmetic for Cryptography
15.10.1 E.1 The Modulo Operation
Modulo is the arithmetic mechanism behind the wraparound behavior used throughout this section. Begin with small remainders to verify the operation, then carry the same rule into modular exponentiation. The examples establish the computation; later cryptographic sections add the essential requirements for large parameters, randomness, authentication, and safe key handling.
Modular arithmetic is “clock arithmetic.” After reaching a maximum value, numbers wrap around to zero.
Notation: = remainder when a is divided by n
Examples:
- (7 = 1x5 + 2)
- (25 = 3x7 + 4)
- (clock wraps at midnight)
15.10.2 E.2 Why Modular Arithmetic for Cryptography?
Key Property: Easy to compute forward, hard to reverse.
Example - Discrete Logarithm:
Given: ,
Forward (easy): Calculate
Reverse (hard): Given 17, find x where
This “trapdoor” property enables public-key cryptography.
15.10.3 E.3 Diffie-Hellman Key Exchange
Two IoT devices can agree on a shared secret over an insecure channel. First read the message sequence in Figure 15.1 from public parameters through exchanged public values to the independently derived shared result.
Follow Figure 15.1 from the public parameters through the exchange. Each device keeps its private exponent, publishes only a modular result, receives the other public value, and reaches the same shared value by combining it with its own secret. Figure 15.2 now restates the one-way property visually: follow public yellow into each private mixture, across the public exchange, and into the matching final colour.
Read Figure 15.2 from public yellow through the two private mixtures, across the public exchange, and into the matching final brown. The eavesdropper sees the public starting colour and both exchanged mixtures but cannot reverse them to recover either private colour. Likewise, an observer may see public values such as 8 and 19, while recovering the private exponents requires solving the discrete logarithm problem for properly chosen large parameters. The analogy explains one-way computation, not authentication; a real exchange still needs authenticated peers and safe key handling.
15.11 F. Complex Numbers for Signal Processing
15.11.1 F.1 What Are Complex Numbers?
Complex numbers extend real numbers to include . They’re essential for representing signals that have both amplitude and phase.
Form:
- = real part
- = imaginary part
Alternative (Polar) Form:
- = magnitude (amplitude)
- = phase angle
15.11.2 F.2 Why Complex Numbers in IoT?
1. Representing Sinusoidal Signals:
A sensor reading:
Using Euler’s formula:
We can write:
2. Fourier Transform:
Converts time-domain signals to frequency-domain:
The result is complex:
- Magnitude tells you “how much” of each frequency
- Phase tells you “when” each frequency component peaks
3. I/Q Signals in Radio:
LoRa and other radios use I/Q (In-phase/Quadrature) representation:
- I = real part of signal
- Q = imaginary part of signal
This allows representing any modulation scheme.
15.11.3 F.3 Complex Number Operations
| Operation | Formula | Signal Processing Meaning |
|---|---|---|
| Addition | Superimposing signals | |
| Magnitude | $ | a+bi |
| Phase | Signal timing | |
| Multiplication | Magnitudes multiply, phases add | Mixing/modulation |
15.12 G. Information Theory Basics
15.12.1 G.1 Bits and Entropy
Treat bits and entropy as measures of uncertainty, not synonyms for file size. First identify the possible outcomes and their probabilities, then calculate how much information a result conveys. The distinction connects source data, compression, cryptographic randomness, and channel capacity while keeping each claim tied to its own assumptions.
Entropy measures information content or uncertainty. More unpredictable data requires more bits to represent.
Entropy formula:
Where is the probability of each outcome.
Example - Sensor Alarm:
- Alarm triggers 1% of the time
- bits
The alarm provides only 0.08 bits of information per reading (very predictable).
15.12.2 G.2 Shannon Capacity
The maximum rate at which information can be reliably transmitted:
Practical Implications:
| SNR | Capacity (per Hz of bandwidth) |
|---|---|
| 1 (0 dB) | 1 bit/s/Hz |
| 3 (5 dB) | 2 bit/s/Hz |
| 7 (8.5 dB) | 3 bit/s/Hz |
| 15 (12 dB) | 4 bit/s/Hz |
| 31 (15 dB) | 5 bit/s/Hz |
Key Insight: To double capacity, you need to roughly quadruple SNR. This explains why LoRa trades data rate for range (lower SNR = lower rate but still works).
Checkpoint: Security and Signals
You now know:
Modular arithmetic wraps values around a modulus, as in 7 mod 5 = 2 and 25 mod 7 = 4. That wraparound supports the forward operations used in the key-exchange example.
Diffie-Hellman relies on forward calculations such as 5^7 mod 23 = 17 being easy while the reverse problem is hard. Authentication and key handling remain separate requirements.
Complex numbers track amplitude and phase, while information theory connects entropy, SNR, bandwidth, and Shannon capacity. Together they bound what the signal chain can represent and carry.
15.13 H. Quick Reference Card
15.13.1 Essential Formulas for IoT
15.13.1.1 Signal Processing
| Formula | Expression |
|---|---|
| Nyquist Rate | |
| Shannon Capacity | |
| dB conversion | |
| dBm from mW |
15.13.1.2 Wireless
| Formula | Expression |
|---|---|
| Free Space Loss | |
| Link Budget | |
| Path Loss (approx) | (n = 2 free space, 3-4 urban) |
15.13.1.3 Electronics
| Formula | Expression |
|---|---|
| Ohm’s Law | |
| Power | |
| RC Time Constant | |
| Capacitor Voltage |
15.13.1.4 Battery Life
| Formula | Expression |
|---|---|
| Average Current | |
| Battery Life |
15.13.1.5 Sensor Fusion
| Formula | Expression |
|---|---|
| Weighted Average | |
| Combined Variance |
15.13.1.6 Probability
| Formula | Expression |
|---|---|
| Gaussian 68-95-99 | (68%), (95%), (99.7%) |
| Expected Value |
15.14 Visual Reference Gallery
To connect the earlier covariance equations to a repeated estimator, read Figure 15.3 from prediction to measurement update and back to the next prediction.
In Figure 15.3, the prediction advances the state and usually widens uncertainty, the measurement supplies independent evidence, and the update narrows or shifts the estimate according to relative covariance. The loop then repeats with the corrected state. This connects matrix and probability tools to navigation and tracking, while reminding you that bad timestamps, frames, or noise assumptions can make a precise-looking estimate wrong.
Signal-processing formulas belong to an ordered measurement chain. Follow Figure 15.4 from the raw analogue signal through filtering and sampling into digital filtering and frequency analysis.
In Figure 15.4, analogue filtering first limits frequencies that would alias, the ADC turns the bounded waveform into samples, and digital filtering shapes the retained time-domain evidence. The FFT then reorganizes those samples by frequency; it does not recover content lost before conversion. This pipeline ties calculus, sampling, complex numbers, and spectral interpretation into one ordered capstone measurement argument.
Common Pitfalls
Every IoT calculation has units that must be tracked: mA for current, mAh for battery capacity, dBm for signal power, Hz for frequency, seconds for time. The battery life formula puts battery capacity (mAh) in the numerator and average current (mA) in the denominator; reversing those terms or confusing mA with uA gives an answer that is wildly wrong. Always write out units in intermediate steps and verify unit cancellation before trusting a numeric result.
RF engineers universally use dB (decibels) for signal strength because path loss spans 6 orders of magnitude (0.001 mW to 1000 mW). A 3 dB increase means double the power, not a 3% increase. Students who add dB values arithmetically (10 dBm + 10 dBm = 20 dBm, assuming 20 mW) make 100x errors. Remember: add dB values for gains/losses in a chain, but convert to linear scale first when adding powers from independent sources.
The Gaussian noise model works well for electronic noise (thermal noise, quantization noise) but fails for systematic errors (calibration drift, EMI interference, sensor saturation). Before applying the 68-95-99.7 rule to your sensor’s error budget, verify that actual error samples look bell-shaped by plotting a histogram. Outlier-prone sensors need robust statistics (median, IQR) rather than mean and standard deviation.
15.15 Summary
This appendix covered the mathematical foundations used throughout the IoT textbook:
| Topic | Key Concept | Primary Use |
|---|---|---|
| Calculus | Rates & accumulation | PID control, energy budgets |
| Exponentials | Growth/decay | Signal attenuation, battery life |
| Logarithms | Compression | dB scales, Shannon capacity |
| Linear Algebra | Vectors, matrices | Sensor fusion, Kalman filter |
| Probability | Uncertainty | Noise modeling, reliability |
| Modular Arithmetic | Wraparound math | Cryptography |
| Complex Numbers | Amplitude + phase | Signal processing, radio |
| Information Theory | Bits, entropy | Channel capacity, compression |
15.16 Continue to the Next Part
Carry this evidence into IoT Mathematics: Fusion and Sampling Decisions, which begins with Worked Example: Designing a Kalman Filter for GPS-Accelerometer Fusion.
