Elchanan Mossel’s Probability Problem in JavaScript

An interesting problem popped into my twitter feed this morning:

Here’s how I wrote the problem in JavaScript:

function rollDie() {
  return Math.floor(Math.random() * (7 - 1) + 1);
}

function allEven(arr) {
  for (var i = 0; i < arr.length; i += 1) {
    if (arr[i] % 2 !== 0) {
      return false;
    }
  }

  return true;
}

function rollsToSix() {
  var rollResults = [];
  var sixRolled = false;

  while (sixRolled === false) {
    var roll = rollDie();

    if (roll === 6) {
      rollResults.push(6);
      sixRolled = true;
    } else {
      rollResults.push(roll);
    }
  }

  console.log(rollResults);
  return rollResults;
}

function howManyPositiveResults(attempts) {
  var positiveResults = 0;

  for (var i = 0; i < attempts; i += 1) {
    var resultOfRoll = allEven(rollsToSix());

    if (resultOfRoll === true) {
      positiveResults += 1;
    }
  }

  return positiveResults;
}

console.log(howManyPositiveResults(100));

The above program runs the results 100 times and returns the number of positive results. It also logs all the rolls even if the consecutive rolls included odd numbers.

It was fun to watch Mike Lawler do this problem with his children. I learned another approach to the problem from him. You can watch it here:

Exploring Elchanan Mossel’s fantastic probability problem with kids

Conda Command Not Running – How I fixed it

First off, here is the page that provided me with the solution. 

I’m going through Google Developers tutorial on YouTube called “Hello World – Machine Learning Recipes #1”. At 2:55 the teacher says ‘assuming that worked…”

It didn’t work for me, terminal moaned the following:

-bash: conda: command not found

My solution was to add a command to my bashrc.sh file:

export PATH=”/Users/<MY USER NAME>/anaconda/bin:$PATH”

After saving the file, I could run conda commands.

How I’m Running my Crypto Currency Hedge Fund

Initially published May 5th 2017

Today I developed a crypto currency hedge fund strategy. I’m using Coinbase to execute all trades.

Crypto Currency Hedge Fund Spreadsheet Viewable to Public Here

Why Bet on the Game

Essentially, this is a tiny portion of my overall investment account. Indeed, I don’t actually call this part of my investment plan. This is just a fun way to stay up to date with crypto-currencies and do a bit of gambling.

Crypto-currencies have the potential to dramatically shake up the global financial system. While studying economics at the University of Nevada, I learned a lot about monetary relations.

I have a perceptions that the financial industry plays an important role in the security and mobility of capital for individuals and companies around the world. Though I believe the institutions are important, I also believe that organizations like these are using their importance to behave sub-optimally.

Hedge Strategy

As I don’t pretend to have any idea on what is going to happen with any specific currency, I’ll just bet evenly across all of those coins avaliable on Coinbase.

I’ll use a risk assessment which is entirely emotional on my part to make decisions on the ratio of cash to coins. I’m sure it would be better to create an algorithm to balance dollar weight average or find some sort of relationship between ‘bitcoin’ tweet frequency and the coin price… but that would take a lot of time and I’m primarily focused on other things.

Assessing Risk to Balance Portfolio

Since I’m gambling, I get to make up the way I hedge the fund. I came up with the following idea.

I’ll make fund balancing decisions based on how I feel about the currency market:

  • Low (0% Cash) – When I feel that the currencies are at their historical lowest, I’ll take from the cash and invest in currencies.
  • Medium (12% Cash) – When I feel that the currencies could go either way, I’ll take from the cash and invest in currencies.
  • High (25% Cash) – When I feel that the currencies are at their highest and are likely to fall, I’ll take from the cash and invest in currencies.

When I feel that the currencies are overvalued, I’ll hold more cash. When I feel they are selling for less, I’ll hold less cash. Overall, I’ll hold at least 75% of the account at all times.

Trading Frequency

I plan to trade, at the very most, in 30 day increments. This is a long game. I expect to be holding crypto-currencies late into life so I’m in no rush here.

Here is an example of my most recent balancing spreadsheet:

My Crypto Currency Hedge Fund

In Coinbase I was able to execute two sell orders denominated in USD. Then a buy order for Litecoin. From logging into the platform, to deciding on a strategy to executing the orders, this took me about 1 hour.

Some people bet on horses, I like betting on crypto currencies.

Dominating Theory

My dominating theory here is that I have no idea what these currencies will do. I don’t know if one has a chance for implosion, or if one has a chance to be the next bitcoin.

If Litecoin or Ethereum grows from $25 per coin to $1000 per coin like Bitcoin did in 2013, I want to hold a few of them.

That is why I’m only betting emotionally. That is why I’ll restrict my buy/sell decision to impacting, at the very most, 25% of the portfolio.

The rest I’ll leave to chance and time.

Updated September 9th 2017

Well this thing is looking more like a bubble every day.

I haven’t been keeping track at all since May 2017. It was totally out of sight and out of mind. Today I look at the numbers and my crypto currency account total looks like this:

updated crypto currency hedge fund strategy

September 2017 Order Planning

So I’ll be selling off BTC and ETH to buy LTC, GNT, TNT and OMG.

All my BTC, ETH and LTC coins are stored at Coinbase. All my other stuff is on a market called Luiqui. To buy GNT, TNT and OMG I’ll need to transfer $380.85 worth of BTC to Luqui. Then I’ll cash out $85.46 from BTC, and $365.65 from ETH. The next move will be to transfer $125.42 worth of ETH to LTC.

Coinbase account after balancing cryptocurrency hedge fund
Coinbase Account – September 9th, 2017

Finally, as you have to buy coins with BTC/ETH on Liqui, I’ll use the transferred BTC to buy TNT and OMG.

Buying TNT and OMG

The price in BTC of TNT is 0.00002980 at the time of writing this.

I’ll buy 0.03587 BTC worth.

Buying TNT - Crypto Currency Hedge Fund

 

The price in BTC of OMG is0.00287464 at the time of writing this.

I’ll buy 0.03587 BTC worth.

buying OMG coin - Crypto Currency Hedge Fund

 

When I first tried, the prices kept going up. Therefore I would put out buy orders and no one would sell as the prices were higher than my orders.

open buy orders on liqui - cryptocurrency hedge fund

So I just bought higher than the market a little in order to secure the coins to the account.

Finally, I need to up my GNT levels by $70.10 worth of BTC (0.01625 at the time of writing this).

Phew. I guess this is why some people call trading a job. I’ve balanced my portfolio. Now time to go outside and forget about this for a few months.

Liqui account balance - Crypto Currency Hedge Fund
Liqui Account Balances – September 9th, 2017

Taking Money Out

The most important thing in bubble surfing is to take money out.

My guess at this point is that I’ll take 10% of the account out each balancing. I’ll put that 10% into index funds or something boring like that.

Today, I can’t pull my ‘USD Wallet’ out. It takes a few days to verify the bank account I want to use to send the money.

Cryptocurrency Codes

Surfing on Bubbles

Please don’t mistake this for a commendation for crypto currencies as a way to make money. I believe these prices are ludicrous. I expect this to be a bubble which will certainly pop.

Blockchain technology is no joke. It’s a legit scientific development. It’s like a new element that humans have created. I believe a lot of value will come due to the technological leap that is bitcoin. That said, markets grow, bubble and pop because of humans being irrational. High coin prices, I guess, will fall just like the value of dutch tulips in 1622.

tulip mania - crypto currency hedge fund

 

When Transferring Domains – Make Sure to Turn WhoIs Privacy Off

contactprivacy.com Transfer Problem Solved

TLDR – Turn off WhoIs Privacy if you are transferring from hover.com to domains.google.com

Reasoning Behind this Blog Post

While having trouble switching a domain from hover.com to domains.google.com I found the solution which would have saved me a bit of time. I hope this blog post saves you a bit of time if you find yourself struggling with this problem.

Unable to Transfer a Domain? An authorization email has been sent to @contactprivacy.com

The Domain Transfer Problem

Here’s the image that got me stuck:

Turn WhoIs Off

Google Domain Message

An authorization email has been sent to <yourDomaing.ninja@contactprivacy.com. Please follow the instructions provided in the email to authorize the transfer. If we don’t hear back by <date>, the transfer will be canceled.