Ported use of Apache commons math to version 3