The mass-ratio and eccentricity distributions of barium and S stars