Converted probability calculation to log space.