Using <boost/math/distributions/non_central_t.hpp> gives unexpected error
Hello,
I am new to using the Boost libraries and I was very happy to see that there is a non-central t distribution class in Boost (I have not managed to find this anywhere else).
Unfortunately I am not able to use this without getting an error. Here is my code:
#include
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of
Avinash K. Hathiramani
Sent: Thursday, August 02, 2012 2:28 AM
To: boost-users@lists.boost.org
Subject: [Boost-users] Using
Unfortunately I am not able to use this without getting an error. Here is my code:
#include
This does not give any results and if I put in an error catch here, I get the following message:
"Error in function boost::math::gamma_p_derivative<e>(e, e): numeric overflow".
I do not follow what is going wrong and I am able to get results for both the CDF and PDF with the same parameters from MATLAB (and an on-line calculator which I found for this distribution), so I do not think that the parameters are invalid.
I would be grateful if anyone can advise me as to whether I am doing anything incorrectly here.
I apologise in advance if I have missed anything obvious, or unintentionally broken any of the discussion policies (it is my first time posting on this forum).
Well, posting a ticket on Trac is the best way for bugs, but in this case, I can't see what the problem is and attached my version of your example which seems to work OK. Ask again if this still doesn't work for you. Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com
I would be grateful if anyone can advise me as to whether I am doing anything incorrectly here. I apologise in advance if I have missed anything obvious, or unintentionally broken any of the discussion policies (it is my first time posting on this forum).
Your code works for me with both VC10 and gcc-4.6 Mingw, both output: Probability density of Student's t is 0.425022 Cumulative probability of Student's t is 0.425022 Can you give us details of the compiler/platform and any other relevant information (for example have you set any of the policy changing macros described in the docs?) John.
Hi Paul and John, Thank you both for your replies. Paul - thank you for attaching your .cpp. I have created a new project and simply copied and pasted your exact code into my main, but I still get the same error as before. Please see below for some additional information on my setup.
Your code works for me with both VC10 and gcc-4.6 Mingw, both output:
Probability density of Student's t is 0.425022 Cumulative probability of Student's t is 0.425022
Can you give us details of the compiler/platform and any other relevant information (for example have you set any of the policy changing macros described in the docs?)
I am using Code::Blocks 10.05, and using the gcc-3.81 Mingw compiler. (My system is Windows XP Professional (Service Pack 3), 32-bit). I have not used Boost previously and am not using too many of it's functions at the moment, so I have not made any changes to the settings (or set any policy changing macros). I'm still a bit new to using external libraries, so I've just done the most basic installation. Also, I am using Boost 1.49.0 - sorry I should have mentioned this in my first post. Please let me know if there is any other information which I can provide to help. Many thanks, Avinash P.S. If necessary I can raise a ticket on Trac instead of continuing this thread - please let me know if/when that becomes appropriate.
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of
Avinash K. Hathiramani
Sent: Thursday, August 02, 2012 2:53 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] Using
Your code works for me with both VC10 and gcc-4.6 Mingw, both output:
Probability density of Student's t is 0.425022 Cumulative probability of Student's t is 0.425022
Can you give us details of the compiler/platform and any other relevant information (for example have you set any of the policy changing macros described in the docs?)
I am using Code::Blocks 10.05, and using the gcc-3.81 Mingw compiler. (My system is Windows XP Professional (Service Pack 3), 32-bit). I have not used Boost previously and am not using too many of it's functions at the moment, so I have not made any changes to the settings (or set any policy changing macros). I'm still a bit new to using external libraries, so I've just done the most basic installation. Also, I am using Boost 1.49.0 - sorry I should have mentioned this in my first post. No code changes to this since Boost 1.49 so that should be fine. Boost.Math does not *require* any libraries to be installed, only to include the headers - ie header only. (In act you should NOT build a library). So you should only link to anything required to get a hello world example to run. (make sure one does?) Do you get this error message from my code? "Error in function boost::math::gamma_p_derivative<e>(e, e): numeric overflow". This is most odd because it appears to be type 'e'???? not double, float etc. When does it throw - can you show the 'echoed' df and non-centrality OK? does the pdf work? or the cdf? on their own? Try some simpler examples using Boost.Math - perhaps \libs\math\example\distribution_construction.cpp. HTH Paul
I am using Code::Blocks 10.05, and using the gcc-3.81 Mingw compiler. (My system is Windows XP Professional (Service Pack 3), 32-bit).
I had no idea there was such a GCC release - actually the last official release appears to be 3.4.6 back in 2006 according to http://gcc.gnu.org/releases.html My guess is that your Mingw install is seriously outdated: very likely some std library call is failing and that's propagating an "incorrect" infinity. Can you try with a recent Mingw 4.x version? John.
participants (3)
-
Avinash K. Hathiramani
-
John Maddock
-
Paul A. Bristow