Archive for the ‘Math’ Category

Hedging your investments… explained

Wednesday, November 12th, 2008

When most think of hedge funds they think of big fat cats sitting around in some office with billions at their disposal rolling the dice on risky futures and derivatives.   While this might be true in some cases it doesn’t explain what a hedge, or a hedgefund does.  And let’s start by eliminating the obvious… a hedgefund does not invest in thick bushes that line driveways :-)

Any investment can be considered a hedge if it helps to reduce the risk of overall loss due to a seperate (usually larger) investment.

The best way to think about a hedge investment is with an example that we should all know very well, cars and car insurance.

When one purchases a vehicle there are two financial sums at risk… the vehicle itself and the damage caused to others or yourself in an accident.  It may happen that while I’m driving my $50k hummer down the highway I, oblivious to the rest of the world, crash into another Hummer (who is equally oblivious to the real world).  Since the accident is my fault I’m now on the hook for my hummer, the other hummer and all medical bills… let’s say $200k all together.  Luckily I hedged against catastrophic loss by taking out a comprehensive auto-insurance policy for $100 a month… they pay for everything.  I’m free to return to my irresponsible hummer driving ways!

Notice that for $100 a month, my hedge has the ability to pay out $200k when a predefined event occurs, this is called leverage: the ability for a small sum of money to control a large sum.

Hedging is not limited to insurance though.  In the stock market one can easily hedge against significant loss via Put and Call options.  If I sell a Put option to some other investor, we’ve agreed that I can “put” my stock on him (sell it to him) for an agreed upon price.  In exchange for the risk that the Put option buyer takes on, I agree to pay him a small fee…say 5% of my stock’s value.  When my stock shoots up 10% the put option gives me no advantage and I keep my stock.   But perhaps it loses 20%… I then shovel off the stock to the purchaser of the put contract for its agreed upon value.  Now instead of losing 20%, I’ve only lost 5%.

Notice:  5% of the stock’s original value creates a contract to control 100% of it’s value.  Again, we see leverage here.

A Call option works the other way, it is an agreement between me and a holder of some stock such that I can “call” him up and purchase the stock for an agreed upon price.  In this case I pay the owner 5% to buy the stock at a certain price.  When the price of the stock shoots up and above our agreed upon price by 20% I excercise my option to buy and purchase the stock for a 20% discount.  If the stock fails to increase in value the owner of the stock makes a 5% profit and I lose the nominal value of the call option.

Again, for 5% I can gain control of 100%.

The essential feature here is that I can take on another’s risk or dish out some of my risk for profit.  No problems here with massive default.

However, what if I don’t have stock to sell options on or the money to purchase the asset indicated in the contract?  I can go naked! wooohooo!!

No not that kind of naked.  Going naked means that you sell someone the option to “put” stock on you without having the money to pay for that stock (which would cause a default on your side).  Likewise you can also sell the right for someone to “call” you on your stock.  In both cases you collect the 5% fee, but you’d better hope that the conditions don’t force you to to have to purchase the requisite amount of stock in order to fulfill the contract[1].

Selling naked options is not hedging, it’s highly leveraged speculation and is ill-advised.

Hedging is not limited to what has been shown above.  Almost any investment can be a hedge as long as it protects against loss from another investment … the possibilities are almost limitless, for example: biodiesel hedges against rising oil, hay bails against rising drywall costs, Japanese steel against American Steel, Apple vs. Microsoft etc.

Perhaps one of the most common hedges in the average person’s life (besides car insurance) is the common resume and occasional job application.  That’s right, hedge against income and job loss by keeping one foot in the door of another company… it only takes a little bit of your time.

  1. this is called securities fraud and => jail []

Local Search Optimization

Thursday, October 2nd, 2008

What do you do to find the optimal solution to a problem that has an overwhelmingly large amount of equally appealing solutions?  Well, it turns out that mathematicians and computer scientists haven’t even really been able to answer the problem either.

In the book Combinatorial Optimization, Christos H. Papadimitriou admits that for most complex problems there is no easy way to find an optimal solution given a finite amount of computation time.  He recommends Local Search as a good starting point.

Local Search is actually a very simple algorithm which humans have been using for years. It goes as follows:

  1. Start off with your best guess, if you have no best guess then start off with a set of random solutions
  2. Modify your initial solution set slightly.  I.e. move about a small neighborhood of your initial solution set.
  3. If solution get’s better, keep on pursuing the direction you moved in, else try another neighboring solution.
  4. Keep proceding until a sufficiently optimal solution is found

Imagine the problem in this way, your friend told you he was going hiking next week, but didn’t tell you a day, time or location.  1 full week from now you’ve not heard from him, and are getting worried.  You call in the search and rescue team but where to start?  Colorado has thousands of trails.

Well, the best place to start is probably his house, then the 5 most frequently hiked or mentioned trails by your friend.  After that, go with the most popular, then the most available to hike.  If you haven’t found him at the initial places, then look at the trails closest to the ones just searched.

Good ol’ combinatorial optimization!

A good analogy for Operations Research

Thursday, September 25th, 2008

The other day I was trying to explain the concept of constrained optimization to an artist.  As I was fumbling around a bit, my friend (who was also a Math nerd) said:

Constrained optimization is like fishing… you have a limited amount of bait, you don’t know what the fish want, how many fish are out there, or what type/proportion they are but the goal is to catch as many as possible in a few hours.

While it’s not a perfect analogy… it’s pretty good.  What’s your favorite analogy for constrained optimization?

Fun with heliostats

Wednesday, September 3rd, 2008

While I was in Africa this summer I worked out how I could aim several mirrors at my old water heater.  I had already stripped off half the casing and foam insulation on the water and heater and painted it black knowing that I wanted to acheive some sort of solar water heating but had never really worked out how to position the mirrors to make it really hot!

So, being a mathematician I set about working out the requisite formulas which would help me to space out the mirrors and determine at which angle I should keep them.

4x Solar concentration

It turns out that instead of tracking the sun it’s actually quite simple to place the water heater perpendicular to the sun, and array the mirrors facing north.  Aligning the mirrors in the center with the long edge running perpendicular to the sun means that at midday there will be an additional 8 sq. ft of solar power to heat the water that will eventually be contained in the heater.

the middle two

In the first picture we can also see that there are 2 additional mirrors placed at 45 degrees in either direction to the middle mirrors.  These mirrors are testing my hypothesis that at about 11 am (a little past quarter day) and 3pm there will be some additional sunlight that could be caught.

Once I get a little more funding for this project I’ll add a few more mirrors (4-10) more and also start work on a smaller concentrator for my home office.

Later I’ll connect up some actual water pipes, and circulate the hot water into the house for our new radiant heating system that I’m hoping to install this fall.

If you’d like to code for your own project please contact me.

Multi-Agent Algorithms

Wednesday, April 30th, 2008

I’m currently doing some work on Mutli-Agent Algorithms for a company in the UK and I thought it might make a nice topic for a post.

A multi-agent algorithm is an algorithm that attempts to simulate a complex phenomenon and thereby solve or make useful predictions and strategies for the phenomenon using millions of simulated autonomous agents.

For example, consider the stock market. The price of each individual stock may seem quite random when viewed on a large scale. However, upon further inspection we can see that the current price of a stock is the result of thousands of interactions over time between a set of traders. Each trader brings his knowledge, his expectations and his goals to the trading floor causing small shifts in price.

(more…)

Life is a bit like an Internet Advertisement

Thursday, April 17th, 2008

I used to work at DoubleClick… now Google… as a Statistical Analyst. In my short career there I learned that internet ads are very rarely clicked on. In fact a rate of 1 in 1000 clicks/deliveries would be considered pretty decent.

Lately I’ve noticed that life seems to be a bit like an Internet Advertisement.

(more…)

Useful trigonometry

Wednesday, April 16th, 2008

Back in high school we learned that any right triangle inscribed inside of a circle has vertices on a point on the circumference and two points on the opposite ends of the diameter (if the right angle vertex is on the circumference).

(more…)

R code for visualizing a reflective surface in 2d

Wednesday, December 19th, 2007

Given that you have some reflective shape expressed in mathematical form the following code written in R will help you to visualize the effect of bouncing light (or potentially audio or any other object) off the surface of the object. It only calculates one bounce however and does not account for multiple reflections…perhaps sometime in the future. This script produces plots like the following:

A circular reflector.

A histogram of the y-intercepts of the reflected rays for a circular dish.

(more…)

Mystical Mathematics

Tuesday, August 21st, 2007

Pythagoras, yes the guy who made the Pythagorean theorem, was one of the first well known mathematicians to fall in love with Mathematics and form a cult. Yes a cult (see this very fascinating article on it http://en.wikipedia.org/wiki/Pythagoras#Pythagoreans). The Pythagoreans were well known for their mixing of religion and science, and avoiding beans. You could say that these guys were part of the original “Geek Squad”.

The Pythagoreans generally get credit for the theory about triangles: [tex=Pythagorean Theorem]c^{2}=a^{2}+b^{2}[/tex] where a and b are legs of the triangle and c is the hypotenuse of a right triangle. The Egyptians also knew about it…so did the Mayans. How else could they have built their incredibly square pyramids and temples? Pythagoras also believed that reality was numbers! He even believed that the planets moved according to equations and that music was simply mathematics. If one discovered these equations one would discover a beautiful planetary symphony!

Any student of mathematics has at one point been tempted to become a Mathematical Mystic. Many religious people have been tempted to use the “powers” of numbers to predict the future (like the Bible code people http://www.nmsr.org/biblecod.htm) Can anyone really love Math this much?

(more…)

Fun with Math

Monday, August 6th, 2007

Hello everyone.

And now…the moment you have been waiting for.

[tex=latex]LaTeX{}[/tex] is now available for use in your posts.

To write a mathematical formula you simply must use latex scripting and enclose it in tags like on the following page.

With latex, you can make things like

[tex=sum formula]\sum_{i=1}^{n}i=\frac{n(n+1)}{2}[/tex]

look really pretty!

Enjoy! I know I will.