Wednesday, December 6, 2017

AlphaZero

The Deep Mind division of Google just released a paper in which they describe how they applied the methods they used to develop a Go program that achieved super human strength to develop programs to play chess and shogi.  The best previously existing chess and shogi programs are based on alpha/beta search and have been incrementally improved over many years.  They have been stronger than the best human chess players for about 20 years (Deep Blue beat Gary Kasparov in a 6 game match in 1997) and recently surpassed human shogi players as well.  However the Google programs (named AlphaZero in each case) appear to be stronger still, defeating Stockfish, a strong chess program, and Elmo, a strong shogi program by wide margins in 100 game matches.  10 example games (all wins for AlphaZero) in the match against Stockfish were included in an appendix to the paper and can be played over here.  They are pretty convincing (with the caveat that there doesn't seem to be much opening variation).  AlphaZero wins several games with long term positional sacrifices where it is not initially apparent that it has sufficient compensation for the material loss.

This is kind of a big deal.  People had tried applying Monte Carlo search with neural net evaluation functions to chess before but were unable to match the performance of highly tuned alpha/beta search programs developed over many years with lots of domain specific knowledge hardwired in.   Using a general algorithm with domain specific knowledge limited to the rules of the game to quickly develop apparently superior programs is impressive and a bit scary.

Sunday, March 26, 2017

Workaround

Long ago I was given a Zenith "Circle of Sound" digital AM/FM clock radio and it has served me well over the years.  Recently however it has developed a bizarre fault.  It has a 3-way switch on the back for setting the time or alarm.  Move the switch one way and you can adjust the time, move it the other way and you can adjust the alarm setting, return the switch to the center position to resume normal operation. But now when I move the switch to adjust the time the time displayed is different from the time displayed in normal operation and adjusting it has no effect on the time displayed once the switch is returned to the center position.  I discovered this when trying to advance the time (spring forward) for daylight savings time.  Fortunately I figured out an alternative way to set the correct time.  If you unplug the radio and then plug it in again the time is set to 12 PM (midnight).  (At one time the radio had a battery that allowed it to keep time across short power failures but this gradually ceased to work.)  So I was able to set the time correctly by unplugging the radio, waiting until midnight and then plugging it in again.  A little inconvenient but fortunately the time doesn't have to be set very often.

Tuesday, January 24, 2017

2016 Portfolio Review

After several years of trailing the market, in 2016 my brokerage account outperformed. It had a total return of 13.67% (composed of capital gains of 10.97% and income of 2.70%).  The market (as represented by the S&P 500 ETF index fund VOO) had a total return of 12.04% (capital gains 9.83%, income 2.21%).

My best performer was SOUHY (a spinoff of BBL) which was up 260.71%.  However this is my smallest position.  BBL also did well up 41.55% but remains badly under water.  These are mining stocks and CAT (which makes mining equipment among other things) also rallied strongly up 40.99% as did my railroad, NSC, up 30.55%.  My Canadian banks (BNS up 43.08% and CM up 29.31%) did well as did JPM (up 33.47%).  My other American bank, Wells Fargo (WFC) lagged (up 4.17%).  I purchased WFC in hopes it would be less scandal prone than JPM which hasn't worked out too good. My Australian bank WBK (down -.22%) continued to underperform.

My energy holdings XOM (up 19.62%)  and the sector ETF, VDE (up 28.84%) beat the market but COP (which I sold in October) lagged (off 2.73%).  The sale proved poorly timed as COP rallied at the end of the year ending up 9.53%. This is a pitfall of tax loss selling, you can end up selling temporarily depressed securities before they recover.  I would have been better off reinvesting the sale proceeds in VDE as I considered but didn't do.

My utilities also beat the market with ED (up 18.81%) and PEG (up 17.65%) slightly outperforming my sector ETF, VPU (up 17.56%).  VYM (a high dividend ETF) also outperformed (up 16.82%) as did insurance companies Allstate (ALL up 21.45%) and Aetna (AET up 15.62%).  IBM (up 24.61%) also outperformed.

Lagging were VNQ (a REIT index ETF) up 8.50%, Intel (INTC) up 8.30% and Target (TGT) up 2.67%.

I began the year with 4.54% in cash and ended with 8.38%.  The increase was due to dividends received and the COP sale slightly offset by the increase in value of the portfolio.  The cash position hurt performance as interest rates remained near 0.  The COP sale was my only trade.

Although I beat the market this year I remain well behind over the life of the account.  Beating the market (other than by luck) is hard and probably isn't something the average person should expect to do.

Tuesday, January 17, 2017

Dubious Bargains

A few months ago I was in  Staples and saw they had 5 reams (a ream is 500 sheets) of printer paper on sale for $5.  I found the price irresistible so I bought a pack.  This is a good price but perhaps I should have passed.  I already had 2.5 reams on hand.  Since I use about 250 sheets a year this is a 5 year supply so I wasn't about to run out.  Furthermore the price wasn't really $5, it was $30.99 with a $25.99 rebate.  Since sales tax is charged on the price before the rebate the effective price was more like $6.70 (still a bargain of course).  And to get the rebate you had to apply (which fortunately you could do online) and then wait months to be mailed a prepaid debit card. Eventually I got an email saying my card was in the mail which seems unlikely as it took another 2 weeks or so to arrive.  But it finally came and it turned out to be simple enough to spend the balance at the place I usually buy lunch.  So things worked out but saving a few dollars probably wasn't worth the hassle.

It is also a little hard to understand how this benefits Staples.  Perhaps enough people fail to apply for or spend their rebates to make the deal profitable.  This seems a little unlikely but it would be interesting to know what the follow through rate is.  Or it could be some sort of promotion to get people comfortable with prepaid debit cards. However while the card was easy enough to use it doesn't seem to me to have any advantage over cash.   But at least the state of New Jersey came out ahead.

Tuesday, January 10, 2017

2016 Election

Some belated comments on the recent Presidential election.  I considered not voting as I was going to be out of state on election day and the result seemed a forgone conclusion.  However voting by absentee ballot isn't all that hard and it is never likely that your individual vote will matter.  So I ended up preserving my perfect record of always voting in Presidential elections.

I voted for Trump.  Obviously Trump is a seriously flawed candidate so this was more an anti-Clinton vote than a pro-Trump vote.  I got a hostile vibe from Clinton and many of her supporters, that they would prefer to win the election without my vote.  This of course didn't endear her to me.  For what it's worth I didn't get the same vibe from Obama. Perhaps he is more open minded or perhaps politics has just gotten more divisive in the last few years.  Anyway it's hard to get someone's vote if you are unwilling to ask them for it.

Of course once you have decided you don't like someone it is easy to find things about them that annoy you.  One such thing in Clinton's case is the nepotism angle.  When George Wallace got his wife elected Governor of Alabama (when he couldn't run himself) no one (as far as I know) claimed this was some great breakthrough for women.  But somehow if Bill Clinton had gotten his wife (who is unlikely to have become a national figure if she hadn't married Bill) elected President we were supposed to pretend she had accomplished this on her own and that it was some major feminist achievement.  Now this is hardly the only example of nepotism in politics but at least when there is a blood connection (as with the Bushes) there is a possibility that political talent runs in the family.

Another thing I found annoying about Clinton was her private email server.  Now you can certainly make the case that this while a dumb mistake wasn't that big a deal.  However in course of defending her, her supporters repeatedly made assertions contrary to my understanding of the regulations about handling classified information and preserving federal records.  Since my understanding is based on courses I am required to take every year as part of my job I am inclined to give it some weight.  Now one of the defenses made on her behalf is that these rules don't apply to the big shots.  While it is true as a practical matter that big shots can often get away with stuff that would get lower level people in trouble this is maybe a defense her supporters would have been better off not making.  

Saturday, January 7, 2017

State Tax Changes

Last November 1, New Jersey raised its state gas tax by 23 cents a gallon.  This was a pretty big increase, the old rate was 14.5 cents per gallon so the tax more than doubled but I didn't really object. The old rate was anomalously low and the roads have to be paid for somehow.  And the effect on me was insignificant.  I estimate I buy about 300 gallons of gas a year in New Jersey so the increase will cost me about $70 a year or a bit more than a penny a mile.

As part of the deal to raise the the gas tax the New Jersey sales tax was cut from 7% to 6.875% starting January 1, 2017 and to 6.625% starting January 1, 2018.  This affects me even less.  I estimate I spend about $10,000 a year subject to this tax.  So I will eventually save about $37.50 a year in sales tax or just over half of what the gas tax increase will cost me.

As noted above the first stage of the sales tax decrease was supposed to take effect on January 1, however I was a bit surprised to see the my local upscale supermarket still charging the old rate on Tuesday January 3.  However this was fixed by Wednesday and they apologetically refunded my nickle when I complained.

Sales tax rules tend to be complex and constantly changing so they impose a considerable compliance burden on businesses.  This is especially true for companies like Amazon who have to keep up with all the changes nationwide instead of just those affecting their particular location.  In my view any effort to make more out of state merchants collect sales tax needs to be coupled with simplification to reduce the compliance burden.

Sunday, December 25, 2016

Leela

Earlier this year I recommended the web based free computer Go program, Cosumi.  Leela is another free computer Go program.  Unlike Cosumi it runs on your computer.  I downloaded version 0.7.0 (the current version is 0.8.0) a few months ago.  I have played both programs quite a bit, mostly 9x9 games.

The programs have distinct styles.  Cosumi apparently plays to maximize its score.  This reduces its winning percentage because it doesn't play safe when ahead or take more risks when behind.  I have won many lost games because Cosumi loses a live group (or allows me to revive a dead group or both) while trying for 1 or 2 more points and misreading something.  Cosumi doesn't resign and will play games out to the end.  I like this as it allows me to practice my endgame and counting skills even if the game isn't close.

Leela on the other hand appears (like other Monte Carlo tree search programs such as Alpha Go) to play to maximize its winning percentage. This has some weird effects when Leela doesn't think the game is close as a bad move which loses some points may be hard to distinguish from a good move in terms of winning percentage.  So when Leela is ahead it will often chuck away points and end up winning by half a point although the game wasn't actually close.  And when Leela is behind at some point it will start making unsound moves in a desperate attempt to catch up.  If you keep your head and reply correctly Leela will then soon resign.  I don't like this behavior as I like to know what the margin of victory (or defeat) was.  Leela does have a "no resign" option which I haven't tried. By itself it won't help much as Leela still won't always be playing good moves if it doesn't think the game is close and the margin of victory may not be an accurate reflection of how close the game was.

Leela is the stronger program especially on the full 19x19 board.  Cosumi is competitive on the 9x9 board.  I matched the programs against each other in a 10 game 9x9 match and Leela only won 6-4. But when I tried a couple of 19x19 games Leela crushed Cosumi.  This is consistent with my experience.  I usually lose to Cosumi on 9x9 but easily won the two 19x19 games I tried against it. Cosumi seems to have trouble evaluating the safety of large groups and sometimes loses them because it fails to adequately secure them.  It's hard to win if you keep losing large groups.

Leela is a pretty simple program but it does have more options than Cosumi.  It has a rated game option in which it tries to adjust its strength to match yours.  And it has an analysis feature in which you can go over a game and see how Leela evaluates each position.  There isn't much documentation and there are additional features I would like to see but I can't complain too much about a free program.

Another difference between the programs is Cosumi uses Japanese (territorial) scoring while Leela uses Chinese (area) scoring.  This usually doesn't matter (it didn't come up in the games I had them play each other) but it can make a point or two difference which could change the result of a close game so it is something to be aware of.  There are also some slight differences in the rules which usually don't matter but sometimes do.

So in summary I would also recommend the Leela program if you are looking for a free computer Go opponent.  I found it easy to download and install on my Windows laptop (there also seems to be a Apple macOS version).  Leela is stronger especially on 19x19 and has more features but Cosumi also has things to recommend it.  And the different styles mean you can vary your experience by playing both.  It is said that constantly playing the same computer opponent can teach you bad habits as a computer program may consistently let you get away with certain bad moves.  Hopefully playing two quite different programs will lessen this problem.