Archive for June, 2012


Today is a day of new things, since I finished my last day at my job yesterday and I’m going to math camp tomorrow. It’s exciting, and I’m going to kick off this first day of new things with a silly but fun thing I recently learned about the earth and the sun.

Some people know this already, but some people don’t, so sorry in advance if I bore you, but it’s super interesting the first time you think about it.

Namely, have you ever noticed, on your globe, a weird figure eight looking thing?

Nobody could be blamed for their curiosity, because there are so many important looking notches and then of course there’s the phrase “Equation of Time” next to it looking both pompous and intriguing. What is that thing??

After a few moments of contemplation, you’ve probably noticed there are months indicated, and since it’s a closed loop it’s probably describing something that is periodic with a one year period. Plus there are two axes, the vertical axis looks to be measured in degrees and the horizontal is called the “scale of time”.

Whenever I see north/south degrees I think of the earth’s tilt, and when I see something about time, it makes me think about how we measure time, which is vague to me, but probably has something to do with the sun, and orbiting around the sun, and spinning while we do it, again at a tilt. And if I want to be expansive at a time like this I’ll remember that the (pretty much circular) orbit of the earth lies on some plane where the sun also lives.

Now as soon as I get to this point I get nervous. What is time, anyway? How do we know what time it is? What with time zones, and daylight savings time, we’ve definitely corrupted the idea of it being noon when the sun is at its highest in the sky or anything as definitive as that.

So let’s imagine there are no time zones, that you are just in some specific place on the earth. You never move from that spot, because you’re afraid of switching time zones or what have you, and you’re’r wondering what time it is. If someone comes by and tells you it’s daylight savings time and to reset your clock, you tell them to go to hell because you’re thinking.

From this vantage point it’s definitely hard to know when it’s midnight, but you can for sure detect three things: sunrise, high noon, and sunset. I say “high noon” to mean as high as it gets, because obviously if you’re way north or way south of the equator the sun will never be totally overhead, as I noticed from living in the northeast my whole life.

But wait, even if you’re at the equator, the sun won’t be directly overhead most of the time. This goes back to the tilt of the earth, and if you imagine your left fist is the sun and your right fist is an enormous earth, and you tilt your right fist and stick your finger out and make it move around the sun (with your finger staying stuck out in the same direction because the tilt of the earth doesn’t change). As you imagine the earth spinning, you realize a point on the equator is only going to be directly in line to see the sun straight overhead about twice a year, and even then only if things line up perfectly.

Similarly you can see that, for any point between the equator and some limit latitude, you see the sun straight overhead twice a year – at the limit it’s once.

Going back to the point of view of a single person looking for high noon at a single place, we can see the height of the sun when it reaches its apex, from her perspective, is going to move around every day, possibly passing overhead depending on her latitude.

This is starting to sound like a periodic loop with a one-year period – and it makes me think we understand the x-axis. But what’s with the y-axis, the so-called “scale of time”?

Turns out it’s a definition thing, namely about what time noon is. Sometimes it takes the earth less time to spin around once than other times, and so the definition of “noon” can either be what we’ve said, namely “high noon,” or when the sun is at its highest in the sky, or you could use a clock, which has, by construction, averaged out all the days of the years so they all have the same length (pretty boring!). The difference between high noon and clock noon is called the equation of time.

By the way, back when we used sundials, we just let different days have different lengths. And when they first made clocks, they adjusted the clocks to the equation of time to agree with sundials (see this). It was only after people got picky about all their days having the same length that we moved away from sundial time. So it’s really just a cultural choice.

But why are some days shorter than others in terms of high noon? There are actually two reasons.

The first one, quaintly named “The Effect of Obliquity,” is again about the tilt. Imagine yourself sitting at the equator, looking up at the sun. It might be better to think of your position as fixed and the sun as going around the earth. And for that matter, we will assume the orbit of the earth around the sun is a perfect circle for this part.

Then what is being held constant is the spin of the tilted earth, or in other words the speed of the sun in the sky from the point of view of an observer on earth (this point is actually not obvious, but I do think it’s true because we’ve assumed a fixed tilt and a perfectly circular orbit. I will leave this to another post).

You can decompose this motion, this velocity vector, at a given moment, into two perpendicular parts: the part going in the direction of the equator (so the direction of some ideal sun if there were no tilt to the earth) and the part going up or down, i.e. in a right angle to the equator. Since we already know the sun doesn’t stay the same height all year, we know there has to be some non-zero part to the second part of this vector.

But since we also know the total vector has constant length, that means that the first vector, in the direction of the equator, is also not constant. Which means the length of the days actually varies throughout the year. The extent to which it does vary is approximated by a sin curve (see here)

The second reason for a varying length of a day, also beautifully named “The Effect of Orbital Eccentricity,” is that we don’t actually have a circular orbit around the sun- it’s an ellipse, and the sun is one of the two foci of the ellipse.

The thing about the earth being on an elliptical orbit is that it goes faster when it’s near the focus, which also causes it to spin more, due to the Conservation of Angular Momentum, which also makes an ice skater spin faster when her legs and arms are close to her body. Update (thanks Aaron!): no, it doesn’t cause it to spin more, although that somehow made sense to me. It turns out it just traverses a larger amount of angle with respect to the sun that we would “expect” because it’s moving faster. Since it turns as it moves faster, the day is shorter than you’d expect (this only works because of the way the earth spins – it’s counterclockwise if you’re looking down at the plane on which the earth is orbiting the sun clockwise). We therefore have faster days when we are closer to the sun.

When you add up these two effect, both approximated by sin curves, you get a weird function.

This is the “x-axis” of the analemma.

You can take a picture of the analemma by shooting a picture of the sun every day at noon, like these guys in the Ukraine did.

And by the way, you can use stuff about the analemma to figure out when sunrise and sunset will be, and why on the longest day of the year it’s not necessarily the day of the earliest sunrise and latest sunset.

And also by the way, there are lots of old things written about this stuff (see here for example) and there’s an awesome CassioPeia Project video (here uploaded on YouTube) explaining how all of this stuff varies over long periods of time.

Categories: musing

Is a $100,000 pension outrageous?

There are lots of stories coming out recently about how public workers, typically police or firefighters, are retiring with “outrageous” pensions of $100,000. Here’s one from the Atlantic. From the article:

That doesn’t frustrate Maviglio, who insists that “people who put their lives on the line every day deserve a secure retirement.” But do they “deserve” more than twice the US median income? Do they “deserve” the sum the average California teacher makes, plus $32,000? Do they “deserve” pensions far higher than the highway workers whose jobs are much more dangerous? These aren’t idle questions, given the public safety worker retirements we can expect in the near future.

Okay, let’s go there. If the median income in the country is 38,000, then $100,000 is a lot. But the median income in the communities where these retired firefighters live is sometimes much higher. For example, in Orange County, where the pension system is getting lots of flak, the median incomes can be seen here. In only one community out of is it below $50,000, and in 8 it’s above $100,000. So if you look at it that way then it doesn’t seem so outrageous.

And maybe we should be paying our teachers and our highway workers more, for that matter.

Point #1: California is a rich state, and it costs a lot of money to live there.

Now let’s move on to articles like this, which frame the issue in a very specific way. The title:

Police and Firefighter Pensions Threaten Government Solvency

How about all the other things that have contributed? Why are we blaming these guys, who have worked all their lives to protect their community? Why aren’t we blaming the mafia behind the muni bond deals, or sometimes even the local politicians as well?

Point #2: This is all a political blame game, trying to manipulate you from thinking about who are the actual crooks behind the scenes here.

My momma always said double down, and this is the ultimate double-down opportunity. Instead of looking for where the money went, or why it was handled so badly, we are going to blame the guys on taking the boring public servant job, and doing it for their adult lives, and trying to retire. Basically, we are blaming them for being right, for making the better choice between public and private.

Point #3: They made the right choice and we can’t swallow it because we thought our whole lives they were suckers for working in public service instead of in finance.

And what about that? Why do we compare $100,000 pensions to median incomes but not to golden parachute retirement packages of failing CEOs? Where’s the real outrage? Here’s another list of some seriously outrageous golden parachutes.

Maybe it’s because we feel like private pay is not our business, as taxpayers. It’s a different arena, and we have no right to judge. Let me remind you then that we taxpayers paid for bonuses at too-big-to-fail banks:

Point #4: These pensions don’t look very big when you compare them to what happens in the private sector.

And yes, I’m talking about the extreme cases, but so does everyone else when they talk about “outrageous pensions”, so it’s extreme-case apples to extreme-case apples.

Categories: finance, rant

Free online classes: the next thing

I love the idea of learning stuff online, especially if it’s free.

So there’s this place called Code Academy. They teach you how to code, online, for free. They crowdsource both the content and the students. So far they focus on stuff to build websites, so javascript, html, and css.

I just found out about Udacity (hat tip Jacques Richer), which also seems pretty cool. They offer various classes online, also free unless you want an official certificate saying you finished the class. And they have 11 courses so far, including this one on basic statistics with Professor Thrun.

Then there’s Coursera, which is starting to have quite a few different options for free online classes. The thing I’d like to bitch about with this is that Andrew Ng’s Machine Learning class, which I took when it came out last year, is not being offered currently, which makes me confused. Why does it need scheduling if it’s already been made?

I also just discovered openculture, which lists lots of free online courses. When you search for “statistics,” it returns the Udacity course I already mentioned as well as a Berkeley stats course on YouTube, among others.

I know this stuff is the future, so I’m hoping there continues to be lots of competition from various small start-ups. We are bound to profit from such competition as a culture. What I’m worried about is that the model goes from “free” to “fee” if it gets crowded by large players who, say, pay their instructors a lot for the content.

Which is not to say the instructors shouldn’t get paid at all, but I hope the revenue can continue to come from advertising or through job matching.

The basic unit is risk

Today I’m going to gush over two excellent blog posts I read recently written over at Interfluidity. But first I’m going to state a pet theory of mine about what units we talk in.

In a mathematical sense, units make no difference. If I give you measurements in inches rather than feet, all I’m doing is multiplying by 12. If I say something in French rather than German, all I need is a translation and we’re talking about equivalent information.

But in a psychological sense, a choice of units can make an enormous different. Things sound bigger in inches, and sometimes you barely understand French and can make bad guesses.

I’d argue that speaking in terms of wealth is a mistake. We should instead speak in terms of risk. It’s a different unit, and it’s harder to quantify, but I think risk is what we actually care about. I claim it’s more basic than money.

For example, why are we afraid of not having money? It’s because we run the risk of not having resources to eat, sleep, or get medicine or treatment when we’re sick. If we didn’t have fears about this stuff then people would have a very different relationship to money. The underlying issue is the risk, not the money.

Financial markets putatively push around money, but I’d argue that why they exist and how they actually function is as a way to spread around risk. That’s why the futures market was developed, for farmers to have less risk, and that’s why the credit default swap market was created, to put a price on risk and sell it to people who think they can handle it.

It also kind of explains, to me at least, the weirdness of super rich people- people who have more money than they can ever use. Why do they continue to collect money so aggressively when they already have so much? My guess is that they are confused about their units- they think all their problems can be solved by money, but their remaining actual problems are problems of risk that can’t be controlled by money. Things like the fact that we all get old and die. Things like that people don’t like you if you’re an asshole or that your wife may leave you. These are risks that most people never get to the point of trying to solve through money, because they’re still stuck in a different part of reality where inflation could screw their retirement plans. But for super rich weirdos, we have the Singularity University where you get to learn how to transcend humanity and live forever.

I’m not making a deep statement here. I’m just suggesting that, next time you hear of a plan by politicians or regulators or Wall Street bankers, think not about where the money is flowing but where the risk is flowing.

A perfect example is when you hear bankers say they “paid back all the bailout”; perhaps, but note that the risk went to the taxpayers and is firmly fixed here with us. We haven’t given the risk back to the banks, and there doesn’t seem to be a plan afoot to do so.

Which gets me to Interfluidity’s first plan, namely to have the government protect up to $200,000 of an individual’s savings from inflation.

Now, on the face of it, this plan is not all that protective of the 99%, because it’s definitely benefiting people who have savings, where we know that the lowest 25% or so of the population is in net debt. Only people with savings to protect can actually benefit.

But if you think about it more, it is good for people like my parents, whose retirement from a state school does not rise with inflation, or more generally for people who have a fixed savings put aside for retirement. And it isn’t at all good for very rich people, who would see a benefit only on a small percentage of their savings (assuming it is possible, as Interfludity says it is, to outlaw the bundling of these inflation-protected accounts like some people now bundle life insurance policies).

Most economic policies in this country are made to benefit rich people, and are defended by saying we need to protect middle-class people nearing retirement with a modest nest-egg. As Interfluidity said, those middle guys are used as “human shields”. Very few policies go into to the weeks sufficiently to figure out how to protect that group without having outsized benefits at the top.

Said in terms of risk, this plan is pushing inflation risk to people who can handle it, and removing it from people who are extremely vulnerable to it.

Which brings me to the second post I want to rave about, namely this one in which Interfluidity dissects the lack of political will in the face of the current depression. From the post:

We are in a depression, but not because we don’t know how to remedy the problem. We are in a depression because it is our revealed preference, as a polity, not to remedy the problem. We are choosing continued depression because we prefer it to the alternatives.

The reason? Because no matter how much someone might say that we care about the middle class, the truth is we are protecting rich people from the risk of getting poor. We have, as he says, a population with individual power roughly weighted in proportion to their wealth (or, to be consistent with my theme, inversely proportional to their risk), and when you take a vote with those weightings, we get a “weighted consensus view,” manifested among the macroeconomists in charge of this stuff, that we should avoid inflation at all costs (ironic that the people with the least risk are also the people with the most influence).

In order to remedy this situation, we’d need to implement something like the inflation-protected bank accounts up to $200,000 for the individual. Then the weighted consensus may change – we might instead actually pull for a policy that would have some risk for inflation and would also possible create jobs.

But of course, in order to implement such a policy, we’d need to have the political will to change the risk profile, which goes back to the weighted consensus thing. Keeping in mind that this policy would push the risk to rich people, I’m guessing they wouldn’t vote for it.

On the other hand, smallish savers would. So it’s not a mathematical impossibility, because there may be enough people in favor of the inflation-protection plan to make it happen, and then the second question, of how to get us out of the current depression, would be easier to address. I’m definitely in favor of trying.

Categories: finance

Why are pharmaceutical companies allowed to do their own trials?

A recent New York Times article clearly addressed the problem with big pharma being in charge of its own trials. In this case it was Pfizer doing a trial for Celebrex, but I previously wrote about Merck doing corrupt trials for Vioxx (see How Big Pharma Cooks Data: The Case of Vioxx and Heart Disease). In the article, it has the following damning evidence that this practice is ludicrous:

  • Research Director Dr. Samuel Zwillich, in an email after a medical conference discussing Celebrex, stated: “They swallowed our story, hook, line and sinker.”
  • Executives considered attacking the trial’s design before they even knew the results. “Worse case: we have to attack the trial design if we do not see the results we want,” a memo read. It went on: “If other endpoints do not deliver, we will also need to strategize on how we provide the data.” This simply can’t happen. There should be an outside third-party firm in charge of trial design, and there needs to be sign-off on the design in advance so no monkey business like this takes place.
  • Executives disregarded the advice of an employee and an outside consultant who had argued the companies should disclose the fact that they were using incomplete data – they were using only half. This kind of statistical dishonesty is the easiest way to get numbers you want.
  • In another email, associate medical director Dr. Emilio Arbe from Pharmacia (which was later bought by Pfizer) disparaged the way the study was being presented as “data massage,” for “no other reason than it happens to look better.” Mind you, this statement was made in September 2000, so in other words the side effects of Celebrex have been known for over a decade.
  • Medical Director Dr. Mona Wahba described it as “cherry-picking” the data. In May 2001.

Why is this happening? It’s all about money:

 It is one of the company’s best-selling drugs, racking up more than $2.5 billion in sales, and was prescribed to 2.4 million patients in the United States last year alone.

How much are you in doubt that the people in charge are being pressured not to be honest? Dr. Samuel Zwillich claims the hook, line and sinker statement was probably about something else. The cherry-picking Dr. Mona Wahba now can’t remember what she meant.

This is bullshit, people. Statistics is getting a bad name, and people are suffering and dying from bad medicine, not to mention paying way too much for fancy meds that don’t actually help them more than aspirin.

What we need here is some basic integrity. And it’s not just a few bad eggs either – stay tuned for a post on Prof. David Madigan’s recent research on the robustness of medical trials and research in general.

Categories: news, rant, statistics

Coding is like being in a band

I asked my friend Nikolai last week what I should learn if I want to be a really awesome data scientist (since I’m an alpha female I’m sure I phrased it more like, how can I be even more awesome than I already am?).

Being a engineer, Nik gave me the most obvious advice possible: become an engineer.

So this past weekend I’ve looked in to learning Scala, which is the language he and I agreed on as the most useful for large-scale machine learning, both because it’s designed to be scalable and because the guys at Twitter are open sourcing tons of new stuff all the time.

That begs the question, though, to what extent can I become an engineer by reading books about languages in my spare time? According to Nik, real coding is an experience you can’t do alone. It’s more like joining a band. So I need to read my books, and I need to practice on my computer, but I won’t really qualify as an engineer until I’ve coded within a group of engineers working on a product.

Similarly, a person can get really good at an instrument by themselves, they can learn to play the electric guitar, they can perfect the solos of Jimi Hendrix, but when it comes down to it they have to do it in conjunction with other people. This typically means adding lots of process they wouldn’t normally have to think about or care about, like making sure the key is agreed upon, as well as the tempo, as well as deciding who gets to solo when (i.e. sharing the show-offy parts). Not to mention the song list. Oh, and then there’s tuning up at the beginning, choosing a band name, and getting gigs.

It’s a similar thing for coders, and I’ve seen it working with development teams. When they bring in someone new, they have to merge their existing culture with the ideas and habits of the new person. This means explaining how unit tests and code reviews are done, how work gets divided and played, how people work together, and of course how success gets rewarded. Moreover, like musicians, coders tend to have reputations and egos corresponding to their skills and talents which, like a good band, a development team wants to nurture, without letting itself become a pure vehicle to it.

Which means that when you hire a superstar coder (and yes the word seems to be superstar- great coders can do the job of multiple mediocre coders), you tend to listen more carefully to their ideas on how to do things, and that includes how to change the system entirely and try something new, or switch languages etc. I imagine that bands who get to work with Eric Clapton would be the same way.

I’ve been in bands, usually playing banjo, as well as in chamber music groups back when I played piano, so this analogy works great for me. And it makes me more interested in the engineering thing rather than less: my experience was that, although my individual contribution was slightly less in a band setting, the product of the group was something I was always very proud of, and was impossible to accomplish alone.

Now I don’t want you to think I’ve done no coding at all. As a quant, I learned python, which I used extensively at D.E. Shaw and ever since, and some Matlab, as well as SQL and Pig more recently. But the stuff I’ve done is essentially prototyping models. That is, I work alone, playing with data through a script, until I’m happy with the overall model. Since I’m alone I don’t have to follow any process at all, and trust me you can tell by looking at my scripts. Actually I wrote some unit tests for the first time in python, and it was fun. Kind of like solving a Sudoku puzzle.

The part I don’t think works about the coding/ band analogy is that I don’t think coders have quite as good a time as bands. Where are the back-stage groupies? Where are the first two parts of sex, drugs, and rock ‘n’ roll? I think coding groups have their work cut out for them if they really want to play on that analogy.

Categories: musing, open source tools

Is science a girl thing?

One of the reasons I chose to call this blog “mathbabe” is that when I searched that term, I found a website, now defunct (woohoo!), where semi-naked women were adorning math.

This pissed me off, because I want math babes to be doing math.

If you get that (what’s not to get?) then you might see why the European Commission’s latest effort to inspire girls to do science is truly repugnant (hat tip Debbie Berebichez, a.k.a. Science Babe).

It’s a commercial where you see a standard male scientist (in a white lab coat no less) being surprised, and, we assume, aroused, when three girly models come in, giggle, dance, and generally adorn the commercial.

At the end they put on lab goggles in the style of an ironic accessory. They’re all wearing high heels and there’s even lipstick in a few shots for some unexplained reason (are we supposed to infer that wearing lipstick makes you more scientific-alicious?).

And although there are a couple of shots of an actual female writing what could be actual formulas on a hyped-up whiteboard, that’s more than balanced by some other shots of the models with unmistakable come-hither looks, gestures and blown kisses.

People. At the European Commission. Do you have no advisors!? Do you have no common sense? Who vetted this garbage video?!?

I’d like to see us get to the point where our slogan is more along the lines of:

Science, it’s for really smart women

And our video consists of cool, funky women giving actual talks and lectures or actually working on experiments. Maybe they’re wearing heels, but for sure they’re not acting like complete fucking idiots. How’s that?

I personally could suggest about 40 people for such a video. Not hard to do.

Categories: rant, women in math