Friday, February 02, 2007

EMI computations

I am recently working on setting up my farmland. To compute the cost of paying back my own investments to myself from the farm income, I was faced with an EMI like situation where the infrastructure investment is amortized over (say) 10 years and I expect some constant amounts to be payed back towards that investment at regular intervals (say once a year or once in 3 months or whatever). Obviously I will also charge myself an interest rate tied to the interest rates of some pessimistic instruments like fixed deposits at a bank (8.5% in India now).

This is a formula I have derived from first principles 2-3 times over in my life so far and each time I seem to lose it (easy as it is to re derive). So as blogging is the right idiom to log that (as long as my blog website is around , at least) here goes.

Some symbols I need to use:


r

the rate of interest as a fraction of 1. 8% is 0.08 and so on. rate of interest in percentage divided by 100, if you will.

m

Number of units of time elapsed between payments.(See y below). Number of months, or number of weeks or whatever - as long as it is in the same level as y below.

y

number of units that go into making up an year. If weeks - you can take it to be 52. If months you can take it to be 12. If days you can take to be 365.

P

Initial Investment - P for 'principal'.

E

Equated Monthly Instalment - when payed monthly. For this more generalized computation its more like Equated Periodical Instalment

n

Number of payments (once in each m units of time) over which the principal would be completely payed back , along with compound interest.



Now We define a handy term called R which is basically
(1+ (r*(m/y)))
This represents the rate at which the residual amount inflates due to interest burden. The residual amount is taken to inflate in bursts or as a single step once in every m units of time. [[ Obiter Dictum: rather than in a continuous manner - though even that could be done : using calculus.]]

So a principal amount P grows to be P*R after m units of time. Left to itself, without any payments, it grows exponentially. After n units of times it would amount to R*R^n, where ^ means exponentiation, "raised to the power".

But every m units of time a sum E is payed back.[[Obiter Dictum: part of which goes to pay the interest and the remaining part goes to pay the principal. The part towards principal in negligible in the beginning and most of the payment is towards interest. the situation is reversed by the end of n payments.]]. This changes the situation.

After m units of time, whats remaining to be payed back is
P*R - E
During the second m units the remaining amount grows again by a factor R to
(P*R - E)*R
And during the third unit the same procedure gives
((P*R - E)*R - E)*R


After n paybacks the remaining amount should be 0(zero, cipher, nill, shunya).After all, that's the definition of EMIs. So we have

(...((P*R - E)*R - E)*R ...)*R - E = 0


Or with some basic regrouping (where ^ is again exponentiation and 1 is chosen to be written as R^0):

P*R^n - E(R^(n-1) + R^(n-2) + ... + R^0) = 0


Now using the summation formula for a geometric series the same equation can be written as:

P*R^n - E*((R^n - 1)/(R-1)) = 0


Therefore E can be found to be:

E=P*R^n*(R-1)/(R^n - 1)


The above closed form formula for computation of EMI is very amenable for entry into a good calculator. In fact on my Casio calculator I have now stored the above as a function and I simply assign values to P, r, m, y and n and I can compute E very easily using that function.

A small example computation.

Say you have borrowed 1 lakh rupees. You want to pay back that 1 lakh rupees in proper EMIs, every month over ten years. Say the rate of interest charged to you is 10% (more then the housing loans in India but less than the rate for other loans).

So R for this situation is (1 + 0.1 * (1/12)). m is 1 as it is payed every one unit of time (a month in this case). and y is 12 as there are 12 months in a year. Notice that if we artifically chose weeks for this case m would be 4 and y would 52 making it the same R. So in short R is 1.00833.

Its good to calculate R^n and keep it handy (in case you dont have functions - like on this windows calculator I am using right now). R^n is 2.70704 as n is 120 (12*10).

Now therefore the EMI is

E = 100000 * 2.70704 * (1.00833 - 1) / (2.70704 - 1) = 1320.97 or 1321
.

So after 120 payments you would have payed back 1321*120 = 158520 rupees.

If you wanted to do the same repayment in annual instalments.

R is (1 + 0.1 * (1/1)) or 1.1. n is 10. R^n is 2.59374. And E is

E = 100000 * 2.59374 * (1.1 - 1) /(2.59374 - 1) = 16274.55 or 16275
.

Now you would have payed back 162750 rupees.

Thursday, February 01, 2007

Conditional Proability

Here is an example of conditional probability from real life. I have found the confusion addressed here in many minds.

Scenario: A couple has a child already. Call it a girl. If they are pregnant again, many people assume its most likely to be a boy this time as overall there has to be balance. In fact if you see around don't you see a mix more often than two boys? yes. And than two girls? yes again.

Actually, the second child is not really a dependent trial (on the first one). Again this time its as likely to be a boy as it is to be a girl. So what trips the conventional logic in the above is that though the mix is more likely than either of "two boys" and "two girls" when seen as same sex versus different sexes the outcomes are equally likely.

To analyze in a more explicit way: Possible child sex combinations are BB,BG,GB,GG. Now if the first child is already a boy the probabilities of each of those outcomes is 0,0,0.5,0.5 although before the first child was born it was 0.25,0.25,0.25,0.25.

Internet Explorer 7

Tried out the IE7 today. It quite obviously has learn lessons like tabbed browsing, search bar, RSS feeds from firefox/mozilla/opera etc.

It has also exceeded the other browsers with their "quick tabs" ,"new tab", and "clear type" concepts. The clear type is certainly more easy on the eyes. Quick Tabs is a cool way to select the tab you want and new tab is quite handy (though I type CTRL-T most of the time).

On the whole I think its quite cool (I am usually a MS basher but what with having to move to a windows based development job now and everything I am learning things like C# etc and using windows more - there are some cool concepts. I expect to post soon about my critical appreciation of C# as a language - I think its quite cool - I initially though it was simply a java clone - its not just that).

And there is also a phishing warning (dont know if oit works well or anything - but its certainly better than nothing, I suppose).


Post Script:
the tabs could use their close buttons even when they are not high lighted

Tuesday, January 30, 2007

How about usability?

The title links to a sample page from MSDN.

Notice that the breadcrumbs section (which lists the parent topic names all the way to the root topic) has a drop down that pops up (that's a funny expression) for each parent topic which lists all the peer topics at that level. This is a cool information architecture.

BUT

the usability of the implementation is bad. Notice that the pop-ups cover other topic names and its nuisance to have to move the mouse or hit escape button to lose the pop up that popped up because you overshot the mouse.

May be the usability testers tested with a few topics in the crumbs. The problem starts when there are many topics. Whats the way out? Nothing easy. Thats probably the reason why it is deployed that way.

Friday, January 19, 2007

Blog Entries or comments?

After posting this I got thinking about whether that should have been a comment on that blog.
  • if I make a comment there I lose an entry on my blog.
  • my blog is a collection of my thoughts (so what if that main article inspired it) - I would rather have them in one place
  • tools like technorati get at my comments anyway (if a reader of a blog entry wants to know). This possibility has a side effect which is more important than the effect-main. Those who want to other's thoughts on someone's thoughts can decide how to understand those thoughts by seeing the collage at my blog and they may even decide to skip my comment altogether based on my blog ranking.