Saturday, June 22, 2013

The Police - "Invisible Sun"

One of my favorite songs by The Police. The video is unavailable online in the U.S. RSS folks: click through if you can't see the video below.

Monday, June 10, 2013

Function Version: Determining Effective APY

In case you're more into functions:


function effective_apy_midpoint = effective_APY_midpoint(P,Y,n)

% Determines the effective annual yield (APY) given a principal amount, 
% a final amount, and number of years.

% Need to calculate r (APY)
% Use mid-point algorithm
% Formula is Y = P(1+r)^n

% Assume range of r from 0 to 5 (0 % to 300%)

r_min = 0;
r_max = 5;
current_guess = r_min;
Y_temp = P*(1+current_guess)^n;
num_guesses = 1;
while Y_temp ~= Y
    if (Y_temp > Y*0.9999) && (Y_temp < Y*1.0001)
        break
    end
    if Y_temp < Y
    next_guess = (current_guess + r_max)/2;
    else next_guess = (r_min + current_guess)/2;
    end
    Y_temp = P*(1+next_guess)^n;
    if Y_temp < Y
        r_min = next_guess;
    else r_max = next_guess;
    end
    current_guess = next_guess;
    num_guesses = num_guesses + 1;
    Y_temp = P*(1+current_guess)^n;
end
effective_apy_midpoint = current_guess;

MATLAB Script: Determining Effective APY

It's ugly, and I'm not sure if "midpoint algorithm" is the actual name of the algorithm. I remember doing this for my Numerical Methods course.



% Determines the effective annual yield (APY) given a principal amount, 
% a final amount, and number of years.
clear
clc
P = input('Enter principal (beginning) amount: ');
Y = input('Enter final (ending) amount: ');
n = input('Enter number of years: ');

% Need to calculate r (APY)
% Use mid-point algorithm
% Formula is Y = P(1+r)^n

% Assume range of r from 0 to 5 (0 % to 300%)

r_min = 0;
r_max = 5;
current_guess = r_min;
Y_temp = P*(1+current_guess)^n;
num_guesses = 1;
tic
while Y_temp ~= Y
    if (Y_temp > Y*0.9999) && (Y_temp < Y*1.0001)
        break
    end
    if Y_temp < Y
    next_guess = (current_guess + r_max)/2;
    else next_guess = (r_min + current_guess)/2;
    end
    Y_temp = P*(1+next_guess)^n;
    if Y_temp < Y
        r_min = next_guess;
    else r_max = next_guess;
    end
    current_guess = next_guess;
    num_guesses = num_guesses + 1;
    Y_temp = P*(1+current_guess)^n;
end
toc
r = current_guess;
effective_apy = r*100;
output_str = ['Effective APY = ',num2str(effective_apy),'%'];
num_guess_str = ['With ',num2str(num_guesses),' guesses.'];
disp(output_str)
disp(num_guess_str)

Wednesday, June 5, 2013

Product Idea: Restaurant-Provided Credit Card Roulette

As a male in his mid 20s, I have come across the "Credit Card Roulette" phenomenon a few times. Personally, I think it's better to just alternate picking up the check, but I can see the appeal of random chance when it comes to paying for a meal.

For those unfamiliar with the game, the basic form involves all diners in a party throwing their credit cards in a hat or similar container. A random credit card is drawn from the hat, sometimes by the server to maintain objectivity, and that card is used to pay for the entire meal. Usually this game is played at the end of the meal to prevent people from ordering more food than they normally would if they were paying for it themselves.

But that particular moral hazard got me thinking: what if restaurants provided a system that would let patrons play Credit Card Roulette before the meal began in exchange for a 10% discount off the entire meal? The restaurant would stand to gain, of course, if non-paying diners ordered more than 10% of what they would normally order.

I'm sure some clever game designer could figure out exactly what the interface to diners would be (kiosk at the table, smartphone app, etc.), but the concept would cater well to the gambling culture in America.


Benefits:

- At worst, the losing player would be treating their friends or colleagues to a meal they enjoyed. And most gamblers just like the adrenaline rush, right?

- Payment would be easier and faster if it's all going on one card (good for diners and the restaurant).

- Losing diners would be encouraged to return, thinking they wouldn't have to pay again because of the general misunderstanding of probability (see: the lottery). That's good for the restaurant.


Nobody really loses.