The Python Misinterpreter

moresexI once wrote a book called More Sex is Safer Sex”. If you’re wondering what that means, you can read the essence of the argument in Chapter 12 of The Big Questions and/or watch me explain it on video.

Python programmer Jack Trainor has posted a simulation that he believes is somehow relevant to this argument. (Comments on his post are here.) I’d thought this was too nonsensical to respond to, but more than one reader has asked for a response, so here goes: Except for the fact that his code runs, Trainor’s managed to get this argument wrong in every possible way. He’s misstated the assumptions, he’s misstated the logic, and he’s misstated the conclusions.

Start with the assumptions. The entire argument is based on the assumption of optimizing behavior — that people weigh potential costs against potential benefits when they choose their sex partners. But Trainor ignores this completely, starting in the first line of code, which reads

HIGH_ACTIVITY_RATE = 0.10
In other words, he assigns activity rates, rather than assuming that people adjust their activity to the ambient risks, which in turn depend on other people’s activity rates. From that moment on, he’s off in Cloud Cuckoo Land.

Next, the logic. There is, after all, a logic to this argument. It goes like this: If you’re an ordinarily-very-cautious person, and you get uncharacteristically frisky tonight, you confer two benefits on the rest of the world. First, whoever goes home with you is having safer sex than they probably realize. Second, if you get infected tonight, you’re unlikely to spread the infection very far — and you’ve at least temporarily deflected your partner from passing on the virus to Promiscuous Pete, who would have spread it to twenty others.

Those are the benefits, of which Trainor accounts for the first and ignores the second, even though I’ve pointed out repeatedly that the second is more important. But that’s not his big mistake. His big mistake is to overlook the fact that you’ve somehow got to weigh these benefits againt the costs of promiscuity. Therein lies the heart of the argument, which Trainor ignores completely.

Here, then, is that heart of the argument. First, if you took on that new partner voluntarily, then we don’t have to worry about any costs that fall on you, because we know those costs were (in expectation) outweighed by benefits — otherwise you’d have stayed home. Second, even if you needed a little nudge toward taking that partner (say with a free condom from the government?), the same argument applies — as long as the nudge was little. In that case, your personal benefits at least almost outweigh all the risks you’re taking (and ditto for your partner), so we can ignore those risks and go back to focusing on the benefits you confer on others. And in a big enough population, there are always people who need only slight nudges to push them over the edge. Therefore, if we nudge the right people, we have to improve social welfare (defined as the excess of benefits over costs).

That’s what all this is about, and Trainor just ignores it. His code doesn’t even have variables to measure costs and/or benefits and so can’t possibly be remotely relevant.

Beyond that: As I stressed in Chapter 12 of The Big Questions, this argument is strictly a logical one. You might choose to doubt some of the assumptions, but if you grant the assumptions then the conclusions follow as the night the day. Logic cannot be falsified by simulations. Trainor might as well write a simulation to check whether every even number is divisible by two. If he manages to reject that claim, then we know his code is off the mark.

Finally, Trainor is entirely confused about the conclusions. The main conclusion is that under any reasonable assumptions, a little extra promiscuity improves social welfare. That can happen in either of two ways: Either fewer people get sick, or more people get sick but they and/or others have so much fun along the way that it’s worth it. The second conclusion is that under some reasonable assumptions, fewer people get sick. I demonstrated this with an example in More Sex (search for the “monogamous wives” example). The third conclusion is that under the most carefully thought out assumptions we know of — that is, in the work of Michael Kremer — fewer people get sick.

(Of course the third conclusion makes the second unnecessary, but I include the second as a separate conclusion because it’s easy to understand whereas Kremer’s work can be technically daunting.)

Which of these conclusions does Trainor think he’s refuting? Surely not the main conclusion — that one is about costs and benefits, but Trainor doesn’t even talk about costs and benefits. So does he think he’s refuting the second conclusion? That’s the one that says that under some assumptions, following a rise in promiscuity, fewer people get sick. You can’t refute that by showing that under some other assumptions, more people get sick. Particularly when your assumptions are as off the mark as Trainor’s.

That leaves the third conclusion — that the careful work of Michael Kremer, well informed by both epidemiology and economics, finds that it is in fact highly likely that a little extra promiscuity would slow the spread of HIV. Surely that’s not what Trainor claims to be refuting with his snippet of code. So what’s his point? I give up.

Share/Save

31 Responses to “The Python Misinterpreter”


  1. 1 1 Coupon_Clipper

    Sigh…. if you click on the 2nd link (the comments link) you’ll see that the comments devolved into a “the safest sex is no sex” and “we should do more to prevent STDs” conversation.

  2. 2 2 Jonathan Kariv

    I’ve always thought (please please correct me if I’m wrong) that the argument here is really saying that the variance of number of partnes taken is more important than the average number of partners taken. e.g. In the monogamous wives example (if I’m remembering this right) there are the same number of encounters with or without the hookers. Just that when the women have 2 partners (and the hookers disappear) we have a much lower variance.

    I believe you didn’t argue at any point that it’s a good thing for promiscuious pete to start taking more parners? In fact there semed to be the implicit assumption that if girl A goes home with martin (sexual conservative) instead of pete then pete doesn’t go home with someone else instead?

  3. 3 3 Noah Yetter

    Programmers are notoriously bad at economics.

  4. 4 4 Harold

    If the main conclusion is an increase in social welfare, then the title is misleading. “More sex may not be safer sex but the benefits outweigh the costs” is not a very snappy title. So lets stick to the safer sex conclusion. Trainor ignores social benefits because the title ignores it. (althought he does mention in his blurb). He is testing merely the proposal “more sex is safer sex”.

    It is reasonable to suppose that the proposal “more sex is safer sex” will hold up under a range of reasonable assumptions, or the title should be “More sex might be safer sex”, so I do not think it unfair to test the hypothesis under other reasonable assumptions. For me, the question only remains is are the assumptions reasonable, and is the model reasonable? It comes to a different conclusion, and I would like to know why. I will have to look a bit further to determine that. Michael Kremer’s peer reviewed work is not going to be contradicted by a relatively speaking “back of the envelope” model, but it is useful to understand why they come up with diffefent conclusions.

  5. 5 5 Steve Landsburg

    Jonathan Kariv:

    I’ve always thought (please please correct me if I’m wrong) that the argument here is really saying that the variance of number of partnes taken is more important than the average number of partners taken

    The argument is that variance matters. Both the mean and the variance matter; I’m not sure the argument says that one is “more important” than the other.

  6. 6 6 Harold

    Is the difference that in Trainors model, the chances of an individual having sex during any cycle is not affected by the activity of others? In your (and Kremer’s) model, if the low activity individuals increase their activity this displaces the activity of high activity individuals.

  7. 7 7 Harold

    Re-reading your post, I see that you have said this, more or less.

  8. 8 8 Ken B

    Well there is a hole in SL’s logic actually, and it is because he assumes that STDs manifest themselves in time to influence behaviour. But postulate a disease with 100% transmission, 100% mortality but a 15 year symptom free incubation period. No-one alive has symptoms so you cannot tell who has it. Now if the disease is prevalent enough these infrequent partakers become disease vectors even in the case where SL seems to assume they do not.

    I note in passing a resemblance between this mythical disease and “sin”.

  9. 9 9 David Wallin

    One nice thing about Mr. Trainor’s willingness to program and post this: the errors in the assumptions and logic become obvious since they must be specified. Alas, the equally erroneous non-programmer can hide behind spin (no absence of that here and elsewhere). Of course, I must be a freak, as I spend part of my professional life programming economic experiments.

  10. 10 10 Sam

    Perhaps this is fundamentally incorrect, but I’ve always understood this in a ‘network’ or ‘graph’ sense, where the network of sexual activity is somewhat like the internet, with, on average, very few edges between nodes via the the enormous connectivity of some nodes – the very promiscuous. Increasing the activity of the lowly connected nodes will, to some degree, crowd out the promiscuous and increase the chances of someone having sex with non-promiscuous partner. The end effect is to increase the average distance between any two people on the ‘sex-network’ and lengthen the work any transmission requires.

    So I essentially see this as a version of ‘six degrees of Kevin Bacon’, where nobodies are substituted into Kevin’s roles, enough to push the game into seven or eight degrees of Kevin Bacon.

    I looked at the python code, but found it hard to reconcile in a programmatic sense with how I see argument. And don’t know enough python the rectify this.

  11. 11 11 Sam

    @ Ken B

    A worrying proposition for all, except Madagascar.

  12. 12 12 Patrick

    In response to Ken B: Which part of the argument assumes “STDs manifest themselves in time to influence behaviour”? The argument is just that more uninfected people entering the pool of sexual partners decreases the overall risk because a. the uninfected people’s partners will not become infected tonight; and b. if the uninfected people become infected, they will in turn spread that infection to fewer people than an average person would.

    If you are arguing that sexual behavior is inherently more risky than people expect, because of some new sexual plague that will kill us all in 15 years… Then yes, everyone is already having too much sex. But I think it is reasonable to assume that people are able to assess the risks of sexual behavior fairly accurately. People already know about HIV/AIDS, and they still seem (rationally) to be having quite a lot of sex.

  13. 13 13 Steve Landsburg

    Patrick: Thanks for the excellent response to Ken B.

  14. 14 14 Ken B

    @SL, Patrick
    Look, the argument cannot be correct in all cases because there is a simple counterexample. 100% transmission, 1 uninfected person. Now if the uninfected person has sex the infection rate goes up.

    To adress the point about behaviour let me quote SL:
    “The entire argument is based on the assumption of optimizing behavior — that people weigh potential costs against potential benefits when they choose their sex partners. But Trainor ignores this completely, starting in the first line of code, which reads
    HIGH_ACTIVITY_RATE = 0.10
    In other words, he assigns activity rates, rather than assuming that people adjust their activity to the ambient risks, which in turn depend on other people’s activity rates.”

    People do not adjust to ambient risks, they adjust to ambient risks THEY KNOW ABOUT. Not just activity rates but also expected infection rates. And it is NOT fair to argue “that people are able to assess the risks of sexual behavior fairly accurately” if you are arguing as SL did that all the assumptions have already been laid bare. Nor is that an answer to my example where that is precisely what people cannot do.

    The first thing I said was that SL has made a hidden assumption, and your riposte is, ‘oh well we make this assumption we didn’t mention.’ That’s my point.

    Nor of course is my example unrealistic, as anyone who knows the early history of syphilis can tell you.

    Just to be clear. I am not arguing more sex is not safe sex. I am not arguing Tranor is right. I am pointing out SL’s claim of logical perfection is wrong.

  15. 15 15 colin

    what would be great is if instead of making this into a “you’re wrong! no you’re wrong!” fight from the start, if both authors worked together on the script to get a proper simulation going.

    instead of “lolol you got everything wrong!”, why not, “hey, if you want a more accurate simulation of the model i was proposing, here’s the parts of the code that you could change and why”

  16. 16 16 Patrick

    Ken B:

    I agree you can find specific cases where more sex is clearly not safer sex. In your example, if everyone except one person already has the disease, the disease has a 100% transmission rate, and that one person decides to have sex, that person will get infected, whereas if the infected people just had sex with each other all day, no new cases would develop. I think the only assumption you have to make to “fix” the argument is that the % of people who are already infected is not close to 100. That way, the uninfected person who becomes infected really does prevent someone else from getting infected and passing it on. Also there is a decent chance that the uninfected person’s partner is not yet infected, but would have become infected had he chosen someone else from the pool of partners.

    This is a separate issue from what happens if people can not accurately assess the riskiness of sexual behavior. I think even in the case where sex is riskier than everyone assumes, adding new, low-risk people to the sex partner pool will still make for safer sex overall, for the reasons given above. It just won’t be “efficient” in an economic/utility sense (people were already having too much sex, because they underestimated how risky it is).

    I appreciate your arguments. This is a difficult (but fun) problem to think about!

  17. 17 17 Steve Landsburg

    Colin:

    instead of “lolol you got everything wrong!”, why not, “hey, if you want a more accurate simulation of the model i was proposing, here’s the parts of the code that you could change and why”

    This might work if the existing code bore any relationship whatsoever to the model. But this code is about as relevant as a single-line program that says:

    PRINT “MODEL FAILS”

    When the code fails to engage the model in any way, it can’t be improved by tweaking.

  18. 18 18 Ken B

    @Patrick
    SL’s assertion that social welfare MUST increase under ANY reasoanble assumption is wrong if the danger is higher than anyone knows. Nor is this an unreasonable assumption as it has happened in the past: the arrival of syphilis in Europe, AIDS in SF, or various forms of VD in Polynesia etc. Or the dangers of smoking in another context. This must affect the calculation of social welfare, and that refutes the claim that “under any reasonable assumptions, a little extra promiscuity improves social welfare.” It might under any set of LIKELY assumptions, but that’s not the same.

  19. 19 19 Bob the programmer

    Steve-

    I’d like to address the title and subtitle. Title “More Sex Is Safer Sex” and “The Unconventional Wisdom of Economics”.

    Sorry I haven’t read the book, but as an economist, did you evaluate this theory from both a Micro-economics and a Macro-economics level? Surely as an economist, you considered this, but I don’t see it addressed in your argument.

    From a micro-economics perspective, your argument seems sound – particularly this paragraph: “First, whoever goes home with you is having safer sex than they probably realize. Second, if you get infected tonight, you’re unlikely to spread the infection very far — and you’ve at least temporarily deflected your partner from passing on the virus to Promiscuous Pete, who would have spread it to twenty others.”

    But the flaw in your argument seems to be that you are focused on two individuals and a single sex act. A macro-economic view of the same situation might lead to different conclusions!

    The false assumption that you seem to be making is that there will be the same amount of sex acts on a given day, regardless of whether the sexual conservatives participate. Do you REALLY think that Promiscuous Pete is going to “do without”, this evening? More conservatives having sex will translate to more sex happening. Your model seems to overlook that.

    A counter example to your example (of ONE conservative participating in random sex) would be if EVERY conservative read your book today, agreed with the logic, and had sex tonight:

    Classifying people as Promiscuous vs Conservative, there will be several pairings evident tonight: a promiscuous person with another promiscuous person (call this PxP), conservatives with Promiscuous (CxP), and conservative with conservatives (CxC).

    In the PxP case, disease will likely be passed with the same percentage likelihood as it is today, but in smaller numbers because there will be less PxP pairings as there are today (because some of the P’s are partnered with C’s). This seems to be the crux of your argument, point 1: “First, whoever goes home with you is having safer sex than they probably realize.”

    But you overlook the fact that there would be more CxP pairings with an infected partner. This number goes up from the current zero, up to some non-zero number.

    The math behind your argument, and where your argument falls apart, is in comparing the incidents of infected partners being paired with non-infected partners, when you introduce C’s in the mix.

    When introducing Conservatives into the mix, here are the results, assuming that Promiscuous people continue to have the same amount of sex:

    The incidents of an infected person being with non-infected person in a Promiscuous x Promiscuous pairing goes down, as noted earlier, because there are less PxP pairings (as some P’s are paired with C’s).

    The incidents of an infected person being with a non-infected person in a Conservative x Conservative pairing goes up (from zero to some very small number, assuming that a a very small number of normally abstaining people (Conservatives) are unfortunately infected).

    However, the biggie is that the incidents of an infected person being with a non-infected person in a Conservative x Promiscuous pairing sky-rockets (from zero to some huge number). Your argument totally ignores this.

    Furthermore, as an economist, I’m sure you are aware of the power of compounding interest! Apply the above logic to Weekend #2 of “Conservatives Gone Wild!” Suddenly the infection rate of the CxP and the CxC is higher than it was in weekend #1. And this is an exponential effect: Week 3′s increase being higher than Week 2′s increase, and so on. The rates of infection will increase, and rapidly approach 100% of the population being infected.

    So, go back to econ 101. :-)

  20. 20 20 Steve Landsburg

    Bob the programmer:

    Sorry I haven’t read the book

    Yes. There is evidence of this in nearly every paragraph of your comment.

  21. 21 21 Bob the programmer

    oh good comeback.

    The only thing to learn here is that if you are an economist and want to make a buck, write a book proposing some nonsense theory mildly related to sex, and it apparently will sell.

    Time to get a real job, Steve.

  22. 22 22 Alia Khouri

    Mr. Trainor’s code may be off the mark in relation to your core argument, but the intermittently arrogant tone of your response to his reasonable and open attempt to engage your ideas is off-putting.

    In this particular case, a gentler more pedagogical approach may have been more appropriate.

    AK

  23. 23 23 Richard Careaga

    Science is anything we can explain to a computer. Every thing else is art. –Donald Kruth

    Trainor is trying to model an argument that he may not understand since HIGH_ACTIVITY_RATE = 0.10 (a constant) should be a variable (to account for the adjustment of behavior to perceived risk).

    Fine. So, let’s come up with a function to describe HIGH_ACTIVITY_RATE. The whole purpose of a simulation is to test models against assumptions, and if we have an assumption that’s hardwired, we lose the opportunity to fully do that.

    On the other hand, if the model depends on assumptions that are so abstract that no specific value for HIGH_ACTIVITY_RATE can be tested, it’s not falsifiable, can’t be explained to a computer, and pro tanto is merely economics and not science.

    So, how do we express the word problem that we started with in code in a way that has reasonable assumptions? Would it satisfy your objections to the simulation to have HIGH_ACTIVITY_RATE vary over the range from 0-1.0?

  24. 24 24 Steve Landsburg

    Alia Khouri:

    In this particular case, a gentler more pedagogical approach may have been more appropriate.

    Mr. Trainor sent me his code by email. I sent him a gentle pedagogical explanation of what was wrong. He ignored me and posted the code, together with commentary that indicated he hadn’t bothered to read the response he’d asked for.

  25. 25 25 Steve Landsburg

    Richard Careaga: Would you write a computer program to test the hypothesis that the angles of a triangle always add up to 180 degrees?

    This might be a useful way to hone your programming skills, but it’s not a useful way to learn about triangles. If you think it is, then you’ve failed to understand the definitive argument that settles this issue without regard to the enumeration of cases.

    The argument Mr Trainor is testing is a special case of the envelope theorem from advanced calculus . He can write a program that tests 100,000 special cases of that theorem, or he can try to understand the proof. If he took a few minutes to do the latter, then he’d realize it’s entirely pointless to attempt the former.

  26. 26 26 Richard Careaga

    Steve Landsburg: HIGH_ACTIVITY_RATE = 0.10 is used in the program as an upper bound and in three of the four functions it is reset downward in 0.01 increments in six steps. If the objection is that 0.10 is too high an estimate, Trainor’s program partially meets it by evaluating the additional cases 0.09 … 0.05. If 0.05 is still unobjectionably high, it only requires changing the lines “for i in range(6).”

    On the other hand, if the claim is that the argument is self-proving or true by definition such that no numerical examples can add anything: Ex falso quodlibet (from a false assumption, any conclusion logically follows), and we are in the realm of Euclidian economics, in which conclusions must necessarily follow from self-evident axioms whose truth is beyond question.

  27. 27 27 Steve Landsburg

    Richard Careaga:

    HIGH_ACTIVITY_RATE = 0.10 is used in the program as an upper bound and in three of the four functions it is reset downward in 0.01 increments in six steps. If the objection is that 0.10 is too high an estimate, Trainor’s program partially meets it by evaluating the additional cases 0.09 … 0.05. If 0.05 is still unobjectionably high, it only requires changing the lines “for i in range(6).”

    Richard Careaga: The issue isn’t whether the activity rate is high or low; the issue is whether it’s privately optimal.

    The argument in question is identical in structure to the (standard) argument that concludes the equilibrium level of pollution is too high. Do you understand that argument? If so, do you think it would be in any sense enlightening to run simulations in which the pollution level is exogenously specified?

  28. 28 28 Steve Landsburg

    Richard Careaga:

    Let me put this another way.

    Suppose two balls collide and bounce off each other. I claim that according to the laws of physics, momentum must be conserved in this collision.

    Now you can write down a computer simulation in which the balls do any damned thing you please, and momentum might or might not be conserved. But that simulation tells us *nothing at all* about what happens in a collision *which obeys the laws of physics*.

    Similarly, you can write down a simulation of the mating market in which people behave any damn way you please, and get any conclusion you like. But that simulation tells us *nothing at all* about what happens in a mating market *in which people make choices that are privately optimal*.

    In the collision case, the only way to figure out what happens is to start with standard assumptions and use logic to derive necessary conclusions. Ditto in the mating case. In both cases, you can question the assumptions (maybe force *doesn’t* equal mass times acceleration, or maybe people *don’t* equate costs and benefits at the margin). But you can’t reasonably question that the conclusions follow inexorably from these standard assumptions.

  29. 29 29 Richard Careaga

    Steven Landsburg: Thanks, that’s helpful in understanding how the argument is being framed. The simulation doesn’t attempt to determine private optimal behavior and so says, “if we look at these behaviors, however they are arrived at, we get such-and-such results.” The economist model, on the other hand, posits that every actor has the information, capacity and inclination to adjust behavior to produce the optimal outcome mix of gratification and risk and, in doing so, the system in which they act will trend toward an equilibrium of sexual activity related risk that will be lower at some levels of overall activity than others. Now I understand the rejection of simulation.

    What if we replace private optimality with Norton Simon-style satisficing “good enough” rationality. How much information, capacity and inclination to we have to subtract from actors in order to see a different equilibrium in which increased overall activity tends toward an equilibrium of higher risk?

  30. 30 30 JLA

    I’m a bit puzzled. The problem of unsafe sex arises from adverse selection and externalities. I don’t see how advocating more people to have sex solves either one.

    It’s not the case that more sex is safer sex, but rather, less promiscuous people having more sex is safer sex.

    If we advocate that more people have sex, it could very well result in less safe sex (we do of course have to account for the benefits of your proposal of subsidizing condoms).

  31. 31 31 JLA

    Sorry – the third sentence should read “I don’t see how advocating people to have more sex solves either one.”

  1. 1 Tweets that mention The Python Misinterpreter at Steven Landsburg | The Big Questions: Tackling the Problems of Philosophy with Ideas from Mathematics, Economics, and Physics -- Topsy.com
  2. 2 Weekend Roundup at Steven Landsburg | The Big Questions: Tackling the Problems of Philosophy with Ideas from Mathematics, Economics, and Physics
Comments are currently closed.