105 points · by bumbledraven · 4y ago · 107 comments
Technically this isn't a fully sound inference. All this proves is that you're at a local optimum. So you'd also need to know or show that there is only one optimum/the problem is convex/local=global or any variant.
Of course that is the case here, but it's always worth noting the specific properties of a problem that make a neat solution possible.
> True, it’s not a rigorous proof. You can find a rigorous proof here:
> “A Simple Noncalculus Proof That the Median Minimizes the Sum of the Absolute Deviations.” Neil C. Schwertman, A. J. Gilks, and J. Cameron. The American Statistician, Vol. 44, No. 1 (Feb., 1990), pp. 38-39.
That paper fits on one page, not counting references. Here's a link: https://tommasorigon.github.io/StatI/approfondimenti/Schwert...
> Technically this isn't a fully sound inference. All this proves is that you're at a local optimum. So you'd also need to know or show that there is only one optimum/the problem is convex/local=global or any variant.
You can't move away from the median without increasing the average distance over all doors, when you're standing on the median.
But that's just a special case of the also-easy-to-prove fact that you can't move away from the median without increasing the average distance over all doors, no matter where you're standing. You can show that by exactly the same argument used in the post - if you move away from the median, your total distance to all doors will increase, because you moved away from more than half of the doors.
This suffices to show that -- if there is a global optimum superior to the local optimum at the median door -- that global optimum cannot be located in the neighborhood of any point on the real number line, which is to say it cannot be located at any finite distance from the median. Or in other words, no such global optimum can exist.
That's is because if there are people in the elevator and you right in front of it, you have to move away, wait, and go back. Not ideal, it makes more sense to wait on the side of the elevator, possibly at a distance proportional to the expected time it takes for the passengers to leave.
That would make the ideal waiting spot somewhere between the middle elevator and the other one that is the furthest away from the middle elevator, but not necessarily the mean.
import math
import random
B = 1000
elevators = [-6, 0, 3]
def time_to_enter_distribution(position):
for _ in range(0, B):
elevator = random.choice(elevators)
distance = elevator - position
# What matters is not how many people are in the elevator, but how
# quickly they can evacuate. Approximate Poisson distribution.
evac_time = [0, 1, 2, 3, 3, 4, 5][random.randint(0, 6)]
# While you walk to the elevator, you give time for people to evacuate
# and your time passes.
evac_time -= abs(distance)
time = abs(distance)
# If people are still evacuating when you have arrived, you have to wait
# for that to end by the side of the elevator, and then take the final
# 0.5 metres to step inside.
if evac_time > 0:
time += evac_time + 0.5
yield time
def time_to_enter_summary(position):
distr = list(time_to_enter_distribution(position))
sum_time = sum(distr)
sum_sq_time = sum(t**2 for t in distr)
mean = sum_time/B
sd = (sum_sq_time - sum_time**2/B)/(B-1)
se = sd/math.sqrt(B)
return (mean, se)
if __name__ == '__main__':
print(f'{"pos":5s} {"t":4s} {"se":3s}')
for p in (i/4 for i in range(-6*4, 3*4)):
(t, se) = time_to_enter_summary(p)
print(f'{p:5.2f}: {t:4.2f} ({se:3.2f})')But: The one big question I have with elevator UX is this: why isn’t it possible to deselect a choice? So pressed 10th floor but wanted 11th. There is no way to press button 10 and then button 11 to correct that mistake.
Will I ever solve this mystery?
1. When the currently targeted floor is deselected and the remaining selected floors are all in the other direction: Then the elevator would have to either reverse course without stopping — a situation which otherwise doesn’t occur and would be unexpected and possibly dangerous for the passengers — or stop on a non-selected floor before changing direction, which would be confusing as well.
2. The deselected floor was the only selected floor: The elevator would then have to choose a floor to stop on by itself — e.g. the next one it can safely stop on — which is also a situation that doesn’t otherwise occur. In addition, deselecting the only selected floor doesn’t seem to be a practical use case.
So instead of having to define, implement and test a behavior for those odd situations, it’s safer and less costly to just disallow deselection.
(I don't usually board elevators traveling in the wrong direction, ofc., so, I'm not that sure.)
[1] https://www.amazon.com/Qualityland-Visit-Tomorrow-Marc-Uwe-K...
Admittedly, that's not very helpful unless you somehow knew that the elevator you were in had been configured in such a way.
In many elevators, one can double-press a button to deselect it.
You are perhaps trying to optimise for a one-person elevator trip, rather than thinking of what is the optimum for a repeated game with many concurrent trip players that includes both cooperator players and defector players. An elevator is a common good to its users.
If people could cancel a destination, then there is less incentive for people to have to prethink their destination before getting on the elevator. Leading to more likely to waste concurrent elevator users’ time in the long run?
If you could cancel a destination, defector players could cancel your destination to speed up their trip (with resulting policing and status meta-games etcetera).
Elevators mostly have the lowest-common-denominator for a UI. Where is the incentive for elevator purchasers (building procurement or facilities) to demand an improved UI? Would a manufacturer get any profit by providing an improved UI? Would such a UI be accessible to the blind? Discoverable? Usable? Cleanable? Predictable (e.g. elevator arriving indicators on destination floors)? Safety? Complexity?
There are a huge number of factors to building anything complicated.
Also see https://danluu.com/sounds-easy/ and https://fs.blog/chestertons-fence/ and all of the elevator wiki starting here https://elevation.fandom.com/wiki/Fire_service_mode_(EFS)
Disclaimer: I’m not an elevator engineer. I feel your pain: I want a government department of niggles which catalogues minor complaints and gets them fixed. Although I admit I am pessimistic enough to think it would only end up increasing the total number of niggles due to second-order effects.
You'd be surprised how often it comes in handy and have never had an issue with anyone deselecting someone else's floor.
In larger/public settings, offering this would be counterproductive, for the reasons listed by sibling comments.
And maybe answer my question too: how do blind people know if they are selecting or deselecting?
Watching foreign button-mashers must be amusing!
https://en.wikipedia.org/wiki/Destination_dispatch
I've only seen this in one building. It was a little weird, but it supposedly is coming soon to more and more elevators.
Whoever made this building made a whole lot of mistakes though:
- They put this into a building with public spaces (e.g. a doctor's office).
- When standing in front of the elevators, nowhere does it say which office is on which floor (it says so in the lobby which you walked by to get to the elevators)
- The screens where riders have to select floors automatically turn off after not being used for a few minutes. At that point, to people who have never used them before, they do not look like they have anything to do with the elevators at all.
- When these screens do turn on, they list the floors in reverse order (i.e. highest first). That makes sense because the people on the highest floors are the most likely to use the elevators, right? Well, all the offices are on floors 1 through 4. They're on page two of the screen. The button for "next page" is not labelled as such. You have to know it's there.
- The screens are resistive touch screens and not well calibrated. The buttons to select a floor are approximately the same height as the tip of your index finger. A first time user won't hit the correct floor the first time, guaranteed.
- At the point where you are standing in front of the elevators, you are so deep into the building that you have 0 cell reception. I have randomly encountered food delivery people be stranded there because they could not call their customers to figure out how to use the elevator.
Every single week I have to rescue a poor 80 year old person who needs to go to the doctor and is horribly lost and confused, and it just breaks my heart how the building's owner (which I've contacted about this to no avail) chose "oh the salesperson said this was more efficient and trendy" and now a large percentage of users are so much worse off for that choice.
Apart from that, the first thing I wondered when I moved in was "oh, as a resident, does that mean I just get a keyfob I can wave at this screen that knows I live on the X-th floor?". That's also feasible, to the degree that the Wikipedia article linked above refers to this.
The problem with all these fixes is of course that they all cost more than $0.
And neither the company owning this building nor any landlord company involved in its operation is even based in the same ZIP code as the building. So why would they care?
Then I found the secret wheel-chair button assortment, which was genuine buttons.
This is true, but I find it more intuitive to think about the signed distance: if you define signed_dist(x, y) = x - y, then the mean is the value that makes the average signed distance closest to 0. Of course in reality distance is unsigned – if you walk 1m left then 1m right, you've walked 1m + 1m = 2m, not 1m + -1m = 0m, so the signed distance is not appropriate.
Here is a practical example where the aim is to get the average signed difference to be closest to 0: You want to count a large number of nails by weighing them. To do that, you need to know the weight of a single nail. But the nails have slightly different weights, so you need to pick some representative value. Question: Should you pick the mean or the median? Answer: You should pick the mean, because when you weigh all the nails together the differences will cancel out.
So the rule is:
- To minimise the average value of the absolute difference, pick the median.
- To minimise the absolute value of the average difference, pick the mean.
Well, yes, that is the definition of the mean.
But you can't know what the mean is without having already answered your original question of "how many nails are there?", so as a formal matter this is completely useless advice.
What you actually want to do is pick out a number of nails that you do know exactly, say 10, weigh them, and use the mean weight of that sample to estimate the mean weight of the entire supply of nails.
Yes, obviously you'd estimate the mean/median by taking a small sample (or using a published value). I left that detail out because it's not relevant to the choice between mean and median.
You're asking what the mean weight of a bundle of nails is and then pointing out that the mean weight is a better estimate of the mean weight than the median weight is. Why is that worth noting?
> What if you want to minimize the worst case instead of the average case? Stand half way between the first and third elevators.
What is the difference between "in front of second" and "halfway between first and third"?
In this scenario, the second elevator isn’t centered between the first and the third elevators.
If I understand the description properly, the layout may be something like this:
[]__[]____[]
> Imagine a bank of three elevators along a wall. The elevators are in a straight line but they are not evenly spaced.
The best "trunk" to minimize total distance to all points is the median of their positions.
It seems like whatever minimizes a squared error should itself have some squares in it.
An intuitive way to look at it is that square function is the simplest function that goes down until it reaches a minimum, and then back up again. If you want this property, you can expect to find squares somewhere. Distance have this property: if you move in a straight line, the distance to your target will go down as you are closing in, then you reach it, then if goes back up again after you pass it.
That's the general intuition for where the squares can be. Let's be a bit more formal.
Let's flip the problem and try to minimize the sum of the squared distances (or squared error, same thing). In 1D, the sum of the squared distances to a and b is (a-x)^2 + (b-x)^2 = a^2 - 2ax + x^2 + b^2 - 2bx + x^2 = a^2 + b^2 - 2(a+b)x + 2x^2
It is a parabola, the minimum is where the derivative is zero. The derivative is -2(a+b) + 4x, solve -2(a+b) + 4x = 2 for x and you have x = (a+b)/2, which is your average. Of course, it works with more than 2 distances.
Another intuition: to minimize something, usually, we take a derivative, and when we take the derivative of something squared, the square tends to disappear, so it shouldn't surprising that the minimum of something squared has no squares in it.
By what measure of simplicity is x^2 simpler than abs(x)?
I mean, if you added the caveat “with a continuous derivative”, sure.
Its description is shorter in English and in most programming languages, mainly because it doesn't have a conditional. (Which is related to it being differentiable everywhere).
First just consider one point, A. The squared distance from that point is a parabola with its apex at A, or as a formula (x - A)^2. The derivative of that is 2x - 2A. So if 2x - 2A > 0, moving to the right makes the squared distance go up, moving to the left makes it go down. If it's < 0 then the opposite is true. If it equals 0 then you have minimized the squared distance to A. All this is trivial, in the case of a single point, because x = A is obviously the solution (the mean of a single value is that value).
But you want to minimize the sum of the squared differences. So you are checking sum(2x - 2Ai) where Ai are all the different points. This means comparing 2nx with sum(2Ai), if n is the number of points. Or equivalently, you can divide by 2n and compare x with sum(Ai)/n. This formula is just the mean of the points. If this is greater than x, you should move a bit to the right. If it is smaller, you should move to the left. If equal, you have minimized the sum of squared differences.
We didn't prove uniqueness but we've established that the derivative of the sum of squared distances has only linear terms in it, so a little more calculus will easily allow us to check that.
tl;dr: To minimize a function requires an equation in that function's derivative. To minimize sum of squared errors we solve an equation with only linear terms.