Monte Carlo Simulation of Pi

Partially out of boredom and partially because I was inspired by the movie title “Life of Pi”, I decided to make a monte carlo simulator that could approximate the value of pi.

Monte carlo simulations are used in everything from derivative pricing to biology (and, in this case, boredom alleviation). Basically, it’s good for solving problems that have no exact solution.

The simulator throws a random point on a 2×2 square and then throws a random point on a circle of radius 1. This is one trial. However, it does this (in this case) for 6000 trials. So the square is filled with 6000 points and the circle is filled with less than 6000 points.

Now that the simulation has done a really good job at filling in the square and the circle, we count the number of points in the the circle and the square to get the areas of each. Then we take the ratio: areaCir/areaSq.

However, we know that the areaSq is 4 for a 2×2 square. So we multiple that ratio by 4 to cancel out the denominator and are left with areaCir. Since areaCir=pi*radius^2, areaCir=pi for our circle because radius=1.

The more trials we conduct, the more filled our circle and square become and, thus, the more accurate out approximation of pi. Here is the result:


It’s clear that as trials -> ∞ , error -> 0% and Pi,Approx -> Pi,True

Doing more than 6000 trials really slows down processing unless the simulator is done in code. So, I built a monte carlo simulator using VBA.

I ran 50,000,000 simulations. It took 34.2187 seconds and it approximated pi=3.14155704. Pi is actually equal to 3.14159265. Error was .001%

“The Subprime Solution”: a must-read

I purchased this book on a whim a few weeks ago. My high hopes were satisfied as Shiller gave insightful explanations of how the subprime bubble occurred and offered innovative short-run and long-run suggestions for minimized the risk of another crisis.


Here are a few of his propositions:

  • Democratize finance. A major cause of the crisis was lack of educated financial action on the part of subprime borrowers. Subprime borrowers agreed to take out adjustable-rate mortgages despite the inherent risk of the instrument. Why? Because the idea that housing prices would increase indefinitely meant they were guaranteed to refinance later and qualify for a lower rate. 

    These borrowers had little access to proper financial advice because firms offering financial advisory tend to market their services to high-income individuals (after all, they charge fees as a percentage of the assets under management). Shiller advocates the institution of a government subsidy to help build a supply of financial advisors for lower-income individuals. In the absence of such advisors, the borrower’s only point of contact are mortgage originators and real estate brokers. Neither of these people’s incentives are aligned with the borrower’s since the broker gets paid as long as the house is sold and the originator can securitize the mortgage and sell it off. 

  • More derivatives! Create a market for derivatives with the Case-Shiller Home Price Index as the underlying. Maintaining a liquid market for options, futures, and forwards is an empirically proven way to decrease the volatility of the underlying asset. It also provides individual investors with a concrete way of gauging future home prices, as opposed to relying on rating agency models.
  • Home Equity Insurance. A drop home value is devastating. It could prevent the owner from refinancing to a lower mortgage rate, it could wipe out the homeowner’s equity, and event prevent them from relocating. The government should subsidize the creation of these insurance instruments to handle such housing risks. It would reduce the amount of underwater borrowers as well as subdue “panic-selling.” 

The Unstarvable Beast: The Need for more Effective Government Spending

Revealing article by Harvard’s Kenneth Rogoff linked above…

Key Takeaways: 

  • The government operates in the service industry, which generally exhibits slow productivity growth.
  • While productivity growth is slow, the industry is still forced to pay higher wages for relatively the same output because it competes for workers in the same labor market as other, high-productivity industries like finance and telecommunications. This translates into ever-increasing costs.
  • This cost issue plagues the service industry. Costs are so high that the industry now accounts for more than 70% of spending.
  • While this “cost disease” permeates the industry as a whole, the government suffers more than most players because (a) it’s expected to provide a wide array of services, making it impossible to specialize and reduce costs and (b) government often provides services in areas where there is little competition, making it difficult to lower costs since there is little incentive to innovate.

The Unstarvable Beast: The Need for more Effective Government Spending

The Welfare Cliff(s)…

After viewing the entirety of “Welfare’s Failure and Solution” (linked below) I found the graph below to be the most informative…and frightening.


The x-axis lists raw, unadjusted income and the y-axis lists income after taxes/entitlements. Ignoring the entitlements, we see that even though we have a progressive tax system, there is still incentive to climb the income ladder (each blue bar is higher than the blue bar before it). If we consider the entitlements, we see that several “cliffs” form on the chart (I count 4). These cliffs represent a disincentive to move up in unadjusted income.