0

There are some real $X_i$ values from $-1$ to $1$. What I need is to find such a new value $Y$ inside this range such that the distance from existing values $X$ inside this range to the new value $Y$ will be minimal.

So if we put it like this: $$S_n = \frac{|X_1-Y| + |X_2-Y|+\cdots+|X_n-Y|}n,$$ where $X_1\dots X_n$ are known numbers.

How to find such an $Y$ so that $S_n$ will be minimal?

$X$ and $Y$ are numbers (integers or floats(real))

Is it multivariate calculus?

Name
  • 1
  • What $X$ and $Y$ are? – Senna Jul 13 '20 at 09:23
  • 1
    Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match many users' quality standards, so it may attract downvotes, or closed. To prevent that, please [edit] the question. This will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers. – José Carlos Santos Jul 13 '20 at 09:28
  • X and Y are numbers (integers or floats(real)) – Name Jul 13 '20 at 09:48
  • @Name if you mean the distance between $X$ values and $Y$, then maybe you should take the absolute difference $|X_i-Y|$ instead of the signed difference $X_i-Y=-(Y-X_i)$?

    The problem as it stands, is not multivariable calculus, since the $X$ values are already given, you can treat them like numbers, except, instead of having a result for an operation between $X_1$ and $X_2$, you have to keep it in the raw form, since you don't know their actual values, but they are fixed values.

    The only variable here is $Y$. The current $S_n$ is decreasing in $Y$, hence minimized at $Y=1$.

    – Fawkes4494d3 Jul 13 '20 at 10:00
  • And if you mean $|X_i-Y|$ instead of $(X_i-Y)$, then you want to take the median of the $X_i$. I expect this question has been asked and answered many times on this site. – Gerry Myerson Jul 13 '20 at 10:04
  • Thanks for improvement suggestions. As I can see it Sn is also unknown. So we have two variables Y and Sn – Name Jul 13 '20 at 10:05
  • Gerry Myerson, may be. But I am not very good with math. Can anybody give me a hint as to what math area to look into to solve this kind of equation. – Name Jul 13 '20 at 10:09
  • See https://math.stackexchange.com/questions/318381/on-a-1-d-line-the-point-that-minimizes-the-sum-of-the-distances-is-the-median and the questions that are linked to it. – Gerry Myerson Jul 14 '20 at 12:25
  • Did that help any, Name? – Gerry Myerson Jul 15 '20 at 13:53
  • Are you still here, Name? – Gerry Myerson Jul 17 '20 at 01:14
  • I guess not. Bye-bye, Name. – Gerry Myerson Jul 18 '20 at 12:58

0 Answers0