Module 2 — Data: turning the world into information
Lesson 4 of 13
Continuous and discrete data
Not all numbers describe the world in the same way.
Some quantities can vary smoothly across a range.
Others take distinct, countable values.
This gives us an important distinction:
continuous data
and
discrete data
Understanding the difference matters because it affects:
- how we measure things,
- how we store them,
- how we visualise them,
- how models interpret them,
- which mathematical tools are appropriate.
It also reminds us that the form of the data depends partly on how we choose to represent the world.
Continuous data
A continuous variable can, in principle, take any value within some range.
Examples include:
- temperature,
- distance,
- time,
- speed,
- voltage,
- mass,
- pressure,
- energy,
- rainfall,
- height.
Suppose the temperature is:
18°C
It could also be:
18.1°C
or:
18.13°C
or:
18.137°C
In principle, there are infinitely many possible values between 18°C and 19°C.
That is what makes the quantity continuous.
The physical world is often continuous
Many physical systems evolve continuously.
A car does not move from:
10 metres
to:
11 metres
without passing through all the positions in between.
A room does not usually jump instantly from:
20°C
to:
21°C
It passes through intermediate temperatures.
A battery's state of charge changes continuously as energy flows in and out.
So when we describe physical systems, continuous variables appear naturally.
But our measurements are never infinitely precise
There is an important complication.
Even if the underlying quantity is continuous, our measurement system cannot record infinitely many decimal places.
A thermometer might record:
18.4°C
but the true value could be:
18.37°C
or:
18.42°C
depending on the precision of the instrument.
A sensor turns a continuous physical quantity into a finite digital representation.
So there is a distinction between:
the quantity itself
and:
how precisely we measure it
This connects directly to the previous lesson on measurement.
Discrete data
A discrete variable takes separate, countable values.
Examples include:
- number of people,
- number of cars,
- number of purchases,
- number of hospital beds,
- number of messages,
- number of failures,
- number of children in a household.
Suppose a bus contains:
42 passengers
It could contain 43.
Or 41.
But not:
42.6 passengers
The possible values occur in distinct steps.
That makes passenger count discrete.
Counts are usually discrete
Many discrete variables are counts.
For example:
| Observation | Number |
|---|---|
| Cars passing in one minute | 17 |
| Customers entering a shop | 42 |
| Machine failures this month | 3 |
| Hospital admissions today | 118 |
Each value represents a count of individual events or objects.
Counts usually take non-negative integers:
0, 1, 2, 3, ...
There is no meaningful value between 2 failures and 3 failures.
Categories are discrete too
Discrete data does not always have to be numerical.
Consider transport mode:
- car,
- train,
- bus,
- bicycle,
- walking.
These are distinct categories.
Likewise:
- red,
- amber,
- green.
Or:
- low risk,
- medium risk,
- high risk.
These values are discrete because the variable belongs to one of a finite or countable set of possibilities.
Numbers can represent categories
Sometimes categories are encoded using numbers.
For example:
| Transport mode | Code |
|---|---|
| Walking | 1 |
| Bicycle | 2 |
| Bus | 3 |
| Train | 4 |
The numbers are labels.
They do not mean that:
Train = twice Bicycle
or that the distance between Bus and Train has any numerical significance.
This is important.
A number in a dataset is not automatically a numerical quantity.
Sometimes it is simply a code.
Ordered categories
Some categories have a natural order.
For example:
- low,
- medium,
- high.
Or:
- strongly disagree,
- disagree,
- neutral,
- agree,
- strongly agree.
These are often called ordinal variables.
We can say:
high > medium > low
in terms of ordering.
But we cannot necessarily assume that the distance between:
low and medium
is the same as the distance between:
medium and high.
This makes ordinal data different from ordinary numerical measurements.
Binary variables
A particularly simple discrete variable has only two possible states.
For example:
- yes / no,
- true / false,
- on / off,
- fraud / not fraud,
- disease / no disease.
These are often called binary variables.
They may be encoded as:
0 and 1
For example:
| Customer | Defaulted |
|---|---|
| A | 0 |
| B | 1 |
| C | 0 |
Again, the numbers represent categories.
They do not necessarily behave like ordinary continuous quantities.
Continuous versus discrete examples
Consider a car.
We might record:
| Variable | Type |
|---|---|
| Speed | Continuous |
| Position | Continuous |
| Fuel level | Continuous |
| Number of passengers | Discrete |
| Gear | Discrete |
| Headlights on/off | Discrete |
One system can therefore contain both continuous and discrete variables.
This is extremely common.
A hospital combines both
A hospital might track:
Continuous variables
- patient temperature,
- blood pressure,
- waiting time,
- oxygen saturation,
- medication dose.
Discrete variables
- number of beds,
- number of patients,
- diagnosis category,
- ward,
- admitted / not admitted.
Intelligent systems often need to reason across both types simultaneously.
Electricity systems combine both too
An electricity system contains continuous quantities such as:
- power,
- voltage,
- frequency,
- energy,
- state of charge.
But it may also contain discrete states such as:
- generator on/off,
- circuit breaker open/closed,
- connection active/inactive,
- number of available units.
This combination can make optimisation problems much more difficult.
A decision involving only continuous variables may be relatively smooth.
A decision involving on/off states introduces discrete choices.
We will return to this when we discuss optimisation.
A continuous quantity can be made discrete
Sometimes we deliberately divide a continuous quantity into categories.
Suppose age is recorded exactly:
37 years
Age can be treated approximately as a continuous numerical variable.
But we might instead create categories:
- 0–17,
- 18–34,
- 35–49,
- 50–64,
- 65+.
Now age has become discrete.
The underlying reality has not changed.
The representation has.
This process is sometimes called binning or discretisation.
Discretisation loses information
Suppose two people are aged:
35
and:
49
If both are placed in the category:
35–49
the distinction between them disappears.
Likewise, ages:
34
and:
35
may fall into different groups even though they differ by only one year.
This shows that categorisation can introduce artificial boundaries.
Turning continuous data into discrete categories simplifies information, but it also destroys detail.
Why discretise at all?
Despite the information loss, discretisation can be useful.
Categories can make data:
- easier to communicate,
- easier to summarise,
- easier to interpret,
- easier to use in rules.
For example:
temperature > 38°C → fever
may be easier to use in a clinical rule than a complicated continuous relationship.
Likewise:
low / medium / high risk
can be easier to communicate than a raw numerical score.
The key is recognising that the categories are a modelling choice.
Boundaries matter
Suppose we define:
high risk = score greater than 70
Then:
69.9 → not high risk
70.1 → high risk
A very small numerical difference creates a completely different category.
This can become important when automated systems make decisions.
For example:
- loan approved / rejected,
- treatment / no treatment,
- priority / no priority.
Discrete decision boundaries can create sharp changes in outcomes.
Measurements can become discrete because of resolution
A continuous physical variable may also appear discrete because of the measurement system.
Suppose a sensor records temperature only to the nearest degree:
18°C, 19°C, 20°C
The underlying temperature is continuous.
But the recorded values occur in steps.
The discreteness comes from the measurement resolution, not from the physical quantity itself.
This is another example of why:
The dataset reflects both the world and the measurement system.
Time can be continuous or discrete
Time is a particularly interesting example.
Physical time is usually treated as continuous.
But datasets often record time at discrete intervals:
- every second,
- every minute,
- every hour,
- every day.
Suppose we record electricity demand every 30 minutes:
09:00
09:30
10:00
10:30
We have converted a continuously evolving system into a sequence of discrete observations.
This will become central when we study time-series data.
Space can be continuous or discrete too
Geographic position can be represented continuously using coordinates:
latitude = 53.3498
longitude = -6.2603
But we can also represent location using discrete regions:
- Dublin,
- Cork,
- Galway.
Or:
- postcode,
- district,
- network node.
Again, the choice of representation changes the information available.
Precise coordinates preserve more spatial detail.
Regions simplify the system.
Digital computers work with discrete representations
Computers ultimately store information using finite digital states.
Even continuous quantities must therefore be represented using finite precision.
For example, a physical voltage may vary continuously.
A digital sensor converts it into a numerical value such as:
2.731 V
That conversion is called digitisation.
Conceptually:
CONTINUOUS WORLD → SAMPLING → DIGITAL VALUES
Modern AI operates on these digital representations.
It does not directly receive continuous reality.
It receives finite numerical encodings.
Images are discrete representations of continuous scenes
A real visual scene contains continuously varying light.
A digital camera samples that scene using a grid of pixels.
Each pixel stores a finite set of values.
So:
CONTINUOUS VISUAL WORLD
becomes:
DISCRETE PIXEL GRID
The resolution of the image determines how much spatial detail is retained.
A low-resolution image may lose information.
A high-resolution image preserves more detail but requires more storage and computation.
Sound is sampled too
Sound is produced by continuously varying air pressure.
A microphone converts that variation into an electrical signal.
A digital system then samples the signal at regular intervals.
The resulting audio file contains a sequence of numbers.
So:
CONTINUOUS SOUND WAVE
becomes:
DISCRETE DIGITAL SAMPLES
Again, the representation depends on:
- sampling frequency,
- bit depth,
- sensor quality.
The physical phenomenon and the stored data are not identical.
Machine learning treats different data types differently
The distinction between continuous and discrete variables matters when building models.
A continuous target might require predicting a numerical value.
For example:
temperature = 18.7°C
This is typically a regression problem.
A discrete target might require predicting a category.
For example:
weather = rainy
This is typically a classification problem.
The nature of the variable shapes the type of prediction task.
Predictions can be continuous or discrete
Suppose a medical model predicts:
probability of disease = 0.83
That is a continuous prediction between 0 and 1.
But the system may then convert it into a discrete decision:
disease
if:
probability > 0.5
Now a continuous estimate has become a binary classification.
This distinction is important:
prediction
and
decision
may have different mathematical forms.
Thresholds turn continuous scores into decisions
Many AI systems generate continuous scores.
For example:
fraud probability = 0.74
Then a threshold is applied:
if probability > 0.70 → flag transaction
The model produces a continuous estimate.
The policy creates a discrete action.
Change the threshold and the decision changes.
This is one reason prediction is not decision-making.
The model may estimate risk.
Someone still has to decide:
At what level of risk should we act?
Different thresholds create different consequences
Suppose a medical screening model produces a probability between 0 and 1.
A threshold of:
0.9
may identify only the highest-risk patients.
A threshold of:
0.2
may identify many more.
Lowering the threshold might:
- catch more true cases,
- create more false alarms.
Raising it might:
- reduce false alarms,
- miss more genuine cases.
The conversion from continuous prediction to discrete action therefore involves a trade-off.
We will explore this in detail when we examine precision, recall and false positives.
Discrete events can occur in continuous time
The distinction can become more subtle.
Suppose a machine fails.
Failure is a discrete event:
working → failed
But the event occurs at a particular point in continuous time.
Likewise:
- a customer purchase,
- a road accident,
- a generator trip,
- a hospital admission.
These are discrete events occurring within a continuously evolving system.
Many real datasets therefore combine event-based and continuous information.
State can contain continuous and discrete components
Recall the idea of a state vector.
A robot's state might contain:
- position,
- velocity,
- battery level,
- operating mode.
The first three may be continuous.
Operating mode might be discrete:
- standby,
- moving,
- charging.
So the system state can contain a mixture of variable types.
This matters because future behaviour may depend on both.
Hybrid systems
Systems containing both continuous dynamics and discrete transitions are sometimes called hybrid systems.
Consider a thermostat.
Temperature evolves continuously.
But the heater may have a discrete state:
ON
or:
OFF
The logic might be:
temperature below threshold → heater ON
temperature above threshold → heater OFF
So:
continuous state + discrete decision → new continuous evolution
Many cyber-physical systems have this structure.
Examples include:
- robots,
- vehicles,
- industrial systems,
- power systems,
- building controls.
Representation affects optimisation
Suppose we need to allocate electricity generation.
If every generator can smoothly produce any output between:
0 MW and 100 MW
the decision variables can be treated as continuous.
But suppose a generator must either be:
OFF
or:
ON with at least 40 MW
Now the optimisation includes discrete choices.
That can make the problem much harder computationally.
This is one reason the distinction between continuous and discrete variables matters beyond simple data description.
It affects decision-making algorithms too.
Representation affects probability
Continuous and discrete variables also require different probability descriptions.
For a discrete variable, we might assign probabilities directly:
| Outcome | Probability |
|---|---|
| Rain | 0.7 |
| No rain | 0.3 |
For a continuous variable such as temperature, we instead reason about ranges of values and probability distributions.
For example:
Tomorrow's temperature is most likely to be around 18°C, with lower probability further away.
We will explore these ideas in the probability module.
Be careful with averages
Discrete quantities can sometimes produce continuous averages.
Suppose two households contain:
2 people
and:
3 people
The average household size is:
2.5 people
No actual household contains half a person.
The average is still mathematically meaningful.
This reminds us that summary statistics do not necessarily correspond to physically possible individual observations.
The representation should match the question
Suppose we want to predict electricity consumption.
Exact power demand may be useful:
3.42 kW
But perhaps the decision only requires knowing whether demand is:
- low,
- medium,
- high.
The correct representation depends on the task.
Likewise, a navigation system may need precise coordinates.
A national planning model may only need regions.
There is no universally best level of detail.
The important question is:
What information does the decision actually require?
Too much precision can be misleading
Suppose a model predicts:
future demand = 4,238.713 MW
The decimal places may suggest extraordinary certainty.
But perhaps the actual forecast uncertainty is:
±300 MW
Reporting excessive precision can make a prediction appear more certain than it is.
The representation of numerical data should therefore reflect the quality of the underlying information.
Precision should not be confused with certainty.
Continuous and discrete are modelling choices as well as properties
Sometimes the world gives us a natural distinction.
We cannot meaningfully have:
3.7 people
But many cases are less obvious.
Age can be treated continuously or grouped into categories.
Location can be coordinates or regions.
Risk can be a probability or a category.
Time can be continuous or divided into intervals.
So the question:
Is this variable continuous or discrete?
sometimes has two answers:
What is the underlying phenomenon?
and:
How have we chosen to represent it?
From reality to representation
Consider a continuously changing physical system.
We might transform it like this:
CONTINUOUS REALITY
↓
MEASUREMENT
↓
SAMPLING
↓
FINITE NUMERICAL VALUES
↓
POSSIBLE CATEGORIES
At each stage, information can be simplified.
That simplification may be necessary.
But we should understand what has been lost.
Ask what kind of variable you have
When examining a dataset, useful questions include:
- Is this variable continuous or discrete?
- Is it numerical or categorical?
- If numerical, does arithmetic make sense?
- Is there a natural ordering?
- Has a continuous variable been placed into categories?
- What information was lost through that categorisation?
- Is the apparent discreteness caused by measurement resolution?
- Is a continuous prediction later converted into a discrete decision?
- Does the chosen representation match the problem?
These questions help prevent inappropriate assumptions about data.
The central idea
Continuous and discrete data represent different kinds of structure.
Continuous variables describe quantities that can vary smoothly across a range.
Discrete variables describe distinct values, counts, states or categories.
But the distinction is not always purely a property of reality.
It can also be created by the way we:
- measure,
- sample,
- categorise,
- store,
- use
information.
The world may be continuous while the data is discrete, and a continuous prediction may ultimately produce a discrete decision.
Understanding these transitions helps us see how reality is progressively transformed into information that machines can process.
In the next lesson, we will examine one of the most important forms of ordered data:
time-series data — observations whose sequence through time is itself part of the information.