Skip to content

Error in standard_normal_inv_cdf #7

@nateosher

Description

@nateosher

Hi there! I believe I have found a bug in the implementation of standard_normal_inv_cdf. For values below P_LOW and P_HIGH, the sign is switched; below is a minimal reprex:

use probability_rs::num::standard_normal_inv_cdf;

fn main() {
    println!("Phi^-1(0.02425): {}", standard_normal_inv_cdf(0.02425));
    println!("Phi^-1(0.02424): {}", standard_normal_inv_cdf(0.02424));
    println!(
        "Phi^-1(1.0 - 0.02425): {}",
        standard_normal_inv_cdf(1.0 - 0.02425)
    );
    println!(
        "Phi^-1(1.0 - 0.02424): {}",
        standard_normal_inv_cdf(1.0 - 0.02424)
    );
}

On my machine, this prints out:

Phi^-1(0.02425): -1.9729610490848712
Phi^-1(0.02424): 1.9731366141503466
Phi^-1(1.0 - 0.02425): 1.9729610490848712
Phi^-1(1.0 - 0.02424): -1.9731366141503455

I think the fix is fairly straightforward; I will make a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions