Saturday, June 16, 2018

Finance and Investment Ideas (by a smart pilot)

Finance and Investing for Everyman, by a Smart Pilot

Smart and simple investing involves three basic principles, and one important early strategy.
  1. Dollar cost averaging
  2. Pre-diversification
  3. Compound interesting
  4. Tax structuring

Compound interesting is simply the effect that applying an interest-rate has to your savings.
It increases over time and in ever increasing amounts. 
Do the simple exercise, take one penny and double it every day for a month and look at your total amount on day 31.
The 100% interest-rate compounded daily will yield you over $10 million on day 31!

A more reasonable interest rate would be 6% compounded monthly. 
If you took a $2000 investment and added $2000 to it every year,
with the 6% compounded monthly interest, 
you would have $330,000 in 40 years!
Without that compounded interest, 
you would only have the $80,000 that you put in yourself. 
The difference of $330,000 vs $80,000 is due to compound interest.

In the figure to the left, the blue line is your money,
the black line is the work the interest is doing,
and the green line is the total amount of money you have. 
VERY POWERFUL STUFF!!!












Dollar cost averaging is simply the principle of reducing risk by investing over a long period of time.
Simply having time and taking this is the most important part of investing after compound interesting. 
If you don’t have time and have to make a large amount of money in a small amount of time, 
then you have to increase your risk and gamble a lot of money upfront for unsure gains. 
This is where most Americans run into trouble at the retirement age when they have to make a lot of money in a hurry and have to assume high risks in doing so.
The simplest way to look at it, is the fact that over the last 150 years, the Dow Jones index has averaged 10% growth per year.
Some years it goes up 40%, some years it goes down 10 or 15% or more.
There have even been stock market crashes where the market has lost 80% of its value overnight.
But when you look at the market long-term, 
the steady average growth is 10% and 10% is a great rate of return for your investment. 
If you invest over a period of 40 years with the stocks in this exchange, your chance of that average return being close to 10% is excellent.
If you invest for just one year it might be a good year or a bad year and that is simply too risky.
Therefore the answer is a steady investment program over a long period of time to dampen out both the positive and negative spikes.


Pre-diversification is reducing the risk by investing in different stocks.
If you buy just one share of one stock of a company you are putting all of your proverbial eggs in one basket. 
If that company does very well and you sell that share of stock you will make a good profit. 
However if the company does poorly you lose money. 
And if the company goes bankrupt you will lose all your money.
A way to avoid that risk is to diversify, i.e. buy a bunch of different stocks.
However that can get very expensive up front if each stock costs $100 or so per share.
But one way to diversify and do it more cheaply is to buy a mutual fund which itself buys many stocks and sells a portion of it to you.
A fund manager determines which stocks will be purchased based on his experience and charges a fee for this called a load.
You can shop for fund managers based on their experience and their past performance i.e. how well they do picking stocks!
You can also just buy a fund that just mirrors the stock market, i.e. buys a tiny portion of each company on the entire stock market.
And there are different markets to look at, for example:
  • Dow Jones Industrial Average which is the collection of all the United States large industrial companies.
  • NASDAQ index which is all of the up-and-coming high tech stocks.
  • Standard & Poores 500 which is a sampling of 500 good companies in the United States.
All of these index funds are very inexpensive because you don’t need a genius fund manager doing a lot of research and work.
He simply picks a percentage of each company in the index fund that accurately reflects the size of the company and its proportional influence in that market.
When you buy a share of that index fund it’s like buying a tiny affordable slice of that market itself.

Cheapest Index Funds

Tax structuring is how you’re going to structure that money for tax purposes. 
You make the investments with an inexpensive, low commission online brokerage firm.
You can either 
invest post-tax with no limits (in a regular cash account paying either short-term or long-term capital gains). 
or invest pre-tax with reasonable yearly amount limits (in a ROTH account) 

If you post-tax the money, you will be able to invest money now and not pay any tax on it 
but when you retire the growth on that investment will be taxed. 
It will be at a lower tax bracket then during your prime earning years,
but it will all still be taxed. 
YUCK!!

But if you pre-tax the money in a ROTH retirement account, 
you will pay tax at your current (higher) tax bracket. 
However the good news is that, at retirement, you won’t have to pay ANY tax on the profit you’ve made on your investments. 
SUHWEET!!!

The tax on your investment is inevitable. 
A good analogy on this makes the choice clearer.
A farmer has a choice of either having to pay tax to buy seeds for his crop
or pay tax on the crop harvest itself later.
For most farmers, it’s best to pay the tax money upfront on cheep seeds, even if the tax bracket is high,
than to pay taxes on the massive crop later, even at a lower tax bracket.

SUMMARY
Tax-structure correctly by setting up your ROTH retirement savings account online with TDAmeritrade.com (or Etrade or Schwab ect ect) 
Dollar-cost-average your investment by starting early, investing $500 each month.
Diversity your investment in a stock index fund (like Fidelity's FUSEX and FNCMX Funds) with low load costs so you have no expensive fancy fund manager eating into your profits.
Your profits are growing at a compounded-interest rate as you stay in the market over the long haul. 
Because of your tax-structure decision, when you retire, all of your investment can be distributed back to you completely tax-free.

You never look at your portfolio, you never stress over it, you just keep investing in a steady consistent strategy as the market rises and falls. 
No work, no stress, just a guaranteed secure retirement with lots of golf and yachting.

Thursday, October 13, 2016

Some thoughts on a simplified approach to ancient Greek grammar using only personal constructions. Since, both Infinitive and Participle constructions can be written as personal clauses with subordinating conjunctions, study of their syntax can be postponed.

Cover the 90% of greek verb morphology while ignoring the exceptions and rare. Instead of 6 principle parts, each verb has an imperfective and aorist stem via their infinitive. Regular verbs form the aorist from the imperfect by adding (s)a. Irregular verbs have an aorist reduced in some way from imperfect or an irregular form.
Past indicative has obligatory augment, either for carrying the stress or for disambiguating the 1st and 2nd plural.

Active endings for use when there is no returned action on subject (either partial or even figurative/implied)

PRESENT TENSES: after consonants or a/e/o uncontracted vowel stems (contains theme vowel): o^ eis ei omen ete onti
after vowels: mi si ti men te nti (not ousi)

PAST TENSES: after consonants (contains theme vowel): on es e omen ete on
after vowels: n s - men te n (all strong root aorists lengthen vowel)

IMPERATIVE: -(e) and -(e)te, etc

Medio-passive endings for use when there is either partial/implied returned action on subject or complete (reflexive); or subject receive action from (named) agent.

PRESENT TENSES: after consonants (contains theme vowel): omai esai etai ometha esthe ontai
after vowels: (remove theme vowel)

PAST TENSES: after consonants (contains theme vowel): ome^n eso eto ometha esthe onto
after vowels: (remove theme vowel)

IMPERATIVE: ?

SUBJUNCTIVE always uses the lengthened theme vowel endings (absorbs any stem vowel), OPTATIVE uses the stem plus iota plus the past endings without augment.

Example: te/mnein (regular aorist in -sa following rules, since there is no aorist form)
MinfVaAi te/mnein ; MparVaAi  te/mno^n
MimpVaAi: te/mne te/mneto^ te/mnete te/mnonto^n; (no past imperative)
MindVaAi: te/mn-o^ eis ei omen ete onti; e/temn-on es e omen ete on
MconVaAi: te/mn-o^ e^s e^ o^men e^te o^nti; te/mnoin ois oi oimen oite oin;
MimpVmpAi: ?
MindVmpAi: te/mnomai esai etai ometha esthe ontai; e/temnon es e omen ete on
MconVmpAi: te/mno^ e^s e^ o^men e^te o^nti; te/mnoin ois oi oimen oite oin

MinfVaAi tei/nai ; MparVaAi  tei/nas
MimpVaAa: tei/na tei/nate; --
MindVaAa: tei/nami.. ; e/teina  (present is not used in writing)
MconVaAi: tei/no^.. ; tai/naimi
MimpVmpAa: tei/naso teina/stho^ tai/nasthe teina/stho^n; (no past imperative)
MindVmpAa: tei/namai.. ; e/teiname^n  (present is not used in writing)
MconVmpAi: tei/no^mai.. ; tai/naime^n

POSTPONE AORIST PASSIVE DISTINCT FROM MIDDLE
FUTURE  is conjunctive, POSTPONE COMPLETE FUTURE SYSTEM UNTIL AORIST PASSIVE
PERFECT is with Perfect participle (redup + ko^s/kot-)  and einai.

IMPERSONAL CONSTRUCTIONS WITH INFINITIVE AND PARTICIPLE
learned as translations from personal subordinate clauses later
literature constantly footnoted until these are learned

Infinitives as hoti clauses when possible, nouns otherwise: need a way to automate this



Participles as hoti (adj) or epeide^,hote,kaiper (adv) clauses, with the verb in 3rd person and number taken from the participle, disregarding the case and number.




Wednesday, November 25, 2015

Making up Lorem Ipsum

The following javascript function showcases two inner functions that have only scope for the outer function. Not something I use often, but seemed apt for what I was doing here. The output generated looks like this (a cross between Hungarian/Turkish and Indonesian?)
ur tojo imfuw ukba aral inoma bodfuy iknedik ofat aav id evajuragonephu nimemobi umajvamjo lo bijpaulim ugpeibgac depi puisrejnahafi getegvoeysepied hu iclupgak parjonuf bos aivhocu us pokehekgerbak mugu itdaceii ikimhup penka iduab tojeme idmethe nalay ugservanuu atub pavdiv sep cowgimaag gon ipokipaberuvapadaehovcahat lonugirfi acasinal giosug dihocadu vumfilocoy ru benumeohuj rejav puj cidomten rom godioncogal likviu hucous cecioieruhubewuda naivac ive.

function randomClauseMarkup() {

    var initials = "bc df gh jk lm np rs tv"; // chance of an initial is 66%
    var vowels = "aeiou"; // 100%, since all syllables must have vowels
    var finals = "y w b c d f g j k l m n p r s t v"; // change of final is 50%
    var randomsyl=function() {
        var initial = initials.charAt( Math.floor(Math.random()*initials.length));
        var vowel = vowels.charAt( Math.floor(Math.random()*vowels.length));
        var final = finals.charAt( Math.floor(Math.random()*finals.length));
        return (initial+vowel+final).trim()
    }

    var randomword=function() {
        var ns= 1 + Math.floor(Math.random()*4);
        var w = '';
        while (w.length<ns*2) w += randomsyl();
        return ' <span class="word">'+w+'</span>';
    }

    var s = '';
    var numwords = 3 +  Math.floor(Math.random()*30); // these clauses will have [3,33] words
    for (w = 0; w < numwords; w++) {
        s += randomword();
    }
    return ' <span class="clause">'+s+'</span>';
}

To turn the string into html, just use $.parseHTML or load element with .html()
 

Saturday, November 7, 2015

Digrams, or two letter graphs, in any language

Every wonder what the most likely letter is after a given letter in a language. Suppose you needed to know to write an interactive keyboard on a mobile phone to save that precious real estate, instead of taking up half the screen like the iPhone does. That is exactly one of my current projects. So, here is some javascript code to get those frequency graphs, given a list of possible letters (and punctuation) along with a sample test.

Here is a typing program I developed to use timed digrams as a way to improve typing:
TYPOR
Comments?



var letters = "abcdefghijklmnopqrstuvwzyxABCDEFGHIJKLMNOPQRSTUVWXYZ ,;:.";

var sampletext = "As they rounded a bend in the path that ran beside the river, Lara recognized the silhouette of a fig tree atop a nearby hill. The weather was hot and the days were long. The fig tree was in full leaf, but not yet bearing fruit. Soon Lara spotted other landmarks—an outcropping of limestone beside the path that had a silhouette like a man’s face, a marshy spot beside the river where the waterfowl were easily startled, a tall tree that looked like a man with his arms upraised. They were drawing near to the place where there was an island in the river. The island was a good spot to make camp. They would sleep on the island tonight. Lara had been back and forth along the river path many times in her short life. Her people had not created the path—it had always been there, like the river—but their deerskin-shod feet and the wooden wheels of their handcarts kept the path well worn. Lara’s people were salt traders, and their livelihood took them on a continual journey. At the mouth of the river, the little group of half a dozen intermingled families gathered salt from the great salt beds beside the sea. They groomed and sifted the salt and loaded it into handcarts. When the carts were full, most of the group would stay behind, taking shelter amid rocks and simple lean-tos, while a band of fifteen or so of the heartier members set out on the path that ran alongside the river. With their precious cargo of salt, the travelers crossed the coastal lowlands and traveled toward the mountains. But Lara’s people never reached the mountaintops; they traveled only as far as the foothills. Many people lived in the forests and grassy meadows of the foothills, gathered in small villages. In return for salt, these people would give Lara’s people dried meat, animal skins, cloth spun from wool, clay pots, needles and scraping tools carved from bone, and little toys made of wood. Their bartering done, Lara and her people would travel back down the river path to the sea. The cycle would begin again. It had always been like this. Lara knew no other life. She traveled back and forth, up and down the river path. No single place was home. She liked the seaside, where there was always fish to eat, and the gentle lapping of the waves lulled her to sleep at night. She was less fond of the foothills, where the path grew steep, the nights could be cold, and views of great distances made her dizzy. She felt uneasy in the villages, and was often shy around strangers. The path itself was where she felt most at home. She loved the smell of the river on a hot day, and the croaking of frogs at night. Vines grew amid the lush foliage along the river, with berries that were good to eat. Even on the hottest day, sundown brought a cool breeze off the water, which sighed and sang amid the reeds and tall grasses.";

var digrams = new Array(letters.length);
for (var i=0; i<letters.length; i++) {
 digrams[i] = new Array(letters.length);
 for (var j=0; j<letters.length; j++) {
  digrams[i][j] = 0;
 }
}

var nextLets = new Array(letters.length);
for (var i=0; i<letters.length; i++) {
 nextLets[i] = new Array();
}

loadDigrams(sampletext);
document.writeln("<table border='1'><tr><td></td>");
for (var j=0; j<letters.length; j++) {
 document.writeln("<td align='center'>"+letters[j]+"</td>");
}
document.writeln("</tr>");
for (var i=0; i<letters.length; i++) {
 document.write("<tr><td>"+letters[i]+"</td>");
 for (var j=0; j<letters.length; j++) {
  document.writeln("<td align='right'>"+digrams[i][j]+"</td>");
 }
 document.writeln("</tr>");
}
document.writeln("</table>");

loadNextlets();
document.writeln("<div>");
for (var i=0; i<letters.length; i++) {
 document.write("<div><span style='border: 1px solid black;'>"+letters[i].replace(' ','_')+"</span> ");
 for (var j=0; j<nextLets[i].length; j++) {
  if (!nextLets[i][j]) continue;
  document.writeln("&nbsp;<span style='text-align:center;border: 1px solid black;'>"+nextLets[i][j].replace(' ','_')+"</span>");
 }
 document.writeln("</div>");
}
document.writeln("</div>");



function loadDigrams(text) {
 text = text + ' ';
 for (var x=0; x<text.length-1; x++) {
   var i = letters.indexOf(text.charAt(x));
   var j = letters.indexOf(text.charAt(x+1));
   if (i>=0 && j>=0) digrams[i][j]++;
 }
}

function loadNextlets() {
 for (var x=0; x<letters.length; x++) {

  var rowvals = digrams[x].slice()
   .sort(function (a,b) {return b-a;})
   .filter(function(item,ix,ary) {return !ix || item != ary[ix-1];})

  for (var y=0; y<rowvals.length; y++) {
   if (rowvals[y]==0) break;
   nextLets[x][y] = '';
   for (var j=0; j<digrams[x].length; j++) {
    if (digrams[x][j]==rowvals[y]) { nextLets[x][y] += letters[j]; }
   }
  }

 }
}


function getRandomInt(min,max) {
    return Math.floor(Math.random()*(max-min+1)+min);
}



Sunday, November 23, 2014

Sanskrit Test Lesson


Original text (with corrections) हास्यकणिका अध्यापिका व्याकरणं पाठयति। कर्ता कः, कर्म किम्, क्रिया का इति बोधयति। तत्परं सा कृष्णफलके इदं वाक्यं लिखति - ‘मण्टुः लड्डुकं खादितुं न इच्छति।’ अध्यापिका - सुरेश, त्वं वद। अस्मिन् वाक्ये मण्टुः कः। सुरेशः - मण्टुः मूर्खः। अध्यापिका - कथम्। सुरेशः - आर्ये, कः लड्डुकं खादितुं न इच्छेत्।
Version without sandhis
हास्य-कणिका अध्यापिका व्याकरणम् पाठयति । कर्ता कः, कर्म किम्, क्रिया का इति बोधयति। तत्परम् सा कृष्ण-फलके इदम् वाक्यम् लिखति - ‘मण्टुः लड्डुकम् खादितुम् न इच्छति।’ अध्यापिका - सुरेश, त्वम् वद। अस्मिन् वाक्ये मण्टुः कः । सुरेशः - मण्टुः मूर्खः। अध्यापिका - कथम्। सुरेशः - आर्ये, कः लड्डुकम् खादितुम् न इच्छेत्।
Inter linear, literal translation हास्य-कणिका laughter-particle अध्यापिका teacher व्याकरणम् grammar पाठयति teaches। कर्ता subject कः who, कर्म object किम् what, क्रिया verb का who इति so बोधयति explains। तत्परम् thereafter सा she कृष्ण-फलके on blackboard इदम् this वाक्यम् sentence लिखति writes - ‘मण्टुः Mantu लड्डुकम् sweetmeat खादितुम् to eat न no इच्छति desires।’ अध्यापिका teacher - सुरेश Suresh, त्वम् you वद speak। अस्मिन् in this वाक्ये in sentence मण्टुः Mantu कः who। सुरेशः Suresh - मण्टुः Mantu मूर्खः fool। अध्यापिका teacher - कथम् how। सुरेशः Suresh - आर्ये madam, कः who लड्डुकम् sweetmeat खादितुम् to eat न no इच्छेत् desires।
Natural translation Joke Teacher is teaching grammar. She explains what is subject, what is object, what is verb. Then she writes this sentence on the blackboard: Mantu does not want to eat sweetmeat. Teacher: Suresh, you answer. What is Mantu in this sentence? Suresh: Mantu is a fool. Teacher: How? Suresh: Who does not want to eat sweetmeat?

Friday, November 14, 2014

First Camel Integration home project

Sanskrit Newspaper - Sanskrit Dictionary integration using Camel
1) spin up a tomcat container running camel (AWS - EC2)
2) pull from articles in http://sudharma.epapertoday.com/
3) event driven pull from dictionary http://spokensanskrit.de/
4) results merged with editorial content on  http://pradyumnsharma.blogspot.in/

Normally I would have gone with a YQL (yahoo query language) solution implemented in javascript, which could be embedded into Pradyumn's blog, but I saw this as a change to architect a simple enrichment pattern in camel, and make this available to him as a webservice.

The camel ETL component also looks promising, so I worked through the example in the Camel download. Be careful that your later version may no longer set the entity manager in the header of the camel exchange -- I simply grabbed the entity manager factory from the exchange via the registry and it worked fine.

Playing around with this example (which uses JPA to consume records as files and insert/update them into a database) naturally led me to consume instead from a webpage (sudharma) -- merely substituting the file component with the http one. WSnotification might be what is under the hood for the camel http endpoint. I ended up making the following changes to get it to work:
(CXF)
Of course, my goal was not merely to load a database, but make the data available via a webservice for the javascript client to have access to. I could have just fronted the database with a Spring Data REST client, but wanted to remain in camel land a while longer. So I am investigating routing to another http component instead.

Final comfy solution resulted in creating a new component: webpage.