How to formulate "The $n$ smallest"

96 Views Asked by At

I know how to formulate the set of all $x$ with minimal distance to $y$ with $d(x,y)$ being the distance function: $\{x \mid \arg\min d(x,y)\}$

But how do I formulate the set of the $n$ closest $x$ to $y$ using $d$?

EDIT: Basically I want a "Highscore" and cut it after the $n$-th entry (to be nit-picky: it's a "Lowscore")

3

There are 3 best solutions below

7
On

How about this : $$ \{ x : d(x,y) \leq d(u,y) \text{ for all } u \}. $$

EDIT

$$ \{ x_i : d(x_i,y) \leq d(u,y) \text{ for all } u \text{ and } i \le n\}. $$

Could be a bit ropey.

1
On

If, as you said, you are using the notation described here, then your example above is wrong as this notation already denotes a set. It would simply have been $\arg \max d(x,y)$ or better $\arg \max_{x\in X}d(x,y)$ to make clear where your $x$ are from.

As to your question, there's no way to write $\{x \mid \dots\}$ in such a way that you at the same time define a set of elements with certain properties and also constrain the set to have exactly (or at most) $n$ elements.

I'd simply write it in English: "Let $A$ be a set of exactly $n$ points such that no point not in $A$ has a distance to $y$ which is smaller than that of any point in $A$."


However, you could write something like this:

$$ \{ x \in X \mid \text{there are at most } n \text{ points } z \text{ with } d(z,y) < d(x,y) \} $$

But that wouldn't be exactly the same you were asking for, especially if several points can have the same distance to $y$.

1
On

I've come up with this, inspired by Nick R's answer:

$\{x_i \mid i \leq n\}$ with $d(x_i,y) \leq d(x_{i+1},y)$ and $d(x_1, y) \in \arg \min d(x_i,y) $

what do you think?