statrs-dev / statrs

Statistical computation library for Rust

Home Page:https://docs.rs/statrs/latest/statrs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG: `laplace.inverse_cdf()` is not correct.

WarrenWeckesser opened this issue · comments

The implementation of the inverse_cdf() method for the Laplace distribution is missing calls to ln().
The following

if p <= 0.5 {
self.location + self.scale * (2. * p)
} else {
self.location - self.scale * (2. - 2. * p)
}

should be

        if p <= 0.5 {
            self.location + self.scale * (2. * p).ln()
        } else {
            self.location - self.scale * (2. - 2. * p).ln()
        }

(See, for example, the entry for Quantile in the table on the right in the Laplace distribution wikipedia page.)

I'll submit a pull request with a fix.