"Margin of Error" is the sixth episode of the fourth season of the HBO original series The Wire. Written by Eric Overmyer from a story by Ed Burns & Eric Overmyer, and directed by Dan Attias, it originally aired on October 15, 2006.

On Sunday morning, MayorRoyce and CouncilmenGray and Carcetti attend church to win support from the ministers as the election approaches. Later, while Carcetti and Wilson are campaigning downtown, State DelegateWatkins shows a flier linking Carcetti to a notorious slumlord. Wilson recognizes the flier as a last-minute smear tactic by Royce, but Carcetti becomes agitated that the attack might work. Carcetti, Wilson, D'Agostino, and Gerry discuss how to respond to the flier. At Wilson's urging, Carcetti appears on a radio talk show and feels more positive from when it proves successful. SenatorDavis offers to support Carcetti and split Royce's vote in exchange for $20,000. Carcetti reluctantly agrees.

Sydnor and Herc watch as Marlo meets with his lieutenants. Marlo makes a phone call about picking up a "skinny girl from New York," which Herc interprets as an arrangement to pick up a supply of cocaine. Herc follows Marlo to Penn Station and has him arrested when he meets a woman who turns out to not be carrying drugs. Marlo has engineered the incident to draw out the police. Meanwhile, Greggs learns that a prisoner has offered information on the dead state's witness. However, Rawls tells Landsman to detail Greggs and Norris to uniformed duty at the polls, stalling the witness case until after the election. At school, Prez offers to help Dukie get clean clothes. Donnelly and Grace remove Namond from regular class and put him in Colvin and Parenti's study program along with nine other students. When Randy is brought to Donnelly concerning a potential sexual assault case with a female student, he reveals that he knows about a murder. Later, Prez appeals to Donnelly to let him hand Randy's confession on to someone that he trusts in the police.

In the Western District, a murder warrant is issued for Omar for the shooting of a delivery woman. McNulty is skeptical that Omar would kill someone not involved in the drug trade. Prez appeals to Daniels to help prevent Randy from getting chewed up by the system. Daniels suggests Prez go to Carver, who has reformed his approach to police work. Carver meets with Randy's foster mother, who worries about the boy's safety should anyone learn that he has spoken to the police. She is disappointed in Randy's bad judgment, but Carver tells her he thinks Randy is a good kid. On Election Day, while accompanying his foster mother to the polls, Randy finds himself being paid by a Carcetti staffer to pass out leaflets. Randy recruits Dukie, Kenard and Donut to help him, completing the job by himself after the others take advantage of the staffer's up front payment. Meanwhile, Brianna cuts Namond and his mother De'Londa loose, partly because her income from the collapsed Barksdale Organization has run out. At home, De'Londa pressures Namond to bring in money by selling drugs.

De'Londa finds Namond playing video games and asks him why he is not in school. Namond explains that the election means that school is closed. De'Londa seizes the opportunity to take Namond to see Bodie. Bodie is initially unsure, but De'Londa persists and uses Wee-Bey's name to convince him. After De'Londa leaves, Bodie tells Namond that talking to her gives him insight into his personality.

Michael goes to the gym where Cutty is already flirting with another woman. Namond arrives and asks Michael for help moving his first package and Michael refuses. Cutty talks to Michael about the woman and then asks about Spider. Michael explains that Spider quit because of Cutty's involvement with his mother, then makes a cutting remark about Cutty being no "angel". When Namond returns home he is faced with his mother telling him that she is counting on him, and he assures her that his new corner duties were easy to carry out. Out of his mother's view, he dumps a full bag of drugs on his bed, indicating that he has not sold any of his package.

At home that evening, Jen and Tommy ignore constantly ringing phones. The news reports that there was a massive voter turnout and that Carcetti is in the lead. Similar scenes unfold at Royce and Gray's homes. Tommy learns that Bond is beating Demper in the State's Attorney race. This is good news for Tommy, as it shows a lack of support for Royce's ticket. Jen convinces Tommy to go for a walk with her. They make their way around the harbor and Tommy tells Jen that he hopes to make Baltimore great again. She is positive about his chances. He gets a call from D'Agostino to tell him that Royce has conceded, making him the presumptive mayor-elect, because Baltimore is such a heavily Democratic city. Tommy is unsure whether he is happy about the win, but finally breaks into a smile. They make their way to a celebration and Tommy thanks his supporters and opponents, appealing for their help in the forthcoming general election and in improving Baltimore for their children. Council President Naresse Campbell congratulates Carcetti. Jen tells him that she is going home and that he should enjoy his night. Davis also attends the party and is unashamed of his actions, telling Carcetti he let him off lightly.

The party continues with Gerry, Wilson, Tommy, and D'Agostino in a downtown hotel. Gerry leaves with Wilson. D'Agostino comes on to Carcetti, telling him that he owes her a win bonus. They start kissing, but he goes on to reject her sexual advances despite his initial response. D'Agostino tries to convince him that he cannot go against his nature, but eventually backs down when he resists a second time and tells Tommy to send her a check instead.

Officer Walker spots Omar in a convenience store. Omar realizes Walker is waiting outside for him and hides his gun in a refrigerator. Walker stops Omar and, as he waits for backup, pockets a ring Omar is wearing—the same ring that Omar took from Marlo Stanfield during his robbery of Marlo's poker game. When Omar talks back, Walker brutally pushes him into the wall and knocks him over. When Omar claims that Walker is being unfair as there is no charge against him, Walker informs him that he is facing a murder charge. Colicchio and McNulty arrive on the scene, where Colicchio mocks Omar for not having his shotgun with him. McNulty then explains he is being arrested on a robbery/murder warrant. Officer Santangelo arrives with the wagon, and Omar asks McNulty for a phone call before he is taken in. McNulty gives him his own personal cell phone and dials Butchie for him. Butchie reassures Omar that he will pay his bail and offers him support even when Omar tells him there will be no bail because the charge is murder. Santangelo playfully mocks McNulty as being a "Democrat" for aiding Omar.

When Omar is brought into the prison, he is faced with aggression from most of the other inmates, many of whom he has robbed in the past. Omar prepares for the worst when two men are sent into his cell, one of them carrying a knife. After a tense stand-off, Omar is immensely relieved as they reveal that Butchie sent them to protect him.[1][2]

The title refers to the results of a poll on voting intentions for the mayoral primary featured in the series. In statistical analysis, the margin of error expresses the amount of the random variation underlying a survey's results. This can be thought of as a measure of the variation one would see in reported percentages if the same poll were taken multiple times. The larger the margin of error, the less confidence one has that the poll's reported percentages are close to the "true" percentages; that is, the percentages in the whole population.

This is made in reference of Norman chiding Carcetti for trying to handle the vote turnout of the primary election on his own. This also is in reference of Sergeant Hauk trying to lead an improper investigation on Marlo with the use of a camera obtained through improper protocol, as well as Namond becoming further immersed in the drug game.