Donald Trump’s victory over Hillary Clinton this week came as a shock to most pundits, and just about all pollsters and forecasters — on par with Harry Truman’s upset win over Tom Dewey in 1948.

But the bewilderment over the 2016 presidential race, just like the earlier one, says more about the follies of observers than about the mysteries of the electoral process. Then as now, polls created a false sense that the race was all but over long before Election Day. The sure prospect of a Clinton victory was comforting to all those who found the prospect of a Trump presidency unpalatable. How could such a flawed man ever hope to enter the Oval Office? Simply unimaginable.

In all fairness to Trump detractors, the American public had lots of negative things to say about him. Even on Election Day, most voters, according to exit polls, held unfavorable opinions of Trump. By better than 3-2 margins, they thought he was not honest and trustworthy, was not qualified to be president and did not have the right temperament to be president. How can a candidate overcome such a barrage of ill feelings in the electorate?

One reason is that his opponent also engendered strong negative reactions. Clinton was not rated much better for being honest and trustworthy, although she was judged by slightly more than half of the voters as being qualified to serve as president and having the right temperament. If this were all voters included in their voting decisions, Clinton would surely have won.

But it was not.

In July, I forecast that Trump had an 87 percent chance of beating Clinton. I used a formula I created 20 years ago, The Primary Model, which is based on elections data dating to 1912. Trump, according to the model, was the candidate of change and voters are willing to overlook many foibles of the change candidate.

advertisement | advertise on newsday

The state of our country and government weighed on the minds of voters. Asked in exit polls to express their feelings about the federal government, 7 in 10 chose “angry” or “dissatisfied.” Most of them voted for Trump, the Washington outsider, over Clinton, the Washington insider. “Draining the swamp” was one of Trump’s signature slogans in the campaign, along with branding her as “crooked Hillary.”

All her preparation for the highest office made less of an impression on voters than the desire for change that Trump exploited with glee. By a 2-1 margin, voters picked “bring about change” as more important than having the “right experience” in this election. Change was Trump’s middle name, just as “experience” was Clinton’s. And change trumped experience, pun intended.

Long before Trump announced his candidacy, 2016 shaped up as a “change election.” The electoral pendulum was poised to swing back to the Republican Party after two terms of Democratic control of the White House under President Barack Obama.

In the roughly 200 years of presidential elections since 1828, the two major parties have alternated in that office after two or three terms, on average. During the last 65 years, the White House party managed to secure a third term only once: in 1988.

Such a prospect was not very bright in 2016, given the narrow margin of Obama’s re-election. In the end, Trump rode to victory on a strong wave of disgust with Washington, sweeping aside misgivings about his temperament and conduct, while exploiting misgivings about Clinton, a Washington insider embroiled in accusations of improper conduct in office.

Helmut Norpoth is professor of political science at Stony Brook University. He is the co-author of “The American Voter Revisited.” His new book, “Commander in Chief: Franklin Roosevelt and the American People,” is forthcoming.