Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/random/random-distributions.html @ 13

Last change on this file since 13 was 12, checked in by landauf, 17 years ago

added boost

File size: 25.7 KB
Line 
1
2<html>
3
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6
7<title>Boost Random Number Library Distributions</title>
8</head>
9
10<body bgcolor="#FFFFFF" text="#000000">
11
12<h1>Random Number Library Distributions</h1>
13
14<ul>
15<li><a href="#intro">Introduction</a>
16<li><a href="#synopsis">Synopsis</a>
17<li><a href="#uniform_smallint">Class template
18<code>uniform_smallint</code></a>
19<li><a href="#uniform_int">Class template <code>uniform_int</code></a>
20<li><a href="#uniform_01">Class template <code>uniform_01</code></a>
21<li><a href="#uniform_real">Class template
22<code>uniform_real</code></a>
23<li><a href="#bernoulli_distribution">Class template
24<code>bernoulli_distribution</code></a>
25<li><a href="#geometric_distribution">Class template
26<code>geometric_distribution</code></a>
27<li><a href="#triangle_distribution">Class template
28<code>triangle_distribution</code></a>
29<li><a href="#exponential_distribution">Class template
30<code>exponential_distribution</code></a>
31<li><a href="#normal_distribution">Class template
32<code>normal_distribution</code></a>
33<li><a href="#lognormal_distribution">Class template
34<code>lognormal_distribution</code></a>
35<li><a href="#uniform_on_sphere">Class template
36<code>uniform_on_sphere</code></a>
37</ul>
38
39<h2><a name="intro">Introduction</a></h2>
40
41In addition to the <a href="random-generators.html">random number
42generators</a>, this library provides distribution functions which map
43one distribution (often a uniform distribution provided by some
44generator) to another.
45
46<p>
47Usually, there are several possible implementations of any given
48mapping.  Often, there is a choice between using more space, more
49invocations of the underlying source of random numbers, or more
50time-consuming arithmetic such as trigonometric functions.  This
51interface description does not mandate any specific implementation.
52However, implementations which cannot reach certain values of the
53specified distribution or otherwise do not converge statistically to
54it are not acceptable.
55
56<p>
57<table border="1">
58<tr><th>distribution</th><th>explanation</th><th>example</th></tr>
59
60<tr>
61<td><code><a href="#uniform_smallint">uniform_smallint</a></code></td>
62<td>discrete uniform distribution on a small set of integers (much
63smaller than the range of the underlying generator)</td>
64<td>drawing from an urn</td>
65</tr>
66
67<tr>
68<td><code><a href="#uniform_int">uniform_int</a></code></td>
69<td>discrete uniform distribution on a set of integers; the underlying
70generator may be called several times to gather enough randomness for
71the output</td>
72<td>drawing from an urn</td>
73</tr>
74
75<tr>
76<td><code><a href="#uniform_01">uniform_01</a></code></td>
77<td>continuous uniform distribution on the range [0,1); important
78basis for other distributions</td>
79<td>-</td>
80</tr>
81
82<tr>
83<td><code><a href="#uniform_real">uniform_real</a></code></td>
84<td>continuous uniform distribution on some range [min, max) of real
85numbers</td>
86<td>for the range [0, 2pi): randomly dropping a stick and measuring
87its angle in radiants (assuming the angle is uniformly
88distributed)</td>
89</tr>
90
91<tr>
92<td><code><a href="#bernoulli_distribution">bernoulli_distribution</a></code></td>
93<td>Bernoulli experiment: discrete boolean valued distribution with
94configurable probability</td>
95<td>tossing a coin (p=0.5)</td>
96</tr>
97
98<tr>
99<td><code><a href="#geometric_distribution">geometric_distribution</a></code></td>
100<td>measures distance between outcomes of repeated Bernoulli experiments</td>
101<td>throwing a die several times and counting the number of tries
102until a "6" appears for the first time</td>
103</tr>
104
105<tr>
106<td><code><a href="#triangle_distribution">triangle_distribution</a></code></td>
107<td>?</td>
108<td>?</td>
109</tr>
110
111<tr>
112<td><code><a href="#exponential_distribution">exponential_distribution</a></code></td>
113<td>exponential distribution</td>
114<td>measuring the inter-arrival time of alpha particles emitted by
115radioactive matter</td>
116</tr>
117
118<tr>
119<td><code><a href="#normal_distribution">normal_distribution</a></code></td>
120<td>counts outcomes of (infinitely) repeated Bernoulli experiments</td>
121<td>tossing a coin 10000 times and counting how many front sides are shown</td>
122</tr>
123
124<tr>
125<td><code><a href="#lognormal_distribution">lognormal_distribution</a></code></td>
126<td>lognormal distribution (sometimes used in simulations)</td>
127<td>measuring the job completion time of an assembly line worker</td>
128</tr>
129
130<tr>
131<td><code><a href="#uniform_on_sphere">uniform_on_sphere</a></code></td>
132<td>uniform distribution on a unit sphere of arbitrary dimension</td>
133<td>choosing a random point on Earth (assumed to be a sphere) where to
134spend the next vacations</td>
135</tr>
136
137</table>
138
139<p>
140
141The template parameters of the distribution functions are always in
142the order
143<ul>
144<li>Underlying source of random numbers
145<li>If applicable, return type, with a default to a reasonable type.
146</ul>
147
148<p>
149<em>The distribution functions no longer satisfy the input iterator
150requirements (std:24.1.1 [lib.input.iterators]), because this is
151redundant given the Generator interface and imposes a run-time
152overhead on all users.  Moreover, a Generator interface appeals to
153random number generation as being more "natural".  Use an
154<a href="../utility/iterator_adaptors.htm">iterator adaptor</a>
155if you need to wrap any of the generators in an input iterator
156interface.</em>
157<p>
158
159All of the distribution functions described below store a non-const
160reference to the underlying source of random numbers.  Therefore, the
161distribution functions are not Assignable.  However, they are
162CopyConstructible.  Copying a distribution function will copy the
163parameter values.  Furthermore, both the copy and the original will
164refer to the same underlying source of random numbers.  Therefore,
165both the copy and the original will obtain their underlying random
166numbers from a single sequence.
167
168<p>
169In this description, I have refrained from documenting those members
170in detail which are already defined in the
171<a href="random-concepts.html">concept documentation</a>.
172
173
174<h2><a name="synopsis">Synopsis of the distributions</a> available from header
175<code>&lt;boost/random.hpp&gt;</code> </h2>
176
177<pre>
178namespace boost {
179  template&lt;class IntType = int&gt;
180  class uniform_smallint;
181  template&lt;class IntType = int&gt;
182  class uniform_int;
183  template&lt;class RealType = double&gt;
184  class uniform_01;
185  template&lt;class RealType = double&gt;
186  class uniform_real;
187
188  // discrete distributions
189  template&lt;class RealType = double&gt;
190  class bernoulli_distribution;
191  template&lt;class IntType = int&gt;
192  class geometric_distribution;
193
194  // continuous distributions
195  template&lt;class RealType = double&gt;
196  class triangle_distribution;
197  template&lt;class RealType = double&gt;
198  class exponential_distribution;
199  template&lt;class RealType = double&gt;
200  class normal_distribution;
201  template&lt;class RealType = double&gt;
202  class lognormal_distribution;
203  template&lt;class RealType = double,
204    class Cont = std::vector&lt;RealType&gt; &gt;
205  class uniform_on_sphere;
206}
207</pre>
208
209<h2><a name="uniform_smallint">Class template
210<code>uniform_smallint</code></a></h2>
211
212<h3>Synopsis</h3>
213
214<pre>
215#include &lt;<a href="../../boost/random/uniform_smallint.hpp">boost/random/uniform_smallint.hpp</a>&gt;
216
217template&lt;class IntType = int&gt;
218class uniform_smallint
219{
220public:
221  typedef IntType input_type;
222  typedef IntType result_type;
223  static const bool has_fixed_range = false;
224  uniform_smallint(IntType min, IntType max);
225  result_type min() const;
226  result_type max() const;
227  void reset();
228  template&lt;class UniformRandomNumberGenerator&gt;
229  result_type operator()(UniformRandomNumberGenerator& urng);
230};
231</pre>
232
233<h3>Description</h3>
234
235The distribution function <code>uniform_smallint</code> models a
236<a href="random-concepts.html#random-dist">random distribution</a>.
237On each invocation, it returns a random integer value
238uniformly distributed in the set of integer numbers {min, min+1,
239min+2, ..., max}.  It assumes that the desired range (max-min+1) is
240small compared to the range of the underlying source of random
241numbers and thus makes no attempt to limit quantization errors.
242<p>
243Let r<sub>out</sub>=(max-min+1) the desired range of integer numbers,
244and let r<sub>base</sub> be the range of the underlying source of
245random numbers.  Then, for the uniform distribution, the theoretical
246probability for any number i in the range r<sub>out</sub> will be
247p<sub>out</sub>(i) = 1/r<sub>out</sub>.  Likewise, assume a uniform
248distribution on r<sub>base</sub> for the underlying source of random
249numbers, i.e. p<sub>base</sub>(i) = 1/r<sub>base</sub>.  Let
250p<sub>out_s</sub>(i) denote the random distribution generated by
251<code>uniform_smallint</code>.  Then the sum over all i in
252r<sub>out</sub> of (p<sub>out_s</sub>(i)/p<sub>out</sub>(i)
253-1)<sup>2</sup> shall not exceed
254r<sub>out</sub>/r<sub>base</sub><sup>2</sup> (r<sub>base</sub> mod
255r<sub>out</sub>)(r<sub>out</sub> - r<sub>base</sub> mod
256r<sub>out</sub>).
257<p>
258
259The template parameter <code>IntType</code> shall denote an
260integer-like value type.
261
262<p>
263<em>Note:</em> The property above is the square sum of the relative
264differences in probabilities between the desired uniform distribution
265p<sub>out</sub>(i) and the generated distribution
266p<sub>out_s</sub>(i).  The property can be fulfilled with the
267calculation (base_rng mod r<sub>out</sub>), as follows: Let r =
268r<sub>base</sub> mod r<sub>out</sub>.  The base distribution on
269r<sub>base</sub> is folded onto the range r<sub>out</sub>.  The
270numbers i &lt; r have assigned (r<sub>base</sub> div
271r<sub>out</sub>)+1 numbers of the base distribution, the rest has only
272(r<sub>base</sub> div r<sub>out</sub>).  Therefore,
273p<sub>out_s</sub>(i) = ((r<sub>base</sub> div r<sub>out</sub>)+1) /
274r<sub>base</sub> for i &lt; r and p<sub>out_s</sub>(i) =
275(r<sub>base</sub> div r<sub>out</sub>)/r<sub>base</sub> otherwise.
276Substituting this in the above sum formula leads to the desired
277result.
278<p>
279<em>Note:</em> The upper bound for (r<sub>base</sub> mod r<sub>out</sub>)(r<sub>out</sub> - r<sub>base</sub>
280mod r<sub>out</sub>) is r<sub>out</sub><sup>2</sup>/4.  Regarding the upper bound for the square
281sum of the relative quantization error of r<sub>out</sub><sup>3</sup>/(4*r<sub>base</sub><sup>2</sup>), it
282seems wise to either choose r<sub>base</sub> so that r<sub>base</sub> &gt; 10*r<sub>out</sub><sup>2</sup> or
283ensure that r<sub>base</sub> is divisible by r<sub>out</sub>.
284
285
286<h3>Members</h3>
287
288<pre>uniform_smallint(IntType min, IntType max)</pre>
289
290<strong>Effects:</strong> Constructs a <code>uniform_smallint</code>
291functor. <code>min</code> and <code>max</code> are the lower and upper
292bounds of the output range, respectively.
293
294
295<h2><a name="uniform_int">Class template <code>uniform_int</code></a></h2>
296
297<h3>Synopsis</h3>
298
299<pre>
300#include &lt;<a href="../../boost/random/uniform_int.hpp">boost/random/uniform_int.hpp</a>&gt;
301
302template&lt;class IntType = int&gt;
303class uniform_int
304{
305public:
306  typedef IntType input_type;
307  typedef IntType result_type;
308  static const bool has_fixed_range = false;
309  explicit uniform_int(IntType min = 0, IntType max = 9);
310  result_type min() const;
311  result_type max() const;
312  void reset();
313  template&lt;class UniformRandomNumberGenerator&gt;
314  result_type operator()(UniformRandomNumberGenerator& urng);
315  template&lt;class UniformRandomNumberGenerator&gt;
316  result_type operator()(UniformRandomNumberGenerator& urng, result_type n);
317};
318</pre>
319
320<h3>Description</h3>
321
322The distribution function <code>uniform_int</code> models a
323<a href="random-concepts.html#random-dist">random distribution</a>.
324On each invocation, it returns a random integer
325value uniformly distributed in the set of integer numbers
326{min, min+1, min+2, ..., max}.
327<p>
328
329The template parameter <code>IntType</code> shall denote an
330integer-like value type.
331
332<h3>Members</h3>
333
334<pre>    uniform_int(IntType min = 0, IntType max = 9)</pre>
335<strong>Requires:</strong> min &lt;= max
336<br>
337<strong>Effects:</strong> Constructs a <code>uniform_int</code>
338object.  <code>min</code> and <code>max</code> are the parameters of
339the distribution.
340
341<pre>    result_type min() const</pre>
342<strong>Returns:</strong> The "min" parameter of the distribution.
343
344<pre>    result_type max() const</pre>
345<strong>Returns:</strong> The "max" parameter of the distribution.
346
347<pre>    result_type operator()(UniformRandomNumberGenerator& urng, result_type
348n)</pre>
349<strong>Returns:</strong> A uniform random number x in the range 0
350&lt;= x &lt; n.  <em>[Note: This allows a
351<code>variate_generator</code> object with a <code>uniform_int</code>
352distribution to be used with std::random_shuffe, see
353[lib.alg.random.shuffle]. ]</em>
354
355
356<h2><a name="uniform_01">Class template <code>uniform_01</code></a></h2>
357
358<h3>Synopsis</h3>
359
360<pre>
361#include &lt;<a href="../../boost/random/uniform_01.hpp">boost/random/uniform_01.hpp</a>&gt;
362
363template&lt;class UniformRandomNumberGenerator, class RealType = double&gt;
364class uniform_01
365{
366public:
367  typedef UniformRandomNumberGenerator base_type;
368  typedef RealType result_type;
369  static const bool has_fixed_range = false;
370  explicit uniform_01(base_type & rng);
371  result_type operator()();
372  result_type min() const;
373  result_type max() const;
374};
375</pre>
376
377<h3>Description</h3>
378
379The distribution function <code>uniform_01</code> models a
380<a href="random-concepts.html#random-dist">random distribution</a>.
381On each invocation, it returns a random floating-point value uniformly
382distributed in the range [0..1).
383
384The value is computed using
385<code>std::numeric_limits&lt;RealType&gt;::digits</code> random binary
386digits, i.e. the mantissa of the floating-point value is completely
387filled with random bits. [<em>Note:</em> Should this be configurable?]
388
389<p>
390The template parameter <code>RealType</code> shall denote a float-like
391value type with support for binary operators +, -, and /.  It must be
392large enough to hold floating-point numbers of value
393<code>rng.max()-rng.min()+1</code>.
394<p>
395<code>base_type::result_type</code> must be a number-like value type,
396it must support <code>static_cast&lt;&gt;</code> to
397<code>RealType</code> and binary operator -.
398
399<p>
400
401<em>Note:</em> The current implementation is buggy, because it may not
402fill all of the mantissa with random bits.  I'm unsure how to fill a
403(to-be-invented) <code>boost::bigfloat</code> class with random bits
404efficiently.  It's probably time for a traits class.
405
406<h3>Members</h3>
407
408<pre>explicit uniform_01(base_type & rng)</pre>
409
410<strong>Effects:</strong> Constructs a <code>uniform_01</code> functor
411with the given uniform random number generator as the underlying
412source of random numbers.
413
414
415<h2><a name="uniform_real">Class template <code>uniform_real</code></a></h2>
416
417<h3>Synopsis</h3>
418
419<pre>
420#include &lt;<a href="../../boost/random/uniform_real.hpp">boost/random/uniform_real.hpp</a>&gt;
421
422template&lt;class RealType = double&gt;
423class uniform_real
424{
425public:
426  typedef RealType input_type;
427  typedef RealType result_type;
428  static const bool has_fixed_range = false;
429  uniform_real(RealType min = RealType(0), RealType max = RealType(1));
430  result_type min() const;
431  result_type max() const;
432  void reset();
433  template&lt;class UniformRandomNumberGenerator&gt;
434  result_type operator()(UniformRandomNumberGenerator& urng);
435};
436</pre>
437
438<h3>Description</h3>
439
440The distribution function <code>uniform_real</code> models a
441<a href="random-concepts.html#random-dist">random distribution</a>.
442On each invocation, it returns a random floating-point
443value uniformly distributed in the range [min..max). The value is
444computed using
445<code>std::numeric_limits&lt;RealType&gt;::digits</code> random binary
446digits, i.e. the mantissa of the floating-point value is completely
447filled with random bits.
448<p>
449
450<em>Note:</em> The current implementation is buggy, because it may not
451fill all of the mantissa with random bits.
452
453
454<h3>Members</h3>
455
456<pre>    uniform_real(RealType min = RealType(0), RealType max = RealType(1))</pre>
457<strong>Requires:</strong> min &lt;= max
458<br>
459<strong>Effects:</strong> Constructs a
460<code>uniform_real</code> object; <code>min</code> and
461<code>max</code> are the parameters of the distribution.
462
463<pre>    result_type min() const</pre>
464<strong>Returns:</strong> The "min" parameter of the distribution.
465
466<pre>    result_type max() const</pre>
467<strong>Returns:</strong> The "max" parameter of the distribution.
468
469
470<h2><a name="bernoulli_distribution">Class template
471<code>bernoulli_distribution</code></a></h2>
472
473<h3>Synopsis</h3>
474
475<pre>
476#include &lt;<a href="../../boost/random/bernoulli_distribution.hpp">boost/random/bernoulli_distribution.hpp</a>&gt;
477
478template&lt;class RealType = double>
479class bernoulli_distribution
480{
481public:
482  typedef int input_type;
483  typedef bool result_type;
484
485  explicit bernoulli_distribution(const RealType& p = RealType(0.5));
486  RealType p() const;
487  void reset();
488  template&lt;class UniformRandomNumberGenerator&gt;
489  result_type operator()(UniformRandomNumberGenerator& urng);
490};
491</pre>
492
493<h3>Description</h3>
494
495Instantiations of class template <code>bernoulli_distribution</code>
496model a <a href="random-concepts.html#random-dist">random
497distribution</a>.  Such a random distribution produces
498<code>bool</code> values distributed with probabilities P(true) = p
499and P(false) = 1-p.  p is the parameter of the distribution.
500
501<h3>Members</h3>
502
503<pre>    bernoulli_distribution(const RealType& p = RealType(0.5))</pre>
504
505<strong>Requires:</strong> 0 &lt;= p &lt;= 1
506<br>
507<strong>Effects:</strong> Constructs a
508<code>bernoulli_distribution</code> object.  <code>p</code> is the
509parameter of the distribution.
510
511<pre>    RealType p() const</pre>
512<strong>Returns:</strong> The "p" parameter of the distribution.
513
514
515<h2><a name="geometric_distribution">Class template
516<code>geometric_distribution</code></a></h2>
517
518<h3>Synopsis</h3>
519<pre>
520#include &lt;<a href="../../boost/random/geometric_distribution.hpp">boost/random/geometric_distribution.hpp</a>&gt;
521
522template&lt;class UniformRandomNumberGenerator, class IntType = int&gt;
523class geometric_distribution
524{
525public:
526  typedef RealType input_type;
527  typedef IntType result_type;
528
529  explicit geometric_distribution(const RealType& p = RealType(0.5));
530  RealType p() const;
531  void reset();
532  template&lt;class UniformRandomNumberGenerator&gt;
533  result_type operator()(UniformRandomNumberGenerator& urng);
534};
535</pre>
536
537
538<h3>Description</h3>
539
540Instantiations of class template <code>geometric_distribution</code>
541model a
542<a href="random-concepts.html#random-dist">random distribution</a>.
543A <code>geometric_distribution</code> random distribution produces
544integer values <em>i</em> &gt;= 1 with p(i) = (1-p) * p<sup>i-1</sup>.
545p is the parameter of the distribution.
546
547
548<h3>Members</h3>
549
550<pre>    geometric_distribution(const RealType& p = RealType(0.5))</pre>
551
552<strong>Requires:</strong> 0 &lt; p &lt; 1
553<br>
554<strong>Effects:</strong> Constructs a
555<code>geometric_distribution</code> object; <code>p</code> is the
556parameter of the distribution.
557
558<pre>   RealType p() const</pre>
559<strong>Returns:</strong> The "p" parameter of the distribution.
560
561
562<h2><a name="triangle_distribution">Class template
563<code>triangle_distribution</code></a></h2>
564
565<h3>Synopsis</h3>
566<pre>
567#include &lt;<a href="../../boost/random/triangle_distribution.hpp">boost/random/triangle_distribution.hpp</a>&gt;
568
569template&lt;class RealType = double&gt;
570class triangle_distribution
571{
572public:
573  typedef RealType input_type;
574  typedef RealType result_type;
575  triangle_distribution(result_type a, result_type b, result_type c);
576  result_type a() const;
577  result_type b() const;
578  result_type c() const;
579  void reset();
580  template&lt;class UniformRandomNumberGenerator&gt;
581  result_type operator()(UniformRandomNumberGenerator& urng);
582};
583</pre>
584
585<h3>Description</h3>
586
587Instantiations of class template <code>triangle_distribution</code>
588model a <a href="random-concepts.html#random-dist">random
589distribution</a>.  The returned floating-point values <code>x</code>
590satisfy <code>a <= x <= c</code>; <code>x</code> has a triangle
591distribution, where <code>b</code> is the most probable value for
592<code>x</code>.
593
594<h3>Members</h3>
595
596<pre>triangle_distribution(result_type a, result_type b, result_type c)</pre>
597
598<strong>Effects:</strong> Constructs a
599<code>triangle_distribution</code> functor. <code>a, b, c</code> are
600the parameters for the distribution.
601<p>
602
603
604<h2><a name="exponential_distribution">Class template
605<code>exponential_distribution</code></a></h2>
606
607<h3>Synopsis</h3>
608<pre>
609#include &lt;<a href="../../boost/random/exponential_distribution.hpp">boost/random/exponential_distribution.hpp</a>&gt;
610
611template&lt;class RealType = double&gt;
612class exponential_distribution
613{
614public:
615  typedef RealType input_type;
616  typedef RealType result_type;
617  explicit exponential_distribution(const result_type& lambda);
618  RealType lambda() const;
619  void reset();
620  template&lt;class UniformRandomNumberGenerator&gt;
621  result_type operator()(UniformRandomNumberGenerator& urng);
622};
623</pre>
624
625<h3>Description</h3>
626
627Instantiations of class template <code>exponential_distribution</code>
628model a <a href="random-concepts.html#random-dist">random
629distribution</a>.  Such a distribution produces random numbers x &gt;
6300 distributed with probability density function p(x) = lambda *
631exp(-lambda * x), where lambda is the parameter of the distribution.
632
633<h3>Members</h3>
634
635<pre>    exponential_distribution(const result_type& lambda = result_type(1))</pre>
636<strong>Requires:</strong> lambda &gt; 0
637<br>
638<strong>Effects:</strong> Constructs an
639<code>exponential_distribution</code> object with <code>rng</code> as
640the reference to the underlying source of random
641numbers. <code>lambda</code> is the parameter for the distribution.
642
643<pre>    RealType lambda() const</pre>
644<strong>Returns:</strong> The "lambda" parameter of the distribution.
645
646
647<h2><a name="normal_distribution">Class template
648<code>normal_distribution</code></a></h2>
649
650<h3>Synopsis</h3>
651
652<pre>
653#include &lt;<a href="../../boost/random/normal_distribution.hpp">boost/random/normal_distribution.hpp</a>&gt;
654
655template&lt;class RealType = double&gt;
656class normal_distribution
657{
658public:
659  typedef RealType input_type;
660  typedef RealType result_type;
661  explicit normal_distribution(const result_type& mean = 0,
662                               const result_type& sigma = 1);
663  RealType mean() const;
664  RealType sigma() const;
665  void reset();
666  template&lt;class UniformRandomNumberGenerator&gt;
667  result_type operator()(UniformRandomNumberGenerator& urng);
668};
669</pre>
670
671<h3>Description</h3>
672
673Instantiations of class template <code>normal_distribution</code>
674model a <a href="random-concepts.html#random-dist">random
675distribution</a>.  Such a distribution produces random numbers x
676distributed with probability density function p(x) =
6771/sqrt(2*pi*sigma) * exp(- (x-mean)<sup>2</sup> /
678(2*sigma<sup>2</sup>) ), where mean and sigma are the parameters of
679the distribution.
680
681
682<h3>Members</h3>
683
684<pre>
685    explicit normal_distribution(const result_type& mean = 0,
686                                 const result_type& sigma = 1);
687</pre>
688
689<strong>Requires:</strong> sigma &gt; 0
690<br>
691<strong>Effects:</strong> Constructs a
692<code>normal_distribution</code> object; <code>mean</code> and
693<code>sigma</code> are the parameters for the distribution.
694
695<pre>    RealType mean() const</pre>
696<strong>Returns:</strong> The "mean" parameter of the distribution.
697
698<pre>    RealType sigma() const</pre>
699<strong>Returns:</strong> The "sigma" parameter of the distribution.
700
701
702<h2><a name="lognormal_distribution">Class template
703<code>lognormal_distribution</code></a></h2>
704
705<h3>Synopsis</h3>
706
707<pre>
708#include &lt;<a href="../../boost/random/lognormal_distribution.hpp">boost/random/lognormal_distribution.hpp</a>&gt;
709
710template&lt;class RealType = double&gt;
711class lognormal_distribution
712{
713public:
714  typedef typename normal_distribution&lt;RealType&gt;::input_type
715  typedef RealType result_type;
716  explicit lognormal_distribution(const result_type& mean = 1.0,
717                                  const result_type& sigma = 1.0);
718  RealType& mean() const;
719  RealType& sigma() const;                                 
720  void reset();
721  template&lt;class UniformRandomNumberGenerator&gt;
722  result_type operator()(UniformRandomNumberGenerator& urng);
723};
724</pre>
725
726<h3>Description</h3>
727
728Instantiations of class template <code>lognormal_distribution</code>
729model a <a href="random-concepts.html#random-dist">random
730distribution</a>.  Such a distribution produces random numbers
731with p(x) = 1/(x * normal_sigma * sqrt(2*pi)) * exp(
732-(log(x)-normal_mean)<sup>2</sup> / (2*normal_sigma<sup>2</sup>) )
733for x > 0,
734where normal_mean = log(mean<sup>2</sup>/sqrt(sigma<sup>2</sup>
735+ mean<sup>2</sup>))
736and normal_sigma = sqrt(log(1 + sigma<sup>2</sup>/mean<sup>2</sup>)).
737
738
739<h3>Members</h3>
740
741<pre>lognormal_distribution(const result_type& mean,
742                       const result_type& sigma)</pre>
743
744<strong>Effects:</strong> Constructs a
745<code>lognormal_distribution</code> functor. <code>mean</code> and
746<code>sigma</code> are the mean and standard deviation of the
747lognormal distribution.
748<p>
749
750
751<h2><a name="uniform_on_sphere">Class template
752<code>uniform_on_sphere</code></a></h2>
753
754<h3>Synopsis</h3>
755
756<pre>
757#include &lt;<a href="../../boost/random/uniform_on_sphere.hpp">boost/random/uniform_on_sphere.hpp</a>&gt;
758
759template&lt;class RealType = double,
760  class Cont = std::vector&lt;RealType&gt; &gt;
761class uniform_on_sphere
762{
763public:
764  typedef RealType input_type;
765  typedef Cont result_type;
766  explicit uniform_on_sphere(int dim = 2);
767  void reset();
768  template&lt;class UniformRandomNumberGenerator&gt;
769  const result_type & operator()(UniformRandomNumberGenerator& urng);
770};
771</pre>
772
773<h3>Description</h3>
774
775Instantiations of class template <code>uniform_on_sphere</code> model a
776<a href="random-concepts.html#random-dist">random distribution</a>.
777Such a distribution produces random numbers uniformly distributed on
778the unit sphere of arbitrary dimension <code>dim</code>.  The
779<code>Cont</code> template parameter must be a STL-like container type
780with <code>begin</code> and <code>end</code> operations returning
781non-const ForwardIterators of type <code>Cont::iterator</code>.
782
783<h3>Members</h3>
784
785<pre>explicit uniform_on_sphere(int dim = 2)</pre>
786
787<strong>Effects:</strong> Constructs a <code>uniform_on_sphere</code>
788functor. <code>dim</code> is the dimension of the sphere.
789<p>
790
791<p>
792<hr>
793Jens Maurer, 2003-10-25
794
795</body>
796</html>
Note: See TracBrowser for help on using the repository browser.