Converting numerical rating into k, d, or p

See the response in How do I get the rank? and further discussion can continue there.