Monday, January 12, 2015

Chronicles of Conrad as a Coder

I have never worked in the tech industry before.

  1. First day to work- try to build the work computer that I choose parts to customize and find out that my graphics card doesn't have linux drivers. I stay till midnight but still can't fix it. I get in to work early Tuesday and fix it just as people are streaming in. Phew.
  2. First week- so our company is a PaaS so we end up doing a lot of tech support for tech guys. I find out that my knowledge is in no way superior to the programmers asking me questions- it takes me a full work day to answer questions that my coworkers take half an hr to answer. My support work basically involves me verbally asking my coworkers and then regurgitating back to the people with questions. And my speed for this particular sort of work is 16x slower than my coworkers.
  3. Over the wkend, my computer completely breaks because of the graphics card issue. The more I try to fix it, the worst it gets, and it gets to the point where I can't even get to the GRUB bootloader screen. I learn a lot about mounting file systems, installing desktop managers, and debugging from commandline. I have also installed and reinstalled various flavors of linux over 10 times. I spend the whole Monday trying to fix this issue but failing. I had the foresight to bring a laptop to work and did not have the foresight to bring my power cable. I have to pop out to buy one and realize that Mac power cables are a total ripoff. Another day spent working at a tech company not using a computer. Manage to fix it Tuesday morning again- I make sure everything is well documented in case my computer blows up again.
  4. Second week- I move from my temporary stay that is 30 seconds away from work to my friend's place that is not in central London. I find out that what seems like a 30min travel time on a good day could easily become 2hrs+. Then the climax: the train station conductor convinces me to board this train that is supposed to go in to central London. Instead, it is a direct train going to Brighton with no stops in between. Brighton is on the UK shoreline and is a "classic British beach town". My coworkers hear about this, think it's hilarious, and encourage me to check it out before I come back.
  5. At end of this second week, it is getting close to Christmas, and I realize everyone is going away for vacation and people are advising me to stock up 3 days of rations because all transportation and restaurants will be closed... I ask if I can take some time off as well. I'm going back to HK so I ask for 2.5 wks of vacation... less than two weeks in. I fully expect the response to be "yes, why don't you just take an extended vacation and not come back".
  6. My third wk (and last wk before vacation starts) is nice and peaceful with no major accidents. Yay! Well I was supposed to experience my first deploy to the live website, but that occurs at 6am in the morning so as not to affect the workflow of our customers. Needless to say, the trains failed me again. I get in at the very end of the deploy. In time to share a post deploy celebratory breakfast with everyone. All in all, I consider my performance this week to be stellar in comparison to the other weeks. I jet off Friday night to HK.
  7. While in HK, I encounter what seems like a problem with my company's email server. I am unable to send emails for multiple days. That sounds bad- I'm just going to disappear for 2.5 wks and not respond to any work emails? It turns out that this time it actually isn't my fault. HK PCCW blocks their users from sending requests to non-whitelisted smtp servers because of spam. Literally the whole of HK needs to use their email server. I am speechless. I also end up tethering my phone a lot.
  8. On new years eve, I notice an irregularity on the web server and go in to try to fix it. I run a bunch of monitoring tools after ssh-ing into the server, identify the problem process, and decide to kill it. Then the server magically comes back up. I believe I am a true hacker. I later find out that my coworker had also saw the problem and went in and actually fixed it as I was fiddling around. Well... at least I tried. Hopefully whoever's process I killed won't be too mad at me.
  9. My first week back after the break- I am now super up to speed with everything, I can do support in 8x the time instead of 16x the time now, and I actually debugged and saved a couple servers from certain death! I am truly, truly a skilled and seasoned programmer now. Of course, I did restart nginx on our load balancer instead of reloading it, and brought down the thousands of websites hosted on our company for a couple minutes, but that only just a scare.
  10. It is now Friday of my fourth week. I am taking on cool side projects such as writing scripts for other people to use. Clearly I am a pro coder now. Here is one such script: clone a git repository of your config files (bashrc etc), and put them into your home directory by creating symlinks. Well but then of course you should create a backup folder for the configs that you are writing. Let's put them in ~/backups. Oh wait, that's weird, ~ doesn't expand to /home/username/. I just created a ~ folder in my current working directory, with backups etc in it. Well I guess I'll just "rm -rf" it.
 Let us just pause for a second to bask in the ramifications of this.

For the non-tech initiated, I just removed everything in the home directory. rm -rf is a locust that will go in and eat and kill and destroy anything in it's path. And I just released it on basically everything*. And there is no such thing as the trash folder where us pro coders play. Nothing is recoverable because you are expected to know what you are doing.

Let us pause again and imagine the worst case scenario.

* not everything. I guess "rm -rf ~" is better than doing it on "rm -rf /". But it sure seemed like everything then.

Tuesday, August 5, 2014

Poker: cbet frequency

Below is a pretty rough look at how frequently you should c-bet.

In particular, I will look at an arbitrary scenario where you were the preflop opener and someone called behind you. It is easier to analyze than in position c-betting, since you have less information and must play more straightforwardly.

To keep it simple, lets say we opened UTG in full ring with the range detailed in the last post (77+, ATs/AQo+, KQs). The flop comes A92 rainbow. Then 40 of the 92 hands (ATs/AQo+) hit the A, 12 hands (AA and 99) flop a set, and the rest 40 combos are worse than top pair. Again following last post, bet sizing for OOP play on this sort of flop should be ~1/2x-3/4x pot.

Bet Sizings of 1/2 pot

Let's say we choose to standardize it at 1/2x. Then let's say we bet the 40 top pair hands, and try to check raise the sets. How many hands can we bluff? To make opponent indifferent to bluff-catching vs folding (ignoring subsequent streets for now), we bluff 1/3 of what we can value bet- 13 hands. This means that we would choose 77 and 88 to bluff with, and check only TT-KK and KQs.

So in this scenario, we are c-betting 56% of the time, and of the 44% we check, we are checking a set (13%) almost 1/3 of the time. Let's say someone bets half pot after we check. Suppose we checkraise all of our sets and we lay them 3:1 odds (ie. will match + raise half pot, or make the total pot size 3x initial flop pot). Then again, we should bluff 1/3 of the time that we check raise with a legit hand = 4 hands- we can bluff and play KQs like we play our sets for this round of betting. That is another 4% of our opening range.

So now we are left with the TT-KK (26%) that we checked. Maybe KK/QQ warrants one street of check calls depending on the bet sizes.

Let's assume that the opponent doesn't have anything. Then we (UTG opener) are taking down the pot ~75% of the time given this board. That sounds about right.

Bet Sizings of 3/4 pot

So let's say we choose to standardize our bets at 3/4 pot. Maybe we can be more conservative and check call with hands like AJs/ATs. Then we are betting 32 hands outright, and should bluff 32*3/7 = 14 hands. So 77, 88, and half the KQs.

You check raise the sets again, but size it to lay 7:3 odds. So then you can bluff 12*3/7 = 5 hands. Lets say 5 out of 6 TT.

So you are left with 23% of hands (JJ-KK, 2 KQs, 1 TT) that you might checkfold here, and another 9% of hands that you are probably check calling (ATs AJs). Of course, whether your check call or check fold these 32% of hands actually just depends on your opponent's bet size.

Bet Sizes and Clairvoyance

Also note that if we were more aggressive and bet AJs/ATs, then we could fit all the KQs into the bluffing range as well, and we are left with 20% (JJ-KK, 1TT) in our checking-call/fold range. This makes sense because the bigger the bet size the more the opponent will have to fold.

However, this requires clairvoyance- we are making the implicit assumption that AJs/ATs are good- when in fact they might be losing hands. By clairvoyance I mean knowing for sure that you are ahead while your opponent is not sure.

Clairvoyance tends to promote heavier betting to maximize EV by replacing parts of our checking range with our bluffing range. However, note that when we do bet, our EV is the same regardless of bet sizing.

For example, if you were deep stacked with the nuts and no hand can improve to beat it, you could bet 100x pot and bluff at close to the same frequency (100/101x nut frequency). Whenever your opponent is faced with this bet, he should theoretically call to bluff catch 1/101 of the time. Of all the hands that you jam, this allows you to take down ~99% of pots right away and showdown with just over 50% chance of having the nuts in a 202xinitial size pot the remaining 1% of time. Notice that even in the scenario where opponent bluff catches, you are expected to get 101.5x initial pot. In fact you expect to get 1.5x initial size when they call. So when you do jam, you get 99% * 1 + 1% * (101/202 * 202 - 100) = 1x initial size.

Compare this to betting only 1x pot. Then you can only bluff 1/2 of the time, and opponent bluff catches 1/2 of the time. So only 50% of pots are taken down right away and you are 2/3 chance of winning if they bluff catch. So the final payoff = 1/2 * 1 + 1/2 * (2/3 * 3 - 1) = 1x initial size.

We make the same amount either way when we bet because everyone is playing optimally. However, we can bet more frequently in the first case vs the second case. ie. Let's say our hand range gives us the nuts 40% of the time. Then if we can jam 100x pot, we can bluff another 39.5%, and say check fold the rest. ie. we get to take the jamming line and make 1x initial size 80% of the time. However, if we bet 1x pot, we only get to bet and make 1x initial size 60% of the time.

In fact, if our hand range was so strong that say we could value bet 67% of the range, then you will see that any bet sizing > 1x pot actually lets us bluff > 33% of our range. ie. we could bet 100% of the time. Once we get past this limit, it is especially profitable to jam. Let us redo the calculations above for expected profit. For any bet sizes up to 1x pot bet, you still make 1x initial size. But for 100x pot bet, you make 99% * 1 + 1% * (67% * 202 - 100) = 1.34x initial size. It turns out that if our range and effective stack size ever allow for a bet size that lets us bet 100% of the time, then jamming above that size potentially lets us make above average profits. In fact, the optimal solution for our opponent if they knew our range would be to fold 100% of the time (ie. they can never try to bluffcatch).

So why do people not jam all the time? As stated above, in practice, it is unclear whether you are ahead or not. A smaller bet size lowers the cost if you make such a mistake. Also, what if your opponent does not play optimally and makes mistakes in subsequent play? Then you may have a reason to give more room/space for them to make errors, instead of forcing them to take the easy correct path.

In real life, the hand that is behind may also have outs. Then, how much you bet is actually affected by how likely you are to get drawn out on. As discussed previously in, this can be calculated by considering pot odds and implied pot odds. In real life, you might not be sure which draw/how many outs your opponent has.

To be safe, you could try to price out the draw with the most outs. Theoretically, overbetting is not a big mistake since your opponent cannot take advantage of it immediately (vs if you underbet, opponent can call and you make < 1x initial size).  However, in practice you are again helping your opponent make the correct decision, and if you were wrong and you were in fact behind, then it will be very costly. So perhaps your should take the most common draw and size your bet according to that.

So it turns out that your bet sizing should be determined by the # of outs/how coordinated the board is, and that your action (value bet/bluff/check) frequency should be affected by your hand range. On a side note, if you needed to bluff catch, you would base your decision off of your opponent's range, not your own range.

Wednesday, June 18, 2014

Poker: An Overview

Hand Ranges

I was doing some house keeping the other day and decided to re-look at my hand ranges to open and raise in a 9 handed game:
  • UTG (7% for 2 opponents) 77+, ATs/AQo+, KQs
  • UTG+1 (10% for 2 opponents) 77+, A9s/AJo+,  KTs+/KQo, QJs
  • UTG+2 (14% for 2 opponents) 66+, A7s/ATo+, K9s/KJo+, QTs+, JTs
  • MP1 lowjack (20% for 2 opponents) 55+, A3s/A8o+, K7s/KTo+, Q9s+/QJo, JTs
  • MP2 highjack (25% for 1 opponent) 44+, Axs/A7o+/A5o, K6s/K9o+, Q9s/QTo+, JTs
  • cutoff (35% for 1 opponent) 33+, Ax, K3s/K7o+, Q6s/9o+, J8s+/JTo, T9s
  • dealer (50% for 1 opponent) 22+, Ax, Kx, Qxs/Q5o+, J5s/J8o+, T7s+/T9o, 98s
  • SB (50)
We can see this gives an attempt to steal of ~40-45% over the cutoff/dealer/SB positions. This sounds slightly high but still reasonable in online poker. Notice that our range is also skewed to play less OOP and more IP, because I just find it to be easier that way. This is in comparison to a "typical" opening range for UTG to SB: 12/14/16/19/24/31/45/60. ie. open UTG with 12% and hands, open UTG+1 with 14% of hands etc.

Using our opponent's "typical" opening range, we can calculate how frequently we will open: (7% + 0.88*10% + 0.88*0.86*14% + 0.88*0.86*0.84*20% + 0.88*0.86*0.84*0.81*25% + 0.88*0.86*0.84*0.81*0.76*35% + 0.88*0.86*0.84*0.81*0.76*0.69*50% + 0.88*0.86*0.84*0.81*0.76*0.69*0.55*50%) / 9 = (7% + 0.88*10% + 0.7568*14% + 0.6357*20% + 0.5149*25% + 0.3913*35% + 0.2700*50% + 0.1485*50%) / 9 = 8.8%

Now also consider the number of times that we 3bet. Roughly, we should 3bet if we are in the top half of the range of the raiser. Instead, let us approximate by saying we are going to 3bet/call raises with the top half of our own open raise range for that position (UTG+1 to dealer). From SB and BB, let's say we will play top 5% of range. Let us approximate our 3bet/call frequency as follows:
(0.12*5% + 0.25*7% + 0.36*10% + 0.49*14% + 0.6*20% + 0.73*25% + 0.85*5% + 0.95*5%) / 9 = 6%

This means we have a VP$IP of very roughly 14%-15%. Tracking my own statistics, I see that I have a VP$IP between 12%-20% each session, and PFR 10%-16%. This sounds roughly inline with what we looked at above (a bit looser) and points to a roughly 50/50 split between 3betting (3%) vs calling (3%) when facing a raise. Whereas previously, most of the calling came from set mining OOP because I was getting say 1:3 odds, I am working on reducing that and instead changing some IP 3bets into flat calling to limit pot sizing, especially against calling stations.

Bet Sizing

Preflop Bet Sizing
Whereas previously I have employed a 3bb bet sizing for late position steals, recently I am testing out a smaller size so the pot doesn't get too bloated. I've frequently had hands before where SPR gets so low that I am committed with mediocre hands.
  • 2bb for UTG, UTG+1, UTG+2
  • 2.5bb MP and LP
  • 3.5bb in SB
For 3bets, I tend to do a bit over half pot if IP and close to full pot if OOP.

Flop Cbet Sizing
Previously, I always ran into trouble betting 1x pot OOP because I would lose pots like overpairs/two pairs against sets or better. That itself is not an issue, but I would be way too committed to fold by the time the opponent showed enough strength/their hand range had clarified to the pt where I am behind/have < 50% equity. Hopefully, the smaller preflop bet sizing should help with the "Bayesian updating" before the pot gets too big. In a 3betted/4betted pot though, I might have to check-call more often on the flop/turn/river, or use 1/2x pot bet sizes.
  • OOP- usually 1x pot
  • IP- usually 1/2x pot
Adjustments:
  • adjust size up by 1.5x-2x of normal bet if flop is super wet
  • adjust down to 2/3-1/2x if the flop is super dry
However, I have not thought very deeply on how to incorporate probe bets into flop betting yet. Also, what % of flops should you cbet, and what % should you check raise/call/fold? Should your hand range or bet sizes change as the effective stack size changes? I hope to think about these points in another article.

Monday, May 12, 2014

Behavior Design

Just read this pdf that David Ngo came out with called learn behavior design. Here are some notes/thoughts:
  • fog behavior model
    • to do anything (eg: pick up phone), you need all three of (1) trigger, (2) ability, (3) motivation
    • hot triggers- something u can do right now- vs billboards
    • ability vs motivation tradeoff-
      ​ doing something hard requires high motivation; if your motivation ever drops, then you break your habit​
  • ​​tiny habits + celebrations
    • ​LT behavior chg can come from chging environment​
    • ​LT behavior chg cannot come from just motivation​ (because it is too unstable and so you will break habit)
    • ​u want to ​
      get to the "blue path"
      ​ from the behavior grid​
      ​ at behaviorgrid.org​. ie. how to start doing familiar behavior, and then slowly increase/build from there
    • ​ design many many beneficial behaviors that get to ​​good outcomes (eg: a bunch of behaviors that make you healthy)​ and then wait for the tiny habits to take hold and grow naturally
      • ​easy to do in beginning and end of day​
    • http://www.behaviorwizard.org
  • ​motivation wave
    • natural to have ​peaks where you can temporarily do hard things and troughs/normal periods
    • ​​
      ​help people succeed on the most desirable behavior that matches their current motivation
    • ​should somehow measure how motivated u r and then do the hardest work possible (any higher == not enough motivation and give up)
    • when you are at peak motivation, do hard things that will 
      1. ​​
        structure future behavior
      2. ​reduce barriers to behavior
      3. increase skill/capability so it's easier to do activity in the future
    • these all move future activities further down the motivation/ability curve towards easier to do --> less motivation required later​
    • ​do your tiny habits, prestructured behavior, and easy one time behaviors, baby steps during trough
    • ​you cannot "motivate" behavior change; artificially boosting motivation doesn't work​

Monday, April 28, 2014

Setting up podcast alarms for your mac

Quick notes on how to configure your mac so that you can wake up to podcasts/get podcasts to play every hr etc.
  1. make a podcast playlist on itunes
    1.  create a smart playlist from your musics tab as follows (I called mine "New Podcasts") 
    2. you probably want to configure the podcast settings so that you only keep the most recent episode (otherwise say for NPR hourly podcasts, your playlist will include multiple podcasts from NPR hourly)
  2. create an application with automator
    1. create a new application and save it somewhere
    2. search for itunes and put "get specified itunes times" into the right side (then add your playlist u just made)
    3. search for itunes and put "play itunes playlist" into the right side
    4. this is how it should look at the end.
  3. system preferences -> users & groups -> login items: add your automator application to get it to run on login
    1. to get computer to automatically turn on, system preferences -> energy saver -> schedule -> startup/wakeup every day at xyz time
  4. go to calendar and add repeating items for daily/hourly runs
    1. create a new event, make it repeat
    2. go to the alerts -> custom -> open file. and instead of opening calendar, open the application
  5. to automatically download/get the most recent podcasts, the easiest would probably be to write an applescript, then export it as an application (and then schedule to run it right before your podcast alarm)