In Fallout 4, companion perks are determined by how close you are to the companion. The closer you are, the better the perk.