# Determining a value of $c$ such that $x/c$ for any $x$ equals $1/2$

$x$ is a variable which take its real values in the interval $[\min x, \max x]$ and $c$ is a real constant value that I want to determine. I want to determine a fixed value for $c$ such that $x/c$ approaches $1/2$ for any value of $x$ in $[\min x,\max x]$.

That is, I want that for any value of $x$ (in the interval $[\min x, \max x]$), $x/c$ approximates $1/2$. How can I determine a reasonable value of $c$ for this purpose (i.e. the most convenient value of $c$ such that $x/c$ is usually near $1/2$)?

Maybe by resolving an equations which looks like

$$\int_{\min x}^{\max x} \frac{x}{c} dx = \frac{1}{2},$$

or something similar? Or by making use of the average value of all possible values of $x$?

This is an example with a finite set of values that $x$ can take (not an interval):

Suppose that $x$ take its values from the set $X = \{2, 5, 6\}$, thus maybe a good value to choose for $c$ is $c = (2+5+6)\cdot2/3 = 26/3$, because the values $2/c$ and $5/c$ and $6/c$ are all not very far from $1/2$. This is the same as saying that $(2/c+5/c+6/c)/|X| = 1/2$ which gives $c = 26/3$. Thought, I don't know if there a more optimal value than $(2+5+6)\cdot2/3$ for this example ...

EDIT1: clarification of what I want to do:

Suppose I have a jar $E$ containing $6$ elements $\{e_1,e_2,e_3,e_4,e_5,e_6\}$ mapped to a set $X$ of $6$ values: $X = \{x_1=2, x_2=4, x_3=6, x_4=1, x_5=8, x_6=3\}$. I take each element $e_i$ from $E$ and put it in another jar $E'$ with a probability of $x_i/c$ (if the probability event of $x_i/c$ occurs, I put $e_i$ in $E'$). At the end, I want that the number of elements in the jar $E'$ equals approximately the half of the number of elements of $E$, that is, for this example ideally the number of elements in $E'$ will be $6/2=3$. How to determine a fixed value of $c$ in order to do that? I guess that the problems turns out to finding the value of $c$, such that for any value $x_i$, the probability $x_i/c$ approximates $1/2$, right?

Ok the answer is probably to choose $c$ as $2$ times the average value of $x_i$.

EDIT2: the second problem (more difficult) after joriki's answer:

Suppose this time that each value $x_i$ is actually the $\min$ distance between the corresponding item $e_i$ and the items that are already in $E'$. That is with previous example:

We have $E = \{e_1,e_2,e_3,e_4,e_5,e_6\}, X = \{\max x, ?, ?, ?, ?, ? \}$

We put $e_1$ in $E'$ according to probability $x_1/c$ which is $1$, thus: $E = \{e_2,e_3,e_4,e_5,e_6\}, E' = \{e_1\}$, and $X = \{x_1=\max x, x_2=\min_{e_j \in {E'}}(e_2,e_j), ?, ?, ?, ?\}$

We put $e_2$ in $E'$ according to probability $x_2/c$, thus: $E = \{e_3,e_4,e_5,e_6\}, E' = \{e_1,e_2\}$, and $X = \{\max x, x_2, x_3=\min_{e_j \in {E'}}(e_3,e_j), ?, ?, ?\}$

And so on ...

So how to determine $c$ in this case ?

-
if $x$ is a variable, how is $x/c$ a probability? – Aang Sep 27 '12 at 9:00
@Avatar if c > maxx, then for any value x in [minx, maxx], 0 < x/c < 1 – shn Sep 27 '12 at 9:31
@Avatar This is an example with a finite set of values that x can take (not an interval): Suppose that x take its values from the set X = {2, 5, 6}, thus maybe a good value to choose for c is c = (2+5+6)*2/3 = 26/3, because the values 2/c and 5/c and 6/c are all not very far from 1/2. Thought, I don't know if there a more optimal value than (2+5+6)*2/3 for this example ... – shn Sep 27 '12 at 9:40
Just because a number is between zero and one does not mean it is a probability ... – kjetil b halvorsen Sep 27 '12 at 10:25
You have to decide what you mean by "optimal" in order to have a ghost of a chance of getting an answer. Suppose your set is just 2 and 8. Is $c=10$ optimal because 2/10 and 8/10 are equally far from 1/2? Is $c=8$ optimal because 2/8 and 8/8 are equally far, multiplicatively, from 1/2? Maybe you want a least squares solution, the one that minimizes $((2/c)-(1/2))^2+((8/c)-(1/2))^2$? Think about what you really want to do. – Gerry Myerson Sep 27 '12 at 11:08

The expected number of items in $E'$ is $\sum_ix_i/c=n\langle x\rangle/c$, where $n$ is the number of items and $\langle x\rangle$ is the average of the $x_i$. You want this to be $n/2$, so you want $\langle x\rangle/c=1/2$, or $c=2\langle x\rangle$. However, note that there is no guarantee that the average is at least half the maximal value, so with this choice the values $x_i/c$ are not guaranteed to be probabilities. To remedy this, you can either use $\min (x_i/c,1)$ as probabilities instead, or choose $c=\max (2\langle x\rangle,\max_ix_i)$.

-
Ok joriki, now I'll edit my post to make the question more difficult and more realistic for what I want to do. I'll suppose this time that each value xi is min distance between the corresponding item ei and the items that are already in E' ! – shn Sep 27 '12 at 12:37
@user995434: Please consider whether it's best to edit this question, or perhaps better to ask a new one. Changing the question too far away from the original question makes it difficult to follow the development of comments and answers and sometimes tends to confuse things. – joriki Sep 27 '12 at 12:45
Well ok, I've edited the post (see edit2), but ok, I'll make it a new question later if it is better. – shn Sep 27 '12 at 12:53
I've created a new similar question at math.stackexchange.com/questions/203452/… – shn Sep 27 '12 at 13:53

Let's suppose $C_i$ is a continuous uniform random variable on the interval $[0,c)$ and you include element $e_i$ if $C_i \le x_i$. Then the expected number of elements included is

$$\sum_{i: x_i \lt c} \frac{x_i}{c} + \sum_{i: x_i \ge c} 1 = \frac{\sum_{i}\min\left({x_i},{c}\right)}{c}.$$

You want this to be equal to $\frac{n}{2}$. A reasonable first estimate $\hat{c}_1$ for $c$ is $2 \times \frac{\sum_{i} x_i}{n}$, twice the mean of the $x_i$, and if this is at least as large as the maximum $x_i$ then you have an answer.

If not then the expected number of elements included will be less than $\frac{n}{2}$, and you need to adjust your estimate (possibly more than once), perhaps using something like

$$\hat{c}_{k+1} = \sum_{i: x_i \lt \hat{c}_k} \frac{x_i}{\hat{c}_k} \left/ \left(\frac{n}{2}-\sum_{i: x_i \ge \hat{c}_k} 1\right) \right.$$

-