With a national election at hand, now is a good time to ask: Is it rational for you to vote?

And by extension, was it worth your while to pay attention to whatever the candidates and party leaders have been saying for the past year or so?

With your chance of casting a decisive vote comparable to your chance of winning the lottery, what is the gain from being a good citizen and casting your vote?

The short answer is: quite a lot.

First, the bad news. With 80 million voters, the chance that your vote will determine who controls the U.S. House or Senate is, at best, on the order of one in a million, even if you vote in a battleground district.

The calculation goes as follows. The Democrats, leading in the polls, are expected to take back the House, but there's a lot of uncertainty in the outcome. For example, fivethirtyeight.com gives a 2-percent chance of the election leading to a 218-217 split, excluding your vote.

Now, suppose you live in a swing district with a tight race that could go either way; say, roughly, it could go anywhere from 45-55 percent to 55-45 percent in terms of the two-party vote. And also suppose that 200,000 people will be voting in your district. Then the vote margin in your district could be anywhere between +20,000 to -20,000.

So, if you decide to vote, the chance of your vote being decisive is roughly 1 in 40,000.

Your vote will determine who controls the House only if your vote determines your local House election and your representative is needed to form a majority for his or her party. The probability of both these things happening is, according to the above calculations, approximately 2 percent times 1/40,000 — or one in 2 million.

You can do a similar calculation for the Senate, if you happen to live in a state with a close Senate election. Your best bet may well be North Dakota, which has the sweet spot of a close election and a small population. FiveThirtyEight gives a 15 percent chance of the Senate being exactly tied. North Dakota will have, I dunno, 300,000 voters — its Senate race had 230,000 votes in 2010. If the election could be anywhere from 45-55 to 55-45, that gives a probability of 1/60,000 that it's tied. Multiply 15 percent times 1/60,000, and you get one in 250,000. So it's still a long shot.

Similarly, we estimated a few years ago that the probability of your vote being decisive in the presidential election is, at best, one in a million in a battleground state and much less in a noncompetitive state. The calculation is based on the chance that your state's vote will be exactly tied, along with the chance that your state's electoral votes are necessary for one party or the other to secure an electoral vote majority. Both of these conditions are necessary for your vote to be decisive.

So voting might at first seem like not such a good use of your time.

But here's the good news. If your vote is decisive, it will make a difference for 300 million people. Now imagine that your preferred candidate could bring the equivalent of a $100 improvement in the quality of life to the average American — not an implausible hope, given the size of the federal budget and the impact of decisions in foreign policy, health, the courts and other areas. So in effect you're now buying a $30 billion lottery ticket.

With that payoff, a one in 10 million chance of being decisive isn't bad odds.

Many people do see it that way. Surveys show that voters choose based on who they think will do better for the country as a whole, rather than their personal betterment. Indeed, when it comes to voting, it is irrational to be selfish — but if you care how others are affected, it's a smart calculation to cast your ballot, because the returns to voting are so high for everyone if you are decisive.

Voting and vote choice (including related actions such as the decision to gather information to make an informed vote) are rational in large elections to the extent that voters are not selfish.

That's also the reason for contributing money to a candidate: Large contributions, or contributions to local elections, could conceivably be justified as providing access or the opportunity to directly influence policy. But small-dollar contributions to national elections, like voting, can be better motivated by the possibility of large social benefit than by any direct benefit to you.

Such civically motivated behavior is consistent with both small and large anonymous contributions to charity.

The social benefit from voting also explains the declining response rates in opinion polls. In the 1950s, when mass opinion polling was rare, we would argue that it was more rational to respond to a survey than to vote in an election. For example, as one of 1,000 respondents to a Gallup poll, there was a real chance that your response could noticeably affect the poll numbers (for example, changing a poll result from 49 percent to 50 percent). Nowadays, polls are so common that a telephone poll was done recently to estimate how often individuals are surveyed; the answer was about once per year. It is thus unlikely that a response to a single survey will have much impact.

Anyway, yes, if you are in a state or district that might be close, it is rational to vote.

I'd like to add one more thing. You've all heard about low voter turnout in America, but among well-educated, older white people, turnout is around 90 percent in presidential elections. Some economists treat this as a source of amusement — and, sure, I'd be the first to admit that well-educated, older white people have done a lot of damage to this country. But it's a funny thing: Usually economists tend not to question the actions of this particular demographic. I'm not saying that the high turnout of these people (like me) is evidence that voting is rational. But I would hope that it would cause some economists to think twice before characterizing voting as irrational or laughable.

Andrew Gelman is a professor of statistics and political science at Columbia University. His books include "Bayesian Data Analysis"; "Teaching Statistics: A Bag of Tricks"; and "Red State, Blue State, Rich State, Poor State: Why Americans Vote the Way They Do." He wrote this article for the Washington Post.