Math Fun

Saw a post at badscience.net which piqued my interest. Before you read it, first think about the odds of a mother having 3 children on the same day of the year. How likely (or unlikely, as the case may be) would you guess it is? Turns out it's a lot more likely than most people would think. OK, now you can click the link.

FWIW, thanks to my recently revived statistical knowledge, I did pick up that the correct odds wouldn't be 365*365*365, but rather just 365*365. That's because once the first kid is born, the chance of him being born on that day is exactly 1 (unless she's a Chinese gymnast in which case she'd be born 3 years later). Think of that the next time someone asks, "what are the chances of that happening again?". The answer is, the same as the chances that it happened in the first place (assuming the factors haven't changed, of course).

I also realized that the odds of same day births would probably be lower due to the dates of conception being non-independent. For instance, my wife and I planned to have our kids in the spring because she didn't want to be pregnant during the heat of the summer. So the range of possible days our kids could have been born is only a window of about 100 days. Would you believe they were all born inside that window? (Actually, one of them did sneak in a bit late, but within a decent margin of error).

tags: 

Kamailio Hashtables

A few weeks ago I completed an upgrade from OpenSER 1.2 to Kamailio1.5. Overall it's been working quite well and actually was not nearly as hard as I feared it might be. Now that I've got this new version with a ton of new bells and whistles, I thought I'd try out a few of them. One of the most exciting is shared memory hashtables.

First a quick primer on hashtables. Currently whenever the proxy needs a value from the database it simply queries the database and gets the value. Straightforward, right? But as the system grows, the database can be greatly put under strain. In my Kamailio cluster the single biggest CPU user is in fact the MySQL database by a large margin. And since the database changes pretty infrequently it would be nice if we could cache those values.

The problem is that Kamailio is a multi-process daemon, so what's cached in one isn't going to be cached in another. Enter shared memory hashtables. The same cache is shared among all the processes. Usage is pretty simple. Here's an example:

# IP based authentication
if ($sht(ht1800=>$var(fU)::ipauth) == null){
	if (is_user_in("From", "ipauth")){
		$sht(ht1800=>$var(fU)::ipauth) = "yes";
	}
	else{
		$sht(ht1800=>$var(fU)::ipauth) = "no";
	}
	$var(ipauth) = $sht(ht1800=>$var(fU)::ipauth);
}
else{
	$var(ipauth) = $sht(ht1800=>$var(fU)::ipauth);
}

if ($var(ipauth) == "yes"){
	# do whatever...
}

Don't worry too much about the nitty-gritty. First we check to see if the value is cached (($sht(ht1800=>$var(fU)::ipauth) == null)). If it's set, we just use the cached value and continue. If not, we have to ask the database (is_user_in("From", "ipauth")) and then save the result in the cache. It actually is that easy.

But the $64,000 question, has it helped? Luckily I thought ahead and got some data before I made the change. I grabbed the query log for a day before and after the change. I made sure to select two days where the call usage was the similar (1% difference). Overall there was a 20% reduction in SQL queries.

I only put in the one change as a proof of concept. Since it sure seems to have panned out I'll continue wrapping all my database calls with hashtable caches. One thing I still need to work out is how to invalidate the cache when I make a change through my provisioning system. And once I'm able to upgrade to Kamailio 3.0 I'll switch over to memcached, which has all the benefits of a shared memory hashtable but it's also clustered. Ooh, I'm so excited!

tags: 

dpkg --configure -a

So, just a word to the wise: dpkg --configure -a is not the same as dpkg-reconfigure -a. The former will continue configuring packages where an interrupted session left off. That's a good thing. The latter will reconfigure every package on your system. That, I think I can safely say, is a bad thing.

And no, I don't know anyone who's made that mistake recently. Nope, nobody.

tags: 

An Electric Lighting Audit

A while back I did an energy audit in my house. Fortunately for me I do live in an area served by cheap hydroelectric and coal energy. Well, fortunately for my pocketbook anyway. Regardless, I'm ever attempting to reduce my energy needs for both personal and altruistic reasons, hence the audit.

I surveyed all the lights in my home, noted their location, type, wattage, etc. When we moved in, most of the lights were old school incandescents. Altogether they added to 2918 watts of lighting. By swapping in a few compact fluorescents I've reduced that total to 1778. That's a savings of 40%. Impressive, but not so fast. Are all those lights used the same amount? Definitely not. The garage lights are on for probably only 10 minutes per day, on average. So clearly we need to factor actual usage into the equation.

So I also estimated the average usage of each bulb. Yes it was as fun as you think. What I found is that our 2918 watts account for about 4950 watt hours of actual usage per day. After my upgrades that dropped to 3274 watt hours, for a savings of 34%. If you notice that's less than the 40% we calculated earlier you get a brownie point. Indeed some of the lights we use the most are ones that I cannot reduce any further.

Even more interesting is something I've recently come to understand as I make a concerted, although to many unquestionably bizarre, attempt at understanding statistics. Quite often a very small number of things will often account for most of your results. A good example is the US federal budget. While McCain notably complained about earmarks in bills (which may be undesirable for many reasons) they account for a very small fraction of the money spent. If you want to make any reasonable dent in the outlays your best bet is defense, social security and medicare/medicaid which account by themselves for 65% of our expenditures.

Getting back to the original point (and hopefully avoiding a political tangent), I found that just a few of the lights in the house account for the majority of the electrical usage. In fact, the two sets of fluorescent lights in the family room account for nearly 60% of the total electricity. Even if I were to upgrade the rest my bulbs to compact fluorescents, it would only decrease my current usage by another 15%. I'm pretty much bound by those two sets of lights.

The exercise was a useful one. I'm on a slow quest to analyze all the electrical usage in the house. The light bulbs were the easiest to tackle. Some time I'll move on to the appliances and computers. The latter I'm rather apprehensive about. I might rather be ignorant.

My data files:
OpenOffice.org format
CSV format

tags: 

OpenWRT and WPA

For whatever reason last night my OpenWRT access point decided to stop working. My laptop would connect for a second and then disconnect. I tried another wifi card and it did the same thing, which eliminated my laptop as the culprit. I turned off WEP and was able to connect. The weirdest thing was when I would try to turn WEP back on, I got this error (in bold):

[root@alberto ~]# iwconfig wl0
wl0 IEEE 802.11-DS ESSID:"zmonkey.org"
Mode:Master Frequency:2.437 GHz Access Point: 00:0F:66:4A:DF:08
Tx-Power:19 dBm
RTS thr:2347 B Fragment thr:2346 B
Encryption key:<too big>

I'm not comfortable without encryption (although honestly I would like to run a captive portal alongside my encrypted network), so after a few reboots and unsuccessful attempts to get WEP working I gave WPA a shot. It's really what I should be running anyway but I've had WEP set up for so long I just didn't feel like dealing with it.

But luckily, it worked out quite flawlessly. Following a guide I found here I got it set up quite simply. I did have to reboot to get the changes to take, but not a big deal. The only remaining problem is reliably getting my laptop to use WPA. That's the real reason I've delayed. I've gotten it to work before, but it's sometimes been a pain. All in the name of progress, I suppose.

tags: 

Autism

I've been following a blog for a while by Jeremy Robb. He's a Linux nerd which is how I came upon him, but turns out he's also the dad of an autistic son. He's chronicled the experience of learning to adapt to his son's condition and it's a great resource for anyone in a similar boat. His most recent post is an excellent story and would be a nice place to start from.

I'm really not sure why I'm so interested in autism. Something about it just strikes me. Maybe it's the fact that when I was in first grade my teacher thought I was autistic. Who knows, maybe I am. At this point in my life I doubt it's really worth investigating. It just really concerns me that lately so much bad information about autism has been going around, and I'd really like to get the word out so that people who are truly autistic can get the correct help and understanding.

tags: 

MindTouch Review


I heard about MindTouch on FLOSS Weekly last week and decided to give it a try. It's a fork of MediaWiki, the framework behind Wikipedia. I've been looking for a wiki for a while so this was a perfect opportunity. Based on the FLOSS Weekly interview I had high hopes, but unfortunately I was quite let down.

The tech in MindTouch is actually pretty cool. The install goes very smoothly. It requires a number of web packages, including Apache, MySQL, and PHP which I already had installed so nothing further was required. The setup was just a few more clicks and away I was going, setting up my wiki.

At that point things seemed great. I spent a few hours creating pages and linking them around. It worked rather smoothly. I really like the embedded FCKeditor which made markup a snap. Life seemed good.

I did have a few problems with the configuration, mainly because just about anything interesting you want to do with the software, beyond an RSS feed, is locked away in the "enterprise" versions. I wanted to set up LDAP authentication or Twitter integration, but no go. Looking through the version lists it seems that they're trying to only put the bare minimum into the open source version. But I figured it was worth a test drive for a few weeks at least.

And then Monday morning hit and I got a curious email in my mailbox. Sam Montes had written to see if I needed any assistance with my MindTouch install. He just wanted to know more about my company and how we planned to use it. Say what?! I went through the roof. At no point during the install was there a "phone home" option displayed. If there had been you can rest assured I wouldn't have selected it (in fact there was an option to join their mailing list and I declined). The fact that they would spy on my like that leads me to suspect their motives. How do I know they're not keeping tabs on all my data? At this point I can't trust anything they say.

I responded to Sam and voiced my concerns. He replied with some drivel about providing the highest level of service and integrity. I'm sorry but I just can't forgive this affront of my privacy. This is the sort of behavior I might expect from a proprietary software company, but I expect more from open source developers.

I've received further email from MindTouch because apparently they put me on their mailing list, despite my request otherwise. I just can't get past this and I shall be uninstalling MindTouch soon. What a shame.

tags: 

A Reasoned Treatise On Health Care

This is an article which is a long time coming. Unless you've had your head in the ground, you can't have missed the discussion on health care going on lately. I've had plenty of chance to muse over the issues myself, both on my own, with my wife and with a number of my friends. I've heard a lot of good ideas, but also some misunderstandings and I'd like a chance to lay things out as I see them.

Background

In my time as a working adult I've had the opportunity to experience pretty much the whole range of health care options. I started at the top, working for a large company who had quite a few options. We picked the one that matched our coverage needs the best, based on the fact that we were planning to start a family. When that momentous occasion came, we ended up payed very little out of pocket. It was quite nice, in fact. And for all that, the cost was very reasonable, my share of the cost, anyway.

Many Americans are in this boat and I think for them, their perspective is clouded. They see a decent system, payed for by the economy of scale of a large company, which gives them good options at decent rates. But such is not the case for everyone.

Jump forward just a few months. The tech bubble burst and I ended up out of a job. For over a year we squeaked by without any insurance. It was rather scary actually. Our new son needed shots, of course, but they were $70 a pop at the doctor. He recommended we go to the county health department instead where the shots where subsidized down to about $10. We had a few things come up. Our son had some breathing trouble early on, something that delightfully has disappeared, and every time he'd have trouble we'd be stuck with a hefty doctor's bill. We would panic if he started having trouble on a weekend and generally we'd (well, he would) suffer through until Monday morning when a doctor's office visit was much cheaper.

I would not wish that experience on anyone, but it's something 40 million Americans experience every day.

After suffering for a while I finally landed a decent job at a small company. The drawback was they didn't offer any benefits, but compared to slogging extended warranties or worse, it was a huge step up. Once we'd saved up a small amount, managed to move out of the in-laws' house, we looked to our options for health care. We came away somewhat depressed. In the end we found a plan on the open market which gave us basically what we needed for basically what we could afford.

Since we were coming in without a current health plan they were very emphatic about not covering preexisting conditions, especially pregnancy. In fact, to cover pregnancy at all required a separate rider, a separate waiting period, and a separate deductible. That was the time of our lives so we shelled out the extra cash and put our family on hold for a bit. Things worked out OK, but I would rate that experience somewhat lower than our first insurance scenario.

Eventually we moved on to a new company, where I'm still working in fact, and they had some pretty good plans. The deductible was higher than we would have liked, and it didn't quite cover as much as we wanted, but it worked and it wasn't outrageously expensive either. But nothing stays the same, and this was no different. Every year our premium went up by $40 a month. Every month some small aspect of the plan was reduced or dropped. Vision care, gone. Dental care, optional. Coverage amounts were lowered but somehow we kept paying more.

The current situation is that we're now on a high deductible health plan coupled with a health savings account. There are some benefits and some drawbacks, the primary one being that every expense is now out-of-pocket making for a strong disincentive to seek necessary care. I'm not yet certain how I feel about this plan but so far (it's been just 3 months) I'm not convinced.

My Options

So hypothetically speaking, if I'm dissatisfied with my situation, what can I do? Well, I do have a few options.

  1. Drop my health care. Obviously that's not a reasonable solution, not with the costs of health care in this country. Just about anything is preferable to that.
  2. Seek out a health care on the open market. For all the people working for small companies, or who own their own business, that's their only choice. The costs are high, the benefits not all that great, and the selection is limited. Consider the amount of leverage a single customer has and you can see it's not really in the company's interests to be competitive.
  3. Get a new job. In this economy that's often easier said than done, and the simple fact is I like my job. I like where I work and what I do. And even more importantly, why should that have anything to do with my health insurance? Does my employer choose my car insurance? My home insurance? My grocery store? The simple fact is that it's rather ludicrous for a health care plan to be tied to employment at all. It's merely a historical happenstance that it occurred that way at all and now we're stuck with it. Life would be much simpler, for both me and my employer, if the two were separated completely.
  4. Or just stick with the one plan that's offered me.

Socialism

Let me switch topics just a bit and address a point which I think is entirely overblown by far too many people: the term "socialism". In some circles even mentioning the word is like preaching vi usage to an emacs mailing list. Too geeky for you? How about wearing a Yankees jersey to Fenway Park? You get the idea I hope. Many people have made "socialism" a religious issue when it needn't be so.

I put the word in quotes above because it's a very mis-understood word and used completely out of context. Consider for a moment a few very socialist institutions: your local police force, the school system and the Forest Service. If we were to take a strictly capitalist approach to those organizations we would have private armies, private schools and private forests. Well, we do. We have both, so don't let anybody convince you that one cannot exist in the presence of the other.

But just looking at the police for a minute, I think we can see that a capitalist police force would be much less efficient. Those with money to hire guards would be able to protect themselves. Those without, well they'd have to fend for themselves. That in turn would encourage more crime by those more destitute which would lead to a pretty miserable feedback loop I fear. So it's in everybody's self-interest to provide for a common police force. And in this country I would argue we've done a good job of it. There's the occasional account of corruption or pandering, but far and away most cops are good folks doing a good job.

We've established that some scenarios just play out better with a socialist scheme, and I would also argue that many scenarios work better with capitalist setups. And many more are a mix because dogmas rarely work perfectly in the real world. The task we face is to select the one that is the best fit. We shouldn't let ourselves be driven by blind ideology or clever witticisms about liberty or freedom. Never let yourself be so vain to think that your ideals are without fault.

Possibilities

Well then, where does that leave us? First and foremost, before you make any choices you need to go watch Frontline: Sick Around The World from PBS. It's the most honest, unbiased collection of the facts of health care around the world that I've ever seen. I reserve the right not to debate anyone who has not watched it. Yes, it's that good.

Next, take a glance at two good Washington Post articles about our current system and the proposed changes.

Now that you've done that (I'm very patient, aren't I?) I can suggest to you what I would prefer. I would like health care to be divorced from employment. I would like minimum health insurance standards to be enforced on insurance providers and required of citizens, with subsidies for low income levels. I would like the option to buy up to better insurance if I felt it would benefit me.

Speaking to a few specific points, I would like to have the public option merely for the fact that it fills a needed gap and provides a certain incentive for private companies to stay competitive. I'm not convinced yet that co-ops would fill that role, but I'm not opposed to those either.

I'm also not against a single payer system (aka the Canada system) in principle. The devil is always in the details but I don't believe we should exclude it just because it's "socialist" or because the moose people do it.

The biggest stumbling block I see to coming to consensus on health care, to bringing affordable insurance to all Americans, to reducing the nightmare that is our heath system, is that people aren't willing to listen to each other any more. I see too much hate. Too many ideologues. Far too much 24 hours cable news. We have to forget our biases and start acting civilly again. If we do, I think we all stand to benefit from the results.

tags: 

UTOSC 2009 Is Full Steam Ahead!


And with that, I've uploaded all my slides for the Utah Open Source Conference. My goal was to have them ready by last night, so I'm a bit late. Still better than last year where I only had one presentation and I was still updating my notes the night before. If you're looking for me make sure to check the schedule as there have been some changes, and there may well be more to come. Also look for my late addition where I'll be joining Gabe Gunderson of izeni to talk about VoIP (specifically FreeSWITCH and Asterisk).

tags: 

Pages

Subscribe to zmonkey.org RSS Subscribe to zmonkey.org - All comments