Lecture 2 - Part 2
Contents
Sensor Data
The form and the nature of data provided by sensors differ based on their type. A few data formats that are commonly encountered in Edge AI applications are as follows:
Time Series
- Time series data represents how a variables of interest changes over time. A single sensor can produce multiple time-series data streams. For instance consider an environmental sensor (e.g. BME680) it may provides measurement for temperature, humidity, pressure, and gas levels.
- Typically, time series data is collected by polling the sensors with a certain frequency. Ironically, this frequency is also called sampling frequency and the rate of polling, i.e. number of samples collected per second is known as sampling rate.
- Note that this sampling rate is not same as the sampling rate we discussed in A/D conversion. Key differences have been articulated in table below.
- Some time series are aperiodic, meaning samples are not taken at fixed intervals. This occurs with sensors that respond to specific events, such as a proximity sensor that triggers when an object enters a defined range. In such cases, it is common to record the exact timestamp along with the sensor reading.
- Time series can also represent aggregated information, such as the number of occurrences of an event within a given time interval.
Key Differences: Time Series Sampling vs Physical Signal Sampling
| Aspect | Physical Signal Sampling (ADC) | Time Series Sampling (Digital) |
|---|---|---|
| Domain | Continuous-time, continuous-amplitude | Discrete-time, already digital |
| Purpose | Convert real-world signal to digital | Reduce, resample, or analyze data |
| Sampling Constraint | Must satisfy Nyquist criterion | No strict Nyquist limit |
| Data Source | Sensor measuring physical quantities | Pre-recorded or generated digital data |
| Sampling Rate | Determined by highest frequency in signal | Determined by analysis or polling requirements |
| Examples | Microphone recording sound at 44.1 kHz | Stock prices sampled daily or hourly |
| Event Handling | Typically continuous measurement | Can be periodic or aperiodic (event-driven) |
| Tools | Sensor + ADC hardware | Software or algorithms |
Signal Modality
Audio Signals
An audio signal captures oscillation of sound waves traveling in a certain medium (air, water, vacuum, etc.). Audio signals are also example of time series data. Audio signals capture changes in air pressure over time. Generally, audio signals are sampled with very high frequency. The upper limits to human hearing are around 20 kHz. Consequently, from Nyquist Theorem, audio signals must be captured at twice the rate, i.e., 40 kHz. With each sample, using ADC N=8, we have 320Kbps. The Ultrasonic signals which can be used to measure density of liquid or other liquid properties go beyond this audible range. Audio signals can also yield multiple time series, specially for stereo audio. However, for sake of simplicity, let us restrict ourselves to mono-audio. Then the discrete-time audio signal can be represented as a column vector:
x=x[0]x[1]x[2]⋮x[N−1]where:
- x is the vector of audio samples,
- x[n] is the amplitude of the n-th sample,
- N is the total number of samples.
Image Signals
An image sensor is a device that captures light from a scene and converts it into electrical signals. Common types include CCD (Charge-Coupled Device) and CMOS (Complementary Metal-Oxide-Semiconductor). The sensor consists of a 2D array of photosensitive elements called pixels, where each pixel measures the intensity of light hitting it and converts it into a digital value. The digital output of an image sensor can be represented as a matrix where each element corresponds to a pixel value. For a grayscale image, the matrix is written as:
I=I[0,0]I[1,0]⋮I[M−1,0]I[0,1]I[1,1]⋮I[M−1,1]⋯⋯⋱⋯I[0,N−1]I[1,N−1]⋮I[M−1,N−1]where I[m,n] is the intensity of the pixel at row m and column n, M is the number of rows, and N is the number of columns. For color images, each pixel contains multiple components (e.g., RGB), so the image can be represented as a 3D array I[m,n,c] where c∈{R,G,B}.Similarly, Radio detection and ranging (radar) and LiDAR systems generate spatial imaging data, which can also be represented as matrices or 3D arrays, where each element corresponds to a measured intensity, distance, or reflectivity value at a specific spatial location.
The image will be available in Python as window.imgData.
Image Channels
No output yet. Click "Run Python" to execute.
video
The Video data is essentially a collection of images sampled at what is known as frame rate. Videos can be encoded through efficient encoding scheme to reduce the storage size. Such encoding schemes also utilise temporal variations across the frames.
Types of Sensors
| Category | What it does | Example |
|---|---|---|
| Acoustic & Vibration | • Measure vibrations traveling through a medium
| Shure SM58 Microphone |
| Visual and Scene | • Capture light using sensor arrays | Sony IMX586 Image Sensor |
| Motion and Position | • Tilt sensor: detects orientation | Tilt Ball Switch ADXL345 |
| Force and Tactile | • Button & Switch: binary signal | CherryMX |
| Environmental & Others | • Temperature | DS18B20 |
Regression in Time-Series Analysis
Having sampled the time-series data, we want to develop some basic understanding of physical phenomenon. Regression is a statistical method used to model the relationship between a dependent variable and one or more independent variables. In time-series analysis, regression can help us understand trends, make predictions, and quantify the influence of time or other factors on a variable.

Example:
We have daily temperature measurements over a month. We want to model the trend of temperature over time and potentially predict future values.
Time-Series Data
Suppose we have:
| Day | Temperature (°C) |
|---|---|
| 1 | 15 |
| 2 | 16 |
| 3 | 16.5 |
| ... | ... |
| 30 | 21 |
- Independent variable x: Day number (1 to 30)
- Dependent variable y: Temperature
We want a simple regression:
y=β0+β1x+ϵWhere:
- β0 = intercept (temperature at day 0)
- β1 = slope (rate of change of temperature per day)
- ϵ = error term

Least Squares Regression
Goal: Find β0 and β1 that minimize the sum of squared errors:
S(β0,β1)=i=1∑n(yi−(β0+β1xi))2This is called Ordinary Least Squares (OLS).
The closed-form solution for simple linear regression:
β1=∑(xi−xˉ)2∑(xi−xˉ)(yi−yˉ),β0=yˉ−β1xˉWhere xˉ and yˉ are the sample means.
Solution Approach
To find the minimum, take derivatives with respect to β0 and β1 and set them to zero:
∂β0∂S=−2i=1∑n(yi−β0−β1xi)=0 ∂β1∂S=−2i=1∑nxi(yi−β0−β1xi)=0Normal Equations
Simplifying the derivatives gives the normal equations:
{nβ0+(∑xi)β1=∑yi(∑xi)β0+(∑xi2)β1=∑xiyiSolve for Slope β1 by defining the means:
xˉ=n1∑xi,yˉ=n1∑yiThen the slope is:
β1=∑i=1n(xi−xˉ)2∑i=1n(xi−xˉ)(yi−yˉ)Once β1 is known, the intercept is:
β0=yˉ−β1xˉ β1=∑i=1n(xi−xˉ)2∑i=1n(xi−xˉ)(yi−yˉ),β0=yˉ−β1xˉTypes of Regression
Regression is a statistical technique used to model the relationship between a dependent variable (y) and one or more independent variables (x).
1. Linear Regression
- Models the relationship as a straight line:
- Goal: Find coefficients β0,β1 that minimize the error.
- Can be simple (one predictor) or multiple (many predictors).

2. Polynomial Regression
- Models the relationship using polynomials of degree n:
- Captures non-linear trends.
- Still solved with least squares.
- Imagine a solar panel on your roof. Early in the morning, with just a little sunlight, it barely produces any power. As the sun rises, output grows faster and faster, but after a point it starts to level off. The pattern isn’t a straight line, it curves

3. Logistic Regression
- Used when the dependent variable is categorical (binary):
- Models probabilities, not continuous outcomes.