HNHacker News
TopNewBestAskShowJobs

throwaway283719

402 karma · joined May 16, 2014

submissionscomments
throwaway283719··on Talking about “types”
Can you explain how this makes every function total? For example, take the `head` function which is not total

    head :: [a] -> a
    head (x:xs) = x
    head []     = undefined
How can you make this total using `Partial`? I can get as far as

    headTotal :: [a] -> Partial a
    headTotal (x:xs) = Now x
    headTotal []     = Later (...)
but what goes in (...)?
throwaway283719··on Haskell, Monads and Purity
I think you might have a bug --

    return :: a -> State a
    get :: State Int
    set :: Int -> State Int -- should be Int -> State () surely?
throwaway283719··on Our Invisible Rich
This ignores second order effects - increasing the minimum wage increases the amount of disposable income people have superlinearly, which leads to more trade, which creates more employment opportunities.
throwaway283719··on Hacker News Leaderboard
Interestingly, within the top 100 there is a weak positive correlation between the total karma, and the average karma per comment, implying that the people at the top of the leaderboard are actually posting quality content, and not just making up for it with quantity.

The closest power law fit is

  predicted average score = 0.27 * (total score) ^ 0.25
which has a correlation of about 20% with the actual average scores.
throwaway283719··on Art project: Train rats to trade markets
There were around 480,000 ticks in my sample - who do you believe? ;)

The difference is probably in what is defined as a "tick" for the purposes of computing the stats. If you are using traded prices as opposed to quotes, for example, you will get very different results. If you sample at regular intervals (e.g. 1s) you will get different results again.

throwaway283719··on Art project: Train rats to trade markets
I should point out that it's not at all surprising that the "top 4" rats performed very well. If you got a couple of hundred people, animals, or random number generators to trade using any set of rules you like, and then looked at the top 4, you would almost always find that they outperform, because that's what being in the top 4 means!

The real question is whether the same four rats would be the outperformers if you ran the experiment again.

throwaway283719··on Art project: Train rats to trade markets
It's actually the other way around. For most stocks, if the last tick was upwards, the next tick is more likely to be downwards (where a "tick" is any time the best bid or ask moves, and "price movement" means the change in the mid price).

For example, taking a random stock over a random three month time period, I compute that after an uptick, the probabilities for the next tick are -

  P(uptick)    = 39.3%
  P(downtick)  = 56.3%
  P(no change) =  4.4%
where "no change" typically happens when the best bid and ask change by the same magnitude, but in opposite directions.

Of course, this is not very useful for trading, because it doesn't give you enough of an edge to overcome the bid-ask spread.

throwaway283719··on Implementing XKCD #688
The logistic map

  x[n] = r * x[n-1] * (1 - x[n-1])
has chaotic behaviour for most values of `r` above 3.56995 so the author just needed to choose any value 3.56995 < r < 4.

The "most" in that sentence is interesting. For example, for values of `r` just above 1 + sqrt(8) ~ 3.82842 you can observe a stable oscillation between three different values!

The math isn't actually all that hard. The map is

  x <- r * x * (1 - x)
To find a fixed point, just set the left and right hand sides equal

  x = r * x - r * x^2
which is a quadratic equation -

  x * (r * x + 1 - r) = 0
which has solutions

  x = 0, x = 1 - 1/r
which are the fixed points. To find a period-2 cycle, you iterate twice and set the two sides equal to each other -

  x = r * (r * x * (1 - x)) * (1 - r * x * (1 - x))
which gives you a quartic (fourth order) equation. Ordinarily these have a very complicated solution, but in this case we already know two of the solutions, because any fixed point is automatically a period-2 cycle, so x = 0 and x = 1 - 1/r will satisfy the equation. We can get rid of those solutions using polynomial long division, leaving a quadratic equation, whose two solutions are the location of the points in a period-2 cycle!

We can do similar tricks to find period-4 cycles (an eighth order equation which can be reduced to 4th order by factoring out the fixed points and period-2 cycle) and period-3 cycles (a 6th-order equation that can be reduced to 4th order by factoring out the fixed points).

Proving the stability or instability of these cycles and fixed points is slightly more involved, but still not too hard - it just requires calculus at about the level you'd pick up in a late high school or early college course.

throwaway283719··on Scotland rejects independence
That's a good point, and I've now corrected for that, but it makes very little difference to the top line result (that the polls underestimated the support for "no" by a large margin).

The proportion of undecided voters in these polls was about 7.1%.

Source is http://whatscotlandthinks.org/opinion-polls

throwaway283719··on Scotland rejects independence
I think it's interesting to talk about the failure of polls to predict the magnitude of the result. Here are the results of the final polls from six major polling organizations, taken 1-3 days before the vote

  Organization    Yes     No      Number*
  ---------------------------------------
  Opinium         0.479   0.521   1087
  ICM             0.477   0.523   1010
  Panelbase       0.474   0.526    954
  Survation       0.473   0.527    910
  YouGov          0.474   0.526   3043
  Ipsos Mori      0.474   0.526    951
  ---------------------------------------
  TOTAL           0.475   0.525   7955

  * excluding undecided voters
On one hand they were accurate in that they forecast a "no" result with high probability - the proportion of "no" voters is more than four standard errors away from 50%; the standard error being

  s.e. = sqrt(0.475 * 0.525 / 7955) = 0.006
On the other hand, the final proportion of "no" voters was 55.3%, which is more than four standard errors away from the forecast value of 52.5%.

So the polls were significantly underestimating the proportion of "no" voters out there. A similar effect was seen in the Quebec independence referendum, where the polls actually predicted a slight advantage for "yes" but the final result was a decisive victory for "no".

throwaway283719··on Monads without pretension (2011)
Yeah, I should have written "computational context" not "effects".
throwaway283719··on Monads without pretension (2011)
The whole point about monads is that they provide a uniform interface for working with values that carry some extra context. The genericity of the interface is nice, in that it allows you to write generic monad combinators, but they are only useful because of the context (effects, control flow, etc). If you don't describe any of the implementations, you are missing the point!

The best introduction to monads was written in 2006 (more than eight years ago now) and I don't imagine that a better one will be written in the near future -

http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...

throwaway283719··on Al-Jazari
I think the majority opinion is that there is exactly one unfabricated religion.
throwaway283719··on Why Amazon Has No Profits and Why It Works
Yes, if that's revenue rather than profits.
throwaway283719··on Citymapper is what happens when you understand user experience
To be clear for non-Londoners, route 29 has one of the highest crime rates amongst all London bus routes, especially late at night. I'm not sure if it's particularly bad around Camden, although there is probably a higher than average rate of drunken idiots.
throwaway283719··on I studied engineering, not English. I still can't find a job
You might get the impression that the author studied engineering ("I studied engineering, not English...") or perhaps computer science ("...graduated at the top of my class in computer science...") whereas a quick look at his LinkedIn profile shows that he studied Management Information Systems[0] which, as far as I can tell, is a non-degree along the same lines as "Marketing" or "Media and Journalism" i.e. light on technical skills and heavy on jargon and buzzwords.

[0] http://www.smeal.psu.edu/scis/mis-undergrad

throwaway283719··on It Is Not About the Money, Silly, It Is All About the Time
Yes, that is why the sentence begins with the word "if".
throwaway283719··on It Is Not About the Money, Silly, It Is All About the Time
It's actually not that hard. I very rarely see advertising, and I didn't even make a conscious effort to do it.

I don't have a TV, I don't listen to the radio, I don't read magazines or newspapers, I pay a subscription for all the streaming services I use and I use ad-blockers when browsing the internet.

None of these are conscious choices to avoid advertisements - I would do all of them even if they didn't have that pleasant side effect.

The only time I see advertisements is when I take public transport - the underground in London is full of them, but they're pretty easy to tune out.

throwaway283719··on It Is Not About the Money, Silly, It Is All About the Time
I didn't mention anything about the stock market. I said if you can invest somewhere with a return greater than 3.5% after tax.

Implicit in that was that the investment is risk-free i.e. it's a government bond or something. But it could be a risky investment, if the risk-return trade-off is high enough.

If I had the opportunity to invest at a 10% rate of return with a stdev of 5% then absolutely, I'd remortgage my house at 4% to do that!

throwaway283719··on It Is Not About the Money, Silly, It Is All About the Time
Yeah, I broadly agree that all of these are valid things to consider, particularly if you are quite risk averse.

I take issue with (4) because if you have a mortgage you are already perfectly hedged against future housing costs. If you have a floating rate mortgage you are exposed to interest rates, but you can hedge against that by fixing your mortgage.

I think a blanket "debt is bad" approach is naive, just as much as a "risk is bad" approach is naive. All other things being equal, you would rather not have any risk or any debt. But for the right price, you should be willing to take on both. What 'the right price' is will depend on many things, like your stage of life, your income, your safety nets (the state, your family) etc. If you take a "debt is bad" approach then you are saying that the right price is infinity, which doesn't seem sensible.

throwaway283719··on It Is Not About the Money, Silly, It Is All About the Time
There can be totally valid reasons for not getting rid of your mortgage even if you have the opportunity - if you have something better to do with the money. If you are paying 3.5% on your mortgage but you can invest somewhere with a return greater than 3.5% after tax, why would you pay down your mortgage?
throwaway283719··on How Norway has avoided the 'curse of oil'
> All speculatively, knowing that their type of oil production is not profitable at all if oil once again goes below $70 a barrel, which could happen overnight (see Sept-Nov 2008)?

Is there an obvious reason they couldn't sell their oil forward (or just sell futures)? You can sell oil forward three years for around $89 a barrel at the moment, as opposed to around $93 a barrel for delivery next month.

That's for WTI, and Brent is currently even more (in fact the Brent curve is in contango at the moment). I don't know what grade Australian oil would be, but I wouldn't be surprised if it's closer to Brent than to WTI.

throwaway283719··on Tim Hortons agrees to Burger King offer for $94 a share
Not true. It might be a reason but it's not the only reason, and certainly not the primary reason.

At the moment Burger King pays tax at a rate of 35% or thereabouts, on all of its income, no matter where it is generated. About half of its income is from the US, and half is overseas.

After the acquisition, it will still pay 35% tax on all of its income generated in the US, however it will only pay the local tax rate on its income generated outside the US. For example, this is about 15% in Canada, and 21% in the UK (there aren't many countries where corporation tax is above 35%... Japan comes to mind).

So the saving is the difference between the local corporation tax and the US corporation tax, on about half of BK's income - if the average worldwide corporation tax is 20%, so the difference is 15% and half that is 7.5%. So this is equivalent to reducing the rate of corporation tax in the US from 35% to 27.5%. While nice, it's not quite the "huge tax benefit" that you mention.

throwaway283719··on A Unified Mathematical Language for Physics and Engineering (1996) [pdf]
Expressing Maxwell's equations using the six-component electromagnetic tensor F, they become

  dF  = μJ
  d*F = 0
where μ is the magnetic permeability of the vacuum and J is the electromagnetic 4-current. The operator 'd' is the differential operator from exterior algebra, and the '*' is the Hodge dual.

Using the bivector field F = E + iB from geometric algebra, they become

  DF = μJ
where μ and J are as before, and D is the covector derivative.

For comparison, using the traditional Gibbs/Heaviside notation Maxwell's equations are

  ∇ . E = ρ/ε
  ∇ . B = 0
  ∇ x E = -∂B/∂t
  ∇ x B = μ(J + ε ∂E/∂t)
throwaway283719··on An American doctor experiences an NHS emergency room
Why guess, when you could get some data?

In the UK, the per-capita spend on healthcare is $3480, of which $2919 is paid by the government (and so raised via taxes) and $561 is private (via health insurance or direct payment).

In the US, the per-capita spend is $8362, of which $4437 is paid by the government (via taxes) and $3925 is private (via health insurance).

This is only a cursory glance, but it does look a bit like nationalized healthcare results in lower private spending and lower government spending (the extra spend in the US presumably goes into the pockets of doctors, pharmaceutical companies and insurance companies).

Data sourced from the World Health Organization, via The Guardian[0]

[0] http://www.theguardian.com/news/datablog/2012/jun/30/healthc...

throwaway283719··on An American doctor experiences an NHS emergency room
It is, however, more than $0 (and presumably somewhat galling when you are already paying for health insurance.)
throwaway283719··on What is reactive programming?
I knew it was by Conal before I got to the end, as soon as I saw the phrase "denotational semantics" ;)

I should really learn what that means one day...

throwaway283719··on What is reactive programming?
Sounds excellent.
throwaway283719··on What is reactive programming?
Not true. Consider the following snippet -

    a = 10
    b = function() { return expensive_computation(a) }
Now, even if you can call b without parens, it still has to redo the expensive calculation every time you access it (because a might have changed... even if it hasn't).

The "destiny" operator is more like

    a = 10
    b = function() {
            persistent cached_value = null
            if is_null(cached_value) or has_changed(a) {
                cached_value = expensive_computation(a)
            }
            return cached_value
        }
but instead of that, you get to write (in this totally fictional programming language)

    a = 10
    b <- expensive_computation(a)
and have the compiler take care of the caching and updating for you.
throwaway283719··on First female winner for Fields maths medal
Hyperbolic geometry is the geometry of surfaces and spaces that aren't flat. Think of a 2D surface which is curved like a saddle. A triangle drawn on this surface will have angles that add up to less than 180 degrees.

Ergodic theory is the study of dynamical systems (things that change over time) that are allowed to run for a long time. They are "ergodic" if the state after the system has run for a long time is like picking a state randomly from the set of all possible states. Pouring cream into coffee and then mixing it is ergodic - after a sufficiently long time, you might as well have just arranged all the molecules at random.

Symplectic geometry is a bit more abstract. It's the study of dynamical systems that look similar to Newtonian mechanics, i.e. there are analogues of position and momentum. It encompasses all of Newtonian mechanics (i.e. mechanics without friction) but also a large set of other possible dynamics, like electrodynamics.

Riemann surfaces are surfaces that look like the complex plane "up close" but might look more complicated "from a distance". For example, an infinitely tall spiral staircases (which extends to infinity in the x and y directions) is a Riemann surface. It's interesting to study functions on Riemann surfaces, because the limitation of behaving like the complex plane at small distances is quite restrictive.

← PreviousPage 2 of 4Next →