]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Frequently Asked Questions FAQ</title> | |
5 | <link rel="stylesheet" href="../math.css" type="text/css"> | |
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> | |
7 | <link rel="home" href="../index.html" title="Math Toolkit 2.5.1"> | |
8 | <link rel="up" href="../overview.html" title="Chapter 1. Overview"> | |
9 | <link rel="prev" href="overview_tr1.html" title="C99 and C++ TR1 C-style Functions"> | |
10 | <link rel="next" href="contact.html" title="Contact Info and Support"> | |
11 | </head> | |
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> | |
13 | <table cellpadding="2" width="100%"><tr> | |
14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> | |
15 | <td align="center"><a href="../../../../../index.html">Home</a></td> | |
16 | <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> | |
17 | <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> | |
18 | <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> | |
19 | <td align="center"><a href="../../../../../more/index.htm">More</a></td> | |
20 | </tr></table> | |
21 | <hr> | |
22 | <div class="spirit-nav"> | |
23 | <a accesskey="p" href="overview_tr1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="contact.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> | |
27 | <a name="math_toolkit.main_faq"></a><a class="link" href="main_faq.html" title="Frequently Asked Questions FAQ">Frequently Asked Questions FAQ</a> | |
28 | </h2></div></div></div> | |
29 | <div class="orderedlist"><ol class="orderedlist" type="1"> | |
30 | <li class="listitem"> | |
31 | <span class="emphasis"><em>I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user and I don't | |
32 | see where the functions like dnorm(mean, sd) are in Boost.Math?</em></span> | |
33 | <br> Nearly all are provided, and many more like mean, skewness, quantiles, | |
34 | complements ... but Boost.Math makes full use of C++, and it looks a bit | |
35 | different. But do not panic! See section on construction and the many examples. | |
36 | Briefly, the distribution is constructed with the parameters (like location | |
37 | and scale) (things after the | in representation like P(X=k|n, p) or ; | |
38 | in a common represention of pdf f(x; μσ<sup>2</sup>). Functions like pdf, cdf are called | |
39 | with the name of that distribution and the random variate often called | |
40 | x or k. For example, <code class="computeroutput"><span class="identifier">normal</span> <span class="identifier">my_norm</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span> <span class="identifier">pdf</span><span class="special">(</span><span class="identifier">my_norm</span><span class="special">,</span> <span class="number">2.0</span><span class="special">);</span></code> | |
41 | <br> | |
42 | </li> | |
43 | <li class="listitem"> | |
44 | I'm a user of <a href="http://support.sas.com/rnd/app/da/new/probabilityfunctions.html" target="_top">New | |
45 | SAS Functions for Computing Probabilities</a>. <br> You will find | |
46 | the interface more familar, but to be able to select a distribution (perhaps | |
47 | using a string) see the Extras/Future Directions section, and /boost/libs/math/dot_net_example/boost_math.cpp | |
48 | for an example that is used to create a C# (C sharp) utility (that you | |
49 | might also find useful): see <a href="http://sourceforge.net/projects/distexplorer/" target="_top">Statistical | |
50 | Distribution Explorer</a>.<br> | |
51 | </li> | |
52 | <li class="listitem"> | |
53 | <span class="emphasis"><em>I'm allegic to reading manuals and prefer to learn from examples.</em></span><br> | |
54 | Fear not - you are not alone! Many examples are available for functions | |
55 | and distributions. Some are referenced directly from the text. Others can | |
56 | be found at \boost_latest_release\libs\math\example. If you are a Visual | |
57 | Studio user, you should be able to create projects from each of these, | |
58 | making sure that the Boost library is in the include directories list. | |
59 | </li> | |
60 | <li class="listitem"> | |
61 | <span class="emphasis"><em>How do I make sure that the Boost library is in the Visual Studio | |
62 | include directories list?</em></span><br> You can add an include path, | |
63 | for example, your Boost place /boost-latest_release, for example <code class="computeroutput"><span class="identifier">X</span><span class="special">:/</span><span class="identifier">boost_1_45_0</span><span class="special">/</span></code> if you have a separate partition X for | |
64 | Boost releases. Or you can use an environment variable BOOST_ROOT set to | |
65 | your Boost place, and include that. Visual Studio before 2010 provided | |
66 | Tools, Options, VC++ Directories to control directories: Visual Studio | |
67 | 2010 instead provides property sheets to assist. You may find it convenient | |
68 | to create a new one adding \boost-latest_release; to the existing include | |
69 | items in $(IncludePath). | |
70 | </li> | |
71 | <li class="listitem"> | |
72 | <span class="emphasis"><em>I'm a FORTRAN/NAG/SPSS/SAS/Cephes/MathCad/R user and I don't | |
73 | see where the properties like mean, median, mode, variance, skewness of | |
74 | distributions are in Boost.Math?</em></span><br> They are all available | |
75 | (if defined for the parameters with which you constructed the distribution) | |
76 | via <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution | |
77 | Function</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability | |
78 | Density Function</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>, | |
79 | <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>, | |
80 | <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>, | |
81 | <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.median">median</a>, | |
82 | <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>, | |
83 | <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>, | |
84 | <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>, | |
85 | <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="dist_ref/nmp.html#math_toolkit.dist_ref.nmp.support">support</a>. | |
86 | </li> | |
87 | <li class="listitem"> | |
88 | <span class="emphasis"><em>I am a C programmer. Can I user Boost.Math with C?</em></span><br> | |
89 | Yes you can, including all the special functions, and TR1 functions like | |
90 | isnan. They appear as C functions, by being declared as "extern C". | |
91 | </li> | |
92 | <li class="listitem"> | |
93 | <span class="emphasis"><em>I am a C# (Basic? F# FORTRAN? Other CLI?) programmer. Can I use | |
94 | Boost.Math with C#? (or ...)?</em></span> <br> Yes you can, including | |
95 | all the special functions, and TR1 functions like isnan. But you <span class="bold"><strong>must build the Boost.Math as a dynamic library (.dll) and compile | |
96 | with the /CLI option</strong></span>. See the boost/math/dot_net_example folder | |
97 | which contains an example that builds a simple statistical distribution | |
98 | app with a GUI. See <a href="http://sourceforge.net/projects/distexplorer/" target="_top">Statistical | |
99 | Distribution Explorer</a> <br> | |
100 | </li> | |
101 | <li class="listitem"> | |
102 | <span class="emphasis"><em>What these "policies" things for?</em></span> <br> | |
103 | Policies are a powerful (if necessarily complex) fine-grain mechanism that | |
104 | allow you to customise the behaviour of the Boost.Math library according | |
105 | to your precise needs. See <a class="link" href="../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policies</a>. But | |
106 | if, very probably, the default behaviour suits you, you don't need to know | |
107 | more. | |
108 | </li> | |
109 | <li class="listitem"> | |
110 | <span class="emphasis"><em>I am a C user and expect to see global C-style<code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code> set for overflow/errors etc?</em></span> | |
111 | <br> You can achieve what you want - see <a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error | |
112 | handling policies</a> and <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user | |
113 | error handling</a> and many examples. | |
114 | </li> | |
115 | <li class="listitem"> | |
116 | <span class="emphasis"><em>I am a C user and expect to silently return a max value for overflow?</em></span> | |
117 | <br> You (and C++ users too) can return whatever you want on overflow | |
118 | - see <a class="link" href="error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a> | |
119 | and <a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error | |
120 | handling policies</a> and several examples. | |
121 | </li> | |
122 | <li class="listitem"> | |
123 | <span class="emphasis"><em>I don't want any error message for overflow etc?</em></span> | |
124 | <br> You can control exactly what happens for all the abnormal conditions, | |
125 | including the values returned. See <a class="link" href="error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>, | |
126 | <a class="link" href="error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a> | |
127 | <a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error handling | |
128 | policies</a> <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user | |
129 | error handling</a> etc and examples. | |
130 | </li> | |
131 | <li class="listitem"> | |
132 | <span class="emphasis"><em>My environment doesn't allow and/or I don't want exceptions. | |
133 | Can I still user Boost.Math?</em></span> <br> Yes but you must customise | |
134 | the error handling: see <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user | |
135 | error handling</a> and <a class="link" href="pol_ref/policy_defaults.html" title="Using Macros to Change the Policy Defaults">changing | |
136 | policies defaults</a> . | |
137 | </li> | |
138 | <li class="listitem"> | |
139 | <span class="emphasis"><em>The docs are several hundreds of pages long! Can I read the docs | |
140 | off-line or on paper?</em></span> <br> Yes - you can download the Boost | |
141 | current release of most documentation as a zip of pdfs (including Boost.Math) | |
142 | from Sourceforge, for example <a href="https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download" target="_top">https://sourceforge.net/projects/boost/files/boost-docs/1.45.0/boost_pdf_1_45_0.tar.gz/download</a>. | |
143 | And you can print any pages you need (or even print all pages - but be | |
144 | warned that there are several hundred!). Both html and pdf versions are | |
145 | highly hyperlinked. The entire Boost.Math pdf can be searched with Adobe | |
146 | Reader, Edit, Find ... This can often find what you seek, a partial substitute | |
147 | for a full index. | |
148 | </li> | |
149 | <li class="listitem"> | |
150 | <span class="emphasis"><em>I want a compact version for an embedded application. Can I use | |
151 | float precision?</em></span> <br> Yes - by selecting RealType template | |
152 | parameter as float: for example normal_distribution<float> your_normal(mean, | |
153 | sd); (But double may still be used internally, so space saving may be less | |
154 | that you hope for). You can also change the promotion policy, but accuracy | |
155 | might be much reduced. | |
156 | </li> | |
157 | <li class="listitem"> | |
158 | <span class="emphasis"><em>I seem to get somewhat different results compared to other programs. | |
159 | Why?</em></span> We hope Boost.Math to be more accurate: our priority is | |
160 | accuracy (over speed). See the section on accuracy. But for evaluations | |
161 | that require iterations there are parameters which can change the required | |
162 | accuracy (see <a class="link" href="../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policies</a>). You might be able | |
163 | to squeeze a little more (or less) accuracy at the cost of runtime. | |
164 | </li> | |
165 | <li class="listitem"> | |
166 | <span class="emphasis"><em>Will my program run more slowly compared to other math functions | |
167 | and statistical libraries?</em></span> Probably, thought not always, and | |
168 | not by too much: our priority is accuracy. For most functions, making sure | |
169 | you have the latest compiler version with all optimisations switched on | |
170 | is the key to speed. For evaluations that require iteration, you may be | |
171 | able to gain a little more speed at the expense of accuracy. See detailed | |
172 | suggestions and results on <a class="link" href="../perf.html" title="Chapter 16. Performance">performance</a>. | |
173 | </li> | |
174 | <li class="listitem"> | |
175 | <span class="emphasis"><em>How do I handle infinity and NaNs portably?</em></span> <br> | |
176 | See <a class="link" href="fp_facets.html" title="Facets for Floating-Point Infinities and NaNs">nonfinite fp_facets</a> for | |
177 | Facets for Floating-Point Infinities and NaNs. | |
178 | </li> | |
179 | <li class="listitem"> | |
180 | <span class="emphasis"><em>Where are the pre-built libraries?</em></span> <br> Good news | |
181 | - you probably don't need any! - just <code class="computeroutput"><span class="preprocessor">#include</span> | |
182 | <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span></code><span class="emphasis"><em>math/distribution_you_want></em></span>. | |
183 | But in the unlikely event that you do, see <a class="link" href="building.html" title="If and How to Build a Boost.Math Library, and its Examples and Tests">building | |
184 | libraries</a>. | |
185 | </li> | |
186 | <li class="listitem"> | |
187 | <span class="emphasis"><em>I don't see the function or distribution that I want.</em></span> | |
188 | <br> You could try an email to ask the authors - but no promises! | |
189 | </li> | |
190 | <li class="listitem"> | |
191 | <span class="emphasis"><em>I need more decimal digits for values/computations.</em></span> | |
192 | <br> You can use Boost.Math with <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>: | |
193 | typically <a href="../../../../../libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_dec_float.html" target="_top">cpp_dec_float</a> | |
194 | is a useful user-defined type to provide a fixed number of decimal digits, | |
195 | usually 50 or 100. | |
196 | </li> | |
197 | <li class="listitem"> | |
198 | Why can't I write something really simple like <code class="computeroutput"><span class="identifier">cpp_int</span> | |
199 | <span class="identifier">one</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> <span class="identifier">cpp_dec_float_50</span> | |
200 | <span class="identifier">two</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> <span class="identifier">one</span> | |
201 | <span class="special">*</span> <span class="identifier">two</span><span class="special">;</span></code> Because <code class="computeroutput"><span class="identifier">cpp_int</span></code> | |
202 | might be bigger than <code class="computeroutput"><span class="identifier">cpp_dec_float</span> | |
203 | <span class="identifier">can</span> <span class="identifier">hold</span></code>, | |
204 | so you must make an <span class="bold"><strong>explicit</strong></span> conversion. | |
205 | See <a href="http://svn.boost.org/svn/boost/trunk/libs/multiprecision/doc/html/boost_multiprecision/intro.html" target="_top">mixed | |
206 | multiprecision arithmetic</a> and <a href="http://svn.boost.org/svn/boost/trunk/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html" target="_top">conversion</a>. | |
207 | </li> | |
208 | </ol></div> | |
209 | </div> | |
210 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
211 | <td align="left"></td> | |
212 | <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, | |
213 | Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert | |
214 | Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, | |
215 | Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> | |
216 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
217 | file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) | |
218 | </p> | |
219 | </div></td> | |
220 | </tr></table> | |
221 | <hr> | |
222 | <div class="spirit-nav"> | |
223 | <a accesskey="p" href="overview_tr1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="contact.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
224 | </div> | |
225 | </body> | |
226 | </html> |