Thursday, March 24, 2011

3-24-11: "Neutral Site" MATLAB Script

I'm not a big college basketball fan. I casually follow my sister's school, the University of North Carolina at Wilmington, but since they didn't make the NCAA Tournament (or the NIT or the one below that), I decided to throw $5 into a now broken bracket and watch a select few games during the tournament.

One thing I couldn't help but notice is that one team always seems to have a home court advantage over the other teams. I realize that with 16 teams, some one is going to be closer, so I don't really think there's much the NCAA can do about it within reason. But it got me thinking: how could I write a script that would figure out the best neutral site given a group of teams?

I threw something together in MATLAB (code below) in a couple hours. It's very simple and is absolutely the most inefficient and brute force way to go about solving the problem, but it is scalable. I ran through it a few times with six locations and got it to simulate in about 50 seconds. Not great, but this isn't a really time-critical application.

I assumed all teams are just points on a 1001 x 1001 grid (with the origin at the center), and chugged through all 1,002,001 points on the grid and calculated the distance to each set point (team location). The user enters how many teams and then enters the coordinates for each team (I didn't make it very simple for the user; something to work on). For each test point (all 1,002,001 of them) I have it calculate the Coefficient of Variation for the set of distances between each team. The point with the lowest COV is the selected "neutral site" as it is roughly equally far from each team. The script displays the neutral site's coordinates and COV, and plots all of the points with the neutral site filled in.

%% Neutral Site Calculator

% Determines the ideal "neutral" site among an assortment of points

% The number of sites is user configurable

% The site locations are entered by the user

% The script assumes all sites are located on a set grid of points

% Author: Pat Canny

%%

clear;clc;

disp('Neutral Site Calculator')

disp('Assume a 1000 x 1000 grid')

%% User Inputs

num_sites = input('Enter number of sites: ');

while num_sites <=1

disp('Number of sites must be greater than one')

num_sites = input('Enter number of sites: ');

end

set_point_x_array = zeros(1,num_sites);

for i=1:num_sites

set_point_x_array(i) = input('Enter x coordinate for site : ');

end

set_point_y_array = zeros(1,num_sites);

for i=1:num_sites

set_point_y_array(i) = input('Enter y coordinate for site : ');

end

%%

%% Calculate average distance (vector magnitude) from each test point

test_point_x_array = -500:500;

test_point_y_array = -500:500;

grid_size = length(test_point_x_array)*length(test_point_y_array);

distance_matrix = zeros(length(test_point_x_array),length(test_point_y_array));

d = zeros(1,num_sites); % initialize vector magnitude array

tic;

for j = 1:length(test_point_y_array) % y dimension

for k = 1:length(test_point_x_array) % x dimension

for i = 1:num_sites % calculate vector magnitude to each set point

x = set_point_x_array(i);

y = set_point_y_array(i);

test_x = k-501;

test_y = 501-j;

d(i) = sqrt((test_x - x)^2 + (test_y-y)^2); % vector magnitude

end

distance_cov_sqd = (std(d) / mean(d))^2;

distance_matrix(j,k) = distance_cov_sqd;

end

end

toc

min_distance_cov_sqd = min(distance_matrix(:));

[m,n] = find(distance_matrix == min_distance_cov_sqd);

neutral_site_x = mean(n)-501;

neutral_site_y = 501-mean(m);

%%

%% Display results

str1 = ['The neutral site is located at: (',num2str(neutral_site_x),',',num2str(neutral_site_y),')'];

disp(str1)

str2 = ['The minimum distance COV is: ',num2str(min_distance_cov_sqd)];

disp(str2)

close all

figure(1)

scatter(set_point_x_array, set_point_y_array)

hold on

scatter(neutral_site_x, neutral_site_y,'filled')

grid on

Wednesday, March 16, 2011

3-16-11: Smoking Rates and Social Security

I heard on NPR this morning a report about a study stating that the rate of smoking in America has significantly decreased since the 1960's. The rate of lung cancer death has also gone down. The number of smokers has dropped, but the amount of smoking being done by the average smoker has also been going down. All of these things are good. I, for one, lost a dear relative to lung cancer, and it's great to see more people aren't being taken away from their families too early due to smoking.

I also heard a report yesterday, again on NPR, about social security, and how politicians in Washington, specifically Democrats, keep away from discussing it due to it being a "political third rail." In 2010, for this first time in its 75+ year history, Social Security paid out more than it took in. At its current rate, Social Security will burn through its cash by 2037, about 15 years before I plan on retiring. Many politicians don't see it as a real problem.

For some strange reason, probably because I've been following great economics blogs like Marginal Revolution and Freakonomics for a while now, but I saw these two stories as being related. Wouldn't it be a bad thing for Social Security if people aren't smoking as much nowadays? People would start living longer, dying less often, and therefore would be receiving benefits later in life. People currently receiving Social Security grew up in the smoking generation, and are probably more susceptible to various forms of cancer caused by tobacco products. As the years go on, those receiving benefits will have likely lived a healthier lifestyle than the generation prior. If you can link smoking and tobacco use to cancer, and plan out 20, 30, and 40 years from now, fewer and fewer people will have been exposed to the same diseases. If we do run out of funding, people my age in their mid twenties will have paid the benefits for a generation of less healthy Americans. Hardly a reward for healthy living.

In general, life expectancy increases with each coming generation. Granted, the obesity rate is higher among youths than it was 30 or 40 years ago, so there is a bit of an offset when it comes to overall health. But nevertheless, the average lifespan of an American receiving Social Security benefits will not be shrinking any time soon.

Why not fix Social Security now? Passing it off as unimportant is a true political cop-out. At the very least, couldn't it be discussed?

Saturday, March 12, 2011

St. Lawrence Tops Yale 4-3 in OT

New Haven, Connecticut --- The Yale Men's Ice Hockey team didn't make things easy for themselves last night, losing 4-3 in overtime to St. Lawrence in Game 1 of their best-of-three weekend series in the Quarterfinal round of the ECAC Men's Ice Hockey Championship Tournament. Yale went into the game as the favorite, and, despite surrendering a fluke goal 53 seconds in after goaltender Ryan Rondeau completely mis-played a looping dump-in from St. Lawrence defender Patrick Raley, Yale looked to take the first game from the visiting Saints.

Yale is led by a powerful offensive corps of Hobey Baker hopefuls Denny Kearney and Broc Little, who each had multi-point games last night. Kearney opened Yale's scoring 3:10 into the game to tie it up 1-1 on a power play goal. Yale then began to apply continuous pressure on the undersized St. Lawrence squad, which resulted in two additional power play goals from Yale captain Jimmy Martin. Going into the third period with a 3-1 lead, Yale looked to have complete control of the game.

St. Lawrence had other thoughts. Led by senior captain Aaron Bogosian, the older brother of Atlanta Thrasher defender Zach Bogosian, the Saints played a very physical third period and tied it up at 13:47 with a power play goal from first year forward Greg Carey.

The overtime period was a very even contest overall, which mirrored the game as a whole. Each team had its chances, but it was St. Lawrence's Carey who put it away to win Game 1 for the Saints.

Walking away from Ingalls Rink last night, the student body looked deflated. Yale gave up a 3-1 lead, and missed several chances. St. Lawrence goaltender Matt Weninger had a strong game, giving up three difficult power play goals and making 31 saves. Yale did not look the stronger side during even strength play, and frankly was gifted a power play which resulted in their first goal after a questionable roughing call against St. Lawrence senior forward Sean Flanagan. Yale goaltender Rondeau had an inconsistent game after the first goal, with some obviously shaky rebounds in the third period and imperfect positioning on Bogosian's goal. Despite the size disadvantage, St. Lawrence used 6' 6" Nic Vangog very well going into the offensive zone, sending the first-year forward directly at the Yale net to cause disruption in the defense. A classic and proven method which wore Yale down.

Game 2 of the Quarterfinal series is tonight at 7:00PM at Ingalls Rink. Can Yale fight back to send the series into a deciding game tomorrow night? Let's hope so.

Wednesday, March 9, 2011

Tuesday, March 8, 2011

3-8-11: Making a Career Move

Last week I gave notice to my current employer that I am leaving the company to take a position at another company in the Boston area. The new company is GE Aviation, based in lovely Lynn, Massachusetts. My current employer, Sikorsky Aircraft, is based in Stratford, CT. I spent a bit more than half of my childhood growing up in the Stratford area (in Easton, to be specific), so it’s not easy for me to leave the area. My parents moved to the South two years ago, though, so I’m the only one left. In fact, most of my family lives in Massachusetts, so I’m moving closer to family. My last day at Sikorsky is March 25th.

The job hunting experience was taxing. I spent a considerable amount of my free time searching for positions, not to mention the multitude of phone screens and a few on-site interviews. It is, however, exhilarating. The prospects of a new job, even in the same industry, bring a new sense of purpose. You begin to examine where you are in your career and life, and some decisions are difficult but necessary to make. I like my job at Sikorsky. I like my group. I like my co-workers. The program I work for is moving from the design to the testing phase, so my favorite thing to do, design, is quickly fading out of my current role. Not to say I don’t like testing what I have designed, but it did come into play. My decision was primarily based on wanting to get an MBA, and UTC’s changes to its Employee Scholar Program won’t allow me to get the MBA on the company dime. Other factors included location and salary considerations. Let me just state that I do think UTC is a fine employer.

Applying for jobs is very, very easy in this day and age. There are tons of great sites out there. I ended up sticking primarily with Indeed and LinkedIn. Believe it or not, Craigslist isn’t too bad, either. Monster and CareerBuilder, however, were a bit of a let-down since they don’t attract smaller employers due to their exorbitant fees. Getting a job, though, is tough, since many companies receive many, many applications for each posting.

Here’s some advice to job seekers: AVOID RECRUITERS. I went through a couple recruiters at some points in the months-long search, and regretted it in both cases. If they insist on you filling out an application on their website, don’t do it. They’ll insist that it’s “just part of the application process” and that it “will help them identify employers” but it’s just a ploy for them to get your personal information so they can spam you. I got two phone calls on consecutive days from one recruiter asking why I hadn’t filled out their application yet (I was genuinely busy), but once I took the time to complete the online application (took almost two hours), I heard absolutely nothing from them for months. When I e-mailed the associate, I was told “Things are slow with this employer.” Very frustrating.

That was a direct application through a recruiter. The other instance where recruiters came into play was when I unwisely put my résumé on public display on Monster. BIG mistake. I got a phone call from a head-hunter (I won’t even call them a recruiter in this case) based on the west coast. He said he had some positions in the Seattle area (probably Boeing) and was wondering if I was interested. I said I was interested in the Boston area, to which he replied: “Oh, are there aerospace companies near Boston?” Let’s see: GE, UTC, Boeing, MITRE, Raytheon, MIT Lincoln Labs, BAE, General Dynamics, Lockheed Martin, Northrop Grumman, Ametek… Not to mention other smaller companies like The MathWorks and Charles River Analytics who service the larger companies. Such blatant ignorance of the job market led me to remove my résumé from public view that day.

I learned a lot from the experience. I got in some great practice doing interviews. I am very good at behavioral interviews. Companies generally ask the same questions (I got this one several times: “Can you think of a time where you had a conflict with a co-worker or project partner? How did you resolve the conflict?”), so it’s good to have canned responses. The toughest interview I had, by far, was with The MathWorks. I applied for an opening as an Application Support Engineer, which I thought I’d be great at since I use their products (MATLAB, Simulink, and Stateflow) in my current position. Boy oh boy, it was a TECHNICAL interview. I got a call from the interviewer and was told “No reference materials allowed.” The questions themselves weren’t hard, but they were geared towards people who were full-time graduate students. I was familiar with all of the concepts, but they wanted me to give abstract definitions. It was awful. Didn’t get that job.

Another thing I learned is that small companies seem to be a lot more fun than big companies. There are more risks involved as far as job security, but I was very excited after interviewing at Charles River Analytics. Unfortunately, the job description and my experience didn’t quite match up. They wanted someone with more experience in Java, which I had studied during my Master’s, but I’ve never used it professionally. The position was in the Cognitive Systems group, but I was more intrigued by the work being done by another group within the company (the Sensor Systems group). I don’t know where my career will take me, but I’d recommend any one looking for something different than the big company environment to look at small companies and startups.

Now it’s down to the logistics of making the move. I’m in contact with about a dozen people from three different companies regarding the move (which is being paid for by GE): Cartus, Electric Insurance, and Castine Moving & Storage. The lady and I found an apartment in Medford through a broker (Apartment Rental Experts; great people). Our current landlords aren’t too happy about us moving four months early, but we get reimbursed for some of the rent, so it’s not a big deal. We’ll see how it goes…

Monday, March 7, 2011

3-7-11: End of the Ski Season

This past weekend marked the end of the ski season for me. I don’t much like spring skiing, so I’m pretty sure I’m packing it in until next winter.

I’m happy that it went out on a high note, for the most part. This weekend was the On Snow Winter Carnival, an annual three-day celebration of winter hosted by the Connecticut Ski Council at a selected Vermont skiing resort. The past two years have been at Mount Snow. Last year’s event was awesome in many regards, but the event this year was still pretty good. I think most of it was due to the weather (this year had one good day, one mediocre day, and one very rainy day; last year had three sunny days). I am sure glad I took Friday off from work to get in a great day in the sun. Saturday was very foggy and misty, and I didn’t even bother skiing with all the rain yesterday.

I made significant progress this season while gaining a considerable amount of confidence. I still have my moments of fear now and then, but I don’t mind the steepness. In fact, I seek it out in moderation. I spent a lot of time working on my mechanics this weekend, and had a few marvelous runs. Mount Snow is great for intermediates (but terrible for beginners). Most of the main face consists of blue cruisers and their grooming is awesome. I was lucky on Friday morning to get first tracks in a few spots. I stopped on “Thanks Walt” over on Sunbrook to appreciate the view and the silence – it was awesome. I really wish the lady could have skied, but she was sidelined due to her injury a few weeks ago at Killington. She was bumming, but still hung out.

One of the things I can appreciate after two good seasons, with 10+ days on the mountain each season, is learning a new skill as an adult. I was three years old when I began learning to ice skate. I honestly don’t remember ever not being able to skate. However, I vividly remember my first time on skis as an adult. I was thrilling and terrifying. When you’re 6’5” tall, 215 pounds, and 24 years old, you don’t want to fall. It hurts. When you’re only five or six, you have nothing to lose! Kids fall all the time. They cry at first, but it doesn’t really hurt all that much. It may take them longer to learn than adults (plenty of people learn to ski as adults and learn faster), but kids have the advantage of having less fear. Most of my friends who ski learned as children or teenagers, and they’re obviously years ahead of me. But I doubt they were where I am now after 23 days on the mountain.

I genuinely enjoy skiing now. For years I avoided it, mostly due to other athletic endeavors. I wasn’t allowed to ski for most of my life due to ice hockey. When I was first approached with the prospect of learning as an adult by the lady, I was very hesitant. I was able to successfully avoid skiing with my ex-girlfriend, but I knew I wasn’t going to get away with it this time. It’s pretty daunting, especially when you’re being exposed to an entirely new culture while learning many new skills. I didn’t want to move too quickly, though. A good friend of mine started snowboarding when he was 23 and ended up going to Jackson Hole in Wyoming in his second season. My other friends say he can handle the tough terrain, but could perhaps use some work on mechanics. There’s a fine line between being brave and being reckless. I like to build up my confidence before hitting the tough terrain.

I achieved my goal for the season of successfully managing a black diamond trail from top to bottom. I did that a few weeks ago at Killington on “Superstar” – and, despite being exhausted at the bottom, was thrilled. Though I’m still not quite there with carved turns, I have significantly reduced my habit of making “hockey-stop-like Z turns” down the hill. My legs have thanked me.


My goals for next season are:

1) Be able to solidly handle a difficult mogul run
2) Be able to manage a relatively difficult glade run
3) Master the carved S turn

Steeper terrain provides me with the requisite energy to make my turns, and forces me, like it or not, to keep my weight more forward. I look forward to the challenge.

See you next season, ski slopes.