Tuesday, January 12, 2016

What are the odds!? **

** - given various pre-conditions.

"If you're ever sad, just remember the Earth is 4.543 billion years old and you somehow managed to exist at the same time as David Bowie"

This has been making the rounds on Facebook following Bowie's recent death. It's pretty amazing, right? Except not really. Because while I could certainly calculate an infinitesimal probability that two human lifespans overlap in a 4.5 billion year window, that's simply not the right constraint for the claim. For one, humans, and written history of particular individuals, has only existed for a few thousand years. Already our odds are a million times better than before. Furthermore, such sentiments tend to come out right when someone well-known dies, in which case there's a 100% chance that anyone reading such a sentiment is alive at the same time. And therein lies a perhaps unintuitive truth: that we only perceive when we exist, so anything we perceive sets a very significant condition on any probability we might think about. If the problem is simply "what are the odds you're alive at the same time as a famous person who just died (or while they are alive)", the real odds are something, but the odds, to you, are 100%. You only perceive in the case where you are also alive, thus limiting the conditional probability significantly.

There are a number of similar realizations. A friend recently posted a picture of her great grandmother, along with the story behind the picture. It was taken to commemorate buying a ticket for the maiden voyage of a certain ship named the Titanic. Gram had gotten out of line to tend to something with the kids who were not on the ship, and by the time she'd gone back, boarding had completed and gates were closed. She missed the ship, and therefore the iceberg, due to unlikely random circumstances. My friend effectively was saying, "look how close I came to never being here". But in the same vein, had she never been born, she wouldn't know it. Alternatively, being born guarantees that the unlikely event did occur. Again, allowing for perspective alters the odds.

Another friend's grandfather flew on bombers during WW2. If I recall right, he was one of the first to successfully complete 25 missions without being maimed or killed. He then met a nice lady, they had a son who also met a nice lady, and my friend became. How lucky he is that his grandfather was one of the few who survived! This is essentially the lottery winner concept. Someone gets lucky, and only because they got lucky are they there to evaluate it. Sure they got the winning ticket, but the ones who didn't, never found out. They never even knew tickets were being passed out.

The notion of "how lucky I am to be here" is funny too. Every single one of us has defied great odds to be here. I myself am born to a father who would be dead at age 2 weeks had a Russian bomb detonated when it hit the next building, a mother who survived some serious lung problems as a child and capsizing into a stormy lake as a teen, a grandmother who had to walk through the raging winter to get away from incoming Russian troops, another grandmother was had been ordered shot if she tried to sneak the kids away, and two grandfathers who were POWs during WW2. Many others weren't so lucky; their prospective offspring are not around to ponder their unluckiness.

Some wonder how we, as a race, have defied cosmic odds to exist in this universe. Isn't it a miracle? Maybe, to some other observer. But to us, the only possible odds are 100%.

Saturday, January 2, 2016

A week with an RDX

My wonderful little Acura RSX-S had to go to the doctor for a transplant. The seatbelt buckle wasn't quite right and was causing the airbag light to come on (which could end with the airbag not deploying, I suppose). This was diagnosed in 5 minutes by regular mechanic, but since he doesn't do warranty service and Acura of Bellevue ("AB") does, he sent me there to get it fixed.

I checked into AB on Dec 30. They told me they'd get back to me by the afternoon. They also quoted me an estimate of $144 for the service (which I hope won't be on my bill because, warranty). They were nice enough to give me a loaner: an Acura RDX. Not really my top choice, but whatever, it's for a day ... until AB called late Dec 30 to let me know that they'll need to replace the buckle and need to order the part. I'd have to keep the loaner until Jan 2. They then called me on Jan 2 to let me know that, just kidding, it won't be here til Jan 5.

Aside about AB: I had already told them the issue was diagnosed by my guy when I dropped the RSX off in the morning (actually, told them when I booked the appointment on Dec 22). It still took them a full day to diagnose it and get the part ordered (or at least I'm concluding that from when they called me). That delay could absolutely affect when the part gets in. I really wish there was some reference concept where they could have just ordered the buckle based on my guy's diagnosis even before I dropped the RSX off. Sure, they could spend some time to confirm it, but they'd be ready and we'd all be done by now. I'm still curious to see what happens with the $144 estimate, hopefully that will just disappear.

So now I've got this beast mobile for a week. I'm not a big-car guy, so this isn't really up my alley and thus I'm not going to looooove driving it around. But that's ok. I can still try and take an objective look at the car. Marisa immediately commented that it "is really nice to sit up high" and that "it looks really good in our garage". She also commented that the seats are really nice. That's all great. In fact, the car overall is hard to fault. The 279 peak hp and 252lb-ft peak torque drag its 3800 pounds around quite easily; acceleration is good for the most part, the engine sounds great. The seats are great, there's plenty of space and all that. The general interface is clean, things are where I'd expect them to be (though Hondas are pretty consistent car-to-car, so it could just be that I'm used to them). I personally don't love the whole navigation system center console thing, but that's me being generally grumpy about such things.

What about my quibbles? Sure, I find the following weird:
1. The shift lever for the auto has a button that you kinda pull up instead of pull back. Marisa and I both found it weird, but this is the kind of thing you get over by the 3rd time and stop thinking about.
2. The driver's side mirror's outer edge is curved to give a very wide angle of view, which is distracting because the edges of what you see in the mirror are heavily distorted.
3. The seat heaters (and the heater in general) take a while to get going. The seats in Marisa's Jetta, for example, will feel warm within 10 seconds. The RDX takes a couple minutes. The RDX also takes a minute or so to start blowing hot air. I think this is a philosophical thing with Honda; they don't want to add an electric heater to their HVAC? My RSX is also a little slow to get the heat blowing.
4. I don't like the material used for the steering wheel. It's too smooth and I'd worry it'd slip if my hands were sweaty. Marisa said the same.

Nothing terrible really, which is a lot more than I can say for some other cars I've driven around.
There is, however, one other thing and this surprised me because it seems so un-Honda. The transmission is slow. There's really no two ways about it: shifts take a long time. I noticed while driving it in D that while it has very nice acceleration once going (like from 30 to 50, or even from rolling to whatever), it's a little sluggish off the line. To debug this more, I popped it over into Sport mode and drove it around with the paddle shifters.

First, the car doesn't really like to stay in 1st gear if you're not flooring it. In my couple trials, it flipped over to 2nd around 3000 rpm (despite the 6500 rpm redline). As most people who drive stick can attest, cars get a little twitchy in 1st, so maybe this is ok. But, the shift takes about 1.5 seconds (whether I initiate the shift with the paddle or not):

Click (+) paddle, instantly see dash show next gear, wait 1.5 seconds, see RPMs actually move (meaning that's when the next gear was actually engaged). The same delay is present between every pair of gears. If you double-click the paddle, it won't show confirmation. The dash will show the next gear, then the gear will engage, then there's a little pause, then the dash shows the 2nd next gear, then that gear will engage. A double-click has an end-to-end runtime of about 4 seconds, with a distinct ambiguous middle zone before you know that the 2nd shift is coming.

This lead to a curious realization: the car would be better served without a 1st gear (or just have 1st be a 'low' gear, out of the way for usual driving). Sure, getting to 20 takes a touch longer, but there's enough torque that you can't remotely make full use of 1st anyways. 2nd isn't much slower, and it avoids one slow shift while getting up to normal speeds. I started just flipping the car into 2nd after stopping, and the driving experience was a lot better.







 

Thursday, November 5, 2015

Terminal betrayal velocity

A friend posted a story from the internet that goes:

A couple decided to commit suicide. They'd had some rough times and chose to jump from a building. When they got to the top, they counted to 3 and the woman jumps. The man watches her fall for about 8 seconds when a parachute opens. Who betrayed whom?

Her comment? "Must be a tall building!"

Of course I took it upon myself to figure out just how tall that building is. This is more interesting than a basic equations of motion problem because the use of a parachute necessitates allowing for variable forces, both during the initial freefall and then during the slowing down process after the chute opens. To frame up the initial fall, we can write, generally:

[1] d/dt D(t) = v(t)
[2] d/dt v(t) = a(t)
[3] a(t) = F(t)/m

These are our base, non-specific equations. The force diagram on the woman has 2 components: mg down (which we'll define as the positive direction), and kv up, where k is some constant aerodynamic coefficient; air resistance can be crudely modeled as proportional to velocity. We have additional data as well. We know that a person in freefall will reach a terminal velocity, Tv, and that value is generally stated as being about 50m/s. I'll use this value for the calculations, but if you feel they aren't right, you're welcome to use alternate values in the final equations. So, at the point of terminal velocity we know that kTv = mg, and thus k = mg/Tv.

[3.1] a(t) = (mg-kv(t))/m
[3.2] a(t) = (mg-mgv(t)/Tv)/m
[3.3] a(t) = g - gv(t)/Tv

We can do a quick sanity check here: as v(t) -> Tv, acceleration indeed goes to zero as expected. The next step involves solving the differential equations [2] and [1]. While this could be a fun exercise in math process, I'll defer to Wolfram Alpha diff eq solver. Known boundary conditions (notably that velocity and distance are both zero at time=0) will be used to solve for constants that appear as a result of integration steps.

[2.1] d/dt v(t) = g - gv(t)/Tv
[2.solved] v(t) = c1 exp(-gt/Tv) + Tv
[2.boundary] v(0) = 0 = c1 + Tv, thus c1 = -Tv
[2.final] v(t) = Tv - Tv exp(-gt/Tv)

[1.1] d/dt D(t) = Tv - Tv exp(-gt/Tv)
[1.solved] D(t) = c2 + Tv t + Tv Tv exp(-gt/Tv) / g
[1.boundary] D(0) = 0 = c2 + Tv Tv / g, thus c2 = -Tv Tv / g
[1.final] D(t) = Tv Tv exp(-gt/Tv) / g + Tv t - Tv Tv /g

Solving for distance fallen and speed after 8 seconds yields her status as:
D(8) = 196 meters down
v(8) = 40 m/s

We're now at the stage where her parachute is opening. Based on a combination of movie scenes and the shortest base jump I could find, it appears it takes about 2 seconds for the chute to open. During this time I'll assume it has negligible braking force, and I'll simplify and assume the woman would continue to fall at v(8) = 40 m/s and thus finish this stage at 276 meters down and still going 40 m/s. Clearly I've simplified here, but due to the short duration of the stage, the effects are not terribly material on the final calculations. Others suggest the time could be as low as 1.2 seconds (derived by dividing the claimed 200 feet distance to open by terminal velocity of 50 m/s). That would put a lower-bound on her fall at 244 meters.

The final stage is to figure out how long it takes for the chute drag to slow her down to a speed she'll survive. We can reuse equations [1.solved] and [2.solved] with new boundary conditions. Tv in this case is the descent speed with the chute open, which I'll call about 5 m/s.

[2.boundary.stage3] v(0) = 40 = c1 exp(-gt/Tv) + Tv = c1 + Tv, thus c1 = 35
[2.final.stage3] v(t) = 35 exp(-gt/Tv) + Tv
[1.boundary.stage3] D(0) = 0 ** = c2 + Tv t - 35 Tv exp(-gt/Tv) / g = c2 - 35 Tv / g, thus c2 = 35 Tv / g
** - I'm re-referencing her position here as zero, this can be trivially added/shifted to the previous stages.
[1.final.stage3] D(t) = 35 Tv / g - 35 Tv exp(-gt/Tv) / g + Tv t

The last thing to figure out is how long it takes her to slow down to a speed she can still land reasonably safely. I'm not sure what the number is, but let's say 2 Tv = 10 m/s. That's the equivalent of jumping from about 15 feet. It'd hurt, but she'd survive. Using [2.final.stage3] and solving for t:

[2.final.stage3.survival1] v(t) = 2 Tv = 35 exp(-gt/Tv) + Tv
[2.final.stage3.survival1.1] Tv = 35 exp(-gt/Tv)
[2.final.stage3.survival1.2] Tv ln (Tv / 35) / -g = t
[2.final.stage3.survival1.3] t ~= 1 second

As an alternative, suppose we want to get to 1.2 Tv for a practically terminal velocity landing
[2.final.stage3.survival2] v(t) = 1.2 Tv = 35 exp(-gt/Tv) + Tv
[2.final.stage3.survival1.1] Tv = 175 exp(-gt/Tv)
[2.final.stage3.survival1.2] Tv ln (Tv / 175) / -g = t
[2.final.stage3.survival1.3] t ~= 1.8 seconds

Plugging in our two values will give us a reasonable upper and lower bound for how much distance she needs after the chute opens.
[1.final.stage3.survival1] D(1) = 20.3 m
[1.final.stage3.survival2] D(1.8) = 26.3 m

The final stage is quite rapid, and slowing down considerably more only costs an extra 6 meters. Let's assume for comfort, she'd want to get to the slower speed. Adding up the 3 stages yields 196 in freefall, 48 to 80 while the chute is opening, and another 26 to slow down. To be on the safe-ish side, let's take the max of each stage and say the building needs to be at least 196 + 80 + 26 = 302 meters (991 feet) tall. In essence, this could be done off, with rounding, any building over 1000 feet (or nominally 100 stories) tall.

There are only a few buildings in America that this story could plausibly have happened on. There are only 17 that are formally tall enough, and a few of those are coming within feet of the exact minimum height. However, a number of those don't qualify because they don't have a platform that's high enough. For example, it's doubtful that anyone could jump outwards enough from high enough on the Empire State Building or Bank of America Tower to avoid significantly outcropping lower layers. The New York Times and Chrysler buildings definitely fall into this category, and judging from other photos, the Bank of America Plaza and US Bank Tower are similarly problematic. The bottom end of the tall-enough buildings all seem to be box-shaped enough that they would support our scenario. All in all, this could happen in maybe 10 or 11 specific places, but would have to be in New York, Chicago or Houston.

What's fun to note is that even from full terminal velocity, the distance needed to open a chute and slow down to safe landing speed is under 150 meters. Scaling this up to the tallest building in the world, Using [1.final] and D(t) = 680 allows for 18 seconds of free-fall! Intense!
 

Tuesday, November 3, 2015

Up or down? A toilet story

"Why can't the guys put the seat down?" says every cliché woman, ever.
"What's the big deal?" is the standard response. And I agree. But let's be more scientific about it, shall we?

Assumptions: a healthy adult pees about 6-8 times per day (counted as 7 from here on) and poops once. Women perform all activities sitting, requiring the seat to be down. Men always stand to pee and sit to poo. All subsequent results can be adjusted if these assumptions are invalid in your household. For base calculations I'll assume that there are an equal number of men and women in a household. This should generally hold true for couples and families, for generalities' sake. Single people have no one complaining to them, so they are uninteresting for this scenario. We'll also call out adjustments for families with more men than women and vice versa. The math is really household-per-toilet, for example if only mom and dad use the master bath (and they only use the master bath), that toilet's usage is by 1 man and 1 woman regardless of the rest of the family composition.

As a practicality:
Flipping a toilet seat up or down is no one's idea of a good time. Naturally we'd like to do this as few times as possible. The seat will have to be flipped if the previous use required the opposite state. In an evenly mixed household, this means that 7 of 16 (P(up)) times the seat will be up and 9 of 16 (P(down)) times the seat will be down. Assuming the events are totally random (which seems reasonable enough), we don't need to flip the seat P(up)*P(up) + P(down)*P(down) = 130/256 ~= 51% of the time if it's just left in the previous user's required state. This means that ~49% of the time we need to flip it.

Simply leaving the seat alone gets the right next state 51% of the time. Always putting the seat down will get the right answer P(down) = 56% of the time. Not a huge win, really. In terms of number of seat flips, it means we average 0.49 flips per use. Always putting the seat down incurs 1 flip in P(up) and 0 flips in P(down) immediately after. Then there's another 1 flip in P(up) and 0 flips in P(down) for the next user, which comes out to P(up) + P(up) =  0.88 flips per use. This is much higher, nearly doubling the number of expected flips. Always putting the seat down is a worse strategy.

The numbers do change as family composition deviates from half-and-half. Suppose a family with 2 men and 1 woman. P(up) changes to 14/24 and P(down) becomes 10/24. Reworking the equations above for leave-as-is yields a don't flip, still, just barely over 51% of the time. The number grows slowly as men outnumber women. 3-to-1 is at 55% and even 4-1 is only at 58%. Conversely, it means that even in a household with a vast male majority, the percent chance that the woman will need to flip the seat stays safely in the 40s. However, the average number of flips climbs to 1.17 for 2-to-1, 1.31 for 3-to-1 and 1.4 for 4-to-1.

Supposing a family has 2 women and 1 man, P(up) falls to 7/24 and P(down) becomes 17/24. Now leaving the seat as-is will work out 59% of the time. The odds climb to 66% for 3-to-1 and 71% for 4-to-1. In other words, a female-heavy household will tend to work out in women's preference favor anyways. Employing the leave-as-is strategy means the average flips falls to 0.41, 0.34 and 0.29, respectively. Always putting the seat down averages 0.58, 0.44 and 0.35 flips, respectively. As women outnumber men more and more, the two strategies converge. However, it is important to note that leave-as-is will never be worse**, and is therefore the statistically correct strategy.

As a courtesy:
If we consider this altruistically, we should look at how often the next person finds the seat in the right state (which is really P(down)). We've done the math above. P(down) is greater than 50% for even households or those with more women. More men cause it to fall below 50%, though a family of 7 could hit a 50/50.
2 men, 1 woman: 43%
3 men, 2 women: 48%
4 men, 3 women: 50%
The takeaway from this is that family composition might dictate that the women leave the toilet seat up! In cases with more men than women, this would generally be the outcome. However, keep in mind that the misses are going to significantly unfairly affect either the men or the women, externalizing a greater cost onto that subset of the family. Is that really being considerate?

In case someone doesn't check and falls in:
I'm just going to laugh.

Conclusion:
Choosing leave-as-is vs always-down strategies is dictated by the philosophy behind the action. If trying to minimize the number of seat flips, leave-as-is is entirely superior. If being considerate to the next person regardless of cost, the choice is dictated by family composition. Families with more men than women should actually opt for an always-up strategy, while others should opt for always-down. The choice is yours. Now you know what you're fighting for!




** Appendix:
[1] Average flips always leaving the seat down = 2 * P(up)
[2] Average flips always leaving the seat as-is = 1 - (P(up)*P(up) + P(down)*P(down)).
Since P(up) + P(down) = 1 always, we can substitute P(down) = 1-P(up) into [2]:
[3] Average flips always leaving the seat as-is = 1 - (P(up)*P(up) + (1-P(up))*(1-P(up)))
[3.expanded] = 1 - (P(up)*P(up) + 1 - 2*P(up) + P(up)*P(up))
[3.collected] = 1 - (1 + 2*P(up) + P(up)*P(up))
[3.simplified] = 2*P(up) + P(up)*P(up).

Since P(up) >= 0, [1] <= [2]. If there are any men in the house, [1] < [2] since P(up) > 0

Wednesday, October 7, 2015

Don't we want the bottom to be fired?

I was reading this article discussing the nuances of the illegal batted ball in the Seahawks-Lions game. When talking about referee performance, it calls out that a section of the refs will be graded as tier three. Two consecutive years in tier three makes a ref a candidate to be fired.

Companies routinely get flak for cycling out their poorest performers. However, wouldn't you, as a consumer of a product, want that company to strive for stronger and stronger employees? We accept (even demand!) this in sports. Poor players need to go. Bad refs need to go. Bad coaches need to go. Why? Because we feel the resulting product is diminished.

If I'm going to buy a car from GM or ride a plane made by Boeing or use software made by Microsoft, shouldn't I want them to use the best people they can find to make those things? Shouldn't I accept (even demand!) that they do so?

The counterargument is usually of the form "what if everyone is an all-star?" or at least "what if everyone is really good?". I counter that there's rarely an absolute definition of good. Being able to, say, assemble 10 cars in a day is objective, but meaningless. Can anyone do that? Can more people than I would ever hire do 20 cars in a day? Hiring guidelines such as these come about by observing relative skill levels. If we hire better and better people, maybe we don't need to make more cars but we can put more effort into other related aspects of assembly. Overall, better workers should create a better product.

Going back to the NFL example, these players, coaches and refs are amongst the absolutely very best in the world, but we still say they suck, they should be fired, etc. Why do we suddenly believe that these same rules don't or shouldn't apply in "real life"?
 

If my parents had guns

My parents were born in 1944 and 1952, in Hungary. For those not familiar, Hungary was emerging, destroyed, out of WW2 and was pretty much immediately taken under Soviet control. The population was progressively subdued and thrust into a communist system. Frustrations peaked in 1956 when a brief revolution was attempted. Predictably, the overpowering might of the Soviet occupying forces crushed it in short order. People who were protesting peacefully were shot. Anyone attributed with leadership roles was executed. One can argue that the revolution was short and relatively few people died only because the population did not have guns. The spirit to fight was there. The weaponry did not.

So what if my parents (or really, my grandparents) and their friends had guns? Lots and lots of guns? I'm pretty sure I wouldn't be here right now. In case it's not clear, because they wouldn't have lived through 1956. While Freddie Mercury wondered out loud if he'd have preferred not to have been born at all, I prefer existing.

The point here is that supporting guns because the 2nd amendment says so seems an outdated stance. First, we made that rule for ourselves and it can be changed. It's not a commandment to Moses. Second, it was written to allow states to defend themselves from a tyrannical government. At the time of writing, the weapons playing field was relatively level. The army came with guns and some cannons. The population defended itself with similar guns (though probably no cannons). Today the population has guns whereas the army has grenades, bombs, tanks, cannons, airplanes, night-vision,  body armor, ... Defending ourselves from an organized, modern army is just not a thing that will happen.  

Wednesday, September 30, 2015

The not-so-ideal candidate

I spent the last few days at UofA, recruiting. Overall it was great, as usual. However, there is a segment of candidates that can get really annoying.

Critical listening:
We have a thing called a program manager. Most people think it's the same as a project manager, or some kind of manager at least. I go out of my way to explain that it is neither of those things. Following it up with "well, I think I'm a good candidate and I have a lot of experience so I'm ready for a management role" will not endear you to me.

Or just not listening:
Many people come prepared with their sales pitch about how great they are. We like to ask questions and have a conversation. It's really hard to do that when unverifiable information is streamed non-stop at my face.

Hygiene:
Onions are delicious. So are other foods. Please clean them out of your mouth before you go talk to a bunch of people in tight quarters.

Compliments:
"You work for Microsoft? You should work for a modeling company" is ... awkward.

Clinginess:
Our process is simple: you talk to us and apply. Coming back day after day just to remind us who you are is, at best, going to do nothing for you.

Connecting:
Use your face-to-face time to make a connection and make me remember you. Don't come back to ask me for a business card because you couldn't find me on LinkedIn. First, I'm not on there. Second, I either already think well of you or I probably don't want to be inundated by the inevitable future followups.

Demands:
Has anyone else gotten back to you about that resume you dropped off yesterday? Yeah, neither have we. Please hold. Even worse is being confronted about "will I be hearing back from you?" or "am I the right fit?" Expect something non-committal.

Just plain out there:
Coming up to our booth and collecting swag while avoiding eye contact and reciting a manifesto about our oppressive ways and your eternal loyalty to Linux is ... I'm not even sure what to call that.