Just two months ago we had “The Stanford Prison Experiment,” based on the 1971 psychological exercise in which 12 college students were randomly selected to play the role of guards and 12 were chosen to play prisoners, with disturbing results.

Now comes “Experimenter,” based on the 1961 exercise (and a number of subsequent, related studies) in which paid participants were told to send increasingly painful electric shocks to test-takers every time a wrong answer was given.

Apparently it’s the year of the period piece, behavior-study movie.

OK, that’s hyperbole, given we’re talking about just two movies. But throw in the Showtime series “Masters of Sex,” and we do have something of a mini-trend of dramas about researchers in the mid- to late-20th century who recruited ordinary people to participate in extraordinary exercises, to startling and sometimes flat-out shocking results.

With his forever forehead, his intelligent eyes, his disarmingly calm manner and (at times) some truly ghastly facial hair, Peter Sarsgaard’s Dr. Stanley Milgram is a quirky but undeniably commanding figure — an unorthodox academic who conducts his ethically questionable experiments with almost ruthless efficiency.

Let others cast doubts about Milgram’s methodology. He’s 100 percent convinced he’s doing important work, and if you disagree — well, that just means you’re wrong.

Milgram’s first notable experiment, which takes place in the basement of a building at Yale in 1961, at first seems to about discerning the effectiveness of pain as a teaching tool.

A handsome, serious man (John Palladino) in a gray lab coat hands envelopes containing paychecks to two regular-looking, middle-aged, visibly nervous men: Miller (Anthony Edwards) and McDonough (Jim Gaffigan).

By a seemingly arbitrary method, Miller is chosen to be the authority figure who asks multiple-choice questions, and McDonough will be the subject.

Miller will be in one room and McDonough will be on the other side of a wall, heard but not seen. Each time McDonough selects the wrong answer, Miller is to press a button giving McDonough a painful electric shock that gets worse each time.

McDonough yelps with pain, pleads for mercy — and even goes silent at one point, leading Miller to wonder if the man is unconscious or worse.

And yet Miller keeps on flipping the switches that administer hundreds of volts of electricity to McDonough, the affable man he met just a few hours ago.

In fact, McDonough works with Milgram, and he’s just pretending to be hit with those electric shocks. Milgram doesn’t care about studying pain as a teaching tool; he’s interested in learning about how far his subjects will go, how much pain they will inflict, simply because an authority figure in a lab coat is giving them the OK to do so.

Milgram conducts the same experiment on hundreds of subjects, with McDonough as the test-taker every time. (Gaffigan is terrific as the mild-mannered accountant who has been hired to play the perpetual victim and becomes something of a Method performer).

Some 65 percent of the time, the test-givers keep on administering those electric shocks until there are no more questions to be asked, no higher voltage to be inflicted.

The study launches Milgram’s career as a celebrity — and as a figure of much controversy, as he conducts a number of experiments in which subjects aren’t told the truth about the nature of the study.

In one of the film’s best scenes, Milgram brings a portable radio into class on Nov. 22, 1963, and tells his students the president has been shot. Their first reaction is to ask him what kind of experiment he’s conducting.

Writer-director Michael Almereyda is a true talent with a seemingly endless array of stylistic tricks up his sleeve, but that’s not always a good thing. Fairly late in the story, we get a scene about a 1970s TV movie based on Milgram’s book, with Kellan Lutz playing William Shatner, and Dennis Haysbert playing Ossie Davis. It’s a mess.

The character of Milgram breaks the fourth wall and addresses us directly. One extended segment looks like something out of a pop-up book, with the characters outlined against deliberately flattened-out backdrops. At times the score is so dramatic and forceful it almost has to be a joke of some kind.

Sarsgaard is a fine actor, but his portrayal of Milgram sometimes seems more about the mannerisms and the tics than giving us true insight into the character.

Winona Ryder gives a solid, more accessible performance as Milgram’s wife. Familiar faces from Anton Yelchin (monumentally irritating and actor-y in just a few minutes onscreen) and John Leguizamo (quietly effective) show up in cameos of wildly varying quality.

In a way (and maybe it was a conscious choice), some of Almereyda’s flourishes mirror Milgram’s flamboyance — but in both cases, when you have such a provocative foundation and such rich material to work with, pushing it to the next level isn’t necessarily the best choice.

[s3r star=2.5/4]

Magnolia Pictures presents a film written and directed by Michael Almereyda. Running time: 90 minutes. Rated PG-13 (for thematic material and brief strong language.). Available on demand and opening Friday at the Music Box Theatre.