Sunday, June 27, 2010

student loans: my trick on how to pay them off faster

regarding my loans, i saved roughly $250 within a 12-month span. you can too.

short version:
i wrote a little java program that uses simulated annealing to find the near-optimal solution of how to distribute your monthly loan payment amongst your various loans every month, while minimizing the amount of accrued interest.


the above .zip file contains 3
files:
for example, run it from a command prompt:
>> java InterestOptimizerTest input.txt


long version:

if you have many loans which total a lot of money, you may be waisting 100s of dollars merely by incorrectly paying the wrong amounts towards each loan. the point of this writing is to help you save money.

obviously, one can save/waste a lot of money depending on when and how much they pay off their loans. this isn't about that. say you have 6 loans and $1,000 you wish to pay towards them. this writing is about how to apply your $1,000 towards the 6 individual loans in the best possible way so that you aren't wasting money. interest is a killer. below, i mention my approaches towards minimizing the interest, and i provide my actual student loans as an example:

upon graduating from ucla last year, my student loans totaled roughly $78,000. it's been 13 months since i've graduated, and i've gotten them down to $27,000. here are my 6 outstanding loans:

loan name, balance, APR, minimum monthly payment
-------------------------
sallie mae 1, $13472.75, 2.58%, $201.03
sallie mae 2, $1544.54, 7.25%, $214.74
sallie mae 3, $5032.22, 6.8%, $221.29
doe 1, $521.06, 8.5%, $52.61
doe 2, $2378.14, 6.8%, $59.50
ecsi, $4495.36, 5.0%, $60.46

for the rest of this article, let's be consistent and say that i pay $2,000 each month.


idea #1 - naive approach based on distribution of annual interest:
this is what i had been doing the whole time. when i had to start paying back my school loans, i didn't give it much thought as to how i would determine how much to spend towards each. i just quickly thought, 'i'll just pay some amount that is proportional to how damaging the interest is.' i now regret not thinking about it more.

the amount i was paying towards each loan was merely determined by its contribution towards my total annual interest across all loans:

loan i's payment := $2,000 * (loan i's yearly interest / total yearly interest across all loans)



idea #2 - brainstorming + linear/non-linear programming:
after filing my taxes, i noticed i paid a lot towards loan interest this past year. so, while brushing my teeth in the morning, i thought to myself that my current method (idea #1) is probably much worse than what i imagined. how can i find the optimal solution? first thing that popped into my mind was to search the solution space by using a genetic algorithm, but by the time i finished brushing my teeth, i had convinced myself that the sheer thought of such was complete overkill, laughable, and non-optimal, and clearly not the best approach.

throughout the day, i thought about other approaches:

linear/non-linear programming:
the idea of using linear programming came to mind. the format would be:

minimize C^T * x || sum(x) = b, where
  • C is a vector of known coefficients that represent the interest for each loan
  • x is a vector we are solving for, which represents how much to spend on each loan
  • b represents how much we are willing to spend in a given month (i.e., $2,000)
in other words, we want an equation for our total interest across a given time period (1 month), and we want to minimize it. but unfortunately, we can't really form a linear equation for it. for example, the interest for one loan would be:

loan i's interest = (loan_i's_original_balance - how_much_to_pay_towards_loan_i) * (1 + APR/365.25)^30

we are minimizing the sum of this value across all loans.

that exponent makes it non-linear. moreover, i'm not sure how to solve it using non-linear programming either, as we no longer have a clean coefficient. we don't have an Ax = b; we have f(x) = b

maybe there's some way to use the simplex algorithm for this, but i wasn't interested in finding out. seems messy.



idea #3 - simulated annealing:

well, when all else fails, use simulated annealing, right? haha. simulated annealing is a pretty simple, common AI approach that seeks to find an optimal solution within a large search space.

i implemented it in a little java program.

basically, it:
  • initially assigns random payment amounts towards each loan, while meeting the constraints of the minimum and maximum payment for each loan.
  • it then calculates the total monthly interest across all loans.
  • then, for however many epochs i care to run my algorithm, it will:

    • randomly decide to increase or decrease a to-be-selected loan,
    • then the loan it chooses to adjust is probabilistically chosen, based on each loan's contribution towards the total amount of interest across all loans.
    • the amount that it perturbs the loans is randomly chosen, too.
    • if the new payment amounts yield a lower interest, let's save these payments as the current state and continue
    • if the new payment amounts yield a higher interest, let's probabilistically save these payments as the current state and continue (this is to help avoid local minimums)
    • saves the best payment distribution that we encounter
the only tricky part was ensuring that the perturbing of the payment amounts still satisfied all of the constraints across every loan. a lot of error-checking tedium.

the program will display how much to pay towards each loan for every month, and it'll produce a summary that tells you how much you paid total, and how much went towards interest.

you can also experiment with choosing different monthly payment amounts and see how much it affects your lifetime interest amount. for example, my program showed me that:
  • paying $2k/mo will take 13 months; i'll accrue ~$500 of interest.
OR
  • paying only $1k/mo will take 26 months; i'll accrue ~$1,000 of interest
so, if i take a bullet of paying a measly extra $500 in lifetime interest, i'll gain the
freedom of having $1k extra of non-loan money each month for the next 26 months! it's definitely worth it.



solution:

the above .zip file contains 3
files:
for example, run it from a command prompt:
>> java InterestOptimizerTest input.txt




future work:
my current solution attempts to minimize the accrued interest, but it only does so over each upcoming month. basically, it works in a month-to-month basis until all loans are gone, which is not guaranteed to be the optimal, global solution, since it's not looking at the bigger picture across the lifetime of all the loans. the optimal solution would need to apply random amounts to all loans across every month of its lifetime, then make shifts both (1) between the various loans and (2) from month-to-month. this would give it a global picture to search within.

i suspect the improvement would be relatively negligible. in my case, i'm guessing that it would save me no more than $20. so, i don't plan to add this improvement. it's not worth it, but yea, i recognize it as an area of improvement.

ideas?
if anyone has any ideas for a faster or more optimal solution, please let me know. i'm curious to hear suggestions.

Friday, June 11, 2010

how i lost my hearing

for the short version, scroll to the very bottom of post.

long version:
the point of this entry is not to seem bold, or to render sympathy, or anything like that. rather, a lot of people have wondered what happened to me lately, so this writing aims to:

(a) tell the whole story so i don't have to repeat myself tons of times
(b) educate people with random tidbits about inner ear problems
(c) bring attention to how amazing the human body is

(a) how it went down

thursday (june 3), i worked out at the gym after work, like always. it was triceps/biceps/shoulders day, and i pushed hard on the clean & presses and shoulder presses, setting new personal records. at the end of my workout, my ears felt very stopped up and weird. no pain, just weirdness. i drove home. arrived by 8pm. by 11pm, my ears started to ring. they both just felt weird. no pain. i went to bed at midnight.

friday morning (june 4), 5 a.m., i woke up for no reason and the room was spinning uncontrollably. you've felt dizziness before. imagine what dizziness feels like. the room spins a little, and it's kind of silly. well, this was 10x more than that. i was half asleep, and out of nowhere it appeared that the room was moving upwards and over very fast. it was as if i were going to fall out bed, even though i was lying down. this is "extreme vertigo."

luckily, sheley was staying over -- sleeping in the living room -- because she originally had a flight at 8am and i was going to drive her to the airport. i woke her up, saying "sheley. something's not right!" i felt very nauseous and couldn't even stand up on my own, much less walk to the bathroom. with sheley's help, i made it. i vomited many times.

harvard's hospital, ranked top 5 in the nation, is literally 1 street away from my apartment. yet, i couldn't even make it there on my own. sheley to the rescue! she drove me. i was admitted to the ER and vomited many times over the next few hours. having received little sleep, i wanted to sleep. however, closing my eyes or reclining back even a few inches made me really nauseous.

friday 3pm: i was moved from the ER to an observation room. they continued to pump fluids into me through an IV. i was told that i vomited many more times between 3pm and 11pm. i have no memory during this 8 hour span, and i was asleep during most of it.

saturday (june 5) 4pm: i was released from the observation room. i was a little dizzy but stable. still no hearing in left ear. sheley was a complete lifesaver. if it weren't for her, things would have been very ugly. just for me, she even cancelled her flight home to see a wedding of an immediate family member. now that's love! she's so great.

sunday (june 6) - today (june 12): i still feel the same. i can walk on my own pretty well, but any quick head movements or turning takes a second or two for things to register. i have zero hearing in my left hear, and it's been ringing for 1 week straight.

what's it like to only hear out of 1 ear?
imagine wearing noise-cancellation headphones only on 1 ear. plus, the headphones constantly emit a high-pitched ringing. imagine wearing these headphones for over 1 week straight. that's the best i can describe it.

loud places with many people (i.e., subway and cafeterias) seem to really do a number on me. imagine: people to your left, who are out of sight, make noises. the noises bounce of walls to your right and enter your right ear. so, you hear the noises coming from your right, but clearly nobody over there is making the noises. plus, you are unfamiliar w/ their voice, so your vision and all gets even more confused. now imagine this happening all around you, with dozens or hundreds of people all talking at once. lol, it's really pretty trippy. it drowns out and overwhelms my right ear so much that everything gets muddled and it's really draining. pretty wild stuff!

i've realized how much of our vestibular/vision/hearing systems that we really take for granted. it's amazing how much is being processed by our bodies all the time.

(b) researching the cause, thanks to doctors and the internet

i initially experienced "extreme vertigo" -- the intense feeling of everything spinning. but, the vertigo itself was not the problem; it was merely the result of the underlying issue. many (17-42%) of people who report vertigo, have it due to something called benign paroxysmal positional vertigo (BPPV) [1][2].


BPPV:
basically, everyone's inner ear has a collection of calcium crystals that hang out within the 'utricle' (see above pic). but, it's possible for these crystals to randomly migrate to the semi-circular canals (the big looping things in above pic). when this happens, crap goes wrong (aka, you get sessions of vertigo).

but wait, what would cause this to happen? BPPV is considered idiopathic, meaning there is often not a clear cause; it just happens. it usually happens in older people, usually in women. it usually lasts for short periods, but can persists over years. oh crap. but there are solutions to it.

the canonical method to diagnose BPPV is to use a voodoo-looking technique called 'dix-hallpike.' basically, the patient tilts the head in certain ways, lies back, rotates head, sits up, and does silly things like this. there are many variations of this. it makes the patient dizzy, but one can look at the patient's eyes to conclude if it's BPPV or not. very interesting: it the patient's eyes spin downwards, it may often suggest that a brain lesion exists, rather than BPPV!

epley manuever, another silly method similar to dix-hallpike, is often used to treat it. how crazy is that? merely turning the head in certain directions can re-adjust the crystals in your inner ear and fix your balance and everything.

the doctors found a liquid buildup/pressure behind my left inner ear. BPPV doesn't necessarily include this. also, my prolonged hearing loss is not too characteristic of BPPV.

let's rule out BPPV.

so, what's causing my inner ear problem? there are a few typical causes:
  • brain lesion(s)
  • meniere's disease
  • labyrinthitis

brain lesions: i didn't have any head injury, but having 8th cranial nerve damage would yield the same exact symptoms as i'm exhibiting (i.e., no hearing in 1 ear, vestibular system messed up). i got an MRI and no tumors were found:

whew! yet, it doesn't mean that nerve damage couldn't exist. we don't know. so, the doctor prescribed a small dosage of prednisone for anti-inflammatory reasons, just in case.

meniere's disease: i might have this. it includes everything i have, including the fluid build-up. it's also idiopathic -- no clear cause -- but the only thing that suggests that it might not be this is that i haven't had migraines, as they often occur within those with meniere's.

labyrinthitis: the doctors listed this as the probable cause. seems about right, and i really hope this is what it is. often, labyrinthitis is cause by a virus in the inner ear -- as opposed to a bacteria -- and goes away within 2-6 weeks, but can take months or years. hearing is gone until it goes away. rarely, permanent hearing damage occurs. [3]. viral labyrinthitis may re-occur anytime, maybe several years later, but if it does, it's likely actually just meniere's disease. they are very similar.

so, what can/should i do in the meantime?
  • don't drive
  • don't do anything that requires balance beyond walking
  • take over-the-counter medicine to help de-congest me.
  • take over-the-country motion sickness medicine
  • take prescribed predisone for 10 days to help w/ possible inflammation
  • avoid loud, crowded places
oh, i forgot to mention that the MRI results show that my sinuses had thick lining, which further suggests that it's either labyrinthitis or meniere's, as opposed to my straining too hard in the gym and causing a hole in a membrane. whew, i hope that's true.

(c) the human body:
how crazy is it that such a very tiny area within the inner ear can completely wipe someone out and make them unable to stand up? sure, parts within the brain are even more sensitive with respect to vitality per volume. it's interesting how vital every part of the body is, and that luckily, most of our body is very resilient and good at automatically rebuilding itself. think about how insane that is.

short version:
over a week ago, i woke up to the world violently spinning. vomited tons, and i haven't had hearing in left ear since. it's hopefully labyrnthitis, a virus in the inner ear, and will go away in a few weeks and maybe never come back again?

[1] Bhattacharyya N, Baugh RF, Orvidas L et al. (2008). "Clinical practice guideline: benign paroxysmal positional vertigo"
[2] http://en.wikipedia.org/wiki/Benign_paroxysmal_positional_vertigo