Monday, April 30, 2012

Alpine, NJ 07620: Nation's Most Expensive Zip Code

When New Yorkers brainstorm of expensive areas in the Metropolitan region, the following answers are common: Upper East Side, Greenwich Village, Riverdale, Hamptons, Westchester County, etc. While all of those area do feature expensive real estate properties, the New Jersey borough of Alpine tops the list as the nation's most expensive zip code, according to Forbes in October 2011. Situated at the northernmost tip of Bergen County along the Hudson River, only about 10 miles north of George Washington Bridge, Alpine maintains a much quiet feel with its community of 2,500. Topping the extremity in Alpine is the Frick Mansion. Listed at $53 million, it features over 30,000 square feet of space in its gated privacy.

What exactly is Alpine like? "This is the kind of place where people come not to be known," according to a local real estate agent. Little commerce exists; in fact, there is not even a high school or mail delivery, which helps to lower the tax rates. Wealthy individuals have chosen Alpine for its privacy. Notable residents include Chris Rock, P Diddy, and CC Sabathia. In such a high-privilege environment, there is a high demand for services like landscape. Mowing one's own garden is "almost unheard of."

Yet to an outsider traveling through the city, Alpine seems fairly typical. On Closter Dock Road, near the intersection with Route 9W, a typical gas station ran by working-class men operates quietly. The most consistent noise comes from the Palisades Parkway that runs along the Hudson River, connecting Alpine to the GW Bridge. On sunny days, cyclists ride along the popular Route 9W. At the borough intersection, a plain "Entering Boro of Alpine" sign welcomes motorists and cyclists.

Despite the wealth, the market isn't booming in Alpine. The Frick Mansion used to have an asking price of $68 million. Overall, prices dropped 23% in 2010. "For Sale" signs are seen across town. Nevertheless, 07620 has consistently ranked among the nation's most expensive zip codes, cherished for its duality of quietude yet proximity to New York City.

Sources:

Sunday, April 29, 2012

Fermat’s Little Theorem Illustration

Fermat’s Little Theorem says that "If p is a prime number and a is an integer such that gcd(a,p) = 1, then a^(p-1) = 1 (mod p)." The proof of this aside, let's just see this in action with some concrete integers. Recall that a^(p-1) = 1 (mod p) equates to a^(p-1) / p = something remainder 1.

Example 1: p = 2, a = 11
  • gcd(2,11) = 1
  • a^(p-1) = 11^1 = 11
  • 11 mod 2 = 1
Example 2: p = 3, a = 4
  • gcd(3,4) = 1
  • a^(p-1) = 4^2 = 16
  • 16 mod 3 =  1
Example 3: p = 5, a = 2
  • gcd(5,2) = 1
  • a^(p-1) = 2^4 = 16
  • 16 mod 5 = 1
 Example 4: p = 11, a = 3
  • gcd(3,11) = 1
  • a^(p-1) = 3^10 = 59049
  • 59049 mod 11 = 1

Tuesday, April 24, 2012

Probabilistic Payoff from Rushing to Train Stations

See related post: Expected Wait Time given Multiple Trains

Is it worth it to run and rush to the train station? It might payoff if running there gets us on an earlier train. But it might not payoff, as we simply end up waiting a longer time for the next train. Does it make a difference what time of the day it is?

To answer this question, we need just two parameters: the frequency of the arrival event, and the extent to which the rushing shortens the time getting onto the site. Let's use the train example for easier understanding. Suppose that the train comes every 10 minutes. As we saw on the previous post, the average wait time until the first train is 5 minutes. Now, suppose that we run to the train station and get there 3 minute earlier than if we had walked.

It turns out that this answer is much simpler than the calculations from the last post. The average wait time is still 5 minutes. However, the probability that we end up catching an earlier train now is 3/10. We can easily see that we'll be able to catch an earlier train, if a train comes within those first 3 minute that we wouldn't have been there otherwise. Given 10-minute frequencies, that probability is simply 30%. This helps us answer the question of whether or not rushing to the arrival site will benefit. Using the variables defined earlier, the probability of benefit is simply (shortened time) / (frequency). In the event that (shortened time) > (frequency), that probability simply caps at 100% certainty.

That simply results also helps us answer whether time of the day affects this decision. Since during rush-hours the trains come more frequent (lower frequencies), rushing to the station will be more likely to be beneficial then. It makes intuitive sense, because in the same 3 minutes or whatever the shortened time may be, there will be a higher chance that a train comes during that period then.

Wednesday, April 18, 2012

3-0 Playoff Series Comebacks in Professional Sports

Vancouver is still hoping. Vancouver Canucks, which recently won the President's Trophy for the second straight season, after finishing the regular season with the best record in the entire National Hockey League, are currently down 3-0 to the 8th-seed Los Angeles Kings in the first round of the playoffs. This comes after last year's Stanley Cup Finals, in which the Canucks lost Game 7 at home to the Boston Bruins, triggering riots in the streets. Vancouver is hoping that the return of Daniel Sedin, who has been out for the past few weeks with injury, will reignite the team. However, the chances are against them. Very few professional sports teams have come back from 3-0 hole in best-of-7 series.

Only 4 times in best-of-7 series across the professional sports have teams come back from being down 3-0 to win the series. However, when miracle comebacks do happen, most of them have come in NHL. The only non-hockey series comeback belong to the 2004 Boston Red Sox during the ALCS, the historical upset of the Yankees on its way to win the World Series. No teams in NBA have rallied from being down 0-3. The other 3 comebacks all have happened in the NHL. Most recently, Philadelphia Flyers rallied back against the Boston Bruins in 2010 Conference Semifinals. Last season in the NHL playoffs, two teams down 0-3 in the series rallied to force, but only to lose, Game 7. Canucks were actually on the other end of that, beating the Chicago Blackhawks. Overall though, in NHL playoffs series when teams are up 3-0, they only clinch the series in Game 4 on 59% of the times.

Can the Canucks salvage its season tonight and move the series back to Vancouver? Or will they exit early in disappointment? Game 4 is tonight in Los Angeles.

Sources:

Population Density Comparison: Manhattan and Greenland

When it comes to population density, Manhattan and Greenland represent the two extremities. Manhattan, with population nearing 1.6 million in slightly less than 23 square miles of land, the population density is 69,467.5 / square mile, according to the US Census Bureau. Now onto the other end, Greenland's land area is 2,166,086 square km, according to the CIA World Factbook. According to the same source, the latest population estimate is 57,695.

To first convert to the same units, Manhattan's population density is 26821.55 per square km. For Greenland, the same figure will be 57,695/2,166,086 = 0.0266355999 per square km. The difference then is 1,006,981.26 or 7 orders of magnitude. To put that into perspective, since Manhattan's population is 1.6 million, under Greenland's population density, slightly fewer than 1.6 people will be living in entire Manhattan. Wouldn't that solve the city's congestion issues?

Sources:

Expected Payoff from Mega Millions

Lottery games usually advertise the enormous amount of money that can be won, and the luxurious life that such winning would bring. But everyone knows that the chance of winning the jackpot is miniscule. So in this battle of extremities, does the large amount of money or the small chance win out?

Information taken right from the Mega Millions website reveals that it takes $1 to play a game. The calculations put aside for each of these possible prizes, here are the monetary amounts of the prizes with their associated chances of winning:

Prize Chance ^ (-1)
Jackpot 175,711,536
$250,000 3,904,701
$10,000 689,065
$150 15,313
$150 13,781
$7 306
$10 844
$3 141
$2 75

The ultimate jackpot prize value varies consistently, but at present is estimated at $65 million. To get the expected payoff, simply multiply each earning by its likelihood, and sum the products. This can be easily done in Excel.

When the jackpot is $65 million, the expected payoff is only 55.18 cents. In fact, it takes slightly less than $144 million for the expected payoff to just reach $1. The jackpot recently reached record high of $656 million. With that, the expected payoff was slightly over $3.91. However, tax was not considered in any of these situation. Furthermore, as in the case of the recent record high, the winning amounts are split if more than one winner arises. In all, the small probability of winning seems to dwarf the large amounts of potential winning.

Sources:

Friday, April 13, 2012

Displaying a Pyramid on MATLAB

This script of codes demonstrates the usage of the fprintf function to properly insert spacings within MATLAB. It also demonstrates the use of nested for loops to make a two-dimensional representation. Given a positive odd integer n as the input, this code displays a pyramid of base length n and height of n/2.
%The input integer 'n' denotes the width of the base of the pyramid
%If 'n' is even, it'll be the same as making a (n-1) sized pyramid
function pyramid = input(n)
%The height of the pyramid will be (n+1)/2
for i=1:2:n
    %Spacings on the left: 'c' is used for a character here, in this case the empty space ' '
    for j=1:(n-i)/2
        fprintf('%c',' ')
    end
   
    %Actual pyramid marks
    for k=1:i
        fprintf('%c','*')
    end
   
    %Spacings on the right: same chunk of code as the code for the left spacings
    for j=1:(n-i)/2
        fprintf('%c',' ')
    end
   
    %Carriage return after each line
    fprintf('\n')
end
If n = 5, for example, the output will be like this:
    * 
  ***
*****
While using the fprintf function, care needs to be taken to ensure the use of the correct conversion letter. Refer to the link below for further references.

Source:

Thursday, April 12, 2012

Mileage Rates: Overestimation or Underestimation?

The Internal Revenue Service (IRS) sets the business mileage reimbursement rate, which on its website is stated as the "optional standard mileage rates for employees, self-employed individuals, or other taxpayers to use in computing the deductible costs of operating an automobile for business, charitable, medical, or moving expense purposes." This rate is also often used by employers to compensate employees for operating their own vehicle for the employer's business purposes. The business mile rate in 2012 is 55.5 cents/mile, unchanged from the second half of 2011. At a first glance, this number may be a huge overestimation. After all, even overestimating gasoline at $5/gallon and less-than-stellar fuel economy of 15 mpg, that's only 33.3 cents/mile. However, while gasoline is the main cost factored into the mileage rate, other fixed and variable costs, notably depreciation is factored in. But the mileage rate doesn't make a distinction between the type of cars.

Let's see how much gasoline factors into the mileage for different type of cars. Data from the Department of Energy lists the most and least efficient vehicles. For two-seat cars, Honda CR-Z was listed as one of the most efficient, while Bugatti Veyron was listed as the least efficient. Next, we can use AAA's Fuel Cost Calculator to estimate the cost of gas needed to travel between two cities. For this exercise, we chose New York as the starting city and Cleveland as the destination. For this 452-mile trip, the 2011 Honda CR-Z needed 14.58 gallons of gasoline. For the same route, the 2012 Bugatti Veyron needed a whopping 56.5 gallons. AAA's estimate used a price of around $3.96 / gallon for the trip, which meant that the New York - Cleveland trip gasoline cost for the CR-Z and the Veyron was $57.75 and $223.77, respectively.

The first noteworthy data is the vast contrast. The CR-Z is about 3.87 more fuel efficient than the Veyron, allowing 31 mpg compared to 8 mpg. Now what does the IRS mileage rate compare? For the 452-mile trip, the cost from the mileage comes to $250.86. That number is only 1.12 times the gasoline cost for the Veyron, while it is 4.34 times the gasoline cost for the CR-Z.

Depreciation and other costs of maintenance may be difficult to measure. But here's a quick way to estimate its order of magnitude. Take the Honda CR-Z; its price as listed on its website is around $20,000. Let's give a conservative estimate, in order to overestimate the depreciation value, that its lifespan is only 100,000 miles. In that case, we can divide the numbers and get $0.20 / mile depreciation value. For the 452-mile trip, this calculation will yield $90.4 in depreciation. That's over 30% higher the total gasoline cost for the CR-Z, so the depreciation figure isn't a trivial value that can be dismissed.

While it may be difficult to exactly calculate the true costs of driving, the calculations here reveal that depending on the fuel economy of the car, the IRS mileage rate may overestimate or underestimate the driving costs. In either case, the mileage rate will cover the current gasoline cost, even for least fuel efficient Veyron. But the calculations here have shown that other costs cannot be ignored, even if costs like maintenance and particularly depreciation are always not tangible. In fact in an April 2011 report, AAA compiled all of the costs of driving and operating various types of vehicles. At this time, the business mileage rate was only 51 cents / gallon. The AAA report stated that the total cost ranged from 45.1 cents for a small sedan to 63.3 cents for a minivan. So in the end, the mileage isn't a gross overestimation by any standards; in fact, for many models of vehicles, it doesn't even fully offset the true total costs of driving.

Sources:

Wednesday, April 11, 2012

Alcoa Inc (NYSE: AA)

Alcoa, the manufacturer of aluminum products, is the first company in the Dow to announce quarterly results. Late Tuesday, Alcoa announced net income of $94 million for Q1-2012, or 9 cents per share, which is actually down 69% from Q1-2011; but it is up from the $-191 million incurred from Q4-2011. More importantly, the results were ahead of analysts' estimates of 4-cent loss per share. As of now, shares of Alcoa have climbed 7.74% to 10.04. Also notable is the climb in most of the US and European stock indexes. The S&P 500 finally stopped a five-day slide, triggered by lackluster March job reports and high borrowing costs in Spain and Italy, that saw its index fall 4.3%.

During the first quarter this year, Alcoa announced the closure of  plants in the United States, Spain, and Italy, cutting over 500,000 tons of aluminum capacity. This cutback came after aluminum prices are down 23% on the London Metal Exchange in the past 12 months, averaging $2,219 a ton. Meanwhile, Alcoa is engaging in billion-dollar venture in Saudi Arabia, which it says will be the "world’s most efficient integrated aluminum production plant." Finally, Alcoa is boosting 2012 aerospace sales forecast by 3 percentage points, and projecting that the US automobile sales will grow 7 to 12%. Its view on the global market also remains optimistic, as it "reaffirms global aluminum demand growth projection of 7% and a global aluminum supply deficit."

Sources:

Tuesday, April 10, 2012

Random Walk: Simulation Given Varying Grid Sizes

Related previous post: Random Walk: Foundational Codes

In the previous post, we saw the codes, both in Java and MATLAB, that calculate the number of unit steps in cardinal direction that would take to get to one corner to the other extreme corner of a 10 x 10 grid. The Java codes were altered to create a RandomWalk object class and a driver class. In the driver class, we tested for grid size of 2 to 101 inclusive, and for each size, ran 100,000 trials. The average of the 100K trials was computed for each size and the results are summarized here:

It shows that the size of the grid and the average number of steps follow a quadratic pattern. The high coefficient of determination (R^2) is actually quite deceptive for low values of the size. In fact, when the size is 11 or smaller, the equation's prediction differs by at least 5%. Here are the values for those sizes:

Grid Size Simulation Avg. Eqn. Prediction    Error
2 4.005 1113.372 276.986
3 18.020 961.017 52.330
4 44.527 836.168 17.779
5 85.095 738.825 7.682
6 141.726 668.988 3.720
7 214.755 626.657 1.918
8 305.839 611.832 1.001
9 414.232 624.513 0.508
10 542.374 664.700 0.226
11 690.416 732.393 0.061

For each of the 100 size, 100K trials were run. Each trial on average took just over 38K steps, upon considering this entire range of grid sizes. Overall, that's around 100*100K*38K = 380 billion iterations in this simulation. This simulation took just over 12 hours to finish running on Eclipse.

Simulation of Expected Wait Time

Related previous post: Expected Wait Time given Multiple Trains

In the previous post, a simulation with 100 million trials was run on MATLAB to verify that in a scenario of two trains running independently with frequency of 10 minutes, the expected waiting time until the earlier train is 10/3 minutes. This was the code in a .m script, along with added comments for explanation:
%We will run 100 million trials, results to be stored in an array
results = zeros(1,100000000);

for i=1:100000000
    %Initiate the variable 'lowest' at 20 for now
    %It will eventually record the time to the earlier train
    %sure be less than 20
    lowest = 20;
   
    %Let both trains start at a random time t=(0,10)
    %This is the first round of the trains
    train1Start = 10*rand;
    train2Start = 10*rand;
   
    %There will be trains 10 minutes ahead, representing the second round
    another1Train = train1Start+10;
    another2Train = train2Start+10;

    %Let the passenger board the platform at a random time t=(10,20)
    passenger = 10*rand+10;
   
    %The next train may be train 1 from first round
    lowest = passenger-train1Start;
    %Or it may be train 2 from the first round
    lowest = min(lowest, passenger-train2Start);
   
    %Or it may be train 1 from the second round
    %Positive value verifies that passengers arrives become the train
    if passenger-another1Train>=0
        lowest = min(lowest, passenger-another1Train);
    end
    %Finally, the earlier train may be train 2 from the second round
    if passenger-another2Train>=0
        lowest = min(lowest, passenger-another2Train);
    end
   
    %Record the time to the earliest train into the results array
    results(i) = lowest;
end

%At last, we want to return the results
disp('Mean:')
disp(mean(results))
disp('Standard deviation:')
disp(std(results))
Upon running the script, the result comes out as a mean of 3.3334 (occasionally may get 3.3333) along with a standard deviation of 2.3572.

Monday, April 9, 2012

Expected Wait Time given Multiple Trains

Suppose a train comes every 10 minute, and we go to the train station at a random time. How much time do we expect to wait before the train comes? In this scenario, it's 5 minutes, because the probability is uniformly distributed between 0 and 10 minutes. This situation highly resembles waiting at the 116th Street - Columbia University station for a Downtown 1 train. Sometimes we get lucky and don't wait much; other times, we luck out.

Now suppose we take the train down to 96th Street and want to transfer to the 2 or 3 train. Suppose each 2 train and each 3 train comes every 10 minutes, independent of each other (this is a bit unrealistic, since they can't both come at the same moment on the same tracks). Anyhow, say if our destination is Chambers Street, we don't care whether we take the 2 or the 3 train; we just want to get on the train that comes first. What's the expected wait time here?

The expected time here is the time that elapses when neither the 2 train nor the 3 train comes. Let's backtrack first:
  • Let f(x) be the probability density function of waiting x minutes at the platform. The function f(x) is simply 1/10 for x = [0,10], and 0 for the rest of the values of x.
  • Let F(x) be the cumulative density function, which is simply the antiderivative of f(x) at F(x) = x/10 for x = [0,10]. 
  • In example, F(7) = 70% means that probability that waiting time is 7 min or fewer is 70%. Or in another word, 1-F(7) = 30% means that there's a 30% chance that waiting time is 7 min or greater.
Let G(x) be the waiting time when there are two trains, each with f(x) = 1/10 for x = [0,10]. Then, the term 1-G(x) denotes the probability that neither train comes within x minutes. That happens with neither of the trains comes within x minutes. Since the two trains come independently in this exercise, 1-G(x) = (1-F(x))*(1-F(x)). Using the example of x=7 again, 1-G(x) = (30%)^2, so G(x) = 1-.3^2 = 91%. This means that there's a 91% chance that one of the trains will come within 7 minutes. So we saw that G(x) = 1-(1-F(x))^2. Recall that F(x) = x/10 for x = [0,10]. Therefore, we have G(x) = 1-(1-x/10)^2. Here's the graph of that:

What's the average waiting time? We need the probability density function g(x), which is just the derivative of G(x), and then integrate x*g(x) over the variable x from 0 to 10. Upon executing that command on MATLAB:
syms x;
y = 1-(1-(x/10))^2;
pdf = diff(y,x);
average = int(x*pdf,x,0,10)
The average time comes out to be 10/3 minutes. To verify that, a simulation of 100 million trials was run on MATLAB. The code isn't shown here (maybe shown in a future post), but the result came dead on at 3.3334.

What if there are more than 2 trains? With a frequency that isn't every 10 minutes? No problem. Look back at G(x) = 1-(1-x/10)^2. If we have understood what each number and variable has stood for, we should have no problem deducing that in the general situation with n trains, each independently coming every f minutes, the cumulative density function is G(x) = 1-(1-x/f)^n. To get the average, differentiate G(x) by x to get g(x), and integrate x*g(x) over x from 0 to n. Just for sake of curiosity, suppose it's rush hour at Chambers Street, and we can catch either one of the 1/2/3 trains to go back Uptown. If each train's frequency is 5 minutes, the average expected waiting time, following the formulas investigated here, is only 1.026 minutes.

For reference, the source of inspiration for the investigation of this subject was the countless amount of time spent waiting on the Subway platforms.

Jobs Report and Progress in Relation to Population Growth

Stocks in the United States are falling today, on the first trading day since the Labor Department announced Friday that employers added 120,000 jobs in March. That's only half of the 240,000 added in February, and way below the expected estimate of around 200,000. The unemployment rate did fall to 8.2%, but that's mainly attributed to decreasing labor force. The CNN report states that "job growth of around 120,000 is just about enough to keep up with population growth." Given the average rate of population growth in the United States, what exactly is the amount of job growth over month just to keep the same employment rate?

From the US Census Bureau data from 2000 to 2010, we can calculate the average monthly population growth rate. Then taking the current US population, we can estimate the monthly population increase:
  • 308,745,538 = 281,421,906*(1+r)^120
  • r = 7.724e-4
  • Δpopulation = 313,332,804*7.724e-4 = 242018.258
Now we need figures on the labor force:
  • 142,034K employed in March 2012
  • 142,034K / 313,332,804 = 45.33% of population employed
At last, Δpopulation * (% of population employed) = 242018.258 * 45.33% = 109,706.876. This means that nearly 110,000 jobs need to be added each month just to accommodate the rising population and keep the unemployment rate steady. Given this number, it's plausible to claim that the jobs added in March barely offset the population increase.

Sources:

Processing List of Numbers into Excel

Suppose we have the a list of numbers separated by comma and space that we need to get into Excel sorted. What's the fastest way to do this? If the data is small, it might be faster to type each. But as the data gets large, that will be very inefficient. Preserving the accuracy will also be more difficult as the number of entries increase. So let's begin with a data like this in a string of text:
84, 49, 61, 40, 83, 67, 45, 66, 70, 69, 80, 58, 68, 60, 67, 72, 73, 70, 57, 63, 70, 78, 52, 67, 53, 67, 75, 61, 70, 81, 76, 79, 75, 76, 58, 31
Here are the steps to generated a sorted list out of those numbers into a column in Excel:
  1. We want to get rid of the commas. Copy the string of text into Microsoft Word. Hit Control + F to bring Find and Replace menu. Click the Replace tab. We want to enter the comma "," under 'Find What' and nothing "" under 'Replace With'. Hit 'Replace All'.  The string should now be cleansed of commas.
  2. With no commas now, it's ready to be used by Excel. Copy this cleansed text and pasted into an Excel cell. Let's call this cell A1. The entire cleansed string should be in A1.
  3. We want to separate each number into its own cell. First highlight A1. At the 'Data' tab at the top of the Excel window, click on 'Text to Columns'. Choose the 'Delimited' option and hit 'Next'. Under the option of 'Delimiters', check the 'Space' box, and hit 'Finish'. Now each number will occupy its own cell.
  4. The data are all on the same row. However most times, we want the data on the same column. To convert, first highlight all of the values on A row. Control C to copy. Now highlight cell A2. Right-click the mouse and choose 'Paste Special'. At the bottom of the menu, check the 'Transpose' box and click 'OK'. The values now will be pasted in a column.
  5. Delete the top row by first clicking on the '1' row numbering. The entire top row should now be highlighted. Right-click and choose 'Delete'. We already have the data in the column, so the row of data is unnecessary.
  6. Finally to sort, first click 'A' to highlight the column. From the 'Home' tab at the top, choose 'Sort & Filter' and select 'Sort Smallest to Largest'. If a menu pops up about whether or not to expand the selection, leave it the way it is and click 'Sort'. Since we only have one column of data, this is not relevant.
At the end of this process, all of the numbers will be sorted in a column in an Excel sheet. When there are many entries of data to input, this method of processing will be much efficient than simply typing each one out.

    Friday, April 6, 2012

    Comparison of Apple and GDP

    Apple Inc. (NASDAQ: AAPL) has been dominating the news. Its shares opened the year at $409.40. Barely more than one quarter into 2012, the prices closed Thursday at $633.68. This is a whopping increase of 54.78%, and some analysts predict a climb as high as $1000 per share. Already with the current prices, the market capitalization (which is the simplest way to measure how much a company is worth) of Apple is around $590.82 billion. How does this compare to the GDP of major world economies? How do the per-employee figures of Apple compare with GDP per capita of major world economies?

    The CIA World Facebook provides the latest figures of GDP. Specifically, the numbers are expressed in purchasing power parity (PPP), which is the "sum value of all goods and services produced in the country valued at prices prevailing in the United States." According to those figures, the GDP of the United States is just about $15 trillion, just slightly below that of the European Union. China comes second at $11.29 trillion. Apple's market capitalization of $590 billion puts it right underneath the GDP of Thailand at #25 ranking in the world. No African countries eclipse the figure, but South Africa would come right underneath with $555 billion.

    According to 10-K form filed by Apple on September 2011, Apple claimed that it had "approximately 60,400 full-time equivalent employees and an additional 2,900 full-time equivalent temporary employees and contractors." Using the figure of 60,400 employees, Apple's worth per employee in terms of market capitalization would be around $9.78 million. In 2011, Apple reported $25.9 billion of net income, or about $430,000 per employee. In comparison, according to the CIA World Factbook, Liechtenstein, the Central European country with a population barely above 36,000, had the highest GDP per capita at $141,100.

    Sources:

    Thursday, April 5, 2012

    Yahoo! Inc (NASDAQ: YHOO)

    It was announced Wednesday by the ADP, the payroll processor, that the private sector in the United States added over 200,000 jobs in March. Nearly half of them were added by small businesses. On the same day, Yahoo announced that it would cut its workforce by 2,000, which is 14% of its employees and the largest layoff in the history of the company in its 17-year history.  The cuts will help save about $375 million annually, and this was the first major decision under new CEO Scott Thompson, who was quoted to say that these cuts were needed to make the company “smaller, nimbler, more profitable and better equipped to innovate."

    Shares of Yahoo actually climbed 9 cents to close at 15.27 Wednesday. But these figures are way shy of the company's heydays. Shares topped over $100 in early 2000, and even as late as 2005, topped over $40. While the S&P has recovered the losses since 2008, Yahoo's shares have not climbed above $20 since end of 2008. Financials show that total annual revenues have fallen from $7.2 billion in 2008 to just under $5 in 2011. In fact, Yahoo's revenue of $353,000 per employee is far below the $1.2 million mark observed in Google and Facebook, and also less than half of that of Microsoft. Much of these figure underscore the failure of Yahoo to capture social networking and competition it faces in advertisement. In recent months under Thompson, Yahoo has also sought to sue Facebook for patent infringements. Facebook has filed a countersuit against Yahoo.

    Sources:

    Wednesday, April 4, 2012

    Random Walk: Foundational Codes

    Imagine a square grid, and start at one corner of it. On each step, if permissible within the boundaries of the grid, move one unit in a randomly chosen cardinal direction. Repeat until the other extreme corner is reached. How many steps does it take? In this post, we'll deal with the programming codes that simulate this scenario. Java and the equivalent MATLAB codes are presented, with commenting on the Java code.

    Java version:
    public class RandomWalk
    {
     public static void main(String[] args)
     {
         int[] coor = new int[2];    //this houses the (x,y) coordinate
         coor[0] = coor[1] = 1;        //begin at (1,1)
         int move = 0;
         final int size = 10;        //this creates 10x10 grid
       
         while(!(coor[0]==size && coor[1]==size))    //game continues while not at the extreme corner
         {
             boolean valid = false;    //indicates whether or not a valid location has been found to move to
             while(!valid)            //while there isn't a valid location, search for one
             {
                 double rand = Math.random();
                 int[] test = new int[2];    //use to house the next potential location
                 test[0] = coor[0];
                 test[1] = coor[1];
               
                 if(rand < 0.25)    //corresponds to moving north
                     test[1]++;
                 else if(rand < 0.5)    //moving east
                     test[0]++;
                 else if(rand < 0.75)    //moving south
                     test[1]--;
                 else                    //moving west
                     test[0]--;
               
                //next location is valid if it's within the boundaries of the grid
                 if(test[0] >= 1 && test[0] <= size && test[1] >= 1 && test[1] <= size)
                 {//if a valid location is found, transfer the coordinate points
                     coor[0] = test[0];
                     coor[1] = test[1];
                     valid = true;
                 }
             }//otherwise, repeat the loop to try to find another valid location
             move++;    //increment move if a valid move is made
         }
         //after the end of the game, indicate the total number of moves
         System.out.println("Number of moves: " + move);
     }
    }

    MATLAB version:
    coor = [1,1];
    numMoves = 0;
    size = 10;

    while ~(coor(1) == size && coor(2) == size)
        valid = false;
        while ~valid
            r = rand;
            test = zeros(1,2);
            test(1) = coor(1);
            test(2) = coor(2);
           
            if r < 0.25
                test(2) = test(2) + 1;
            elseif r < 0.5
                test(1) = test(1) + 1;
            elseif r < 0.75
                test(2) = test(2) - 1;
            else
                test(1) = test(1) - 1;
            end
           
            if(test(1) >= 1 && test(1) <= size && test(2) >= 1 && test(2) <= size)
                coor(1) = test(1);
                coor(2) = test(2);
                valid = true;
            end
        end
       
        numMoves = numMoves + 1;
    end
    numMoves

    In subsequent posts, we'll work with this code and add variations.

    Monday, April 2, 2012

    Groupon Inc (NASDAQ: GRPN)

    Shares of Groupon are dropping Monday, after the company announced a revision of fourth quarter revenues. Groupon had reported a loss of $37 million for its fourth quarter, but on Friday the company further reduced the quarterly revenue by $14.3 million and net income by $22.6 million, after discovering that executives had failed to set aside enough money for customer refunds.

    Launched in 2008, Groupon "features a daily deal on the best stuff to do, see, eat, and buy" according to its website. It earns revenue by offering discounted deals to its subscriber base and splitting the value of the deal with the merchant that offered the deals. While revenue has been growing, rising from $313 million in 2010 to $1.62 billion in 2011, Groupon still reported a negative income in 2011, as it has for every year in operation and all past four quarters.

    The recent announcement was concerning for Groupon, which has been trying to build confidence with investors. The revised numbers correspond to the first quarter as a public company, and on top of reliability issue comes from the more-than-expected refunds. In explaining the revision, Groupon has explained that the company's move to offer more high-price deals has lead to a higher volume of refunds. Shares of Groupon has dropped over 11% today to 16.28 currently.

    Sources: