1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Distribution Algorithms</title> 5<link rel="stylesheet" href="../../math.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../index.html" title="Math Toolkit 2.12.0"> 8<link rel="up" href="../dist_ref.html" title="Statistical Distributions Reference"> 9<link rel="prev" href="dists/weibull_dist.html" title="Weibull Distribution"> 10<link rel="next" href="../future.html" title="Extras/Future Directions"> 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="dists/weibull_dist.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="../future.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="math_toolkit.dist_ref.dist_algorithms"></a><a class="link" href="dist_algorithms.html" title="Distribution Algorithms">Distribution Algorithms</a> 28</h3></div></div></div> 29<h5> 30<a name="math_toolkit.dist_ref.dist_algorithms.h0"></a> 31 <span class="phrase"><a name="math_toolkit.dist_ref.dist_algorithms.finding_the_location_and_scale_f"></a></span><a class="link" href="dist_algorithms.html#math_toolkit.dist_ref.dist_algorithms.finding_the_location_and_scale_f">Finding 32 the Location and Scale for Normal and similar distributions</a> 33 </h5> 34<p> 35 Two functions aid finding location and scale of random variable z to give 36 probability p (given a scale or location). Only applies to distributions 37 like normal, lognormal, extreme value, Cauchy, (and symmetrical triangular), 38 that have scale and location properties. 39 </p> 40<p> 41 These functions are useful to predict the mean and/or standard deviation 42 that will be needed to meet a specified minimum weight or maximum dose. 43 </p> 44<p> 45 Complement versions are also provided, both with explicit and implicit (default) 46 policy. 47 </p> 48<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">policy</span><span class="special">;</span> <span class="comment">// May be needed by users defining their own policies.</span> 49<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">complement</span><span class="special">;</span> <span class="comment">// Will be needed by users who want to use complements.</span> 50</pre> 51<h5> 52<a name="math_toolkit.dist_ref.dist_algorithms.h1"></a> 53 <span class="phrase"><a name="math_toolkit.dist_ref.dist_algorithms.find_location_function"></a></span><a class="link" href="dist_algorithms.html#math_toolkit.dist_ref.dist_algorithms.find_location_function">find_location 54 function</a> 55 </h5> 56<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">find_location</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre> 57<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> 58 59<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> <span class="comment">// explicit error handling policy</span> 60 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_location</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span> 61 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span> 62 <span class="comment">// For example, a nominal minimum acceptable z, so that p * 100 % are > z</span> 63 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span> 64 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">scale</span><span class="special">,</span> <span class="comment">// scale parameter, for example, normal standard deviation.</span> 65 <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&</span> <span class="identifier">pol</span><span class="special">);</span> 66 67<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">></span> <span class="comment">// with default policy.</span> 68 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_location</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span> 69 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span> 70 <span class="comment">// For example, a nominal minimum acceptable z, so that p * 100 % are > z</span> 71 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span> 72 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">scale</span><span class="special">);</span> <span class="comment">// scale parameter, for example, normal standard deviation.</span> 73 74 <span class="special">}}</span> <span class="comment">// namespaces</span> 75</pre> 76<h5> 77<a name="math_toolkit.dist_ref.dist_algorithms.h2"></a> 78 <span class="phrase"><a name="math_toolkit.dist_ref.dist_algorithms.find_scale_function"></a></span><a class="link" href="dist_algorithms.html#math_toolkit.dist_ref.dist_algorithms.find_scale_function">find_scale 79 function</a> 80 </h5> 81<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">find_scale</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre> 82<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> 83 84<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 85 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_scale</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span> 86 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span> 87 <span class="comment">// For example, a nominal minimum acceptable weight z, so that p * 100 % are > z</span> 88 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span> 89 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">location</span><span class="special">,</span> <span class="comment">// location parameter, for example, normal distribution mean.</span> 90 <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&</span> <span class="identifier">pol</span><span class="special">);</span> 91 92 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Dist</span><span class="special">></span> <span class="comment">// with default policy.</span> 93 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">find_scale</span><span class="special">(</span> <span class="comment">// For example, normal mean.</span> 94 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">z</span><span class="special">,</span> <span class="comment">// location of random variable z to give probability, P(X > z) == p.</span> 95 <span class="comment">// For example, a nominal minimum acceptable z, so that p * 100 % are > z</span> 96 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">p</span><span class="special">,</span> <span class="comment">// probability value desired at x, say 0.95 for 95% > z.</span> 97 <span class="keyword">typename</span> <span class="identifier">Dist</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">location</span><span class="special">)</span> <span class="comment">// location parameter, for example, normal distribution mean.</span> 98<span class="special">}}</span> <span class="comment">// namespaces</span> 99</pre> 100<p> 101 All argument must be finite, otherwise <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a> 102 is called. 103 </p> 104<p> 105 Probability arguments must be [0, 1], otherwise <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a> 106 is called. 107 </p> 108<p> 109 If the choice of arguments would give a negative scale, <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a> 110 is called, unless the policy is to ignore, when the negative (impossible) 111 value of scale is returned. 112 </p> 113<p> 114 <a class="link" href="../stat_tut/weg/find_eg.html" title="Find Location and Scale Examples">Find Mean and standard 115 deviation examples</a> gives simple examples of use of both find_scale 116 and find_location, and a longer example finding means and standard deviations 117 of normally distributed weights to meet a specification. 118 </p> 119</div> 120<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 121<td align="left"></td> 122<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 123 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 124 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 125 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 126 Daryle Walker and Xiaogang Zhang<p> 127 Distributed under the Boost Software License, Version 1.0. (See accompanying 128 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>) 129 </p> 130</div></td> 131</tr></table> 132<hr> 133<div class="spirit-nav"> 134<a accesskey="p" href="dists/weibull_dist.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dist_ref.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="../future.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 135</div> 136</body> 137</html> 138