15 IoT Mathematics: Linear Algebra and Probability
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
15.1 Start With the Decision
This section: Start With the Decision — Several sensor values form a vector, while noise makes each value unsure.
Several sensor values form a vector, while noise makes each value unsure. Matrices and probability keep those facts visible.
15.2 Route Overview
This section: Route Overview — This is part 1 of 2.
This is part 1 of 2. Continue with IoT Mathematics: Fusion and Sampling Decisions.
15.3 Part Objectives
This section: Part Objectives
- Use vectors and matrices to combine sensor state.
- Represent sensor uncertainty with probability and variance.
15.4 Start With the Situation
This section: Start With the Situation — A single formula can bound change, accumulation, or signal scale, but many IoT decisions combine several measurements and uncertain events.
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 section: Overview — This route builds linear-algebra and probability tools, then applies them to cryptography, radio links, sensors, power, and capstone calculations.
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
This section: 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
This section: 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
This section: 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
This section: 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) | For normally distributed readings, +/- 1 sigma covers about 68% |
Practical Example - Sensor Reliability:
If a sensor has 99.9% uptime:
- P(working) = 0.999
- P(failure) = 0.001
For 100 sensors with 99.9% uptime each, the expected number unavailable at a randomly chosen instant is 100 x 0.001 = 0.1.
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.
This section:
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
This section: 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 of modular exponentiation in suitable large groups: Easy to compute forward; the discrete logarithm can be hard to recover.
Example - Discrete Logarithm:
Given: ,
Forward (easy): Calculate
Reverse (hard only with suitable large parameters; easy in this toy example): Given 17, find x where
This one-way property supports Diffie-Hellman key agreement and related public-key systems.
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.
Inspect Figure 15.2 to ask how two devices can exchange public mixtures yet reach the same result without sending either private part.
Read Figure 15.2 from the public yellow to the final brown. One device mixes in private red and sends orange. The other mixes in private blue and sends green. Each device adds its own secret colour to the mix it got, so both reach brown. A watcher sees yellow, orange, and green but cannot split either mix to find red or blue. In the math, values such as 8 and 19 may be public, while the private powers stay hard to find when the numbers are large. The picture explains a one-way step, not peer trust; real links still need known peers and safe key care.
15.11 F. Complex Numbers for Signal Processing
This section: 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
This section: 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).
This section:
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
This section: 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
This section: 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 moves the state to the next time step. Its range of doubt will often grow. The new measure then gives the filter a separate fact. The update shifts the state and cuts that doubt based on how much each source can be trusted. The loop starts again from this fixed state. This is how matrix and chance tools support tracking. A bad time stamp, frame, or noise model can still make the final answer look exact when it is wrong.
Inspect Figure 15.4 to ask which loss or change each step can cause before the samples reach frequency analysis.
In Figure 15.4, the analogue filter first removes high tones that could fold into the kept band. The ADC then turns the bounded wave into samples. A digital filter shapes the time record that remains. The FFT sorts those same samples by frequency; it cannot bring back a tone lost before the ADC. The Nyquist test gives the key limit. If the highest kept tone is 2 kHz, the sample rate must be at least 4 kHz. The order links the math to one sound measurement path.
Common Pitfalls
This section: 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 section: 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
This section: 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.
Carry this evidence into IoT Mathematics: Fusion and Sampling Decisions, which begins with Worked Example: Designing a Kalman Filter for GPS-Accelerometer Fusion.
Find help
3 reviewed answers.
Where should I start in a module?
Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.
Modules and pathsReviewed
What can I try when a project does not work?
Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.
When you are stuckReviewed
How do interactive examples work?
Use the interactive guide to check how examples and simulations work before changing your project.
Interactive examples guideReviewed
