Pittsburgh’s police force is at loggerheads with the city it serves. Since 1902, the city has required police officers to live within the city limits, but an arbitration panel recently ruled in favor of allowing officers to live within 25 air miles of downtown. City officials want the requirement to remain in place, as do the people of Pittsburgh, who voted overwhelmingly in a referendum last year to keep it.

Residency requirements are hugely unpopular among police officers in Pittsburgh and in other cities with similar rules. Many cities and states have contested the constitutionality of these strictures on the grounds that they violate freedom of travel and the equal protection clause of the 14th Amendment. Even where they are in place, they are routinely flouted. Today, only 15 of America’s largest police departments have a strict residency requirement for police officers, and a majority of cops live outside the cities they serve.

Residency requirements for police officers have long been tied to better relations between cops and the communities they’re meant to protect. They continue to be seen by activists and politicians as a social good, part of the struggle to improve police force diversity. These concerns remain significant in Pittsburgh and in cities across the country, where demographic gaps plague police forces and are often linked to tensions with the public. The fatal shooting of an unarmed black teenager, Michael Brown, by a white officer in Ferguson, Missouri, in August threw into relief the lack of representation for minority groups on the police force there and in hundreds of other departments.

On that measure, Pittsburgh isn’t doing great: 25 percent of city residents are black, but only 12 percent of the police force is, according to a FiveThirtyEight analysis. The police force is 85 percent white, even though whites make up only 65 percent of the city’s population.

Pittsburgh is far from an outlier — a look at the demographic data of 75 cities and their police forces reveals it’s as average as it gets. Although it’s impossible to establish causation between requiring cops to live in the city and the demographics of the police force in Pittsburgh or anywhere else, our analysis does show that departments with the rule tend to reflect their communities less than departments without it.

Residency requirements for city workers date to the turn of the 20th century, when aldermen would staff municipalities with a cadre of friends. Reformers in the 1920s argued that these requirements kept the best candidates from getting jobs and that they fostered a culture of corruption that pervaded cities and their governments. The laws were allowed to lapse until the 1970s, when the requirements had something of a renaissance. They were reintroduced and justified as a way of keeping tax revenue in a city and arresting the flight of the middle class to the suburbs. And according to Werner Z. Hirsch and Anthony M. Rufolo, two economists who wrote about residency requirements in 1983, the rules were also thought to increase a police officer’s “interest in the results of his work.” This interest was specified by Peter Eisinger, a professor at the University of Wisconsin, Madison, in a 1980 paper, in which he described the requirement as satisfying “the desire to create greater social symmetry between public servants and their clientele.”

In the mid- and late-1970s, more than half of the biggest American cities had such requirements, and the U.S. Supreme Court upheld them in the case of a Philadelphia firefighter who was fired for moving to New Jersey. The defense of residency requirements came to be known as the “stake in the community” doctrine. In a California Supreme Court case in 1973, the court listed “the promotion of ethnic balance in the community” and “enhancement of the quality of employee performance by greater personal knowledge of the city’s conditions and by a feeling of greater personal stake in the city’s progress” as benefits, though it ultimately ruled against the stricture.

In the ensuing years, the effects of police residency requirements have gotten scant academic attention, even as they’ve come up for debate on city councils and in state capitols. Tim Stevens, the chairman and CEO of the Black Political Empowerment Project, a nonpartisan voting awareness group in Pittsburgh, thinks the city’s police residency requirement still serves two important functions: It generates tax revenue for the city, and it creates a connection between police officers and the community. “If they live in the city, they belong to a neighborhood, and they are part of the city,” he said. “They’re not just coming in from the suburbs. There’s an allegiance to the community they serve other than a paycheck.”

In Chicago, Mayor Rahm Emanuel used similar logic to argue against repealing the city’s residency requirements for police officers and firefighters in 2011. “They are more than police and fire,” he told the Chicago Sun Times at the time. “They are anchors in a neighborhood. They’re the Little League coaches, the hockey coaches, the volunteers at the place of worship. They are anchors — not just in their block, but in their community.” The requirement stayed.

Chicago’s police department is more similar demographically to Chicago than Pittsburgh’s is to Pittsburgh. To get those figures, we compared Equal Employment Opportunity Commission (EEOC) data from 2006 to 2010 with American Community Survey (ACS) data for the same period, and found that the cities with a residency requirement were less likely to have a police force that demographically resembled the population they police.

To figure out whether police forces with the requirement were more or less demographically similar to their cities, we calculated a dispersion index — a measure of how much the racial and ethnic composition of a city’s force differs from that of the population. We used EEOC data on police officers to organize the top 75 cities by police force size into four demographic categories: Hispanic, non-Hispanic white, non-Hispanic black and non-Hispanic Asian. Then we used the ACS data to organize the overall population of these cities into those same four demographic groups. We were then able to construct an overall racial dispersion “score,” as the sum of the absolute deviations between the percentage of police and the percentage of the city’s population for that demographic group. Jersey City, New Jersey, and Newark, New Jersey, have the largest dispersion scores; while Brownsville, Texas, and Los Angeles have the lowest.

What we found was that police departments with a residency requirement had consistently higher dispersion scores than those without. In other words, these police forces were less demographically similar to their cities.

The following chart shows the top 75 cities by police force size and their dispersion scores. Cities with residency requirements are highlighted.

The chart shows that Jersey City has the highest dispersion score, 86.9. Nearby Newark, New Jersey, comes in at a close second with 85.1. On the other end of the spectrum, Brownsville has a 3.5, and Los Angeles a 10.0.

These findings resonate with older research by David Murphy, then a researcher at Washington State University, and John L. Worrall, a professor of criminal justice at California State University at San Bernandino. They wanted to know whether there was a correlation between the cities that had a requirement and how people in those cities viewed their police officers, even if the public was unaware of the requirement. In the mid-1990s, the researchers explored the connection between residency requirements and the confidence levels of their communities in three aspects of policing: the perceived ability of the police to prevent crime, their perceived ability to solve crime, and their perceived ability to protect citizens. They discovered the last thing they were expecting.

“We found to our surprise that residency requirements did not improve confidence,” Murphy said in a recent interview. Quite the opposite: Residency requirements were correlated with less public confidence in the police, specifically in the police force’s ability to protect its citizens.

Murphy thinks the explanation lies in the constraints the requirement puts on a department’s recruitment efforts, though he hasn’t been able to test the theory. In the paper, Murphy and Worrall concluded tentatively that “it is possible that the critics of residency requirements are correct — the limitations on hiring pools, for example, could lead to poor personnel choices and a less qualified commissioned officer corps.”

Their hunch corresponds with the arguments of police officers in departments around the country, who say recruitment, rather than residency, is the key to a diverse force.

Jacksonville, Florida’s police department rescinded its residency requirement six months ago. Recruitment Officer A. W. Latimer said residency requirements have pros and cons: On the one hand, the city benefits from property taxes paid by officers who own homes in the city. But on the other hand, “You’re really limiting your applicant pool,” he said. Jacksonville ranks No. 13 in closest racial matching between the city and the police department; 30 percent of the city is black, as opposed to 20 percent of the police force, but the force is just 4 percent more white and 4 percent more Hispanic than the city as a whole.

Diversity depends on recruitment, Latimer said, not residency. “All police departments should be a reflection of the people you patrol,” he said. “You need blacks, Hispanics, whites, men and women. Everyone should be able to look at a police officer and identify with them.”

Jorge Gomez, an assistant chief of police in Miami, where there is no requirement, agrees that police diversity is crucial. Like Latimer, he thinks it is achieved through a “conscious effort” on the part of recruiters. Miami employs a minority recruiter and advertises on ethnic media radio stations and in newspapers. It ranks about the middle of the pack, with a dispersion score of 35.0.

Some of the worst departments by our index disagree about whether their disparities are overly large. The Newark police department, which has a residency requirement, also has the second-highest dispersion score: 85.1.

“The police department is representative of Newark in all races,” Detective Hubert Henderson said. “The numbers we have in the department are representative of the demographics of our residents.” But he also said there is little the department can do to improve its demographics. Recruiting a diverse police force is challenging regardless of residency requirements.

Prospective officers in Newark apply for the job by taking a civil service test, Henderson said, and the department hires from the list based on the scores. “We have no control,” he said. “We start at the top and work our way down. If you’re number one, you’re number one. You can’t breach the scores. It doesn’t matter what their race is.”

Milwaukee doesn’t have a residency requirement and ranks 14th in terms of the largest disparity between the police and the city. While just 38 percent of the city is white, 68 percent of the police department is. But according to the police chief, that isn’t for lack of trying.

“When it comes to role models or empathy, it would certainly be extraordinarily valuable if the police force could reflect our communities,” Police Chief Edward Flynn said. Especially in professions called upon to deal with people in crisis, Flynn said, there is a strong case to be made for a police force that mirrors the population it serves.

But he said the civil service tests, originally put in place to fight corruption, have hurt minority placement, even as lawsuits have tried to make such tests race-neutral. “We can’t hold spots for minorities, even if it’s an admirable social good,” Flynn said. There is also a preference for veterans, which takes up a number of spots, as well as an advantage for the college-educated. “The test adds to the hurdles we face.”

“Believe me, someone shows me that solution, I’m there,” Flynn said. “We all get it. I don’t know a big city chief who doesn’t want more African-Americans on the force. It is a constant discussion, how to diversify.”

CORRECTION (Oct. 1, 4:00 p.m.): The data used to make the chart in an earlier version of this story had incorrect demographic figures for Rochester, New York, and Wichita, Kansas. The chart has been updated with the correct data. The error did not affect the dispersion index scores or rankings mentioned in the text or the overall analysis, except for the average dispersion score, which is 39.3, not 38.6.