SlideShare a Scribd company logo
1 of 87
Download to read offline
Wherefore Representations?
Sanket Patil
sanketvpatil@gmail.com
November 22, 2020
Sanket Patil Representations
Who am I?
I’m Sanket. I am a product guy, a data scientist, a mentor,
“strategic thinker”, and an impostor at large.
Products and Data Science at DataWeave. Solving problems
for online retailers and consumer brands.
Working with start ups building data products. Analytics,
Machine Translation, Search, NLP, etc.
Previous Life: Research in Distributed Algorithms and
Complex Adaptive Systems.
Sanket Patil Representations
Who am I?
Outside of Work, I have a number of eclectic interests.
I’m an aspiring writer: Writing
I’m part of some experiments around sustainability and
growing food: Tamarind Valley Collective
A few years ago I picked up bird watching.
Website: Where I write about books, tech, and life in general:
Dilettante Diaries
Twitter: @sanketp
Talk to me
I spend some time during weekends giving guidance on product
and tech problems, mentoring, and playing the role of a “sounding
board”. If you think this might be useful for you, click here to talk
to me.
Sanket Patil Representations
Why am I doing this?
Over the last 15 years or so I have worked in research labs and
startups thinking deeply about problems in a bunch of
different areas. I want to share some of those learnings with
others.
I have always liked discussing interesting problems and
concepts with others; I think that’s when I learn better.
Also, I suck at doing small talk, but I really love having long
conversations about topics that interest me.
So, this is my way of engaging with people, if you will.
And, look, it’s just fun, so I don’t think it really needs much
justification beyond that.
Sanket Patil Representations
Wherefore Representation?
First of all . . .
What on earth does “wherefore” mean? It’s an archaic word that
means: “for what reason / purpose” or simply, “why”.
So, why?
That’s precisely what we want to explore together. Hopefully, that
will be clear through the course of this and subsequent talk.
With all that out of the way, . . .
Sanket Patil Representations
. . . let’s begin
The White Rabbit put on his spectacles. “Where shall I begin
please your Majesty?” he asked.
“Begin at the beginning,” the King said gravely, “and go on till
you come to the end: then stop.”
Representations
Figure: The Treachery of Images, by Ren´e Magritte
Source: Wikipedia
“But it is a pipe.”
“No, it’s not,” I said. “It’s a drawing of a pipe. Get it? All rep-
resentations of a thing are inherently abstract. It’s very clever.”
An Object and its Representation
“It’s quite simple. Who would dare pretend that the rep-
resentation of a pipe is a pipe? Who could possibly smoke
the pipe in my painting? No one. Therefore it IS NOT A
PIPE.”
Sanket Patil Representations
An age-old question
Figure: Object and its Representation
Source: Science Direct
Sanket Patil Representations
An Object and its Representation
“The shape of an object, the layout of a scene, the sense of a
word, and the meaning of a sentence must all be represented as
spatio-temporal patterns of neural activity.”
Sanket Patil Representations
A Word and its Meaning
“I don’t know what you mean by ‘glory’,” Alice said.
Humpty Dumpty smiled contemptuously. “Of course you
don’t—till I tell you. I meant ‘there’s a nice knock-down ar-
gument for you!’ ”
“But glory’ doesn’t mean ’a nice knock-down argument’,” Alice
objected.
“When I use a word,” Humpty Dumpty said, in rather a scornful
tone, “it means just what I choose it to mean—neither more nor
less.”
“The question is,” said Alice, “whether you can make words
mean so many different things.”
“The question is,” said Humpty Dumpty, “Which is to be
master—that’s all.”
Sanket Patil Representations
Map and Territory
Figure: “Sylvie and Bruno Concluded”, by Lewis Carroll
Source: Lit2Go
Sanket Patil Representations
Figure: “On Exactitude in Science”, by Jorge Luis Borges
Source: KWARC
Sanket Patil Representations
This is not a Story
Figure: “Ceci n’est pas un conte”, by Denis Diderot written in 1772.
Source: Goodreads
Sanket Patil Representations
Why Representations?
The duality of objects and their representations is well
explored in the arts.
You might have come across concepts such as: “the map is
not the territory”, “the word is not the thing.”
Such symbolism and art and literature and philosophy aside,
the idea of representations is all too pervasive.
It has practical importance in almost every field of scientific
endeavour.
Sanket Patil Representations
More Practically: Why Representations?
They are fundamental to the way we understand the world
and navigate through it. They are all pervading: language,
communication, mathematics, biology, systems, machine
learning, . . .
The way information is represented plays a crucial role in how
we understand it, draw inferences, do computations on it, and
organize it. A good representation makes all of these efficient.
Scripts and alphabets help us give concrete form to abstract
thought, and communicate them with each other.
Sanket Patil Representations
Calculus helps us measure, compute and reason about real
world quantities such as distance, time, and volume.
Data structures help us represent data, and even abstract
concepts (such as “trust”) such that they can be retrieved
and processed efficiently.
They capture underlying “patterns”. Good representations
essentially have the effect of “disentanglement”.
That is to say they highlight the variances in underlying data
clearly. This is what makes Machine Learning work.
Sanket Patil Representations
Prehistory and DNA Sequencing
Recently I’ve been reading a little bit about prehistory and
certain new techniques in DNA sequencing.
These are helping in understanding—well, in a manner of
speaking—who we are and how we came to be.
What were our migration patterns, the movement of
languages and culture.
Now, while all of this is fascinating in itself I was also
pleasantly surprised to know that fairly simple techniques from
machine learning such as principle component analysis
(popularly known as PCA) play a key role in this.
(We will talk about PCA and related techniques in a
subsequent session.)
The long and short of it: the centrality of representations
cannot be overstated.
Sanket Patil Representations
This talk · · ·
Somewhat generic. Introduction to the talk series and
motivation for the overall theme.
In the rest of the talk
Examples of representations and how they help solve real
problems
A brief note on number systems (with focus on Roman
numerals)
Some old problems from discrete mathematics (with a new
twist)
I will keep it slightly high level focussing more on the intuition
and less on rigour
Might be quite basic for many of you; but hopefully you’ll still
find it enjoyable and may even get a new insight or two.
Sanket Patil Representations
Rest of the Talk Series: Three Broad Themes
1 Theme 1: Distributed Data Structures/Algorithms; efficient
storage structures.
2 Theme 2: Information Theory/Machine Learning/Deep
Learning.
3 Theme 3: Game Theory; modelling behaviour; Multi-agent
Systems.
Sanket Patil Representations
Examples of Representations
Figure: Exempli Gratia
Source: Thesaurus.plus
Sanket Patil Representations
Visualization in the Time of
Cholera
Figure: John Snow’s original map with clusters
Source: Wikipedia
Cholera Epidemic of 1854
One of the first usage of data representation to solve real
world problems in modern times was done in London in 1854.
Prevailing theory: cholera was an airborne disease. A popular
theory called the miasma or miasmatic theory.
Miasma Theory was quite fascinating but equally misguided.
that attributed “bad air” or “pollution” or some evil in the air
to most diseases at the time.
But there was this physician called John Snow, who had a
different hypothesis. He suspected that the cause of Cholera
and resultant deaths are due to contaminated water.
Sanket Patil Representations
Data Visualization
John Snow mapped all the cholera cases and related deaths
on and around broad street.
Using basic visualizations he inferred that there are clusters of
cases around water pumps.
This lead to his conclusion that contaminated water might be
the cause for he disease.
He convinced the authorities to remove the handle the pump
at Broad Street. (Today there is a small pump at the same
location commemorating this.)
This resulted in a drop of cholera cases within a few days!
Sanket Patil Representations
John Snow didn’t have access to the modern visualization
techniques.
Today we use Voronoi Diagrams or Cluster Analysis to model
such problems (each one a major topic that we can look into
subsequently).
Sanket Patil Representations
Cholera Clusters
Figure: Modern visualization techniques
Source: SAS Blogs
Sanket Patil Representations
Voronoi Diagrams
Start with a set of seed points or ”sites” or generators.
Partition the region into a set of cells each one containing a
site into a set of cells each one containing a site (called
Voronoi cells) such that every point within that cell is closer
to the site than it is to any other site.
Imagine these seeds or sites to be important public service
institutions such as hospitals, fire stations, schools, and of
course, water pumps.
In this case we are looking at a plane, but it can be
generalized to higher dimensions as well.
Sanket Patil Representations
John Snow Memorial
Figure: John Snow Memorial
Source: Wikipedia
Sanket Patil Representations
Linear Separability
Figure: Flatland: A Romance of Many Dimensions
Source: Wikipedia
Two Classes
Figure: Linearly Separable?
Source: Deep Learning Book
Question
Can you draw a straight line through this scatterplot to separate
the two classes? How do we make them linearly separable?
Sanket Patil Representations
Two Classes
Figure: Linearly Separable?
Source: Deep Learning Book
Polar Coordinates
The same data points represented using their polar coordinates.
Now, it is straightforward to draw a line through this plane.
Sanket Patil Representations
Cartesian vs Polar Coordinates
r = 1
r = 3
r = 9
r = 4
θ = 60
X
Y
Figure: Cartesian and Polar Coordinates
Sanket Patil Representations
Cartesian to Polar and Back
Step 1: Cartesian to Polar
Visualize a bunch of (well, lots of them, infinitely many)
concentric circles with different radii. Each of the dots and
triangles shown in the first figure lie on one of these circles.
The radius of the circle on which a data point lies is its r
polar coordinate and the angle that the ray from the origin
passing through this point forms with the x-axis is its θ polar
coordinate.
Step 2: Represent data with new coordinates
Think of r and θ as your new x and y, and scatter the dots
and triangles on this new plane.
What you get is something similar to second figure with the
two types of points more or less neatly separated.
Sanket Patil Representations
Intuition
The underlying process or the function (which is not known to
us a priori) that generated the data was not linear. Therefore,
you can’t use a linear function (a straight line) to separate
them.
They are not linearly separable in the Cartesian space.
However, you can clearly see that the two classes of data
points fall in two roughly separate circular or quadratic spaces.
By using polar coordinates in Cartesian space, we are
transforming the space in such a manner that now we are able
to disentangle the two sets of data points.
Sanket Patil Representations
Dimensions: Lower to Higher to Lower
Representation Learning
This happens a lot in machine learning (and especially deep
learning) wherein you represent data points in a different kind of
space—sometimes higher dimensions and sometimes reduced
number of dimensions—depending on where a model can learn
better representations such that it’s “easier” for it to separate
classes.
Dimensionality Reduction
Dimensionality reduction techniques are also used a lot to
represent data in lower number of dimensions which carry the most
distinctive information, while reducing noise. Example: Principal
Component Analysis
The above description is quite hand wavy, of course, but we will
learn about some of these techniques with more rigour in
subsequent talks.
Sanket Patil Representations
Proof without Words
Figure: Visual Proof of Nichomachus Theorem
Source: Wikipedia
Solving an Infinite Series using a Geometric Representation
Figure: A Geometric Series
Source: Mathematical Association of America
Sanket Patil Representations
Sum of Odd Numbers
Figure: Visual Proof of Sum of Odd Numbers Theorem
Source: Wikipedia
Sanket Patil Representations
A Tweet sized proof for an old identity
Sanket Patil Representations
Representation: More Examples from Different Disciplines
Calculus as a language to represent continuous quantities.
The Talking Drums of Africa: long distance language and
cultural communication.
Morse code as an efficient way of encoding and transmitting
information
Language Models: Representing redundancy and capturing
statistics inherent to languages
Representing trust over the Internet: Blockchains (powered by
Merkle Trees)
Representing “Meaning”: word embeddings, speech vectors,
image embeddings.
· · ·
Sanket Patil Representations
Numbers
“There are 10 kinds of people in the world.
Those that understand binary,
those that don’t,
and those that didn’t expect this joke to be in ternary.”
Roman vs Hindu-Arabic
Think
What are the main differences between Roman and
Hindu-Arabic numeral systems?
Is arithmetic more difficult with Roman numerals in
comparison with Hindu-Arabic numerals?
What made the Hindu-Arabic system superior and/or popular?
Sanket Patil Representations
Friends, Romans, countrymen · · ·
· · · lend me a hand in doing basic arithmetic;
Addition
What is DLXXIII + CCLXXXVII?
Question
How do you add two numbers represented in Roman numerals
without converting them to the decimal form?
Sanket Patil Representations
Before that: Underlying Principles
Think about how Roman number are constructed.
Not a positional system. No place value. Only face value.
Additive system. To go from one number to the next, you
stick an I in front.
Numerals are ordered in non-increasing order. You add them
up to get the final number.
A bunch of numerals to indicate bigger numbers.
However, it is also subtractive, but that is to manage “short
cuts”.
When a numeral has to be repeated more than 3 times, a
short cut is used. E.g., XL instead of XXXX.
If a smaller numeral comes before a larger one, together they
form a group and is treated as such.
If you keep that in mind, you will see that a Roman
representation is an additive system with individual numerals
(including short cut groups) are sorted in non-increasing order.
Sanket Patil Representations
It’s simple(r)
Roman Arithmetic can be built easily on top of these principles.
A Four Step Algorithm
Let’s add IV and IX
1 Expand: IV → IIII, IX → VIIII, and so on.
2 Append: IIIIVIIII
3 Sort (non-increasing): VIIIIIIII
4 Contract: VIIIIIIII → VVIII → XIII
Exercise: Think
How do we do subtraction?
What about multiplication and division?
Sanket Patil Representations
Number Systems: Some Observations
There is nothing sacrosanct about the decimal system that we
are used to except that it’s convenient and widely used.
Similarly, there’s nothing sacrosanct about the binary system
either.
There are other kinds of number systems and bases that can
be very useful in certain applications
We will see some examples next.
Sanket Patil Representations
Three Problems from Discrete
Mathematics
1 A Geometric Problem
2 A Survival Problem
3 A Weight Problem
Problem 1: Lines in a Plane
Maximum Number of Regions
Suppose you have a pizza and a sharp knife. (If you don’t fancy
pizza, consider a chapati or a plain dos´e.) What is the maximum
number of slices that you can get by making 1, 2, 3, or in the
general case, n, straight cuts on the surface of the pizza (or
equivalent)?
Sanket Patil Representations
Number of Regions
1
7
6
5
4
3
2
1
4
3
2
1
2
1
n = 0
n = 3n = 2
n = 1
Figure: Can you see the pattern: 1, 2, 4, 7, . . . ?
Sanket Patil Representations
What happens when a new line is added?
1
8
7
6
5
43
10
2
L1
L2
L3
L4
New region formed by L3 common

to both L1 and L2
New region formed 

by L4 common

to both L1 and L2
New region formed 

by L4 common

to both L2 and L3
New region formed 

at the boundary
New region formed 

at the boundary
Figure: Number of regions added when a new line is added
Sanket Patil Representations
Key Insights
Every new line added to the plane meets each of the existing
lines exactly once.
A new line (L4) in the previous figure) “cuts” the region on
either side of a previous line in two when it intersects with it:
once as it “enters” and once as it “exits”.
However, the number of regions does not increase as 2n
because there are “common” regions formed between pairs of
previous lines, as you can see in the figure.
Thus,if there are k lines previously, the k + 1th line adds k + 1
new regions.
What does that tell us?
Sanket Patil Representations
Solution
n R(n) S(n) + 1
0 1 0 + 1
1 2 1 + 1
2 4 3 + 1
3 7 6 + 1
4 11 10 + 1
5 16 15 + 1
. . . . . . . . .
Triangular Numbers
The number of regions, R(n) = S(n) + 1 = n(n+1)
2 + 1
Sanket Patil Representations
Aside: Can you prove this?
Theorem (Sum of first n natural numbers)
1 + 2 + · · · + n = n×(n+1)
2
You can use the good old proof by induction, of course. But
it’s boring.
Sanket Patil Representations
Gauss’ Trick
Sum of first n natural numbers.
1 + 2 + 3 + · · · + (n − 2) + (n − 1) + n
+
n + (n − 1) + (n − 2) + · · · + 3 + 2 + 1
=
(n + 1) + (n + 1) + · · · + (n + 1) + (n + 1) + (n + 1)
=
n · (n + 1)
But since we have taken the sum twice, we just halve it to get:
n·(n+1)
2
Sanket Patil Representations
Problem 2: The Josephus Problem
Roman-Jewish war; Jews were surrounded by Romans;
preferred suicide to getting captured.
Scheme: Form a circle. Start from position 1. Kill every
second person alive.
Josephus Flavius — a historian — didn’t want such a thing.
In the original story, he and a co conspirator found suitable
places in the circle by quickly solving the problem mentally
and survived.
What we are going to look at is one variant of the problem.
Sanket Patil Representations
An Instance
1
8
7
6
5
4
3
2
Round 1

Starting

Position
1
8
7
6
5
4
3
2
Round 2

Starting

Position
1
8
7
6
5
4
3
2
Round 3

Starting

Position
1
8
7
6
5
4
3
2
Round 4

Starting

Position Survivor!
Figure: Instance with n = 8
Sanket Patil Representations
Let’s look at a few cases
n w(n)
1
2
3
4
5
6
7
8
1
1
3
1
3
5
7
1
1
2

3 2

1
3
1
4 2

1
1
5
4 3
2
1
6
5
4 3
2
3
3


5


7


9


11


13


15


1
9


10


11


12


13


14


15


16
Figure: The survivor w(n) for different values of n
Sanket Patil Representations
Do you see a pattern?
It’s obvious that under the given conditions, all even
numbered people get killed in the first round. So the survivor
is always found in an odd numbered position.
Something interesting is happening for certain values of n
such as 1, 2, 4,etc, (marked with the golden yellow line).
w(n) is always 1 for these n.
These are powers of 2. So, when n = 2m, m >= 0 it looks like
w(n) = 1 regardless of m.
Between two golden yellow lines—that is between two groups
of powers of 2—survivor number increases by 2 before
“wrapping around” to 1.
Sanket Patil Representations
Solution
n w(n) n = 2m + l w(n) = 2 · l + 1
1 1 20 + 0 2 · 0 + 1 = 1
2 1 21 + 0 2 · 0 + 1 = 1
3 3 21 + 1 2 · 1 + 1 = 3
4 1 22 + 0 2 · 0 + 1 = 1
5 3 22 + 1 2 · 1 + 1 = 3
6 5 22 + 2 2 · 2 + 1 = 5
. . . . . . . . . . . .
Solution
Represent n in the form, n = 2m + l
The survivor number, w(n) = 2l + 1
Sanket Patil Representations
Exercises
Alternative Solutions
Can you arrive at a solution by forming recurrence relations?
[Hint: This is a recursive problem if you think about it.]
Can you use modulo arithmetic to arrive at this solution?
[Hint: Look at the circular arrangement. It is amenable to
clock arithmetic.]
Sanket Patil Representations
Binary Representation
n = 789 = 29 + 277 = (1100010101)b
w(n) = 2 · 277 + 1 = 555 = (1000101011)b
Figure: You can get the same result by moving MSB to LSB!
Sanket Patil Representations
Bitwise Algorithm
While the previous method is fairly straightforward, you can
achieve the same by a couple of simple bitwise operations
regardless of how big n is.
Write a program in your favourite programming language and
verify this for different values of n.
Can you see why this works?
Sanket Patil Representations
Proof Sketch
Proof.
1 Any n can be represented in binary as,
n = bmbm−1bm−2 . . . b1b0, where each bi ∈ 0, 1
2 But since n = 2m + l, the Most Significant Bit (MSB),
bm = 1. Thus, n = 1bm−1bm−2 . . . b1b0
3 Similarly, the remaining part l can be represented as,
l = 0bm−1bm−2 . . . b1b0 (E.g. if n = 15, n = 23 + 7,
8 ≡ 1000, and 7 ≡ 0111)
4 Multiply l by 2. This is the same as a left shift operation.
Thus, 2 · l = bm−1bm−2 . . . b1b00 (E.g.,
2 · l = 7 · 2 = 14 ≡ 1110 )
5 2 · l + 1 = bm−1bm−2 . . . b1b01 = bm−1bm−2 . . . b1b0bm
(Since, bm = 1, from Step 2).
6 But 2 · l + 1 = w(n). Thus, w(n) = bm−1bm−2 . . . b1b0bm.
Sanket Patil Representations
Exercises
1 We looked at an instance of the problem with a starting
position, p = 1, and a “skip”, k = 2. Generalize Josephus
Problem. Find the solution for any (n, p, k)
2 What is the time and space complexity for the first method?
And for the bitwise method?
3 Can you find a bitwise method for the generalized problem?
4 This is a lovely combinatorial problem. Highly instructive.
Now, think of some applications.
Sanket Patil Representations
Problem 3: The Good Old Balance
Figure: Weighing Balance with Weights
Source: Wikipedia
Sanket Patil Representations
The Balance Problem
Minimum Number of Weights
Suppose you have a weighing balance that you can use to measure
objects of different weights. Let’s assume that you can measure
only integral weights, not fractional ones. What is the minimum
number of weights required to weigh objects whose weights range
from 1 kg to 40 kg?
Sanket Patil Representations
Key Insights
It’s a balance with two pans. Not a spring balance, not a
weighing scale.
That is to say, there are three states in which a weight can be:
left pan, outside, right pan.
You can put weights on either or both pans. Not only can you
add two weights, you can subtract also.
Instead of 40, were you to weigh up to 4, you would do it as
follows: 1, 2 =3 -1, 3, 4 = 3 + 1
Sanket Patil Representations
Solution Approach
This is akin to constructing numbers using a ternary number
system. (Yes, there are 10 kinds of people in the world.)
Except, the alphabet is not the usual {0, 1, 2}, but it’s,
α = {−1, 0, 1}
α = {−1, 0, 1} ≡ {left pan, outside, right pan}
So, the original puzzle now reduces to: how many ternary
digits do you need to construct 40 ternary numbers?
40 = 27 + 13 + 9 + 1 = 33 + 32 + 31 + 30
You need the weights, w = {1, 3, 9, 27}
Try a few:
37 = 27 + 9 + 1
35 = 27 + 9 − 1
14 = 27 − (9 + 3 + 1)
Sanket Patil Representations
Exercises: Generalizations
We chose n = 40, which could be neatly partitioned using
powers of 3. Can you find the solution for any n?
What happens if only additions were allowed? That is you can
add weights to only one pan.
We solved this for a balance with two pans, k = 2. Can you
solve it for any k? (k = 1 is binary, whereas k = 4 is quinary
— base 5)
This is a fun problem. But can you think of any real
applications?
Sanket Patil Representations
And Now for Something
Completely Different
Figure: If you don’t know how to solve a problem, model it using Graph
Theory. Now you have a combinatorial problem. That might not make it
easier to solve the problem, but definitely looks good.
Source: Spiked Math Comics
The Balance Problem and DHTs
I can think of at least one extremely interesting application of
the previous problem. It’s in Distributed Hash Tables (DHT).
(If you don’t know what DHT is, don’t worry, we will discuss
it in the next talk.)
The first step is to model the problem as a Graph Theoretic
problem.
Shameless Plug: This problem inspired a part of my research
work in optimal network design during my PhD. I’m going to
briefly present that next.
Sanket Patil Representations
(Balanced) Base−b Networks
A class of Distributed Hash Tables inspired by the previous
puzzle.
The construction technique is derived from representations of
numbers in different bases.
Generalization of the well known Chord DHT.
Question
What is the graph theoretic interpretation of additive vs
subtractive weights from the previous problem?
Sanket Patil Representations
Representation-1: The Number Line
-13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13
-13 130
Figure: A Segment of the number line
Constructing numbers is the same as moving along a number
line.You can go from 7 to 8, by taking one step to the right.
OTOH, if you want to move to -5, you take 12 steps to the
left.
This is the same as adding or subtracting weights—but you
only have a single weight of 1.
However, here we are looking at a segment of the number line
[−13, 13].
Sanket Patil Representations
You can think of the number line as an undirected line graph
extending infinitely. That means you can traverse in both
directions.
It’s a line graph with 27 nodes, with each number forming one
node. The values represent the names of nodes. They can be
anything.
The diameter of this graph is 27—it takes 27 steps to reach
Node 13 from Node -13.
Sanket Patil Representations
Representation-2: The ”Wrap around” Number Line
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
0
-13 13
Figure: Number line wrapped around
Let’s wrap around the segment of the number line.
Now suddenly the distances are halved on average.
And you have two ways of reaching a node (a number) from
another — one shorter and the other one longer.
Sanket Patil Representations
Representation-3: The Balanced Ternary Network
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
0 1
2
3
4
5
6
7
8
9
10
11
12
13-13-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
Figure: Constructing the balanced ternary network
Sanket Patil Representations
Construction Algorithm
Let’s add some more short cuts. In fact, let’s use the solution
from the balance problem.
For every node, add an edge to a node that is at a distance of
30, 31, and so on.
Since, 13 = 9 + 3 + 1,from Node 1, we have edges to 2, 4,
and 10.
Do the same at every node. Each node connects to nodes that
are at a distance of 1, 3, and 9 nodes away going clockwise.
When you are done, you will get the network in the next slide.
It’s “balanced” because you can go both forwards and
backwards.
Sanket Patil Representations
The Balanced Ternary Network
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
0 1
2
3
4
5
6
7
8
9
10
11
12
13-13-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
Figure: The complete balanced ternary network
Sanket Patil Representations
Reaching from one node to another
In this network, you can reach any node from any other in a
maximum of 3 hops.
For example, the distance between Node 4 and Node -4 on
the circle is −8.
The number -8 is represented in balanced ternary as, (−1)01
or ¯101.
In terms of routing over the balanced ternary network this is
equivalent to taking the first skip (9 steps) backward from 4
to -5; then take the last skip (1 step) forward to reach -4.
Note that this is in principle the equivalent of weighing 8 (9 -
1) in the original problem.
Sanket Patil Representations
The Ternary Network
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22-21-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 20 21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
0 1 3
27
48
49
50
56
75
80
9
Figure: The ternary network – partial
Sanket Patil Representations
The Ternary Network
What if you weren’t allowed to subtract? This is the
equivalent of saying edges are now directed.
Ternary networks use the regular ternary alphabet {0, 1, 2}
(no “balanced”).
You can construct directed graphs using a similar technique as
we described before.
Sanket Patil Representations
Properties and Generalization
You can generalize this to any base b.
Given a base–b, and a k, k ∈ Z+, the number of nodes that
can be packed in a balanced base–b network is, n = bk.
The diameter of such a network with an alphabet l is,
d = max {|i| ∈ l} · k, where max {|i| ∈ l} ≈ b
2 . That is to say,
d ≈ b
2 logb n.
Given a base–b, and a k, k ∈ Z+, the number of nodes that
can be packed in a network is, n = bk.
The diameter of such a network is, d = max {|i| ∈ l} · k,
where max {|i| ∈ l} = b − 1. That is to say,
d = (b − 1) logb n.
Sanket Patil Representations
Next Session
Figure: Hypercubes and Hamming Distance
Source: Wikipedia
The Geometry of DHTs
If some of the above is unclear / confusing, don’t worry about
it. We will look at DHTs and their underlying geometrical
structures in more detail in the next session.
We will discuss the interplay of metric spaces, geometry, and
graph theoretic representations as applied to DHTs, which are
underpinning of most distributed systems.
Sanket Patil Representations
References and Further Reading
1 A nice intuitive explanation of the Josephus Problem Source:
Numberphile YouTube Channel
2 Concrete Mathematics: A Foundation for Computer Science.
R. Graham, D. Knuth, and O. Patashnik. Addison-Wesley,
Reading, (1989)
3 Designing optimal network topologies under multiple efficiency
and robustness constraints. My PhD Thesis. Source:
Shodhganga
Book Recommendations
Concrete Mathematics. Highly recommended for anyone who
wants to hone mathematical thinking.
What’s the Point of Maths?Informative and entertaining book
for kids and adults alike.
Flatland: A Romance of Many Dimensions by Edwin Abbott
Abbott.
Sanket Patil Representations
Thank you!
Feedback
Please feel free to share your feedback with me. over email,
Twitter, LinkedIn, or my website.
License
I’m distributing this under Creative Commons License. Feel free
reuse., modify, distribute this material (with suitable attribution).
If you want the source files, send me an email.
Sanket Patil Representations
Fin
“May you live in interesting times.”
[An ancient Chinese curse.]

More Related Content

Similar to Talk0 representations

Similar to Talk0 representations (20)

Singularity
Singularity Singularity
Singularity
 
Systems Thinking & Social Media Notes
Systems Thinking & Social Media NotesSystems Thinking & Social Media Notes
Systems Thinking & Social Media Notes
 
Steps Of Research Paper Writing - How T. Online assignment writing service.
Steps Of Research Paper Writing - How T. Online assignment writing service.Steps Of Research Paper Writing - How T. Online assignment writing service.
Steps Of Research Paper Writing - How T. Online assignment writing service.
 
How To Write A Song 6 Great Ways To Create A Song - Mixing Tips
How To Write A Song 6 Great Ways To Create A Song - Mixing TipsHow To Write A Song 6 Great Ways To Create A Song - Mixing Tips
How To Write A Song 6 Great Ways To Create A Song - Mixing Tips
 
2015 Arts Midwest Workshop: Embracing the Digital Age
2015 Arts Midwest Workshop: Embracing the Digital Age2015 Arts Midwest Workshop: Embracing the Digital Age
2015 Arts Midwest Workshop: Embracing the Digital Age
 
Pay Someone To Write My Paper Cheap - Ireland Assi
Pay Someone To Write My Paper Cheap - Ireland AssiPay Someone To Write My Paper Cheap - Ireland Assi
Pay Someone To Write My Paper Cheap - Ireland Assi
 
KR in the age of Deep Learning
KR in the age of Deep LearningKR in the age of Deep Learning
KR in the age of Deep Learning
 
Visual Essay Example
Visual Essay ExampleVisual Essay Example
Visual Essay Example
 
Essay Contest 2015 Malaysia
Essay Contest 2015 MalaysiaEssay Contest 2015 Malaysia
Essay Contest 2015 Malaysia
 
Normal Considered Harmful
Normal Considered HarmfulNormal Considered Harmful
Normal Considered Harmful
 
Engineer Girl Essay Competition
Engineer Girl Essay CompetitionEngineer Girl Essay Competition
Engineer Girl Essay Competition
 
Fundamentals of Writing a Pitch
Fundamentals of Writing a PitchFundamentals of Writing a Pitch
Fundamentals of Writing a Pitch
 
Tableau Usage Essays
Tableau Usage EssaysTableau Usage Essays
Tableau Usage Essays
 
Exploratory Essays
Exploratory EssaysExploratory Essays
Exploratory Essays
 
Metaphors in Qualitative Research & Synthesis
Metaphors in Qualitative Research & SynthesisMetaphors in Qualitative Research & Synthesis
Metaphors in Qualitative Research & Synthesis
 
My Writing A Perfect Paper Immigrant.Com.Tw
My Writing A Perfect Paper Immigrant.Com.TwMy Writing A Perfect Paper Immigrant.Com.Tw
My Writing A Perfect Paper Immigrant.Com.Tw
 
The Future of AI: Going Beyond Deep Learning, Watson, and the Semantic Web
The Future of AI: Going BeyondDeep Learning, Watson, and the Semantic WebThe Future of AI: Going BeyondDeep Learning, Watson, and the Semantic Web
The Future of AI: Going Beyond Deep Learning, Watson, and the Semantic Web
 
Finding Vorpal Blades: Questing for Content
Finding Vorpal Blades: Questing for ContentFinding Vorpal Blades: Questing for Content
Finding Vorpal Blades: Questing for Content
 
Personal Observation Examples. How To Write A
Personal Observation Examples. How To Write APersonal Observation Examples. How To Write A
Personal Observation Examples. How To Write A
 
Eduserv Digital Identities Workshop
Eduserv Digital Identities WorkshopEduserv Digital Identities Workshop
Eduserv Digital Identities Workshop
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Talk0 representations

  • 2. Who am I? I’m Sanket. I am a product guy, a data scientist, a mentor, “strategic thinker”, and an impostor at large. Products and Data Science at DataWeave. Solving problems for online retailers and consumer brands. Working with start ups building data products. Analytics, Machine Translation, Search, NLP, etc. Previous Life: Research in Distributed Algorithms and Complex Adaptive Systems. Sanket Patil Representations
  • 3. Who am I? Outside of Work, I have a number of eclectic interests. I’m an aspiring writer: Writing I’m part of some experiments around sustainability and growing food: Tamarind Valley Collective A few years ago I picked up bird watching. Website: Where I write about books, tech, and life in general: Dilettante Diaries Twitter: @sanketp Talk to me I spend some time during weekends giving guidance on product and tech problems, mentoring, and playing the role of a “sounding board”. If you think this might be useful for you, click here to talk to me. Sanket Patil Representations
  • 4. Why am I doing this? Over the last 15 years or so I have worked in research labs and startups thinking deeply about problems in a bunch of different areas. I want to share some of those learnings with others. I have always liked discussing interesting problems and concepts with others; I think that’s when I learn better. Also, I suck at doing small talk, but I really love having long conversations about topics that interest me. So, this is my way of engaging with people, if you will. And, look, it’s just fun, so I don’t think it really needs much justification beyond that. Sanket Patil Representations
  • 5. Wherefore Representation? First of all . . . What on earth does “wherefore” mean? It’s an archaic word that means: “for what reason / purpose” or simply, “why”. So, why? That’s precisely what we want to explore together. Hopefully, that will be clear through the course of this and subsequent talk. With all that out of the way, . . . Sanket Patil Representations
  • 6. . . . let’s begin The White Rabbit put on his spectacles. “Where shall I begin please your Majesty?” he asked. “Begin at the beginning,” the King said gravely, “and go on till you come to the end: then stop.”
  • 7. Representations Figure: The Treachery of Images, by Ren´e Magritte Source: Wikipedia “But it is a pipe.” “No, it’s not,” I said. “It’s a drawing of a pipe. Get it? All rep- resentations of a thing are inherently abstract. It’s very clever.”
  • 8. An Object and its Representation “It’s quite simple. Who would dare pretend that the rep- resentation of a pipe is a pipe? Who could possibly smoke the pipe in my painting? No one. Therefore it IS NOT A PIPE.” Sanket Patil Representations
  • 9. An age-old question Figure: Object and its Representation Source: Science Direct Sanket Patil Representations
  • 10. An Object and its Representation “The shape of an object, the layout of a scene, the sense of a word, and the meaning of a sentence must all be represented as spatio-temporal patterns of neural activity.” Sanket Patil Representations
  • 11. A Word and its Meaning “I don’t know what you mean by ‘glory’,” Alice said. Humpty Dumpty smiled contemptuously. “Of course you don’t—till I tell you. I meant ‘there’s a nice knock-down ar- gument for you!’ ” “But glory’ doesn’t mean ’a nice knock-down argument’,” Alice objected. “When I use a word,” Humpty Dumpty said, in rather a scornful tone, “it means just what I choose it to mean—neither more nor less.” “The question is,” said Alice, “whether you can make words mean so many different things.” “The question is,” said Humpty Dumpty, “Which is to be master—that’s all.” Sanket Patil Representations
  • 12. Map and Territory Figure: “Sylvie and Bruno Concluded”, by Lewis Carroll Source: Lit2Go Sanket Patil Representations
  • 13. Figure: “On Exactitude in Science”, by Jorge Luis Borges Source: KWARC Sanket Patil Representations
  • 14. This is not a Story Figure: “Ceci n’est pas un conte”, by Denis Diderot written in 1772. Source: Goodreads Sanket Patil Representations
  • 15. Why Representations? The duality of objects and their representations is well explored in the arts. You might have come across concepts such as: “the map is not the territory”, “the word is not the thing.” Such symbolism and art and literature and philosophy aside, the idea of representations is all too pervasive. It has practical importance in almost every field of scientific endeavour. Sanket Patil Representations
  • 16. More Practically: Why Representations? They are fundamental to the way we understand the world and navigate through it. They are all pervading: language, communication, mathematics, biology, systems, machine learning, . . . The way information is represented plays a crucial role in how we understand it, draw inferences, do computations on it, and organize it. A good representation makes all of these efficient. Scripts and alphabets help us give concrete form to abstract thought, and communicate them with each other. Sanket Patil Representations
  • 17. Calculus helps us measure, compute and reason about real world quantities such as distance, time, and volume. Data structures help us represent data, and even abstract concepts (such as “trust”) such that they can be retrieved and processed efficiently. They capture underlying “patterns”. Good representations essentially have the effect of “disentanglement”. That is to say they highlight the variances in underlying data clearly. This is what makes Machine Learning work. Sanket Patil Representations
  • 18. Prehistory and DNA Sequencing Recently I’ve been reading a little bit about prehistory and certain new techniques in DNA sequencing. These are helping in understanding—well, in a manner of speaking—who we are and how we came to be. What were our migration patterns, the movement of languages and culture. Now, while all of this is fascinating in itself I was also pleasantly surprised to know that fairly simple techniques from machine learning such as principle component analysis (popularly known as PCA) play a key role in this. (We will talk about PCA and related techniques in a subsequent session.) The long and short of it: the centrality of representations cannot be overstated. Sanket Patil Representations
  • 19. This talk · · · Somewhat generic. Introduction to the talk series and motivation for the overall theme. In the rest of the talk Examples of representations and how they help solve real problems A brief note on number systems (with focus on Roman numerals) Some old problems from discrete mathematics (with a new twist) I will keep it slightly high level focussing more on the intuition and less on rigour Might be quite basic for many of you; but hopefully you’ll still find it enjoyable and may even get a new insight or two. Sanket Patil Representations
  • 20. Rest of the Talk Series: Three Broad Themes 1 Theme 1: Distributed Data Structures/Algorithms; efficient storage structures. 2 Theme 2: Information Theory/Machine Learning/Deep Learning. 3 Theme 3: Game Theory; modelling behaviour; Multi-agent Systems. Sanket Patil Representations
  • 21. Examples of Representations Figure: Exempli Gratia Source: Thesaurus.plus Sanket Patil Representations
  • 22. Visualization in the Time of Cholera Figure: John Snow’s original map with clusters Source: Wikipedia
  • 23. Cholera Epidemic of 1854 One of the first usage of data representation to solve real world problems in modern times was done in London in 1854. Prevailing theory: cholera was an airborne disease. A popular theory called the miasma or miasmatic theory. Miasma Theory was quite fascinating but equally misguided. that attributed “bad air” or “pollution” or some evil in the air to most diseases at the time. But there was this physician called John Snow, who had a different hypothesis. He suspected that the cause of Cholera and resultant deaths are due to contaminated water. Sanket Patil Representations
  • 24. Data Visualization John Snow mapped all the cholera cases and related deaths on and around broad street. Using basic visualizations he inferred that there are clusters of cases around water pumps. This lead to his conclusion that contaminated water might be the cause for he disease. He convinced the authorities to remove the handle the pump at Broad Street. (Today there is a small pump at the same location commemorating this.) This resulted in a drop of cholera cases within a few days! Sanket Patil Representations
  • 25. John Snow didn’t have access to the modern visualization techniques. Today we use Voronoi Diagrams or Cluster Analysis to model such problems (each one a major topic that we can look into subsequently). Sanket Patil Representations
  • 26. Cholera Clusters Figure: Modern visualization techniques Source: SAS Blogs Sanket Patil Representations
  • 27. Voronoi Diagrams Start with a set of seed points or ”sites” or generators. Partition the region into a set of cells each one containing a site into a set of cells each one containing a site (called Voronoi cells) such that every point within that cell is closer to the site than it is to any other site. Imagine these seeds or sites to be important public service institutions such as hospitals, fire stations, schools, and of course, water pumps. In this case we are looking at a plane, but it can be generalized to higher dimensions as well. Sanket Patil Representations
  • 28. John Snow Memorial Figure: John Snow Memorial Source: Wikipedia Sanket Patil Representations
  • 29. Linear Separability Figure: Flatland: A Romance of Many Dimensions Source: Wikipedia
  • 30. Two Classes Figure: Linearly Separable? Source: Deep Learning Book Question Can you draw a straight line through this scatterplot to separate the two classes? How do we make them linearly separable? Sanket Patil Representations
  • 31. Two Classes Figure: Linearly Separable? Source: Deep Learning Book Polar Coordinates The same data points represented using their polar coordinates. Now, it is straightforward to draw a line through this plane. Sanket Patil Representations
  • 32. Cartesian vs Polar Coordinates r = 1 r = 3 r = 9 r = 4 θ = 60 X Y Figure: Cartesian and Polar Coordinates Sanket Patil Representations
  • 33. Cartesian to Polar and Back Step 1: Cartesian to Polar Visualize a bunch of (well, lots of them, infinitely many) concentric circles with different radii. Each of the dots and triangles shown in the first figure lie on one of these circles. The radius of the circle on which a data point lies is its r polar coordinate and the angle that the ray from the origin passing through this point forms with the x-axis is its θ polar coordinate. Step 2: Represent data with new coordinates Think of r and θ as your new x and y, and scatter the dots and triangles on this new plane. What you get is something similar to second figure with the two types of points more or less neatly separated. Sanket Patil Representations
  • 34. Intuition The underlying process or the function (which is not known to us a priori) that generated the data was not linear. Therefore, you can’t use a linear function (a straight line) to separate them. They are not linearly separable in the Cartesian space. However, you can clearly see that the two classes of data points fall in two roughly separate circular or quadratic spaces. By using polar coordinates in Cartesian space, we are transforming the space in such a manner that now we are able to disentangle the two sets of data points. Sanket Patil Representations
  • 35. Dimensions: Lower to Higher to Lower Representation Learning This happens a lot in machine learning (and especially deep learning) wherein you represent data points in a different kind of space—sometimes higher dimensions and sometimes reduced number of dimensions—depending on where a model can learn better representations such that it’s “easier” for it to separate classes. Dimensionality Reduction Dimensionality reduction techniques are also used a lot to represent data in lower number of dimensions which carry the most distinctive information, while reducing noise. Example: Principal Component Analysis The above description is quite hand wavy, of course, but we will learn about some of these techniques with more rigour in subsequent talks. Sanket Patil Representations
  • 36. Proof without Words Figure: Visual Proof of Nichomachus Theorem Source: Wikipedia
  • 37. Solving an Infinite Series using a Geometric Representation Figure: A Geometric Series Source: Mathematical Association of America Sanket Patil Representations
  • 38. Sum of Odd Numbers Figure: Visual Proof of Sum of Odd Numbers Theorem Source: Wikipedia Sanket Patil Representations
  • 39. A Tweet sized proof for an old identity Sanket Patil Representations
  • 40. Representation: More Examples from Different Disciplines Calculus as a language to represent continuous quantities. The Talking Drums of Africa: long distance language and cultural communication. Morse code as an efficient way of encoding and transmitting information Language Models: Representing redundancy and capturing statistics inherent to languages Representing trust over the Internet: Blockchains (powered by Merkle Trees) Representing “Meaning”: word embeddings, speech vectors, image embeddings. · · · Sanket Patil Representations
  • 41. Numbers “There are 10 kinds of people in the world. Those that understand binary, those that don’t, and those that didn’t expect this joke to be in ternary.”
  • 42. Roman vs Hindu-Arabic Think What are the main differences between Roman and Hindu-Arabic numeral systems? Is arithmetic more difficult with Roman numerals in comparison with Hindu-Arabic numerals? What made the Hindu-Arabic system superior and/or popular? Sanket Patil Representations
  • 43. Friends, Romans, countrymen · · · · · · lend me a hand in doing basic arithmetic; Addition What is DLXXIII + CCLXXXVII? Question How do you add two numbers represented in Roman numerals without converting them to the decimal form? Sanket Patil Representations
  • 44. Before that: Underlying Principles Think about how Roman number are constructed. Not a positional system. No place value. Only face value. Additive system. To go from one number to the next, you stick an I in front. Numerals are ordered in non-increasing order. You add them up to get the final number. A bunch of numerals to indicate bigger numbers. However, it is also subtractive, but that is to manage “short cuts”. When a numeral has to be repeated more than 3 times, a short cut is used. E.g., XL instead of XXXX. If a smaller numeral comes before a larger one, together they form a group and is treated as such. If you keep that in mind, you will see that a Roman representation is an additive system with individual numerals (including short cut groups) are sorted in non-increasing order. Sanket Patil Representations
  • 45. It’s simple(r) Roman Arithmetic can be built easily on top of these principles. A Four Step Algorithm Let’s add IV and IX 1 Expand: IV → IIII, IX → VIIII, and so on. 2 Append: IIIIVIIII 3 Sort (non-increasing): VIIIIIIII 4 Contract: VIIIIIIII → VVIII → XIII Exercise: Think How do we do subtraction? What about multiplication and division? Sanket Patil Representations
  • 46. Number Systems: Some Observations There is nothing sacrosanct about the decimal system that we are used to except that it’s convenient and widely used. Similarly, there’s nothing sacrosanct about the binary system either. There are other kinds of number systems and bases that can be very useful in certain applications We will see some examples next. Sanket Patil Representations
  • 47. Three Problems from Discrete Mathematics 1 A Geometric Problem 2 A Survival Problem 3 A Weight Problem
  • 48. Problem 1: Lines in a Plane Maximum Number of Regions Suppose you have a pizza and a sharp knife. (If you don’t fancy pizza, consider a chapati or a plain dos´e.) What is the maximum number of slices that you can get by making 1, 2, 3, or in the general case, n, straight cuts on the surface of the pizza (or equivalent)? Sanket Patil Representations
  • 49. Number of Regions 1 7 6 5 4 3 2 1 4 3 2 1 2 1 n = 0 n = 3n = 2 n = 1 Figure: Can you see the pattern: 1, 2, 4, 7, . . . ? Sanket Patil Representations
  • 50. What happens when a new line is added? 1 8 7 6 5 43 10 2 L1 L2 L3 L4 New region formed by L3 common to both L1 and L2 New region formed by L4 common to both L1 and L2 New region formed by L4 common to both L2 and L3 New region formed at the boundary New region formed at the boundary Figure: Number of regions added when a new line is added Sanket Patil Representations
  • 51. Key Insights Every new line added to the plane meets each of the existing lines exactly once. A new line (L4) in the previous figure) “cuts” the region on either side of a previous line in two when it intersects with it: once as it “enters” and once as it “exits”. However, the number of regions does not increase as 2n because there are “common” regions formed between pairs of previous lines, as you can see in the figure. Thus,if there are k lines previously, the k + 1th line adds k + 1 new regions. What does that tell us? Sanket Patil Representations
  • 52. Solution n R(n) S(n) + 1 0 1 0 + 1 1 2 1 + 1 2 4 3 + 1 3 7 6 + 1 4 11 10 + 1 5 16 15 + 1 . . . . . . . . . Triangular Numbers The number of regions, R(n) = S(n) + 1 = n(n+1) 2 + 1 Sanket Patil Representations
  • 53. Aside: Can you prove this? Theorem (Sum of first n natural numbers) 1 + 2 + · · · + n = n×(n+1) 2 You can use the good old proof by induction, of course. But it’s boring. Sanket Patil Representations
  • 54. Gauss’ Trick Sum of first n natural numbers. 1 + 2 + 3 + · · · + (n − 2) + (n − 1) + n + n + (n − 1) + (n − 2) + · · · + 3 + 2 + 1 = (n + 1) + (n + 1) + · · · + (n + 1) + (n + 1) + (n + 1) = n · (n + 1) But since we have taken the sum twice, we just halve it to get: n·(n+1) 2 Sanket Patil Representations
  • 55. Problem 2: The Josephus Problem Roman-Jewish war; Jews were surrounded by Romans; preferred suicide to getting captured. Scheme: Form a circle. Start from position 1. Kill every second person alive. Josephus Flavius — a historian — didn’t want such a thing. In the original story, he and a co conspirator found suitable places in the circle by quickly solving the problem mentally and survived. What we are going to look at is one variant of the problem. Sanket Patil Representations
  • 56. An Instance 1 8 7 6 5 4 3 2 Round 1 Starting Position 1 8 7 6 5 4 3 2 Round 2 Starting Position 1 8 7 6 5 4 3 2 Round 3 Starting Position 1 8 7 6 5 4 3 2 Round 4 Starting Position Survivor! Figure: Instance with n = 8 Sanket Patil Representations
  • 57. Let’s look at a few cases n w(n) 1 2 3 4 5 6 7 8 1 1 3 1 3 5 7 1 1 2 3 2 1 3 1 4 2 1 1 5 4 3 2 1 6 5 4 3 2 3 3 5 7 9 11 13 15 1 9 10 11 12 13 14 15 16 Figure: The survivor w(n) for different values of n Sanket Patil Representations
  • 58. Do you see a pattern? It’s obvious that under the given conditions, all even numbered people get killed in the first round. So the survivor is always found in an odd numbered position. Something interesting is happening for certain values of n such as 1, 2, 4,etc, (marked with the golden yellow line). w(n) is always 1 for these n. These are powers of 2. So, when n = 2m, m >= 0 it looks like w(n) = 1 regardless of m. Between two golden yellow lines—that is between two groups of powers of 2—survivor number increases by 2 before “wrapping around” to 1. Sanket Patil Representations
  • 59. Solution n w(n) n = 2m + l w(n) = 2 · l + 1 1 1 20 + 0 2 · 0 + 1 = 1 2 1 21 + 0 2 · 0 + 1 = 1 3 3 21 + 1 2 · 1 + 1 = 3 4 1 22 + 0 2 · 0 + 1 = 1 5 3 22 + 1 2 · 1 + 1 = 3 6 5 22 + 2 2 · 2 + 1 = 5 . . . . . . . . . . . . Solution Represent n in the form, n = 2m + l The survivor number, w(n) = 2l + 1 Sanket Patil Representations
  • 60. Exercises Alternative Solutions Can you arrive at a solution by forming recurrence relations? [Hint: This is a recursive problem if you think about it.] Can you use modulo arithmetic to arrive at this solution? [Hint: Look at the circular arrangement. It is amenable to clock arithmetic.] Sanket Patil Representations
  • 61. Binary Representation n = 789 = 29 + 277 = (1100010101)b w(n) = 2 · 277 + 1 = 555 = (1000101011)b Figure: You can get the same result by moving MSB to LSB! Sanket Patil Representations
  • 62. Bitwise Algorithm While the previous method is fairly straightforward, you can achieve the same by a couple of simple bitwise operations regardless of how big n is. Write a program in your favourite programming language and verify this for different values of n. Can you see why this works? Sanket Patil Representations
  • 63. Proof Sketch Proof. 1 Any n can be represented in binary as, n = bmbm−1bm−2 . . . b1b0, where each bi ∈ 0, 1 2 But since n = 2m + l, the Most Significant Bit (MSB), bm = 1. Thus, n = 1bm−1bm−2 . . . b1b0 3 Similarly, the remaining part l can be represented as, l = 0bm−1bm−2 . . . b1b0 (E.g. if n = 15, n = 23 + 7, 8 ≡ 1000, and 7 ≡ 0111) 4 Multiply l by 2. This is the same as a left shift operation. Thus, 2 · l = bm−1bm−2 . . . b1b00 (E.g., 2 · l = 7 · 2 = 14 ≡ 1110 ) 5 2 · l + 1 = bm−1bm−2 . . . b1b01 = bm−1bm−2 . . . b1b0bm (Since, bm = 1, from Step 2). 6 But 2 · l + 1 = w(n). Thus, w(n) = bm−1bm−2 . . . b1b0bm. Sanket Patil Representations
  • 64. Exercises 1 We looked at an instance of the problem with a starting position, p = 1, and a “skip”, k = 2. Generalize Josephus Problem. Find the solution for any (n, p, k) 2 What is the time and space complexity for the first method? And for the bitwise method? 3 Can you find a bitwise method for the generalized problem? 4 This is a lovely combinatorial problem. Highly instructive. Now, think of some applications. Sanket Patil Representations
  • 65. Problem 3: The Good Old Balance Figure: Weighing Balance with Weights Source: Wikipedia Sanket Patil Representations
  • 66. The Balance Problem Minimum Number of Weights Suppose you have a weighing balance that you can use to measure objects of different weights. Let’s assume that you can measure only integral weights, not fractional ones. What is the minimum number of weights required to weigh objects whose weights range from 1 kg to 40 kg? Sanket Patil Representations
  • 67. Key Insights It’s a balance with two pans. Not a spring balance, not a weighing scale. That is to say, there are three states in which a weight can be: left pan, outside, right pan. You can put weights on either or both pans. Not only can you add two weights, you can subtract also. Instead of 40, were you to weigh up to 4, you would do it as follows: 1, 2 =3 -1, 3, 4 = 3 + 1 Sanket Patil Representations
  • 68. Solution Approach This is akin to constructing numbers using a ternary number system. (Yes, there are 10 kinds of people in the world.) Except, the alphabet is not the usual {0, 1, 2}, but it’s, α = {−1, 0, 1} α = {−1, 0, 1} ≡ {left pan, outside, right pan} So, the original puzzle now reduces to: how many ternary digits do you need to construct 40 ternary numbers? 40 = 27 + 13 + 9 + 1 = 33 + 32 + 31 + 30 You need the weights, w = {1, 3, 9, 27} Try a few: 37 = 27 + 9 + 1 35 = 27 + 9 − 1 14 = 27 − (9 + 3 + 1) Sanket Patil Representations
  • 69. Exercises: Generalizations We chose n = 40, which could be neatly partitioned using powers of 3. Can you find the solution for any n? What happens if only additions were allowed? That is you can add weights to only one pan. We solved this for a balance with two pans, k = 2. Can you solve it for any k? (k = 1 is binary, whereas k = 4 is quinary — base 5) This is a fun problem. But can you think of any real applications? Sanket Patil Representations
  • 70. And Now for Something Completely Different Figure: If you don’t know how to solve a problem, model it using Graph Theory. Now you have a combinatorial problem. That might not make it easier to solve the problem, but definitely looks good. Source: Spiked Math Comics
  • 71. The Balance Problem and DHTs I can think of at least one extremely interesting application of the previous problem. It’s in Distributed Hash Tables (DHT). (If you don’t know what DHT is, don’t worry, we will discuss it in the next talk.) The first step is to model the problem as a Graph Theoretic problem. Shameless Plug: This problem inspired a part of my research work in optimal network design during my PhD. I’m going to briefly present that next. Sanket Patil Representations
  • 72. (Balanced) Base−b Networks A class of Distributed Hash Tables inspired by the previous puzzle. The construction technique is derived from representations of numbers in different bases. Generalization of the well known Chord DHT. Question What is the graph theoretic interpretation of additive vs subtractive weights from the previous problem? Sanket Patil Representations
  • 73. Representation-1: The Number Line -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 -13 130 Figure: A Segment of the number line Constructing numbers is the same as moving along a number line.You can go from 7 to 8, by taking one step to the right. OTOH, if you want to move to -5, you take 12 steps to the left. This is the same as adding or subtracting weights—but you only have a single weight of 1. However, here we are looking at a segment of the number line [−13, 13]. Sanket Patil Representations
  • 74. You can think of the number line as an undirected line graph extending infinitely. That means you can traverse in both directions. It’s a line graph with 27 nodes, with each number forming one node. The values represent the names of nodes. They can be anything. The diameter of this graph is 27—it takes 27 steps to reach Node 13 from Node -13. Sanket Patil Representations
  • 75. Representation-2: The ”Wrap around” Number Line -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 -13 13 Figure: Number line wrapped around Let’s wrap around the segment of the number line. Now suddenly the distances are halved on average. And you have two ways of reaching a node (a number) from another — one shorter and the other one longer. Sanket Patil Representations
  • 76. Representation-3: The Balanced Ternary Network -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 1 2 3 4 5 6 7 8 9 10 11 12 13-13-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 Figure: Constructing the balanced ternary network Sanket Patil Representations
  • 77. Construction Algorithm Let’s add some more short cuts. In fact, let’s use the solution from the balance problem. For every node, add an edge to a node that is at a distance of 30, 31, and so on. Since, 13 = 9 + 3 + 1,from Node 1, we have edges to 2, 4, and 10. Do the same at every node. Each node connects to nodes that are at a distance of 1, 3, and 9 nodes away going clockwise. When you are done, you will get the network in the next slide. It’s “balanced” because you can go both forwards and backwards. Sanket Patil Representations
  • 78. The Balanced Ternary Network -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 1 2 3 4 5 6 7 8 9 10 11 12 13-13-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 Figure: The complete balanced ternary network Sanket Patil Representations
  • 79. Reaching from one node to another In this network, you can reach any node from any other in a maximum of 3 hops. For example, the distance between Node 4 and Node -4 on the circle is −8. The number -8 is represented in balanced ternary as, (−1)01 or ¯101. In terms of routing over the balanced ternary network this is equivalent to taking the first skip (9 steps) backward from 4 to -5; then take the last skip (1 step) forward to reach -4. Note that this is in principle the equivalent of weighing 8 (9 - 1) in the original problem. Sanket Patil Representations
  • 80. The Ternary Network -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22-21-20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 0 1 3 27 48 49 50 56 75 80 9 Figure: The ternary network – partial Sanket Patil Representations
  • 81. The Ternary Network What if you weren’t allowed to subtract? This is the equivalent of saying edges are now directed. Ternary networks use the regular ternary alphabet {0, 1, 2} (no “balanced”). You can construct directed graphs using a similar technique as we described before. Sanket Patil Representations
  • 82. Properties and Generalization You can generalize this to any base b. Given a base–b, and a k, k ∈ Z+, the number of nodes that can be packed in a balanced base–b network is, n = bk. The diameter of such a network with an alphabet l is, d = max {|i| ∈ l} · k, where max {|i| ∈ l} ≈ b 2 . That is to say, d ≈ b 2 logb n. Given a base–b, and a k, k ∈ Z+, the number of nodes that can be packed in a network is, n = bk. The diameter of such a network is, d = max {|i| ∈ l} · k, where max {|i| ∈ l} = b − 1. That is to say, d = (b − 1) logb n. Sanket Patil Representations
  • 83. Next Session Figure: Hypercubes and Hamming Distance Source: Wikipedia
  • 84. The Geometry of DHTs If some of the above is unclear / confusing, don’t worry about it. We will look at DHTs and their underlying geometrical structures in more detail in the next session. We will discuss the interplay of metric spaces, geometry, and graph theoretic representations as applied to DHTs, which are underpinning of most distributed systems. Sanket Patil Representations
  • 85. References and Further Reading 1 A nice intuitive explanation of the Josephus Problem Source: Numberphile YouTube Channel 2 Concrete Mathematics: A Foundation for Computer Science. R. Graham, D. Knuth, and O. Patashnik. Addison-Wesley, Reading, (1989) 3 Designing optimal network topologies under multiple efficiency and robustness constraints. My PhD Thesis. Source: Shodhganga Book Recommendations Concrete Mathematics. Highly recommended for anyone who wants to hone mathematical thinking. What’s the Point of Maths?Informative and entertaining book for kids and adults alike. Flatland: A Romance of Many Dimensions by Edwin Abbott Abbott. Sanket Patil Representations
  • 86. Thank you! Feedback Please feel free to share your feedback with me. over email, Twitter, LinkedIn, or my website. License I’m distributing this under Creative Commons License. Feel free reuse., modify, distribute this material (with suitable attribution). If you want the source files, send me an email. Sanket Patil Representations
  • 87. Fin “May you live in interesting times.” [An ancient Chinese curse.]