Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67236 - trunk/libs/math/dot_net_example/boost_math
From: pbristow_at_[hidden]
Date: 2010-12-15 05:16:57


Author: pbristow
Date: 2010-12-15 05:16:55 EST (Wed, 15 Dec 2010)
New Revision: 67236
URL: http://svn.boost.org/trac/boost/changeset/67236

Log:
added new distributions.
Text files modified:
   trunk/libs/math/dot_net_example/boost_math/AssemblyInfo.cpp | 12 ++--
   trunk/libs/math/dot_net_example/boost_math/Stdafx.h | 15 ++++-
   trunk/libs/math/dot_net_example/boost_math/boost_math.cpp | 100 ++++++++++++++++++++++++++++-----------
   3 files changed, 88 insertions(+), 39 deletions(-)

Modified: trunk/libs/math/dot_net_example/boost_math/AssemblyInfo.cpp
==============================================================================
--- trunk/libs/math/dot_net_example/boost_math/AssemblyInfo.cpp (original)
+++ trunk/libs/math/dot_net_example/boost_math/AssemblyInfo.cpp 2010-12-15 05:16:55 EST (Wed, 15 Dec 2010)
@@ -1,6 +1,6 @@
 #include "stdafx.h"
 
-// Copyright Paul A. Bristow & John Maddock 2009
+// Copyright Paul A. Bristow & John Maddock 2009, 2010
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt
@@ -12,17 +12,15 @@
 using namespace System::Runtime::InteropServices;
 using namespace System::Security::Permissions;
 
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
+// General Information about an assembly is controlled through the following set of attributes.
+// Change these attribute values to modify the information associated with an assembly.
+
 [assembly:AssemblyTitleAttribute("boost_math")];
 [assembly:AssemblyDescriptionAttribute("Math Toolkit")];
 [assembly:AssemblyConfigurationAttribute("")];
 [assembly:AssemblyCompanyAttribute("jmc")];
 [assembly:AssemblyProductAttribute("boost_math")];
-[assembly:AssemblyCopyrightAttribute("Copyright (c) jmc 2007, 2009")];
+[assembly:AssemblyCopyrightAttribute("Copyright (c) jmc 2007 - 2010")];
 [assembly:AssemblyTrademarkAttribute("")];
 [assembly:AssemblyCultureAttribute("")];
 

Modified: trunk/libs/math/dot_net_example/boost_math/Stdafx.h
==============================================================================
--- trunk/libs/math/dot_net_example/boost_math/Stdafx.h (original)
+++ trunk/libs/math/dot_net_example/boost_math/Stdafx.h 2010-12-15 05:16:55 EST (Wed, 15 Dec 2010)
@@ -3,14 +3,14 @@
 // but are changed infrequently.
 
 // Copyright John Maddock 2007.
-// Copyright Paul A. Bristow 2007, 2009
+// Copyright Paul A. Bristow 2007, 2009, 2010
 
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt
 // or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-// Laplace added Aug 2009 PAB
+// Laplace added Aug 2009 PAB, and several others Nov 2010.
 
 #pragma once
 
@@ -26,9 +26,19 @@
 #include <boost/math/distributions/extreme_value.hpp>
 #include <boost/math/distributions/fisher_f.hpp>
 #include <boost/math/distributions/gamma.hpp>
+#include <boost/math/distributions/geometric.hpp>
+#include <boost/math/distributions/hypergeometric.hpp>
+#include <boost/math/distributions/inverse_chi_squared.hpp>
+#include <boost/math/distributions/inverse_gamma.hpp>
+#include <boost/math/distributions/inverse_gaussian.hpp>
 #include <boost/math/distributions/laplace.hpp>
+#include <boost/math/distributions/logistic.hpp>
 #include <boost/math/distributions/lognormal.hpp>
 #include <boost/math/distributions/negative_binomial.hpp>
+#include <boost/math/distributions/non_central_beta.hpp>
+#include <boost/math/distributions/non_central_chi_squared.hpp>
+#include <boost/math/distributions/non_central_f.hpp>
+#include <boost/math/distributions/non_central_t.hpp>
 #include <boost/math/distributions/normal.hpp>
 #include <boost/math/distributions/pareto.hpp>
 #include <boost/math/distributions/poisson.hpp>
@@ -37,4 +47,3 @@
 #include <boost/math/distributions/triangular.hpp>
 #include <boost/math/distributions/uniform.hpp>
 #include <boost/math/distributions/weibull.hpp>
-

Modified: trunk/libs/math/dot_net_example/boost_math/boost_math.cpp
==============================================================================
--- trunk/libs/math/dot_net_example/boost_math/boost_math.cpp (original)
+++ trunk/libs/math/dot_net_example/boost_math/boost_math.cpp 2010-12-15 05:16:55 EST (Wed, 15 Dec 2010)
@@ -21,7 +21,9 @@
 #include "stdafx.h"
 
 #pragma warning(disable: 4400) // 'const boost_math::any_distribution ^' : const/volatile qualifiers on this type are not supported
-
+#pragma warning(disable: 4244) // 'argument' : conversion from 'double' to 'unsigned int', possible loss of data
+#pragma warning(disable: 4512) // assignment operator could not be generated
+// hypergeometric expects integer parameters.
 #include "boost_math.h"
 
 namespace boost_math
@@ -32,7 +34,7 @@
    TRANSLATE_EXCEPTIONS_BEGIN
    // This is where all the work gets done:
    switch(t) // index of distribution to distribution_info distributions[]
- { // New entires must match distribution names, parameter name(s) and defaults defined below.
+ { // New entries must match distribution names, parameter name(s) and defaults defined below.
    case 0:
       this->reset(new concrete_distribution<boost::math::bernoulli>(boost::math::bernoulli(arg1)));
       break;
@@ -61,42 +63,72 @@
       this->reset(new concrete_distribution<boost::math::gamma_distribution<> >(boost::math::gamma_distribution<>(arg1, arg2)));
       break;
    case 9:
- this->reset(new concrete_distribution<boost::math::laplace_distribution<> >(boost::math::laplace_distribution<>(arg1, arg2)));
+ this->reset(new concrete_distribution<boost::math::geometric_distribution<> >(boost::math::geometric_distribution<>(arg1)));
       break;
    case 10:
- this->reset(new concrete_distribution<boost::math::lognormal_distribution<> >(boost::math::lognormal_distribution<>(arg1, arg2)));
+ this->reset(new concrete_distribution<boost::math::hypergeometric_distribution<> >(boost::math::hypergeometric_distribution<>(arg1, arg2, arg3)));
       break;
    case 11:
+ this->reset(new concrete_distribution<boost::math::inverse_chi_squared_distribution<> >(boost::math::inverse_chi_squared_distribution<>(arg1, arg2)));
+ break;
+ case 12:
+ this->reset(new concrete_distribution<boost::math::inverse_gamma_distribution<> >(boost::math::inverse_gamma_distribution<>(arg1, arg2)));
+ break;
+ case 13:
+ this->reset(new concrete_distribution<boost::math::inverse_gaussian_distribution<> >(boost::math::inverse_gaussian_distribution<>(arg1, arg2)));
+ break;
+ case 14:
+ this->reset(new concrete_distribution<boost::math::laplace_distribution<> >(boost::math::laplace_distribution<>(arg1, arg2)));
+ break;
+ case 15:
+ this->reset(new concrete_distribution<boost::math::logistic_distribution<> >(boost::math::logistic_distribution<>(arg1, arg2)));
+ break;
+ case 16:
+ this->reset(new concrete_distribution<boost::math::lognormal_distribution<> >(boost::math::lognormal_distribution<>(arg1, arg2)));
+ break;
+ case 17:
       this->reset(new concrete_distribution<boost::math::negative_binomial_distribution<> >(boost::math::negative_binomial_distribution<>(arg1, arg2)));
       break;
- case 12:
+ case 18:
+ this->reset(new concrete_distribution<boost::math::non_central_beta_distribution<> >(boost::math::non_central_beta_distribution<>(arg1, arg2, arg3)));
+ break;
+ case 19:
+ this->reset(new concrete_distribution<boost::math::non_central_chi_squared_distribution<> >(boost::math::non_central_chi_squared_distribution<>(arg1, arg2)));
+ break;
+ case 20:
+ this->reset(new concrete_distribution<boost::math::non_central_f_distribution<> >(boost::math::non_central_f_distribution<>(arg1, arg2, arg3)));
+ break;
+ case 21:
+ this->reset(new concrete_distribution<boost::math::non_central_t_distribution<> >(boost::math::non_central_t_distribution<>(arg1, arg2)));
+ break;
+ case 22:
       this->reset(new concrete_distribution<boost::math::normal_distribution<> >(boost::math::normal_distribution<>(arg1, arg2)));
       break;
- case 13:
+ case 23:
       this->reset(new concrete_distribution<boost::math::pareto>(boost::math::pareto(arg1, arg2)));
       break;
- case 14:
+ case 24:
       this->reset(new concrete_distribution<boost::math::poisson>(boost::math::poisson(arg1)));
       break;
- case 15:
+ case 25:
       this->reset(new concrete_distribution<boost::math::rayleigh>(boost::math::rayleigh(arg1)));
       break;
- case 16:
+ case 26:
       this->reset(new concrete_distribution<boost::math::students_t>(boost::math::students_t(arg1)));
       break;
- case 17:
+ case 27:
       this->reset(new concrete_distribution<boost::math::triangular>(boost::math::triangular(arg1, arg2, arg3)));
       break;
- case 18:
+ case 28:
       this->reset(new concrete_distribution<boost::math::uniform>(boost::math::uniform(arg1, arg2)));
       break;
- case 19:
+ case 29:
       this->reset(new concrete_distribution<boost::math::weibull>(boost::math::weibull(arg1, arg2)));
       break;
 
+
    default:
- // TODO:
- // Need some proper error handling here:
+ // TODO Need some proper error handling here?
       assert(0);
    }
    TRANSLATE_EXCEPTIONS_END
@@ -105,10 +137,10 @@
 struct distribution_info
 {
    const char* name; // of distribution.
- const char* first_param; // parameters name like "degrees of freedom"
- const char* second_param; // if required, else "".
+ const char* first_param; // Parameters' name like "degrees of freedom",
+ const char* second_param; // if required, else "",
    const char* third_param; // if required, else "".
- // triangular need 3 parameters.
+ // triangular and non-centrals need 3 parameters.
    // (Only the Bi-Weibull would need 5 parameters?)
    double first_default; // distribution parameter value, often 0, 0.5 or 1.
    double second_default; // 0 if there isn't a second argument.
@@ -129,19 +161,29 @@
    { "Exponential", "lambda", "", "", 1, 0, 0}, // case 5
    { "Extreme value", "Location", "Scale", "", 0, 1, 0}, // case 6
    { "Fisher-F", "Degrees of freedom 1", "Degrees of freedom 2", "", 1, 1, 0}, // case 7
- { "Gamma", "Shape", "Scale", "", 1, 1, }, // case 8
- { "Laplace", "Location", "Scale", "", 0, 1, 0}, // case 9
- { "Lognormal", "Location", "Scale", "", 0, 1, 0}, // case 10
- { "Negative Binomial", "Successes", "Probability of success", "", 1, 0.5, 0}, // case 11
- { "Normal (Gaussian)", "Mean", "Standard Deviation", "", 0, 1, 0}, // case 12
- { "Pareto", "Location", "Shape","", 1, 1, 0}, // case 13
- { "Poisson", "Mean", "", "", 1, 0, 0}, // case 14
- { "Rayleigh", "Sigma", "", "", 1, 0, 0}, // case 15
- { "Student's t", "Degrees of Freedom", "", "", 1, 0, 0}, // case 16
- { "Triangular", "Lower", "Mode", "Upper", -1, 0, +1 }, // case 17 3rd parameter!
+ { "Gamma (Erlang)", "Shape", "Scale", "", 1, 1, 0}, // case 8
+ { "Geometric", "Probability", "", "", 1, 0, 0}, // case 9
+ { "HyperGeometric", "Defects", "Samples", "Objects", 1, 0, 1}, // case 10
+ { "InverseChiSq", "Degrees of Freedom", "Scale", "", 1, 1, 0}, // case 11
+ { "InverseGamma", "Shape", "Scale", "", 1, 1, 0}, // case 12
+ { "InverseGaussian", "Mean", "Scale", "", 1, 1, 0}, // case 13
+ { "Laplace", "Location", "Scale", "", 0, 1, 0}, // case 14
+ { "Logistic", "Location", "Scale", "", 0, 1, 0}, // case 15
+ { "LogNormal", "Location", "Scale", "", 0, 1, 0}, // case 16
+ { "Negative Binomial", "Successes", "Probability of success", "", 1, 0.5, 0}, // case 17
+ { "Noncentral Beta", "Shape alpha", "Shape beta", "Non-centrality", 1, 1, 0}, // case 18
+ { "Noncentral ChiSquare", "Degrees of Freedom", "Non-centrality", "", 1, 0, 0}, // case 19
+ { "Noncentral F", "Degrees of Freedom 1", "Degrees of Freedom 2", "Non-centrality", 1, 1, 0}, // case 20
+ { "Noncentral t", "Degrees of Freedom", "Non-centrality", "", 1, 0, 0}, // case 21
+ { "Normal (Gaussian)", "Mean", "Standard Deviation", "", 0, 1, 0}, // case 22
+ { "Pareto", "Location", "Shape","", 1, 1, 0}, // case 23
+ { "Poisson", "Mean", "", "", 1, 0, 0}, // case 24
+ { "Rayleigh", "Shape", "", "", 1, 0, 0}, // case 25
+ { "Student's t", "Degrees of Freedom", "", "", 1, 0, 0}, // case 26
+ { "Triangular", "Lower", "Mode", "Upper", -1, 0, +1 }, // case 27 3rd parameter!
    // 0, 0.5, 1 also said to be 'standard' but this is most like an approximation to Gaussian distribution.
- { "Uniform", "Lower", "Upper", "", 0, 1, 0}, // case 18
- { "Weibull", "Shape", "Scale", "", 1, 1, 0}, // case 19
+ { "Uniform", "Lower", "Upper", "", 0, 1, 0}, // case 28
+ { "Weibull", "Shape", "Scale", "", 1, 1, 0}, // case 29
 };
 
 // How many distributions are supported:


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk