Modify

Opened 6 years ago

Closed 6 years ago

#6151 closed Bugs (fixed)

Wrong output from boot::math, cdf(complement(laplace_distribuiton<>(...))

Reported by: Yan Zhou <zhouyan@…> Owned by: Paul A. Bristow
Milestone: Boost 1.49.0 Component: math
Version: Boost 1.48.0 Severity: Problem
Keywords: laplace distribution Cc:

Description

To illustrate the bug, see the following code,

#include <boost/math/distributions/laplace.hpp>
#include <iostream>

int main ()
{
    boost::math::laplace lap(1, 1);
    std::cout << boost::math::cdf(lap, 1) << std::endl;
    std::cout << boost::math::cdf(boost::math::complement(lap, 1)) << std::endl;

    return 0;
}

The output should be two numbers sum up to 1. Instead, it print

0.5 (this is correct) 0.0676676 (this is wrong)

I have double read the boost::math documents, to make sure that I didn't misused the library. Hopefully I am not making a stupid mistake here. Otherwise, the bug looks so stupid to me that I still don't believe this is a bug in boost::math, instead I did something wrong here.

Attachments (1)

laplace.patch (571 bytes) - added by Yan Zhou <zhouyan@…> 6 years ago.
fix the bug

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by Yan Zhou <zhouyan@…>

Attachment: laplace.patch added

fix the bug

comment:1 Changed 6 years ago by Yan Zhou <zhouyan@…>

Component: Nonemath
Owner: set to John Maddock

comment:2 Changed 6 years ago by John Maddock

Owner: changed from John Maddock to Paul A. Bristow

Ouch. Nasty bug.

Paul, did you work on this one? I can't remember now, except I don't think I've touched it...

comment:3 Changed 6 years ago by Paul A. Bristow

OK, looks like a bug, and I think I wrote it, so will look at it soon.

comment:4 Changed 6 years ago by Paul A. Bristow

Ok I did some work on this, but Thijs did most of it ;-)

Thanks for Yan Zhou for patch which looks good. Test adjusted (previous test was wrong too) and now passes cdf + complement == 1 for a range of scale, location, x and p, cdf and quantiles.

Both committed to trunk At revision: 75592

comment:5 Changed 6 years ago by Paul A. Bristow

Keywords: laplace distribution added
Milestone: To Be DeterminedBoost 1.49.0
Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Paul A. Bristow.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.