Thursday, October 3, 2013

Why Do Joints Ache When It Rains?

Last year, 31 years of treating my body like a rental car finally caught up to me.  Unexpectedly though, it was one of my hip joints and not my liver that crapped out.  From what I understand, years of bike riding and a malformed femur bone had gradually mashed the cartilage in my hip joint into a very painful paste.  After trying a bunch of stuff that didn't work for six months, I eventually had to have arthroscopic surgery to do something about the bits of dangling flesh that were getting pinched whenever my hip joint moved.  One painful operation, three months of physical therapy, and an assload of painkillers later I'm mostly fine again, with one exception: the joint aches like hell when it's raining or about to rain.

If I undestood the nice doctor correctly, the labrum (latin for "horrible pain flesh") had to be sewn or trimmed back so the femur would stop squishing the edge of it.  Don't get old, kids.  

Everyone's heard old people complain about this, but old people love to complain about all kinds of things so I never took it that seriously.  Thinking about it a little bit though, it's very weird-- common sense would dictate that it's either the barometric pressure drop or spike in relative humidity you get with a rainstorm that causes the joint pain, but I'm at a loss to explain why either of those would do it.  There also seems to be a time-delay effect at work-- right now I'm sitting two stories underground, in a clean room with its temperature, pressure, and humidity regulated to the second decimal place, and somehow my hip still seems to know it's raining out.  

It doesn't make sense that humidity would have any effect on a joint-- your body is mostly water and your joint is buried deep in your body and behind your somewhat-impermeable-to-water skin, so it's hard to imagine a slight increase in the partial pressure of water vapor in the air being something a joint could "feel." Barometric pressure is a little bit more believable-- a change in the pressure differential between the inside and outside of your body could cause slight decompression or compression of the joint.  Not much, but since joint tissue is apparently made entirely of angry nerves, it might be enough to feel.

The first article in my Google search results for this question was on WebMD.  Given that, I expected it to blame weather-related joint pain on HIV, since that seems to be their explanation for most other things that can go wrong with your body, but the article was actually pretty decent.  Apparently, the jury is still out on exactly what causes weather-based joint pain; it's one of those things that has loads of anecdotal evidence but not enough incentive to actually bother studying in detail (kind of like baby colic, the subject of a future post).

The article pretty much agrees with me that it's got to be a pressure thing.  Barometric pressure is a pretty good leading indicator of weather; you can often detect a front coming through by a drop in pressure long before any physical indicators of it, like rain clouds, become obvious.  As mentioned above, a drop in ambient pressure is going to change the pressure differential between the inside of your body and the environment, which means your body will expand outward like a balloon very slightly (the extreme case of this would be explosive decompression in space, or that experiment where you stick a knotted balloon in a vacuum chamber).  In this case, the expansion is very, very minor.  Like I said though, damaged joints are basically tiny globs of connective tissue and hate; even a slight change that causes a tiny pressure to be put on the tissue is enough to cause noticeable discomfort.

One thing I've learned as the owner and operator of a bona fide Bad Hip is that once something makes it hurt, it's going to keep hurting for awhile.  Anything that causes joint pain is also going to cause inflammation of the tissue, which makes it come into more contact with the surrounding bone, which makes it hurt worse, which makes it get inflamed more, etc.  That's probably the explanation for why, even down here in my little climate-controlled hole in the ground, my leg still knows it's raining-- it had 12 hours at "rainstorm" pressure to get good and inflamed, and it's damned well not going to stop doing that just because the original cause is no longer present.  Thanks, leg!

WebMD has listed a number of helpful "solutions" to this problem, including "Apply a heating pad to the joint" and "Try to improve your mood".  While I'm sure sitting at work with a heating pad jammed down the front of my pants would help the pain, the resulting sexual harassment lawsuit would probably drop my mood down a couple of notches and I'd be back at square one, so that's not that useful.  I've found anti-inflammatories like aspirin help a little, but mostly the cure seems to be just waiting it out (luckily it doesn't seem to rain more than two or three times a year in Minnesota now).  In conclusion, being old sucks and if any of you have a bionic leg you're looking to sell, drop me a line.

Tuesday, July 16, 2013

Why Do Cats Like Fish?

It's common knowledge to anyone who gets most of their information about animals from cartoons that cats love eating fish.  Being the owner/butler of two of the ungrateful food vacuums myself, I can empirically verify that this is true at least half the time (the other cat is a special case, as he considers things like bread and rubber bands to be perfectly reasonable sources of food, so we're going to throw him out as a data point).  The non-stupid cat, while pretty enthusiastic about the normal spectrum of cat food in general, will abandon all subtlety and inhibition when there's any kind of fish or fish-derived food within smelling range.  Even though he's 15, arthritic, and generally moves the bare minimum necessary to prevent bedsores, he's more than happy to jump on the dining room table and run off with a piece of salmon bigger than his head if there's a three-second window of opportunity to do it.  He usually can't actually eat it, since he's trying to chew while involuntarily purring, but if you try to reclaim your dinner he'll act like you're tearing his legs off.  The point is that my cats are monsters, but the other point is that cats (at least some cats) are batshit for a food they have no evolutionary reason at all to be interested in.

Image of cat enjoying fish, taken from a popular series of nature documentaries.  Apparently mice like fish too, but that's beyond the scope of this post.  

Your basic felis catus (and its closest wild relatives, bobcats and lynx and such) is built for hunting birds and small mammals on the ground and up trees in more wooded areas.  That's pretty standard across the whole cat family; with one odd exception (the fishing cat, one of those niche-evolved oddities that does exactly what its name advertises) cats are pretty exclusively terrestrial predators.  So domestic cats' similar enthusiasm for things like chicken makes some sense, since "poultry" to "unfortunate songbirds" isn't really a huge leap.  I imagine if we ate a lot of rabbit in our house the cats would be into that too (full disclosure: as a vegetarian, I mostly just get to point and laugh as the cats steal my wife's stuff).
A fishing cat doing what it does.  How it has the patience to fish without a six pack is not clear. 

Fish smell and taste quite a bit different from any normal cat prey though.  Moreover, most cats don't even like getting their paws damp, which tends to preclude any kind of major underwater hunting activity (there are exceptions, because cats are all special snowflakes, but they're not common).  So where did they pick up a taste for fish? 

The answer to this one is obvious when you think about domestic cats a little bit.  They're what wildlife experts like to call "opportunistic feeders" (a fancy way of saying "they'll try to eat any goddamn thing," a philosophy my dumber cat takes to its logical extreme) and they've also had thousands of years to get good at hanging around humans and scavenging their leftovers.  So in a really half-assed way, this is a natural-selection/co-evolution thing: the cats who figured out that all the weird-smelling meat the humans down by the docks were throwing away was both tasty and good for their coats had a basically limitless, zero-effort food source available and could reproduce to the point of ridiculousness.  There's a story I ran across a few times in my extensive research for this post about how this all started back in ancient Egypt, when the first crazy cat people domesticated the first cats by luring them into their houses with bits of fish.  That may be apocryphal (I couldn't verify it at even the Wikipedia level of rigor I usually use for these things) but it does make some sense; the cats who ended up domesticated were the descendants of the cats willing to be suckered into someone's hut by a chunk of some kind of meat they'd never seen before.  

It's worth mentioning that, since cats' digestive systems haven't really caught up with their relatively recent discovery that fish tastes awesome, fish really isn't that good for them.  Even ignoring all the mercury/lead issues that come with seafood in general, too much fish in the diet can leave cats susceptible to UTIs and other issues.  Speaking from experience the combination of a cat, a UTI, and any furniture you aren't willing to burn is one of the worst things there is, so make sure your cats only get fish in moderation, no matter how much they try to convince you otherwise.  

It's easy to forget that humans have had both intentional and unintentional effects on the evolution of all kinds of other species, from corn all the way to house cats.  Cats liking to eat fish makes no sense if you think about it in terms of what they did before humans were around (hunt small land critters and stay the hell away from water) but all the sense in the world if you consider it in terms of how they've lived with us for the past several thousand years (as unapologetic, indiscriminate scavengers).  And speaking of "unapologetic, indiscriminate scavengers," I'm totally going to bust my cats' chops about how my species evolved their species when I get home later.  I'm sure that will make me feel much better when I'm sleeping in the living room because they successfully crowded me out of the bed again.  

Monday, April 22, 2013

What Is the Pressure in Outer Space?

For those of you getting ready to hit "Post" on a comment reading "It's a vacuum, dipshit" or something similar, give me at least a paragraph to explain this one a little.  One of the rarely-discussed fringe benefits of doing semiconductor engineering is that you end up learning a lot about vacuum systems.  For various reasons (most of which have to do with contamination) almost every process associated with making and looking at things on the micro/nano scale has to take place in vacuum.  That means all the machines you use for said processes are basically vacuum chambers.  Eventually, one of the pumps or gauges or other expensive things connected to a vacuum chamber will break, at which point you'll have to figure out how to fix or replace it.  As a result, spending any time at all working in nanofabrication or related fields will get you well-versed in the finer points of the care and feeding of vacuum systems in a hurry.

These two things are not, in fact, equivalent even though we use the same word for both of them (vacuum swiped from www.bubblews.com, space-scape from www.outerspaceuniverse.org).

One of the first things you learn about vacuum environments is that "vacuum," at least in the real world, is a catch-all term that encompasses many, many orders of magnitude of sub-atmospheric pressure, some of which are much harder to maintain than others.  The vacuum created by your vacuum cleaner ("low vacuum") is about 500-600 torr, which is only a bit lower than the standard atmospheric pressure of 760 torr (my guess is that my monster Dyson Animal does a bit better than that.  Damn thing can suck the fibers out of a carpet if you don't watch it).  On the other end of the scale, the vacuum you need to keep a high-voltage electron gun from arcing is on the order of 10-9 to 10-11 torr ("ultra-high vacuum", or UHV), pressures so low that it honestly starts to make more sense to count them in particles per volume or something.   Most vacuum equipment isn't quite that extreme; typical base pressures on semiconductor gear tend to be in the 10-5 to 10-7 torr ("high vacuum") range, which is still pretty low but achievable without weird things like ion getter pumps.

Vacuum system status screen for my electron beam lithography system at work.  Pressures range from an astronomical 10-2 torr in the pre-vacuum area (G6), to about 10-7 torr (G4) in the main chamber where the magic actually happens, all the way down to 10-9 torr (G5) near the 100 keV electron gun.


As we know, space isn't empty, although it's pretty close.  Earth's atmosphere actually extends a good fraction of the way to the moon, if you define "atmosphere" as "higher pressure than interplanetary space" rather than "where I can breathe without dying," and by the same logic the sun's "atmosphere" is present throughout most of the solar system.  So space in earth orbit, on the moon, out in the solar system, and deep in interstellar/intergalactic space are all going to be "vacuum," but very different degrees of vacuum.

Let's start with low-earth orbit.  Low-earth orbit is generally defined as "high enough to not fall out of the sky that fast," or between 200-2000 km above Earth's surface.  You're generally considered to be outside the atmosphere in the conventional sense at this point.  From a vacuum-systems standpoint though, the pressure here isn't particularly low-- about 10-7 torr, or on the outside range of what's achievable with a single good vacuum pump.  The technical term for this part of the sky is the "exosphere"--not empty space, but nowhere near enough pressure to even begin to call it the atmosphere.

The exosphere extends almost an entire earth-diameter from the surface, apparently (image swiped from www.universetoday.com)

Head out to the moon and you'll unsurprisingly see the pressure drop quite a bit.  The moon being about 400,000 km from Earth (sidenote: holy shit that's far. We really went there? That's bananas), it's pretty much completely free of Earth's atmosphere; surface pressure is going to range from 10-10 (night) to 10-11 (day) torr, or right about at the practical limit of artificial "ultra-high vacuum" conditions.  That's about standard for interplanetary space in the solar system too, although it can vary a bit with solar wind flux.

That's pretty low, but even between the planets we're still sitting in an almost insubstantial cloud of "solar atmosphere."  We know this because as soon as you get well outside of the solar system, pressure drops again, to about 10-15 torr in the interstellar voids of the Milky Way galaxy.  That's substantially lower than anything we've been able to artificially create; even the best ultra-high vacuum systems top out at about 10-12 mBar.

Even the "empty space" of the Milky Way has some density to it though.  Calling it an atmosphere is probably pushing it a little bit, but the pressure out in the intergalactic void, light-years away from pretty much anything that could cause matter to gravitationally accrete, is even lower, about 10-17 torr.

So the "vacuum of space" can refer to about ten different orders of magnitude of pressure, depending on what you're calling "space."  It's important to note at this point that for anyone but a vacuum-systems engineer and/or pedant, there's no practical difference between 10-7 and 10-17 torr; each one will cause you to die of freezing/explosive decompression at exactly the same speed if you're exposed to it without protection.  Given that, it seems pretty reasonable to just call it all "vacuum," but it's interesting that stars and galaxies have atmospheres just like we do, provided you're extremely loose with the definition of "atmosphere."

Wikipedia has a neat table of pressure orders of magnitude, which is where I cribbed a lot of this stuff from.  You can figure out how astronomers were able to calculate, say, the pressure in intergalactic space by following the reference links.

Friday, February 1, 2013

What's the NFL Quarterback Passer Rating?

(NOTE: This post was written in early December 2012, but only recently edited to be publishable.  Most of the current-season NFL stats herein are therefore pretty nonsensical now.  Apologies in particular to Alex Smith, who I feel kind of bad for these days.)

I don't really like watching most sports.  Baseball, especially in a post-Moneyball world, holds all the excitement of watching a weighted random number generator update every few seconds for me.  Basketball at least moves quickly, but it's hard to get excited about a game where only the last few minutes seem to matter very much.  I don't have a snarky reason for not liking hockey (in principle it's fast, violent, and scoring is infrequent enough to matter) but I never quite got into it, despite basically learning to curse from watching my parents watch Flyers-Islanders games as a kid.

Football (note to non-American readers, if any: I'm not talking about that thing you play with the round ball and awesomely faked injuries.  Never got into that either, sorry) is a different beast.  It's violent as hell, deceptively strategic, and to a large extent totally unpredictable.  Anyone attempting to apply Moneyball-style "Sabermetrics" to the NFL runs into basically the same problem I did when I was trying to optimize my fantasy football team using the powers of math: there are so many variables, most of them coupled together, as well as totally random factors like injuries (which are much, much more frequent than in other sports), that we haven't yet built a supercomputer that can do anything useful with NFL stats analysis.  And quite honestly that's kind of awesome.

One downside of the fact that the NFL is completely impervious to rigorous statistical analysis is that it still uses a lot of the weird, probably anachronistic metrics that baseball has largely phased out.  For example, a key stat for receivers is number of catches, which is fairly meaningless without knowing how many times they were thrown catchable passes, which is going to depend in large part on the quarterback, who is relying on the offensive line to give him time to accurately throw the ball, etc etc.  Like I said, it's really hard to pull useful individual numbers out of a sport where everything is so interconnected, so we mostly just don't bother and count up what we can, whether it makes much sense or not, and hope averaging over a long enough period (usually the whole season) will get rid of most of the noise.  Which brings us to the weirdest artificial stat of all: the QB passer rating.

The QB passer rating was apparently designed in 1973 by Don Smith of the Pro Football Hall of Fame, who was trying to find a useful way to quantify QB performance holistically, since looking at a single statistic (completion ratio or points scored, for example) is a highly misleading way to evaluate all the things that make a good quarterback.   It's supposed to be an aggregate measure of quarterback performance, distilling completed passes, points scored, times sacked, interceptions, and other stuff into one convenient number that even ESPN reporters can understand.  If the number is higher, the quarterback is better.  It usually falls between about 50 and 150 and seems to correlate reasonably well with observed quarterback performance (Peyton Manning, for example, has a season rating of 108 as of this writing, while perennial object of ridicule in my household Jay Cutler is rocking about an 81), but sometimes seems to be way off (or maybe Alex Smith really is the third best quarterback in the NFL right now?  Who knows).  What you never see or hear about, probably because most sportscasters have no idea, is how this magic number is actually calculated.

I crammed the entire NFL passer rating calculation into one equation to give you an idea of just how complicated it is:


All four of those terms in the numerator are bounded, meaning they get replaced with zero if they go negative and aren't allowed to be higher than 2.375, just to add confusion.

Ignoring all the arbitrary weighting, the four relevant metrics here are completion percentage (comp/att), average yardage (yards/att), touchdown frequency (TD/att), and interception frequency (INT/att).  The first two metrics (completion percentage and average yardage) are pretty hard to argue with.  You obviously want a quarterback to complete most of his passes, and ideally you'd like those passes to be for as much yardage as possible.  Similarly, interception percentage is pretty important, since throwing lots of interceptions (hi Michael Vick!) is somewhat less than ideal.  TD frequency is the most problematic of the bunch.  Offenses with good running options are going to drive down the field a lot, get close to the goal line, and then run the ball into the end zone, meaning the QB doesn't get a touchdown credit no matter what he did on the drive (even if the QB is the one who runs the ball in, oddly enough).  So TD frequency is going to be biased pretty heavily towards QBs leading pass-centric offenses, although good quarterbacks are still going to generally throw more touchdown passes than bad ones.

Sum it all up and you get a number between zero and 158.3, which is a perfect passer rating.  Interestingly, while you'd think that would mean perfect passing (all completions, no interceptions, lots of yards and touchdowns) it's actually almost real-world attainable, thanks to the way each stat is weighted; a perfect rating corresponds to a lower bound of 77.5% completion percentage, 12.5 yards per attempt, and touchdowns on 11.875% of passes (and zero interceptions, obviously).  That's by design, since "perfect" is completely unachievable in some categories (100% of your passes are for TDs?) and just nonsensical in others (an average passing yardage of...INFINITY?); it was set up so the numbers would be low enough to be theoretically achievable, but still high enough that it's unlikely that a quarterback could hit the ceiling on any of them, let alone all four at once.  Unsurprisingly, that's been proven wrong; there are lots of QBs who have exceeded the "perfect" threshold on one or more of these stats over one game, and perfect single-game ratings have been achieved 41 times at last count, most recently by Robert Griffin III against my own perennially useless Philadelphia Eagles in November of 2012.

There are some pretty obvious problems with the passer rating formulation, as you'd probably guess.  Conspicuously left out of the numbers are sacks, fumbles, and any kind of rushing contribution, meaning "running" QBs like Cam Newton and RGIII are always going to get undervalued in the passer rating (it should be noted at this point, to be fair, that it is called a "passer rating" and not a "quarterback rating," so only taking passing-related stuff into account is technically kosher).  Similarly, getting sacked a lot or fumbling the ball won't hurt your rating (since there was no pass attempt), even though a QB that's constantly getting sacked and/or fumbling the (hi Michael Vick!) is not particularly useful.  From a more numerical standpoint, making it possible to "max out" the passer-rating contribution of any of the four statistics it measures is problematic.  Take, for example, two QBs with identical stats, except that QB #1 has an average of 15 yards per completion and QB #2 has an average of 12.5.  Since the completion-yardage term has to max out at 12.5 yards/pass, they'd both have the same passer rating; that extra 2.5 yards/completion that QB #1 has effectively don't count.  Luckily it's next to impossible to string out numbers like that over a whole season; while single-game perfect passer ratings have been achieved fairly often, the highest season-length passer rating ever was 122.5 (Aaron Rodgers 2011, if you were wondering).  The last (and presumably only) time anyone has maxed out even a single term in the passer rating equation was in 1943, when Sid Luckman posted a 13.9 yards/completion ratio.  So taken over a whole season, the "ceiling" values for all four terms are apparently high enough to not matter, even though they can underrate really good single-game performances.  Why the "perfect" number was left at 158.3, instead of just being normalized to 100, is completely beyond me; it doesn't really matter, it's just weird is all.

So the passer rating is kind of an imperfect statistic.  In the only way it matters at the end of the day (correlating to whether or not QBs can win football games) though, it's pretty good; in 2010; 80% of the NFL games played were won by the team with the higher-rated quarterback.  There have been some attempts to tweak the formula, most famously with ESPN's largely-ignored total quarterback rating, an attempt to take all the situational factors that could possibly affect a QB's stats into account.  It was insanely complex, drew on lots of weird hard-to-access stats like pass travel distance and something called a "clutch factor", proprietary (ESPN never revealed exactly how it was calculated), and not appreciatively better than passer rating at predicting wins.  In principle it wouldn't be too hard to just tweak the passer rating formula to, say, count rushes as pass attempts, rushing yards as pass yards and rushing touchdowns as touchdown passes (that's not perfect but it's a starting point), but to my knowledge nobody's done it, or if they have it hasn't caught on.

The entire clusterfuck that is the passer rating calculation is an almost perfect illustration of the mind-bending difficulty of applying statistical analysis to football.  It's an oddly-calculated, arbitrarily-aggregated statistic that has some pretty major omissions and issues, particularly when used to calculate single-game performance.  It also predicts quarterback performance fairly well when integrated over a good number of games (a season, say) and it's simple enough to calculate it that anyone with a pen and calculator (and access to Wikipedia for the formula, probably) can do it.  That makes it a pretty good metric, especially compared to previous ways quarterback performance was measured, and the fact that ESPN's attempt to take every single possible contributing factor of quarterback performance into account didn't produce appreciably better results speaks volumes for its efficacy.  That's the beauty of statistics; you don't need to know everything about the system you're analyzing if you can average over enough data and come up with a way to measure the results that helps you predict future behavior.  You don't need to know the thumb position, angular velocity, and air turbulance during 100 coin flips (basically the equivalent of what ESPN's system was trying to do) to know that about 50 of them will end up heads, to use a more concrete example.