/
Random Partition via Shifting Random Partition via Shifting

Random Partition via Shifting - PowerPoint Presentation

kittie-lecroy
kittie-lecroy . @kittie-lecroy
Follow
400 views
Uploaded On 2016-06-27

Random Partition via Shifting - PPT Presentation

Tomer Margalit 2152012 Table of Contents Introduction and fundamental properties of randomly shifted grids Application minimal disk covering of points We improve the running time of the trivial approach using randomly shifted grids ID: 379598

points cover disk algorithm cover points algorithm disk metric partition point time shifted cell minimal disks randomly proof covers tree set distance

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Random Partition via Shifting" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Random Partition via Shifting

Tomer

Margalit

, 21/5/2012Slide2

Table of Contents

Introduction and fundamental properties of randomly shifted grids.

Application – minimal disk covering of points. We improve the running time of the trivial approach using randomly shifted grids.

Shifting

Quadtrees

– we will see how using random shifts when constructing

Quadtrees

can be beneficial.

Approximation of an n-point Metric Space – We will show how we approximate such a metric using a new data structure called an HST.Slide3

Background

In this lecture we will introduce randomness to partitions of a domain.

We will do this by partitioning starting from a random shift.

For instance, suppose that we have

as the domain that we would like to partition.

Then we randomly choose a uniformly distributed vector in , to use to shift to .For instance, we can shift a quadtree over a region of interest.This yields some simple clustering and nearest neighbor algorithms.

 Slide4

Example – General Points in

 Slide5

Example – Points in squareSlide6

Example – Unshifted

PartitionSlide7

Example – Shifted PartitionSlide8

Example – Shifted PointsSlide9

Partition via Shifting 1

We initially focus on partition shifting of the real line.

First, we define the partition function:

This function partitions the real line according to its

preimage

– i.e. for any integer I, the group

is a unique cell.

 Slide10

Example – Partition FunctionSlide11

Partition via Shifting 2

Remark – The value of the function does not affect the partition, only the partitioned sets do. That is, the partition is determined according to the equivalence

classes implied by h.

Simply put, if we have two functions h and h’ that agree on two points everywhere, then they are treated as the same partition.

Equivalently, if we have b and b’ such that

for some integer k, then the partitions are identical, even though the functions may differ.In particular, we can pick shifts uniformly from , without losing any partitions.We could also pick them from any

, as long as

.

 Slide12

Good Probability for a Nice Distribution

Lemma – For any

, we have that

In other words, if two points are at some distance, and we use a coarse partition, then there is a very low chance we will classify them together.

For example, what is the chance that for

we choose a

b

such that x and y have different ids?

 Slide13

Intuition 1Slide14

Intuition 2Slide15

Proof

Claim: For

any

, we have that

.

The claim is obviously true if

. Indeed, then x and y must be in separate cells because we partition to stripes of width

.

If not, assume that x < y and pick some shift b uniformly from

.

As said before, we still get all partitions this way, so we are in the same probability space.

But now,

if and only if

.

 Slide16

Generalized Partition Shift

Now we generalize the notion of shifting partitions to multidimensional spaces.

We have a group of points

.

Consider a shift

randomly chosen from .We partition the points according to a grid

that has its origin in b, and with a side length of

.

We define the id of a point

to be

 Slide17

Example – 2D Shifted PartitionSlide18

Example – 3D PartitionSlide19

Good Probability for a Nice

Distribution in Multidimensional spaces

Given a ball B of radius r in

, the probability that B is not contained in a single cell of a randomly shifted grid,

, is bounded by

.Proof:Project B into the ith coordinate.Now we have an interval of length 2r in the shifted grid

.

Now we know that B is contained in a single cell if and only if all

s are contained in a single cell of the one dimensional grid.

 Slide20

Proof, Continued

Now, denote by

denote the event in which

is not contained in a single cell.

Then obviously, suffice that even one of these events occurs for the ball to not be contained in a single cell.

In other words, if we denote by the event that the ball is not contained in a single cell, then we have that:

If this is larger than one, than we get a probability of one, which proves our claim.

 Slide21

Remarks about Randomly Shifted Grids

We have shown that if we choose grids randomly, we get a good chance of separating two points if we have a coarse enough partition.

Obviously, we will use this property to give randomized algorithms, and algorithms that have a high probability to succeed.Slide22

Application – Covering by Disks

Now we show an application for these simple facts about random partitions.

Given a set of n points in the plane, we would like to cover them by the minimal amount of unit disks.

Apparently, the randomly shifted grids can improve the trivial algorithm by quite a bit.

First we show the trivial algorithm, and then the improvement gained by using randomly shifted grids.Slide23

Disk Cover - PointsSlide24

Disk Cover - CoverSlide25

Trivial Cover

We show the trivial algorithm first. We will also use it later.

We can cover trivially – that is by traversing all covers – by using

.

Before we can show that, we must establish some fundamental insights about equivalence of disk covers:

 Slide26

Intuition – What Sets Two Covers Apart? (1)Slide27

Intuition – What Sets Two Covers Apart?

(2)Slide28

Intuition – What Sets Two Covers Apart?

(3)Slide29

Intuition – What Sets Two Covers Apart?

(4)Slide30

From Intuition to Proof

The intuition shows that two covers are equivalent if all the disks in both covers cover the same set of points.

This intuition will direct us in providing the trivial algorithm.

Instead of considering any cover, we consider only

equivalence classes

of covers.Very trivially, we can consider every partition of the points into (not necessarily disjoint) groups, and check if that cover exists for them.However, this approach gives us a lot of invalid covers.We can use some simple observations to cut that number.Slide31

I. Every pair of input points (at distance under 2) defines two possible disksSlide32

II. Given a cover, we can move every disk to have at most 2 points on the edgeSlide33

Proof

The first insight is obvious.

The second insight is not that obvious though.

To get the second claim, given a disk (that is part of a cover), we can move the disk downward until it “hits” a point.

And then rotate it (around the point) until it “hits” another one.Slide34

Move downward until a point is hitSlide35

Rotate until a second point is hitSlide36

Trivial Cover – Feasibility

In case the disk contains at most one point, we get one point on the edge.

Now, using these facts, it is obvious that every arbitrary disk cover is equivalent to a cover of disks that have either 1 or 2 points on their edge.

Given this insight, we can just traverse all possible covers composed of these disks to find the minimal one.

Ok, so how many disks are there?

 Slide37

Trivial Cover – Given the Minimal Cover Size

If we knew the minimal cover has m disks, how much time would it take to find the cover?

We have

covers, and checking if a cover is valid takes O(nm) time (check each point against each disk).

So in total, it takes

time to find the cover. Slide38

Trivial Cover – Full Algorithm

To complete the algorithm, given a set of points, we exhaustively check for each k between 1 and n, whether we have a cover with k disks.

According to the insights we saw, the first cover we find must also be a minimal cover.

Now, the time it takes to find the cover is

 Slide39

Trivial Cover – Final Statement

In conclusion, we get the following claim:

Claim: Given a set P of n points in the plane one can compute, in

a minimal cover – where k is the size of the minimal cover

.

The problem with this approach is that k may be large (say n/4). Slide40

Minimal Disk Cover - Improvement

Now, we compromise some accuracy – we will try to calculate an

approximation

of the minimal disk cover.

To do that, we will use the randomly shifted grids.

As mentioned before, this will be a randomized algorithm, that will give a good approximation for the minimal cover size on average.Specifically, like algorithms we have seen in the past, we choose some small factor (denote it by ), and then both our running time and the expectation of the cover size depend on it. Slide41

Minimal Disk Cover – Randomized Algorithm

Claim: Given a set

P

of n points in the plane and a parameter

, one can compute using a randomized algorithm, in

time, a cover of P by X unit disks, where , where opt is the minimum number of unit disks required to cover P.

 Slide42

Algorithm

First, let

.

Now, for a shift

, consider the grid

. Compute all the grid cells that contain points of P.That is done by computing the id of every point, and then storing it in a hash table.This clearly can be done in linear time.Now, for each grid cell c, we denote by the points of P in the cell.Observe that any cell of

can be covered by

unit disks.

 Slide43

Calculate the id of each point (

)

 Slide44

Cover the cells by

disks (ratio is 1)

 Slide45

Cover the cells by

disks (ratio is

0.5)

 Slide46

Algorithm 2

Note that the bound of M is very loose.

We can do much better – instead of using this cover, we use the trivial algorithm to compute the minimal cover for each square.

Since the minimum is at most M, we can compute it in

, according to what we showed about the trivial algorithm.

As for the running time, there are at most n non-empty grid cells, which means it will take us . Now since

, we get that the time is

.

Note that

and that

.

 Slide47

Good Expectation of the Cover Size

Now that we have reached our goal time, we turn to the expectation.

Reminder – We denoted X to be the size of the returned cover, and we claimed that

– a property we will prove.

Plan: Given an optimal cover, we will show another cover that is considered by the algorithm, and that the expectation of its size (with regards to all the possible shifts) is what we want.

 Slide48

Proof 1

Consider the optimal solution

.

We generate a solution

from

that is checked by the algorithm.For each grid cell, c, denote by the set of disks of the optimal solution that intersect c, and denote each disk with c.Now, define

.

Remember, this set may contain the same disk twice – for instance in cases where the same disk covers two cells.

 Slide49

Optimal CoverSlide50

 Slide51

 Slide52

Proof 2

Now, since we find an optimal cover of every square, we have that for each square c, the cover we find is of size less than

.

So, the cover we find is smaller than the cover we defined (

).

Now, we only need to bound ’s size on expectation.Note that a disk should not be in too many cells – as long as is not too small.In fact, it can’t intersect more than 4 cells. Slide53

Proof 3

Indeed, since

we get that

.

Now, if there were more than 4 squares containing a unit disk, then there must be 2 that aren’t adjacent (at most 4 squares can be adjacent (pairwise).

But that would mean there are two squares at distance more than 2 – i.e. the minimal distance between two points from these squares is 2.But if the disk covers both squares, then we have two points that are both in the circle but at distance more than 2, which is a contradiction to it being a unit square. Slide54

Proof 4

In fact, a disk from the optimal solution will only intersect more than one cell if it is not completely contained in one. Fortunately, we saw something that bounds this chance:

Given

a ball B of radius r in

, the

probability that B is not contained in a single cell of a randomly shifted grid, , b is bounded by .In this case , and thus we get that the chance that a disk from the optimal solution is not contained in a single cell is

.

 Slide55

Proof 5

Let

be an indicator variable that is one if and only if the

ith

disk in the optimal cover is not contained in a single cell of the grid.

So, we saw that .And also that

.

Finally:

 Slide56

Minimal Disk Cover – Randomized

Algorithm Applications

Note the sensitivity to the factor (it is the exponent of n!).

Doesn’t really find the minimal cover – but gives an approximation of it very easily.

Can’t use a small epsilon – using a value as big as

could result in operations for just 100 input points!However, if we choose an epsilon of 1, then we get a very reasonable running time.If we use it several times, we can get a rough estimate for our minimal cover size, with high confidence. Slide57

Shifting Quadtrees

We now use the randomly shifted grids in combination with

Quadtrees

.

Later on we will show applications for this approach.

We start with one-dimensional Quadtrees, and later on extend the approach to higher dimensions.Slide58

Shifting Quadtrees

– One dimensional

We have a set of points P of size n, all in the interval

.

We randomly (and uniformly) choose a shift

, and consider the (one-dimensional) quadtree of P, using the interval for the root cell.Now, for two numbers

let

Reminder:

is the first bit (in base 2) of the numbers where they differ.

In our case, it would be the first level of the grid where they are in the same cell.

Which makes

the last common level of the points.

 Slide59

1 Dimensional Shifted QuadtreeSlide60

Example

 Slide61

 Slide62

Good Chance for the

lca

to be Close to the Level of the Distance

We assume that

can be computed in constant time.

Next we show a lemma that bounds the chance that the least common ancestor of two numbers is in charge of an interval that is considerably longer than the difference between the two numbers.Claim: Let be two numbers, and consider a random number

. Then for any positive integer t, we have that

.

 Slide63

Proof 1

Denote M=

, and given a positive integer

i

consider the shifted partition of the real line by intervals of length

and a shift b.Let be an indicator variable that is one

iff

and

are in different intervals.

That is the same as saying that

.

Now, if

then the highest level such that the points are both contained in a shifted interval is

.

As such, going one level down, these two numbers are in different intervals, and

or

.

 Slide64

Proof 2

We proved earlier that

, so:

 Slide65

Corollary

Directly following from this lemma is the following corollary:

Let

be two numbers, and consider a random number

. Then, for any parameter

, we have

, where

.

 Slide66

Higher Dimensional Quadtrees

Let P be a set of n points in

, and pick uniformly and randomly a point

.

Now consider the shifted compressed

quadtree of P having

as the root cell.

Consider any two points

, their

lca

, and the one dimensional

quadtrees

, built on the

ith

coordinate.

Since the

quadtree

is a combination of these trees, the level where p and q get separated is the first level in any of the one dimensional trees.

In particular, the level of the least common ancestor is:

 Slide67

2D Randomly Shifted

QuadtreeSlide68

Hierarchical Representation of a Point Set

We now switch our discussion to metric spaces.

From now on instead of speaking about

euclidean

spaces, we will talk about a metric space M with metric d.

We will now show a new type of data structure (tree), that can be used to define a metric over a set of points.Slide69

Hierarchically Well-Separated T

ree

Let P be a set of elements and H be a tree having the elements of P as leaves. The tree H defines a hierarchically well-separated tree (HST) over the points of P, if for each vertex

there is associated a label

, such that

iff u is a leaf of H. Furthermore, the labels are such that if a vertex u is a child of a vertex v then .Now for two leaves u,v

we may define

 Slide70

HSTs 2

If

every internal node has exactly two children, we will refer to it as being a Binary HST (BHST).

It is easy to see that d and P form a metric.

The point of the HST is that the metric it defines has a simple structure and it can be easily manipulated algorithmically

.Example: Let P be a set of n points in , and a compressed quadtree storing P.For each node in the tree define the diameter of the node to be the label. Slide71

HSTs 3

From now on we will work with BHSTs exclusively, since any HST can be converted to a BHST in linear time, while retaining the same metric (distances).

We will also associate with every node of the tree an arbitrary representative point

(that is the representative is a point stored in the

subtree

of ).We also require that is the representative of one of it’s children (so that there is at least one direct child of with the same representative). Slide72

t-Approximation

A metric space

is said to t-approximate the metric

, if they are defined over the same set of points P and

for any

.

For instance, on the space

, the distance

is 2-approximated by the usual (2-norm) distance

.

In the same space, the

norm is approximated by the

norm, which means that the distance

is

approximated by

-

Next we show that any n-point metric can be (n-1)-approximated by some HST.

 Slide73

Approximating n-point Metrics by HSTs

Claim:

Given a weighted connected graph

G=(V,E)

on n vertices and m edges, it is possible to construct, in O(

nlogn+m) time, a binary HST H that (n-1)-approximates the shortest path metric of G.To clarify, the shortest path metric of a graph G assigns to every two nodes the weight of the lightest path between them.We give the algorithm, and the proof of correctness afterwards.Slide74

Algorithm 1

Compute the minimum spanning tree

of G in

time (using Prim’s algorithm).

Next sort the n-1 edges of the tree in non-decreasing order, and add them to the graph one by one, starting with an empty graph on V(G

).The tree is built bottom up. Slide75

Algorithm 2

At each stage we have a collection of HSTs, each corresponding to a connected component of the current graph.

Each added edge merges two connected components in the graph, and we merge the two corresponding HSTs by adding a common root, labeled with the edge’s weight times

.

This algorithm is only a slight variation on

Kruskal’s algorithm, so it has the same running time. Slide76

Example Run - MSTSlide77

Example Run 1Slide78

Example Run 2Slide79

Example Run 3Slide80

Example Run 4Slide81

Example Run 5Slide82

Tightness of the Approximation

Note that in the example, we can see that the approximation is not perfect.

In fact, it is tight – i.e.

Even worse, it is always tight – the vertices of the last edge added,

, will always have the root as their

lca

, and thus their tree weight will be

Note that

since if there was a lighter path then we would have replaced the edge by the path in the tree for a lighter (graph containing a lighter) tree.

 Slide83

Correctness

Let H denote the resulting HST.

First, We denote the shortest-path metric of G by d. That is, given two nodes

, their distance is

We also denote by

the distance induced by H, that is

We will show that the metric induced

by the

HST (n-1)-approximates the shortest path metric of G, that

is for any two node

 Slide84

Proof

Let

be two nodes in the tree, and assume that

is the first edge added, such that after it is added, the vertices are in the same connected component.

Denote this component C, and the components of x and y before this edge was added

respectively. Slide85

Proof 2

Note that e must be the lightest edge between

and the rest of G – in particular between

and

.

Thus, any path between x and y will have weight at least w(e), which means that .However, e is also the heaviest edge in C, which is why the weight of the path between x and y is at most

.

Now:

 Slide86

HST Approximating an n-point Metric

Now, given this claim, if we have a metric space over n points, we can show an HST that (n-1)-approximates it.

Indeed, we only need to build the (complete) graph of the vertices and edges, and weight every edge with the distance of the vertices it sits on.

Now that we have this graph, we use the algorithm we showed to build an HST that (n-1)-approximates the shortest path metric.

However, since by definition of a metric the shortest path between two points is also the distance between them, we get that it is the same metric.

The time would be , since there are edges, and since the construction time is . Slide87

The End.