crntaylor's comments

crntaylor | 12 years ago | on: Why Python Runs Slow, Part 1: Data Structures

The part that really surprised me was this:

  We only had 23 years of Python interpreter development,
  how would things look like when Python is 42, like C?
C, which I always think of as an ancient venerable systems language, is less than twice as old as Python, which I think of as a hot new kid on the block.

In thirty years, when my career will probably be drawing to a close, Python will be 53 years old and C will be 72 years old. Barely any difference at all.

crntaylor | 12 years ago | on: Hemingway makes your writing bold and clear

It was a reference to the Hemingway app. If you paste acqq's comment into Hemingway, it suggests "Four adverbs used. Try to aim for two or less."

As humour goes, it's a few levels of indirection away from Seinfeld. But you're on a forum full of people who spend all day thinking of abstractions for their abstractions, so what do you expect?

crntaylor | 12 years ago | on: The Book of Graham

You might not work any less hard, but you'll certainly take more risks if you don't experience the downside.

Answer quickly - how much of your net worth would you risk on a bet with 1% chance of a 1000X payout? Now how much would you risk if you can hand off 90% of any loss you take to someone else?

The difference is what we call moral hazard: http://en.wikipedia.org/wiki/Moral_hazard

crntaylor | 12 years ago | on: The Book of Graham

The investment banking industry basically invented the concept of OPM (other people's money) in the 1980s (okay, I'm sure it existed before that, but the 1980s was when it became a buzzword).

A great read if you're interested in learning more about the history and operating procedures of the sales & trading side of investment banking is Traders, Guns and Money by Satyajit Das. Its sections on credit default swaps and collateralized debt obligations are particularly interesting when you consider that they were written in 2006, pre-crisis (around the same time that Leveraged Sell Out was getting started, in fact).

crntaylor | 12 years ago | on: Why Mt. Gox is full of shit

In case it's not clear to you, there are two reasons that you are getting downvoted: 1. snark, and 2. you are committing the logical fallacy of affirming the consequent. [0]

In particular, dijit asserted that "Not ACID => Not secure" (which is debatable, but that doesn't matter here) from which you can also validly deduce the contrapositive "Secure => ACID". However, you then (sarcastically) asserted that dijit is saying "ACID => Secure", whereas in fact he said nothing like that.

[0] http://en.wikipedia.org/wiki/Affirming_the_consequent

crntaylor | 12 years ago | on: High-Speed Trading Isn't About Efficiency—It's About Cheating

You tend to hear high frequency traders refer to the code that makes pricing and trading decisions as a system, or signal, or model, or (very occasionally) algo (all refer to slightly different things) but I have never heard them refer to the code that makes trading decisions as a bot or algobot.

Source: I used to work in high frequency trading.

crntaylor | 12 years ago | on: The Egg (2009)

This would have been a significantly more enjoyable experience if the title of the submission didn't give away the ending.

crntaylor | 12 years ago | on: 1/9998 = 0.0001 0002 0004 0008 0016 0032 0064 0128 0256..

The pattern will break down once you get past 8192, which is 2^13. That means that the pattern continues for an impressive 52 significant figures (well, it actually breaks down on the 52nd digit, which will be a 3 instead of a 2).

The reason it works is that 9998 = 10^4 - 2. You can expand as

    1 / (10^n - 2) = 1/10^n * 1/(1 - 2/10^n)
                   = 1/10^n * (1 + 2/10^n + 2^2 /10^2n + 2^3 /10^3n + ...)
which gives the observed pattern. It breaks down when 2^k has more than n digits, which happens approximately when

    2^k > 10^n   =>   k > n log(10) / log(2)
which comes out to 4 * log(10)/log(2) = 13.28 when n = 4.

---

Another pattern can be generated from the power series expansion

    x / (1 - x)^2 = x + 2x^2 + 3x^3 + 4x^4 + ...
setting x = 1/10^n gives the infinite series

    1/10^n + 2/10^2n + 3/10^3n + ...
which leads to the neat fact that

    1 / 998001 = 0.000 001 002 003 004 005 006 007...
---

Another example is the fraction

    1000 / 997002999 = 0.000 001 003 006 010 015 021 ...
which goes through the triangle numbers[0] in its expansion, or

    1 / 998999 = 0.000 001 001 002 003 005 008 013 021 ...
which goes through the Fibonacci numbers[1].

---

Getting the squares is harder, but you can do it with

    1001000 / 997002999 = 0.001 004 009 016 025 036 049 ...

[0] http://en.wikipedia.org/wiki/Triangle_number

[1] http://en.wikipedia.org/wiki/Fibonacci_number

crntaylor | 12 years ago | on: A Worst Case for Functional Programming?

Having someone re-write my 7 line Haskell program into 40+ lines of C# is the best argument I can think of for why it's worth learning a functional programming language ;)

crntaylor | 12 years ago | on: A Worst Case for Functional Programming?

"Turning your code inside out" is a great piece of advice, as it often opens up abstractions and refactorings that you didn't realize where there to begin with. The same idea is behind several common object-oriented design patterns (Command, Mediator, Strategy, Visitor) but it's baked into to many functional programming languages.

For example, say we want to write a function to compute square roots. A common approach to computing sqrt(n) is to start with a guess of x = 1.0, and keep replacing x with (0.5 * (x + n/x) until the relative difference between subsequent guesses is small enough.

  sqrt n = loop x0 x1
   where
    loop x y = if converged x y
      then y
      else loop y (0.5 * (y + n/y))
    converged x y = abs (x/y - 1) < 1e-10
    x0 = 1.0;
    x1 = 0.5 * (1.0 + 1.0/n)
That's good, but it has the test for convergence all mixed up with the logic for generating the guesses. What if we could factor out the code that generates an infinite sequence of guesses?

  sqrtGuesses n = go 1.0
   where
    go x = x : go (0.5 * (x + n/x))
Note that this works in Haskell because of laziness, but it's simple in any language that has a mechanism for delaying computations. Now we've decoupled the method for generating a sequence of guesses, we can write a function that checks for relative convergence

   converge (x:y:rest) = if abs (x/y - 1) < 1e-10
     then y
     else converge (y:rest)
and define the square root function in terms of these

   sqrt n = converge (sqrtGuesses n)
The logic of the program is now much cleaner, and we've got a useful function 'converge' which can be re-used in other parts of the program.

This kind of 'turning inside out' is often possible in functional languages, often leads to more compact and more compositional code, and is one of the reasons that I enjoy programming functionally so much.

crntaylor | 12 years ago | on: Money and wealth

Disclaimer - I've never played Starcraft or Magic: The Gathering.

But I expect that in both of them, just like in real life, there is some value to having unspent liquid assets, in that they give you optionality. Unspent liquid assets can be converted at a later time into marines/computing hardware/other 'real' assets, depending on what is most needed at the time. If you turn all of your liquid assets into illiquid assets as soon as you get them, you lose that optionality.

crntaylor | 12 years ago | on: What is your best programmer joke?

I know an accounting joke:

An engineer and an accountant are on a train when they pass between two fields of sheep.

"Boy, there are a lot of sheep in those fields." says the engineer.

"There are 1,005" says the accountant.

"How do you know?"

"Well, there are about 1,000 in that field, and there are 5 in the other one."

crntaylor | 12 years ago | on: Bruno Latour - Scientific Humanities MOOC

Anyone thinking about taking this course should be aware that Bruno Latour is not, and has never been, a scientist. He is in the same camp as Derrida, Lacan and Foucault, in that he has a great deal to say about science but very little experience of it.

He is the creator of 'Actor-Network Theory'. I summarize the introductory paragraphs from Wikipedia, to give you a flavor.

  Actor–network theory is an approach to social theory and
  research, originating in the field of science studies, which treats
  objects as part of social networks. It can technically be described
  as a "material-semiotic" method. This means that it maps relations
  that are simultaneously material (between things) and semiotic 
  (between concepts). It assumes that many relations are both 
  material and semiotic.

  Broadly speaking, ANT is a constructivist approach in that it 
  avoids essentialist explanations of events or innovations (e.g. 
  explaining a successful theory by understanding the combinations 
  and interactions of elements that make it successful, rather than 
  saying it is “true” and the others are “false”). However, it is 
  distinguished from many other STS and sociological network theories 
  for its distinct material-semiotic approach.

crntaylor | 12 years ago | on: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

Completely shameless plug for a tiny probabilistic programming language that I wrote as an embedded DSL in Haskell:

https://github.com/chris-taylor/hs-probability

The code that solves this problem is:

  solve = do
    coin   <- choose (999/1000) fair biased
    tosses <- replicateM 10 coin
    condition (tosses == replicate 10 Head)
    nextToss <- coin
    return nextToss
   where
    fair   = choose (1/2) Head Tail
    biased = certainly Head
page 1