Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2007-04-26 05:53:18


Bugs item #1707940, was opened at 2007-04-26 09:53
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1707940&group_id=7586

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: random
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jeffrey Brent McBeth (mcbeth)
Assigned to: Jens Maurer (jmaurer)
Summary: random::normal_distribution

Initial Comment:
random::normal_distribution always returns a NaN when presented with a UniformRandomNumberGenerator that provides values outside the range of (0,1).

So, for example, this will print a NaN.

#include <boost/random.hpp>
#include <iostream>

int main(int argc, char *argv[])
{
        boost::mt19937 eng(40);
        boost::normal_distribution<> norm(0,1);
        std::cout << norm(eng) << std::endl;
}

Looking at the code, it is clear that for normal_distribution's answers to be defined, the values need to be in the range (0,1)

The attached patch uses uniform_real to restrict the range to [0,1). Unfortunately, this leaves 0 as a fail point. I don't see a clear way to fix that at the moment.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1707940&group_id=7586

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk