Modified to be more compatible with existing Ruby PRNGs.