Is statrs::distribution::Laplace correct?
vi opened this issue · comments
Vitaly Shukela commented
Assuming it is this Laplace distribution, generated samples look strangely distributed:
Wikipedia shows symmetric density function, but all values generated by statrs::distribution::Laplace
are positibe (assuming zero location
parameter).
Formula used in the code reuses uniform float value both as sign and as exponential distribution generator, but actually has no way to ever generate negative values.
Michael Ma commented
Looks like there's a bug here
Should be
self.location - self.scale * x.signum() * (1.0 - 2.0 * x.abs()).ln()
Vitaly Shukela commented
@boxtown Are you going to submit a pull request for this?