5d and 4ƒ mixing coefficients for rare earth ions in the pure metals and in silver and gold