Monthly Archives: June 2007

Math for pill poppers

I’ve always felt that mathematics is a useful tool in everyone’s daily life. Here is an example.

Recently, I was prescribed some medicine, and it was to be taken twice daily: once in the morning, and once before bed. However, I made a couple mistakes. The first morning, I took twice the dosage in the morning. And, in the evening I dutifully took another dosage, but made the same error and took a double dosage again. I realized my hapless error just as I downed the requisite glass of water. So what was I to do. Clearly, the drug was now above the prescribed concentration in my bloodstream, so should I continue the normal schedule the next morning?

We can use math to figure this out. Most drugs taken in orally can be considered to have a “half-life” in your bloodstream. Yes, this is the same concept of half-life in radioactivity. Basically, your body gets rid of stuff from your bloodstream at a constant rate, given the current concentration of the ‘stuff’ in your blood. This is modeled in math as an exponential decay function. To illustrate, have a look at these equations.

equations
The simplest form is (1), which illustrates the basic shape of the drug concentration. We add a step function (2), which allows us to make just the part after the dose is administered, along with a t0 time offset parameter to give a more accurate shape in (3). (4) adds a half-life parameter, which is scaled away from the irrational e to become (5). This is the concentration resulting from a single dose, over all time, parameterized by dose administration (6). While you are taking the medicine (t=0 to t=t_finish), we can represent your idealized concentration as (7). The summation variable i gets incremented by 0.5 each time, which flies in the face of normal convention. Sorry about that. The code farther down is correct.
All simple, right? Let’s plot things. I used Mathematica to generate these plots. Equation (6) becomes:

dose equation
Note that in this function, x is time (in days), and t is the time offset. I threw the equation together before thinking about how best to represent things for others… Sorry…. The 1.3333 factor is the the half-life constant. The half-life for my medicine was roughly 18 hours, which is 0.75 days, which is roughly 1.3333 (close enough for my (government’s) purposes).
And then we can plot our ideal concentration.

dose, ideal

This is how the concentration would look like if I took the medicine exactly as directed. We can see that the concentration is roughly periodic after about two days of accumulation. But! I messed up, remember? How can I adjust my next doses to return to the ideal case?

dose, adjusted

You can see that at t=0, my medicine concentration is twice the ideal(conc = 2), since I took twice the dosage. Accordingly, the second dose, which was also twice too large, boosted my concentration to about 3.25. In this scenario, I skipped the third dosage (second day, morning), to bring my concentration roughly the same as the ideal case at t=1.5 . So there you go.

The bottom line is that I should skip the third dose if I take two double-doses on the first day. Yay! Isn’t math fun? This amount of math is no more than what a high-school graduate should have, and probably less than what an overachieving middle schooler could do.
I’ll be sure to post other examples math in real life when I get the gumption. Have a nice day!

Regulating broadband and wireless

For the record, I am in favor of unlicensed frequency spectrum and in favor of “net neutrality”. By “unlicensed frequency spectrum,” I’m referring to the sort of free use of sections of the electromagnetic spectrum (e.g. the 2.4Ghz Industrial/Scientific/Medical band) that allow people to transmit without having to purchase the spectrum from the government.
I used to think that the availability of unlicensed spectrum was unassailable as a public good. IEEE 802.11-based networking (i.e WiFi) has completely transformed computing and has allowed people to create/share/consume content and to pervasively communicate with others at levels completely unprecedented and completely wonderful. Wireless networking first got really popular when I was in graduate school, but it now seems inseparable from university campus life. Those not belonging to university communities or (tech) companies with their own deployments may not understand how WiFi has changed the game. Outside of those environments, we have coffee shops with free/semi-free wireless (lovely) and other places with paid wireless (*sigh*), but if your experience is only with those few spots, then you won’t understand. It’s like getting internet at home through dial-up versus ‘broadband’. Broadband (esp. with static, public IP addresses) is just a far more pervasive networking experience, and it changes the way we get information. Wireless networking has that effect.

But wireless networking existed before WiFi and 802.11, so why didn’t we go wireless earlier? The main reason for the creation of 802.11 and its subsequent explosion was the availability of the unlicensed 2.4Ghz band. Now anyone could produce equipment operating on that band and sell that equipment to anyone else. There’s hardly any incentive to do this if that spectrum is licensed, since only the spectrum owner will buy such equipment, and even a humongously rich owner has less money than, uh, the rest of the world. Sometimes the lack of control in unlicensed spectrum is a pain– my wireless connection drops every time my colleague uses the 2.4Ghz cordless phone– but my connection would not exist without unlicensed spectrum that enabled the creation of my wifi hardware.

This being how I feel, I read Wired’s article on an upcoming proposed frequency auction and was struck by the linked articles that decry open-access spectrum. Corporate welfare for dot-com billionaires? Please. Open access spurs innovation. Do you have a wireless router at home? It’s conceivable that (insert traditional telco name) could’ve taken part of their licensed spectrum and sold people wireless hardware (for laptops and home routers), but did they? No. Would they have? Probably not. Look at where they are with wireless data plans and hardware. Is that market flourishing? Every laptop sold has wireless these days, but not connectivity to a 2.5/3G data carrier. I should be happy that 3G data is available at all. It just costs them a lot more to provide the service than it costs for lots of independent places to provide WiFi hotspots.

Perhaps I should have expected an opponent of open access to decry net neutrality as well, but I wasn’t expecting him to be so bold as to say that net neutrality is “anti-consumer.” Come on. Net neutrality is equalizing in the way that it levels the costs of bandwidth for everyone. It means that a kid putting his skateboarding videos up on a webserver in his garage has his data treated the same as CNN trying to stream advertisements and breaking video of (insert rich young celebrity name)’s arrest for DUI.

Anyway, this article on broadband by the same misguided soul who decries open-access talks about how there’s no broadband problem in the US. Oh, I don’t know about that. I think we’ve just gotten used to the slow pace at which our telecom companies give us speed. Verizon is trying to roll out their FIOS fiber service with 5down/2up Mbps at $40 and 15down/2up Mbps at $50, while Japan had 100Mbps Ethernet available a few years ago (and is working on mandating Gbps Ethernet in a few years). 20Mbps became prevalent in South Korea years ago, so in 2004, Korean ISPs had to compete on service, since 20Mbps was, well, uninteresting. Besides, 90% of South Korean homes had 3Mbps or greater at home, with overall average of 8Mbps.
I think Japan and South Korea look at our level of broadband the way we look at dialup.

I’ll be the first to say that America has a harder problem in deploying telecommunications– we have a huge area of deployment and we built our cities around cars as transportation (which now seems rather foolish with oil and anthropogenic abrupt climate change)– but surely we can do better. I still think America (particularly Silicon Valley) invents much of the technology in use for all of this, so don’t we have some advantage?
I’ll take a moment here to say that with corruption and other troubles in corporate governance, smaller companies tend to be more efficient at producing value. There’s less people to spread out blame. Higher-ups can more easily see the impact of their decisions on their employees in the trenches and junior employees are less likely to assign any air of nobility or rich-and-famous-glow to their higher-ups. And in any case, the world changes quickly. Smaller companies are more agile, and younger companies have less traditions to reinvent when they adapt.

Anyway, have a nice day. And remember that it will be hard for people older than Bill Gates to understand these new technologies, so go with someone younger, or in the industry. There was something said about technology and our perspective as we age: “Things which existed in our 20s are natural and obvious, while things invented after our 30s are indistinguishable from magic.” Please correct this quote if you know the source.