# Digital Signal Processing/Discrete Data

This page may need to be reviewed for quality.

Continuous data is something that most people are familiar with. A quick analogy: when an analog data sensor (e.g., your eye) becomes active (you blink it open), it starts receiving input immediately (you see sun-shine), it converts the input (optical rays) to a desired output (optic nerve signals), and sends the data off to its destination (your brain). It does this without hesitation, and continues doing so until the sensor turns off (you blink your eyes closed). The output is often called a data "stream"; once started, it might run forever, unless something tells it to stop. Now, instead of a physical sensor, if we're able to define our data mathematically in terms of a continuous function, we can calculate our data value at any point along the data stream. It's important to realize that this provides the possibility of an infinite (∞) number of data points, no matter how small the interval might be between the start and stop limits of the data stream.

This brings us to the related concept of Discrete data. Discrete data is non-continuous, only existing at certain points along an input interval, and thereby giving us a finite number of data points to deal with. This data can also be defined by a mathematical function, but one that is limited and can only be evaluated at the discrete points of input. These are called "discrete functions" to distinguish them from the continuous variety.

Discrete functions and data give us the advantage of being able to deal with a finite number of data points.

## Sets and Series

Discrete data is displayed in sets as such:

```X[n] = [1 2 3& 4 5 6]
```

We will be using the "&" symbol to denote the data item that occurs at point zero. Now, by filling in values for n, we can select different values from our series:

```X[0] = 3
X[-2] = 1
X[3] = 6
```

We can move the zero point anywhere in the set that we want. It is also important to note that we can pad a series with zeros on either side, so long as we keep track of the zero-point:

```X[n] = [0 0 0 0 1 2 3& 4 5 6] = [1 2 3& 4 5 6]
```

In fact, we assume that any point in our series without an explicit value is equal to zero. So if we have the same set:

```X[n] = [1 2 3& 4 5 6]
```

We know that every value outside of our given range is zero:

```X[100] = 0
X[-100] = 0
```

## Two Types of Discrete Data Sets

Data can be discrete in magnitude, discrete in time, or both. Here are some examples:

Discrete in Time
Discrete-in-time values only exist at specific points in time. If we try to take the value of a discrete-in-time data set at a time point where there is no data, our result will be zero. The image below shows an example waveform that is discrete in time, having gain values defined only at certain points along the time line. Notice that while it is discrete in time values, the gain value of each sample is not limited or quantized, and it may take any magnitude value.
Discrete in Value
Discrete-in-value series can only exist at certain values of magnitude, no matter when we look at them. For instance, we might say that a certain computer device can only handle integers, and no decimals. The image below shows a signal that is discrete in magnitude, but is not discrete in time. While the waveform indeed has a gain value at every point in time, the values are quantized to specific magnitudes, such as only integers. The steps between the allowed values produce the "staircase" effect in the image. If we try to take the value at a time point exactly when the magnitude transition occurs, a quantization rule must be in place to deal with it, setting the value to the appropriate previous or subsequent magnitude.

## Stem Plots

Discrete data is frequently represented with a stem plot. Stem plots mark data points with dots, and draw a vertical line between the t-axis (the horizontal time axis) and the dot:

```F[n] = [5& 4 3 2 1]
```

## About the Notation

The notation we use to denote the zero point of a discrete set was chosen arbitrarily. Textbooks on the subject will frequently use arrows, periods, or underscores to denote the zero position of a set. Here are some examples:

```            |
            v
Y[n] = [1 2 3 4 5]
```
```            .
Y[n] = [1 2 3 4 5]
```
```            _
Y[n] = [1 2 3 4 5]
```

All of these things are too tricky to write in wikibooks, so we have decided to use an ampersand (&) to denote the zeropoint. The ampersand is not used for any other purpose in this book, so hopefully we can avoid some confusion.

## Sampling

Sampling is the process of converting continuous data into discrete data. The sampling process takes a snapshot of the value of a given input signal, rounds if necessary (for discrete-in-value systems), and outputs the discrete data. A common example of a sampler is an Analog to Digital Converter (ADC).

Let's say we have a function based on time (t). We will call this continuous-time function f(t):

$f(t) = 2tu(t)$

Where u(t) is the unit step function. Now, if we want to sample this function, mathematically, we can plug in discrete values for t, and read the output. We will denote our sampled output as F[n]:

```F[n] = 0 : n < 0
F[1] = f(1) = 2
F[2] = f(2) = 4
F[100] = f(100) = 200
```

This means that our output series for F[n] is the following:

```F[n] = [0& 2 4 6 8 10 12 ...]
```

## Reconstruction

We digitize (sample) our signal, we do some magical digital signal processing on that signal, and then what do we do with the results? Frequently, we want to convert that digital result back into an analog signal. The problem is that the sampling process loses a lot of data. Specifically, all the data between the discrete data points is lost, and if the sampler rounds the value, then a small amount of error is built into the system that can never be recovered. A common example of a reconstructor is a Digital to Analog Converter (DAC).

### Interpolation

When converting a digital signal into an analog signal, frequently a process called Interpolation is used to make the analog version a more likely representation of the signal. Interpolation essentially "connects the dots" between discrete data points, and the reconstructor then outputs an analog waveform with the dots connected. We will show the process below:

We start out with an uninterpolated stem plot:

We connect the points in our stem plot with straight lines (dotted lines):

We draw new points on that line, mid way between our existing lines (dashed lines):
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 1, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9005133509635925, "perplexity_flag": "middle"}