Ron Paul for President, 2008!!

Thursday May 17, 2007

I don't normally write political articles; matter of fact, this is the first one. I feel compelled to voice my concerns about the upcoming presidential elections and to back a candidate that I believe strongly in.

Read more here: /articles/3

New Captcha System

Monday January 8, 2007

I hate spammers, they are the scum of the earth. I've been getting spammed like crazy lately via my comments form and my feedback form. I've been forced to implement a captcha system to try and prevent the not stop automated spamming. I'm sure whoever is doing it will figure out a way around it. Then I'll just have to change it, and we'll play this cat and mouse game forever. I am recording IP addresses now whenever someone posts a comment or sends me a message via my feedback form. Just be warned.

Java Function to Calculate Statistical Mode

Tuesday January 10, 2006

I looked everywhere on the web to find a java function to calculate the mode of an array of primitive ints. This will work for floats and long ints too, I suppose.

Anyway, since it was impossible to find, I figured I would post it here so maybe someone else can benefit.

public int calcMode(int[] sourceArray) {
	int mode = 0;	    
	Arrays.sort(sourceArray);	
	int[] valCounts = new int[(sourceArray.length-1)];
	for(int val:sourceArray) valCounts[val]++;
	int i = 0;			
	while(i < valCounts.length) {
		if(valCounts[i] >= valCounts[mode]) mode = i;
		i++;
	}
	return mode;
}

Hope this helps someone!


Archives