casacore
Loading...
Searching...
No Matches
Random.h
Go to the documentation of this file.
1// # Random.h: Random number classes
2// # Copyright (C) 1992,1993,1994,1995,1999,2000,2001
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_RANDOM_H
27#define CASA_RANDOM_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/BasicMath/Math.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35class String;
36
37// <summary>Base class for random number generators</summary>
38//
39// <use visibility=export>
40// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
41// </reviewed>
42//
43// <prerequisite>
44// <li> A knowledge of C++, in particular inheritance
45// <li> College level mathematics
46// </prerequisite>
47//
48// <etymology>
49// RNG stands for "Random Number Generator"
50// </etymology>
51//
52// <synopsis>
53// <h4>General Structure of the Classes</h4>
54//
55
56// The two base classes <linkto class=RNG>RNG</linkto> and
57// <linkto class=Random>Random</linkto> are used together to generate a variety
58// of random number distributions. A distinction must be made between
59// <em>random number generators</em>, implemented by class derived from
60// <src>RNG</src>, and <em>random number distributions</em>. A random number
61// generator produces a series of randomly ordered bits. These bits can be
62// used directly, or cast to another representation, such as a floating point
63// value. A random number generator should produce a <em>uniform</em>
64// distribution. A random number distribution, on the other hand, uses the
65// randomly generated bits of a generator to produce numbers from a
66// distribution with specific properties. Each instance of <src>Random</src>
67// uses an instance of class <src>RNG</src> to provide the raw, uniform
68// distribution used to produce the specific distribution. Several instances
69// of <src>Random</src> classes can share the same instance of <src>RNG</src>,
70// or each instance can use its own copy.
71
72// <h4> RNG </h4>
73//
74
75// Random distributions are constructed from classes derived from
76// <src>RNG</src>, the actual random number generators. The <src>RNG</src>
77// class contains no data; it only serves to define the interface to random
78// number generators. The <src>RNG::asuInt</src> member returns a 32-bit
79// unsigned integer of random bits. Applications that require a number of
80// random bits can use this directly. More often, these random bits are
81// transformed to a uniformly distributed floating point number using either
82// <src>asFloat</src> or <src>asDouble</src>. These functions return differing
83// precisions and the <src>asDouble</src> function will use two different
84// random 32-bit integers to get a legal <src>double</src>, while
85// <src>asFloat</src> will use a single integer. These members are used by
86// classes derived fro the <src>Random</src> base class to implement a variety
87// of random number distributions.
88//
89// Currently, the following subclasses are provided:
90// <ul>
91// <li> <linkto class=MLCG>MLCG</linkto>:
92// Multiplicative Linear Congruential Generator.
93// A reasonable generator for most purposes.
94// <li> <linkto class=ACG>ACG</linkto>: Additive Number Generator.
95// A high quality generator that uses more memory and computation time.
96// </ul>
97//
98// <note role=warning> This class assumes that IEEE floating point
99// representation is used for the floating point numbers and that the integer
100// and unsigned integer type is exactly 32 bits long.
101// </note>
102// </synopsis>
103//
104// <example>
105// </example>
106//
107// <motivation>
108// Random numbers are used everywhere, particularly in simulations.
109// </motivation>
110//
111// <thrown>
112// <li> AipsError: If a programming error or unexpected numeric size is
113// detected. Should not occur in normal usage.
114// </thrown>
115//
116// <todo asof="2000/05/09">
117// <li> Nothing I hope!
118// </todo>
119
120class RNG {
121 public:
122 // A virtual destructor is needed to ensure that the destructor of derived
123 // classes gets used.
124 virtual ~RNG();
125
126 // Resets the random number generator. After calling this function the random
127 // numbers generated will be the same as if the object had just been
128 // constructed.
129 virtual void reset() = 0;
130
131 // Return the 32-random bits as an unsigned integer
132 virtual uInt asuInt() = 0;
133
134 // Return random bits converted to either a Float or a Double. The returned
135 // value x is in the range 1.0 > x >= 0.0
136 // <group>
139 // </group>
140};
141
142// <summary>Additive number generator</summary>
143//
144// <use visibility=export>
145// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
146// </reviewed>
147//
148// <prerequisite>
149// <li> A knowledge of C++, in particular inheritance
150// <li> College level mathematics
151// </prerequisite>
152//
153// <etymology>
154// ACG stands for "Additive Congruential Generator"
155// </etymology>
156//
157// <synopsis>
158// This class implements the additive number generator as presented in Volume
159// II of The Art of Computer Programming by Knuth. I have coded the algorithm
160// and have added the extensions by Andres Nowatzyk of CMU to randomize the
161// result of algorithm M a bit by using an LCG & a spatial permutation table.
162//
163// The version presented uses the same constants for the LCG that Andres uses
164// (chosen by trial & error). The spatial permutation table is the same size
165// (it is based on word size). This is for 32-bit words.
166//
167// The <src>auxillary table</src> used by the LCG table varies in size, and is
168// chosen to be the the smallest power of two which is larger than twice the
169// size of the state table.
170//
171// Class <src>ACG</src> is a variant of a Linear Congruential Generator
172// (Algorithm M) described in Knuth, "Art of Computer Programming, Vol III".
173// This result is permuted with a Fibonacci Additive Congruential Generator to
174// get good independence between samples. This is a very high quality random
175// number generator, although it requires a fair amount of memory for each
176// instance of the generator.
177//
178// The constructor takes two parameters: the seed and the size. The seed can
179// be any number. The performance of the generator depends on having a
180// distribution of bits through the seed. If you choose a number in the range
181// of 0 to 31, a seed with more bits is chosen. Other values are
182// deterministically modified to give a better distribution of bits. This
183// provides a good random number generator while still allowing a sequence to
184// be repeated given the same initial seed.
185//
186// The <src>size</src> parameter determines the size of two tables used in the
187// generator. The first table is used in the Additive Generator; see the
188// algorithm in Knuth for more information. In general, this table contains
189// <src>size</src> integers. The default value, used in the algorithm in Knuth,
190// gives a table of 55 integers (220 bytes). The table size affects the period
191// of the generators; smaller values give shorter periods and larger tables
192// give longer periods. The smallest table size is 7 integers, and the longest
193// is 98. The <src>size</src> parameter also determines the size of the table
194// used for the Linear Congruential Generator. This value is chosen implicitly
195// based on the size of the Additive Congruential Generator table. It is two
196// powers of two larger than the power of two that is larger than
197// <src>size</src>. For example, if <src>size</src> is 7, the ACG table
198// contains 7 integers and the LCG table contains 128 integers. Thus, the
199// default size (55) requires 55 + 256 integers, or 1244 bytes. The largest
200// table requires 2440 bytes and the smallest table requires 100 bytes.
201// Applications that require a large number of generators or applications that
202// are not so fussy about the quality of the generator may elect to use the
203// <src>MLCG</src> generator.
204//
205// <note role=warning> This class assumes that the integer and unsigned integer
206// type is exactly 32 bits long.
207// </note>
208// </synopsis>
209//
210// <example>
211// </example>
212//
213// <thrown>
214// <li> AipsError: If a programming error or unexpected numeric size is
215// detected. Should not occur in normal usage.
216// </thrown>
217//
218// <todo asof="2000/05/09">
219// <li> Nothing I hope!
220// </todo>
221
222class ACG : public RNG {
223 public:
224 // The constructor allows you to specify seeds. The seed should be a big
225 // random number and size must be between 7 and 98. See the synopsis for more
226 // details.
227 explicit ACG(uInt seed = 0, Int size = 55);
228
229 // The destructor cleans up memory allocated by this class
230 virtual ~ACG();
231
232 // Resets the random number generator. After calling this function the random
233 // numbers generated will be the same as if the object had just been
234 // constructed.
235 virtual void reset();
236
237 // Return the 32-random bits as an unsigned integer
238 virtual uInt asuInt();
239
240 private:
241 uInt itsInitSeed; // # used to reset the generator
243
251};
252
253// <summary> Multiplicative linear congruential generator </summary>
254
255// <use visibility=export>
256// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
257// </reviewed>
258//
259// <prerequisite>
260// <li> A knowledge of C++, in particular inheritance
261// <li> College level mathematics
262// </prerequisite>
263//
264// <etymology>
265// MLCG stands for "Multiplicative Linear Congruential Generator"
266// </etymology>
267//
268
269// <synopsis>
270// The <src>MLCG</src> class implements a <em>Multiplicative Linear
271// Congruential Generator</em>. In particular, it is an implementation of the
272// double MLCG described in <em>Efficient and Portable Combined Random Number
273// Generators</em> by Pierre L'Ecuyer, appearing in <em>Communications of the
274// ACM, Vol. 31. No. 6</em>. This generator has a fairly long period, and has
275// been statistically analyzed to show that it gives good inter-sample
276// independence.
277//
278
279// The constructor has two parameters, both of which are seeds for the
280// generator. As in the <src>ACG</src> generator, both seeds are modified to
281// give a "better" distribution of seed digits. Thus, you can safely use values
282// such as <src>0</src> or <src>1</src> for the seeds. The <src>MLCG</src>
283// generator used much less state than the <src>ACG</src> generator; only two
284// integers (8 bytes) are needed for each generator.
285
286// <note role=warning> This class assumes that the integer and unsigned integer
287// type is exactly 32 bits long.
288// </note>
289// </synopsis>
290
291// <example>
292// </example>
293//
294// <thrown>
295// <li> AipsError: If a programming error or unexpected numeric size is
296// detected. Should not occur in normal usage.
297// </thrown>
298//
299// <todo asof="2000/05/09">
300// <li> Nothing I hope!
301// </todo>
302
303class MLCG : public RNG {
304 public:
305 // The constructor allows you to specify seeds.
306 explicit MLCG(Int seed1 = 0, Int seed2 = 1);
307
308 // The destructor is trivial
309 virtual ~MLCG();
310
311 // Return the 32-random bits as an unsigned integer
312 virtual uInt asuInt();
313
314 // Resets the random number generator. After calling this function the random
315 // numbers generated will be the same as if the object had just been
316 // constructed.
317 virtual void reset();
318
319 // Functions that allow the user to retrieve or change the seed integers. The
320 // seeds returned are not the user supplied values but the values obtained
321 // after some deterministic modification to produce a more uniform bit
322 // distribution.
323 // <group>
324 Int seed1() const;
325 void seed1(Int s);
326 Int seed2() const;
327 void seed2(Int s);
328 void reseed(Int s1, Int s2);
329 // </group>
330
331 private:
336};
337
338inline Int MLCG::seed1() const { return itsSeedOne; }
339
340inline void MLCG::seed1(Int s) {
341 itsInitSeedOne = s;
342 reset();
343}
344
345inline Int MLCG::seed2() const { return itsSeedTwo; }
346
347inline void MLCG::seed2(Int s) {
348 itsInitSeedTwo = s;
349 reset();
350}
351
352inline void MLCG::reseed(Int s1, Int s2) {
353 itsInitSeedOne = s1;
354 itsInitSeedTwo = s2;
355 reset();
356}
357
358// <summary>Base class for random number distributions</summary>
359
360// <use visibility=export>
361// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
362// </reviewed>
363//
364// <prerequisite>
365// <li> A knowledge of C++, in particular inheritance
366// <li> College level mathematics
367// </prerequisite>
368//
369// <synopsis>
370// A random number generator may be declared by first constructing a
371// <src>RNG</src> object and then a <src>Random</src>. For example,
372// <srcblock>
373// ACG gen(10, 20);
374// NegativeExpntl rnd (1.0, &gen);
375// </srcblock>
376// declares an additive congruential generator with seed 10 and table size 20,
377// that is used to generate exponentially distributed values with mean of 1.0.
378//
379// The virtual member <src>Random::operator()</src> is the common way of
380// extracting a random number from a particular distribution. The base class,
381// <src>Random</src> does not implement <src>operator()</src>. This is
382// performed by each of the derived classes. Thus, given the above declaration
383// of <src>rnd</src>, new random values may be obtained via, for example,
384// <src>Double nextExpRand = rnd();</src>
385//
386// Currently, the following subclasses are provided:
387//
388// <ul>
389// <li> <linkto class=Binomial>Binomial</linkto>
390// <li> <linkto class=Erlang>Erlang</linkto>
391// <li> <linkto class=Geometric>Geometric</linkto>
392// <li> <linkto class=HyperGeometric>HyperGeometric</linkto>
393// <li> <linkto class=NegativeExpntl>NegativeExpntl</linkto>
394// <li> <linkto class=Normal>Normal</linkto>
395// <li> <linkto class=LogNormal>LogNormal</linkto>
396// <li> <linkto class=Poisson>Poisson</linkto>
397// <li> <linkto class=DiscreteUniform>DiscreteUniform</linkto>
398// <li> <linkto class=Uniform>Uniform</linkto>
399// <li> <linkto class=Weibull>Weibull</linkto>
400// </ul>
401// </synopsis>
402//
403// <example>
404// </example>
405//
406// <thrown>
407// <li> No exceptions are thrown directly from this class.
408// </thrown>
409//
410// <todo asof="2000/05/09">
411// <li> Nothing I hope!
412// </todo>
413
414class Random {
415 public:
416 // This enumerator lists all the predefined random number distributions.
417 enum Types {
418 // 2 parameters. The binomial distribution models successfully drawing
419 // items from a pool. Specify n and p. n is the number of items in the
420 // pool, and p, is the probability of each item being successfully drawn.
421 // It is required that n > 0 and 0 <= p <= 1
423
424 // 2 parameters. Model a uniform random variable over the closed
425 // interval. Specify the values low and high. The low parameter is the
426 // lowest possible return value and the high parameter is the highest. It
427 // is required that low < high.
429
430 // 2 parameters, mean and variance. It is required that the mean is
431 // non-zero and the variance is positive.
433
434 // 1 parameters, the mean. It is required that 0 <= probability < 1
436
437 // 2 parameters, mean and variance. It is required that the variance is
438 // positive and that the mean is non-zero and not bigger than the
439 // square-root of the variance.
441
442 // 2 parameters, the mean and variance. It is required that the variance is
443 // positive.
445
446 // 2 parameters, mean and variance. It is required that the supplied
447 // variance is positive and that the mean is non-zero
449
450 // 1 parameter, the mean.
452
453 // 1 parameter, the mean. It is required that the mean is non-negative
455
456 // 2 parameters, low and high. Model a uniform random variable over the
457 // closed interval. The low parameter is the lowest possible return value
458 // and the high parameter can never be returned. It is required that low <
459 // high.
461
462 // 2 parameters, alpha and beta. It is required that the alpha parameter is
463 // not zero.
465
466 // An non-predefined random number distribution
468
469 // Number of distributions
471 };
472
473 // A virtual destructor is needed to ensure that the destructor of derived
474 // classes gets used. Not that this destructor does NOT delete the pointer to
475 // the RNG object
476 virtual ~Random();
477
478 // This function returns a random number from the appropriate distribution.
479 virtual Double operator()() = 0;
480
481 // Functions that allow you to access and change the class that generates the
482 // random bits.
483 // <group>
484 RNG* generator();
485 void generator(RNG* p);
486 // </group>
487
488 // Convert the enumerator to a lower-case string.
490
491 // Convert the string to enumerator. The parsing of the string is case
492 // insensitive. Returns the Random::UNKNOWN value if the string does not
493 // cotrtrespond to any of the enumerators.
494 static Random::Types asType(const String& str);
495
496 // Convert the Random::Type enumerator to a specific object (derived from
497 // Random but upcast to a Random object). Returns a null pointer if the
498 // object could not be constructed. This will occur is the enumerator is
499 // UNKNOWN or NUMBER_TYPES or there is insufficient memory. The caller of
500 // this function is responsible for deleting the pointer.
502
503 // These function allow you to manipulate the parameters (mean variance etc.)
504 // of random number distribution. The parameters() function returns the
505 // current value, the setParameters function allows you to change the
506 // parameters and the checkParameters function will return False if the
507 // supplied parameters are not appropriate for the distribution.
508 // <group>
509 virtual void setParameters(const Vector<Double>& parms) = 0;
510 virtual Vector<Double> parameters() const = 0;
511 virtual Bool checkParameters(const Vector<Double>& parms) const = 0;
512 // </group>
513
514 // returns the default parameters for the specified distribution. Returns an
515 // empty Vector if a non-predifined distribution is used.
517
518 protected:
519 // # This class contains pure virtual functions hence the constructor can only
520 // # sensibly be used by derived classes.
522
523 // # The RNG class provides the random bits.
525};
526
527inline Random::Random(RNG* gen) { itsRNG = gen; }
528
529inline RNG* Random::generator() { return itsRNG; }
530
531inline void Random::generator(RNG* p) { itsRNG = p; }
532
533// <summary> Binomial distribution </summary>
534
535// <synopsis>
536// The binomial distribution models successfully drawing items from a pool.
537// <src>n</src> is the number of items in the pool, and <src>p</src>, is the
538// probability of each item being successfully drawn. The
539// <src>operator()</src> functions returns an integral value indicating the
540// number of items actually drawn from the pool. It is possible to get this
541// same value as an integer using the asInt function.
542
543// It is assumed that <src>n > 0</src> and <src>0 <= p <= 1</src> an AipsError
544// exception thrown if it is not true. The remaining members allow you to read
545// and set the parameters.
546// </synopsis>
547
548// <example>
549// </example>
550//
551// <thrown>
552// <li> AipsError: if bad values for the arguments are given, as specified
553// above.
554// </thrown>
555//
556// <todo asof="2000/05/09">
557// <li> Nothing I hope!
558// </todo>
559
560class Binomial : public Random {
561 public:
562 // Construct a random number generator for a binomial distribution. The first
563 // argument is a class that produces random bits. This pointer is NOT taken
564 // over by this class and the user is responsible for deleting it. The second
565 // and third arguments are the parameters are the Binomial distribution as
566 // described in the synopsis.
567 Binomial(RNG* gen, uInt n = 1, Double p = 0.5);
568
569 // The destructor is trivial
570 virtual ~Binomial();
571
572 // Returns a value from the Binomial distribution. The returned value is a
573 // non-negative integer and using the asInt function bypasses the conversion
574 // to a floating point number.
575 // <group>
578 // </group>
579
580 // Functions that allow you to query and change the parameters of the
581 // binomial distribution.
582 // <group>
583 uInt n() const;
584 void n(uInt newN);
585 void n(Double newN);
586 Double p() const;
587 void p(Double newP);
588 // </group>
589
590 // These function allow you to manipulate the parameters (n & p) described
591 // above through the base class. The Vectors must always be of length two.
592 // <group>
593 virtual void setParameters(const Vector<Double>& parms);
594 virtual Vector<Double> parameters() const;
595 virtual Bool checkParameters(const Vector<Double>& parms) const;
596 // </group>
597
598 private:
601};
602
603inline uInt Binomial::n() const { return itsN; }
604
605inline Double Binomial::p() const { return itsP; }
606
607// <summary>Discrete uniform distribution</summary>
608
609// <synopsis>
610
611// The <src>DiscreteUniform</src> class implements a quantized uniform random
612// variable over the closed interval ranging from <src>[low..high]</src>. The
613// <src>low</src> parameter is the lowest possible return value and the
614// <src>high</src> parameter is the highest. The <src>operator()</src>
615// functions returns a value from this distribution. It is possible to get this
616// same value as an integer using the asInt function.
617
618// It is assumed that low limit is less than the high limit and an AipsError
619// exception thrown if this is not true. The remaining members allow you to
620// read and set the parameters.
621
622// </synopsis>
623
624// <example>
625// </example>
626//
627// <thrown>
628// <li> AipsError: if bad values for the arguments are given, as specified
629// above.
630// </thrown>
631//
632// <todo asof="2000/05/09">
633// <li> Nothing I hope!
634// </todo>
635
636class DiscreteUniform : public Random {
637 public:
638 // Construct a random number generator for a discrete uniform
639 // distribution. The first argument is a class that produces random
640 // bits. This pointer is NOT taken over by this class and the user is
641 // responsible for deleting it. The second and third arguments define the
642 // range of possible return values for this distribution as described in the
643 // synopsis.
644 DiscreteUniform(RNG* gen, Int low = -1, Int high = 1);
645
646 // The destructor is trivial
648
649 // Returns a value from the discrete uniform distribution. The returned
650 // value is a integer and using the asInt function bypasses the conversion to
651 // a floating point number.
652 // <group>
655 // </group>
656
657 // Functions that allow you to query and change the parameters of the
658 // discrete uniform distribution.
659 // <group>
660 Int low() const;
661 void low(Int x);
662 Int high() const;
663 void high(Int x);
665 // </group>
666
667 // These function allow you to manipulate the parameters (low & high)
668 // described above through the base class. The Vectors must always be of
669 // length two.
670 // <group>
671 virtual void setParameters(const Vector<Double>& parms);
672 virtual Vector<Double> parameters() const;
673 virtual Bool checkParameters(const Vector<Double>& parms) const;
674 // </group>
675
676 private:
681};
682
683inline Int DiscreteUniform::low() const { return itsLow; }
684
685inline Int DiscreteUniform::high() const { return itsHigh; }
686
687// <summary>Erlang distribution</summary>
688
689// <synopsis>
690// The <src>Erlang</src> class implements an Erlang distribution with mean
691// <src>mean</src> and variance <src>variance</src>.
692
693// It is assumed that the mean is non-zero and the variance is positive an
694// AipsError exception thrown if this is not true. The remaining members allow
695// you to read and set the parameters.
696// </synopsis>
697
698// <example>
699// </example>
700//
701// <thrown>
702// <li> AipsError: if bad values for the arguments are given, as specified
703// above.
704// </thrown>
705//
706// <todo asof="2000/05/09">
707// <li> Nothing I hope!
708// </todo>
709
710class Erlang : public Random {
711 public:
712 // Construct a random number generator for an Erlang distribution. The first
713 // argument is a class that produces random bits. This pointer is NOT taken
714 // over by this class and the user is responsible for deleting it. The second
715 // and third arguments define the parameters for this distribution as
716 // described in the synopsis.
717 Erlang(RNG* gen, Double mean = 1.0, Double variance = 1.0);
718
719 // The destructor is trivial
720 virtual ~Erlang();
721
722 // Returns a value from the Erlang distribution.
724
725 // Functions that allow you to query and change the parameters of the
726 // discrete uniform distribution.
727 // <group>
728 Double mean() const;
729 void mean(Double x);
730 Double variance() const;
731 void variance(Double x);
732 // </group>
733
734 // These function allow you to manipulate the parameters (mean & variance)
735 // described above through the base class. The Vectors must always be of
736 // length two.
737 // <group>
738 virtual void setParameters(const Vector<Double>& parms);
739 virtual Vector<Double> parameters() const;
740 virtual Bool checkParameters(const Vector<Double>& parms) const;
741 // </group>
742
743 private:
744 void setState();
749};
750
755
756inline Double Erlang::mean() const { return itsMean; }
757
758inline void Erlang::mean(Double x) {
759 itsMean = x;
760 setState();
761}
762
763inline Double Erlang::variance() const { return itsVariance; }
764
765inline void Erlang::variance(Double x) {
766 itsVariance = x;
767 setState();
768}
769
770// <summary> Discrete geometric distribution </summary>
771
772// <synopsis>
773// The <src>Geometric</src> class implements a discrete geometric distribution.
774// The <src>probability</src> is the only parameter. The <src>operator()</src>
775// functions returns an non-negative integral value indicating the number of
776// uniform random samples actually drawn before one is obtained that is larger
777// than the given probability. To get this same value as an integer use the
778// asInt function.
779//
780// It is assumed that the probability is between zero and one
781// <src>(0 <= probability < 1)</src> and and AipsError exception thrown if this
782// is not true. The remaining function allow you to read and set the
783// parameters.
784// </synopsis>
785
786// <example>
787// </example>
788//
789// <thrown>
790// <li> AipsError: if bad values for the arguments are given, as specified
791// above.
792// </thrown>
793//
794// <todo asof="2000/05/09">
795// <li> Nothing I hope!
796// </todo>
797
798class Geometric : public Random {
799 public:
800 // Construct a random number generator for a geometric uniform
801 // distribution. The first argument is a class that produces random
802 // bits. This pointer is NOT taken over by this class and the user is
803 // responsible for deleting it. The second argument defines the range of
804 // possible return values for this distribution as described in the synopsis.
806
807 // The destructor is trivial
808 virtual ~Geometric();
809
810 // Returns a value from the geometric uniform distribution. The returned
811 // value is a non-negative integer and using the asInt function bypasses the
812 // conversion to a floating point number.
813 // <group>
816 // </group>
817
818 // Functions that allow you to query and change the parameters of the
819 // geometric uniform distribution.
820 // <group>
821 Double probability() const;
823 // </group>
824
825 // These function allow you to manipulate the parameter (probability)
826 // described above through the base class. The Vectors must always be of
827 // length one.
828 // <group>
829 virtual void setParameters(const Vector<Double>& parms);
830 virtual Vector<Double> parameters() const;
831 virtual Bool checkParameters(const Vector<Double>& parms) const;
832 // </group>
833
834 private:
836};
837
839
840// <summary> Hypergeometric distribution </summary>
841
842// <synopsis>
843// The <src>HyperGeometric</src> class implements the hypergeometric
844// distribution. The <src>mean</src> and <src>variance</src> are the
845// parameters of the distribution. The <src>operator()</src> functions returns
846// a value from this distribution
847
848// It is assumed the variance is positive and that the mean is non-zero and not
849// bigger than the square-root of the variance. An AipsError exception is
850// thrown if this is not true. The remaining members allow you to read and set
851// the parameters.
852// </synopsis>
853
854// <example>
855// </example>
856//
857// <thrown>
858// <li> AipsError: if bad values for the arguments are given, as specified
859// above.
860// </thrown>
861//
862// <todo asof="2000/05/09">
863// <li> Nothing I hope!
864// </todo>
865
866class HyperGeometric : public Random {
867 public:
868 // Construct a random number generator for an hypergeometric
869 // distribution. The first argument is a class that produces random
870 // bits. This pointer is NOT taken over by this class and the user is
871 // responsible for deleting it. The second and third arguments define the
872 // parameters for this distribution as described in the synopsis.
873 HyperGeometric(RNG* gen, Double mean = 0.5, Double variance = 1.0);
874
875 // The destructor is trivial
877
878 // Returns a value from the hypergeometric distribution.
880
881 // Functions that allow you to query and change the parameters of the
882 // hypergeometric distribution.
883 // <group>
884 Double mean() const;
885 void mean(Double x);
886 Double variance() const;
887 void variance(Double x);
888 // </group>
889
890 // These function allow you to manipulate the parameters (mean & variance)
891 // described above through the base class. The Vectors must always be of
892 // length two.
893 // <group>
894 virtual void setParameters(const Vector<Double>& parms);
895 virtual Vector<Double> parameters() const;
896 virtual Bool checkParameters(const Vector<Double>& parms) const;
897 // </group>
898
899 private:
900 void setState();
904};
905
910
911inline Double HyperGeometric::mean() const { return itsMean; }
912
914 itsMean = x;
915 setState();
916}
917
919
921 itsVariance = x;
922 setState();
923}
924
925// <summary>Normal or Gaussian distribution </summary>
926
927// <synopsis>
928// The <src>Normal</src> class implements the normal or Gaussian distribution.
929// The <src>mean</src> and <src>variance</src> are the parameters of the
930// distribution. The <src>operator()</src> functions returns a value from this
931// distribution
932
933// It is assumed that the supplied variance is positive and an AipsError
934// exception is thrown if this is not true. The remaining members allow you to
935// read and set the parameters. The <src>LogNormal</src> class is derived from
936// this one.
937// </synopsis>
938
939// <example>
940// </example>
941//
942// <thrown>
943// <li> AipsError: if bad values for the arguments are given, as specified
944// above.
945// </thrown>
946//
947// <todo asof="2000/05/09">
948// <li> Nothing I hope!
949// </todo>
950
951class Normal : public Random {
952 public:
953 // Construct a random number generator for a normal distribution. The first
954 // argument is a class that produces random bits. This pointer is NOT taken
955 // over by this class and the user is responsible for deleting it. The second
956 // and third arguments define the parameters for this distribution as
957 // described in the synopsis.
958 Normal(RNG* gen, Double mean = 0.0, Double variance = 1.0);
959
960 // The destructor is trivial
961 virtual ~Normal();
962
963 // Returns a value from the normal distribution.
965
966 // Functions that allow you to query and change the parameters of the
967 // normal distribution.
968 // <group>
969 virtual Double mean() const;
970 virtual void mean(Double x);
971 virtual Double variance() const;
972 virtual void variance(Double x);
973 // </group>
974
975 // These function allow you to manipulate the parameters (mean & variance)
976 // described above through the base class. The Vectors must always be of
977 // length two.
978 // <group>
979 virtual void setParameters(const Vector<Double>& parms);
980 virtual Vector<Double> parameters() const;
981 virtual Bool checkParameters(const Vector<Double>& parms) const;
982 // </group>
983
984 private:
990};
991
992inline Double Normal::mean() const { return itsMean; }
993
994inline Double Normal::variance() const { return itsVariance; }
995
996// <summary> Logarithmic normal distribution </summary>
997
998// <synopsis>
999// The <src>LogNormal</src> class implements the logaraithmic normal
1000// distribution. The <src>mean</src> and <src>variance</src> are the
1001// parameters of the distribution. The <src>operator()</src> functions returns
1002// a value from this distribution
1003
1004// It is assumed that the supplied variance is positive and an AipsError
1005// exception is thrown if this is not true. The remaining members allow you to
1006// read and set the parameters.
1007// </synopsis>
1008
1009// <example>
1010// </example>
1011//
1012// <thrown>
1013// <li> AipsError: if bad values for the arguments are given, as specified
1014// above.
1015// </thrown>
1016//
1017// <todo asof="2000/05/09">
1018// <li> Nothing I hope!
1019// </todo>
1020
1021class LogNormal : public Normal {
1022 public:
1023 // Construct a random number generator for a log-normal distribution. The
1024 // first argument is a class that produces random bits. This pointer is NOT
1025 // taken over by this class and the user is responsible for deleting it. The
1026 // second and third arguments define the parameters for this distribution as
1027 // described in the synopsis.
1029
1030 // The destructor is trivial
1031 virtual ~LogNormal();
1032
1033 // Returns a value from the log-normal distribution.
1035
1036 // Functions that allow you to query and change the parameters of the
1037 // log-normal distribution.
1038 // <group>
1039 virtual Double mean() const;
1040 virtual void mean(Double x);
1041 virtual Double variance() const;
1042 virtual void variance(Double x);
1043 // </group>
1044
1045 // These function allow you to manipulate the parameters (mean & variance)
1046 // described above through the base class. The Vectors must always be of
1047 // length two.
1048 // <group>
1049 virtual void setParameters(const Vector<Double>& parms);
1051 virtual Bool checkParameters(const Vector<Double>& parms) const;
1052 // </group>
1053
1054 private:
1055 void setState();
1058};
1059
1060inline Double LogNormal::mean() const { return itsLogMean; }
1061
1062inline Double LogNormal::variance() const { return itsLogVar; }
1063
1064// <summary>Negative exponential distribution</summary>
1065
1066// <synopsis>
1067// The <src>NegativeExpntl</src> class implements a negative exponential
1068// distribution. The <src>mean</src> parameter, is the only parameter of this
1069// distribution. The <src>operator()</src> functions returns a value from this
1070// distribution. The remaining members allow you to inspect and change the
1071// mean.
1072// </synopsis>
1073
1074// <example>
1075// </example>
1076//
1077// <thrown>
1078// <li> No exceptions are thrown by this class.
1079// </thrown>
1080//
1081// <todo asof="2000/05/09">
1082// <li> Nothing I hope!
1083// </todo>
1084
1085class NegativeExpntl : public Random {
1086 public:
1087 // Construct a random number generator for a negative exponential
1088 // distribution. The first argument is a class that produces random
1089 // bits. This pointer is NOT taken over by this class and the user is
1090 // responsible for deleting it. The second argument defines the parameters
1091 // for this distribution as described in the synopsis.
1093
1094 // The destructor is trivial
1096
1097 // Returns a value from the negative exponential distribution.
1099
1100 // Functions that allow you to query and change the parameters of the
1101 // negative exponential distribution.
1102 // <group>
1103 Double mean() const;
1104 void mean(Double x);
1105 // </group>
1106
1107 // These function allow you to manipulate the parameters (mean)
1108 // described above through the base class. The Vectors must always be of
1109 // length one.
1110 // <group>
1111 virtual void setParameters(const Vector<Double>& parms);
1113 virtual Bool checkParameters(const Vector<Double>& parms) const;
1114 // </group>
1115
1116 private:
1118};
1119
1120inline Double NegativeExpntl::mean() const { return itsMean; }
1121
1122// <summary> Poisson distribution </summary>
1123// <synopsis>
1124// The <src>Poisson</src> class implements a Poisson distribution. The
1125// <src>mean</src> parameter, is the only parameter of this distribution. The
1126// <src>operator()</src> functions returns a value from this distribution. The
1127// remaining members allow you to inspect and change the mean.
1128
1129// It is assumed that the supplied mean is non-negative and an AipsError
1130// exception is thrown if this is not true. The remaining members allow you to
1131// read and set the parameters.
1132// </synopsis>
1133
1134// <example>
1135// </example>
1136//
1137// <thrown>
1138// <li> No exceptions are thrown by this class.
1139// </thrown>
1140//
1141// <todo asof="2000/05/09">
1142// <li> Nothing I hope!
1143// </todo>
1144
1145class Poisson : public Random {
1146 public:
1147 // Construct a random number generator for a Poisson distribution. The first
1148 // argument is a class that produces random bits. This pointer is NOT taken
1149 // over by this class and the user is responsible for deleting it. The second
1150 // argument defines the parameters for this distribution as described in the
1151 // synopsis.
1152 Poisson(RNG* gen, Double mean = 0.0);
1153
1154 // The destructor is trivial
1155 virtual ~Poisson();
1156
1157 // Returns a value from the Poisson distribution. The returned value is a
1158 // non-negative integer and using the asInt function bypasses the conversion
1159 // to a floating point number.
1160 // <group>
1163 // </group>
1164
1165 // Functions that allow you to query and change the parameters of the
1166 // Poisson distribution.
1167 // <group>
1168 Double mean() const;
1169 void mean(Double x);
1170 // </group>
1171
1172 // These function allow you to manipulate the parameters (mean)
1173 // described above through the base class. The Vectors must always be of
1174 // length one.
1175 // <group>
1176 virtual void setParameters(const Vector<Double>& parms);
1178 virtual Bool checkParameters(const Vector<Double>& parms) const;
1179 // </group>
1180
1181 private:
1183};
1184
1185inline Double Poisson::mean() const { return itsMean; }
1186
1187// <summary>Uniform distribution</summary>
1188
1189// <synopsis>
1190// The <src>Uniform</src> class implements a uniform random variable over the
1191// copen interval ranging from <src>[low..high)</src>. The <src>low</src>
1192// parameter is the lowest possible return value and the <src>high</src>
1193// parameter can never be returned. The <src>operator()</src> functions
1194// returns a value from this distribution.
1195
1196// It is assumed that low limit is less than the high limit and an AipsError
1197// exception is thrown if this is not true. The remaining members allow you to
1198// read and set the parameters.
1199
1200// </synopsis>
1201
1202// <example>
1203// </example>
1204//
1205// <thrown>
1206// <li> AipsError: if bad values for the arguments are given, as specified
1207// above.
1208// </thrown>
1209//
1210// <todo asof="2000/05/09">
1211// <li> Nothing I hope!
1212// </todo>
1213
1214class Uniform : public Random {
1215 public:
1216 // Construct a random number generator for a uniform distribution. The first
1217 // argument is a class that produces random bits. This pointer is NOT taken
1218 // over by this class and the user is responsible for deleting it. The
1219 // remaining arguments define the parameters for this distribution as
1220 // described in the synopsis.
1221 Uniform(RNG* gen, Double low = -1.0, Double high = 1.0);
1222
1223 // The destructor is trivial
1224 virtual ~Uniform();
1225
1226 // Returns a value from the uniform distribution.
1228
1229 // Functions that allow you to query and change the parameters of the
1230 // uniform distribution.
1231 // <group>
1232 Double low() const;
1233 void low(Double x);
1234 Double high() const;
1235 void high(Double x);
1237 // </group>
1238
1239 // These function allow you to manipulate the parameters (low & high)
1240 // described above through the base class. The Vectors must always be of
1241 // length two.
1242 // <group>
1243 virtual void setParameters(const Vector<Double>& parms);
1245 virtual Bool checkParameters(const Vector<Double>& parms) const;
1246 // </group>
1247
1248 private:
1253};
1254
1255inline Double Uniform::low() const { return itsLow; }
1256
1257inline Double Uniform::high() const { return itsHigh; }
1258
1259// <summary>Weibull distribution</summary>
1260
1261// <synopsis>
1262
1263// The <src>Weibull</src> class implements a weibull distribution with
1264// parameters <src>alpha</src> and <src>beta</src>. The first parameter to the
1265// class constructor is <src>alpha</src>, and the second parameter is
1266// <src>beta</src>. It is assumed that the alpha parameter is not zero and an
1267// AipsError exception is thrown if this is not true. The remaining members
1268// allow you to read and set the parameters.
1269// </synopsis>
1270
1271// <example>
1272// </example>
1273//
1274// <thrown>
1275// <li> AipsError: if bad values for the arguments are given, as specified
1276// above.
1277// </thrown>
1278//
1279// <todo asof="2000/05/09">
1280// <li> Nothing I hope!
1281// </todo>
1282
1283class Weibull : public Random {
1284 public:
1285 // Construct a random number generator for a uniform distribution. The first
1286 // argument is a class that produces random bits. This pointer is NOT taken
1287 // over by this class and the user is responsible for deleting it. The
1288 // remaining arguments define the parameters for this distribution as
1289 // described in the synopsis.
1290 Weibull(RNG* gen, Double alpha = 1.0, Double beta = 1.0);
1291
1292 // The destructor is trivial
1293 virtual ~Weibull();
1294
1295 // Returns a value from the Weiball distribution.
1297
1298 // Functions that allow you to query and change the parameters of the
1299 // Weiball distribution.
1300 // <group>
1301 Double alpha() const;
1302 void alpha(Double x);
1303 Double beta() const;
1304 void beta(Double x);
1305 // </group>
1306
1307 // These function allow you to manipulate the parameters (alpha & beta)
1308 // described above through the base class. The Vectors must always be of
1309 // length two.
1310 // <group>
1311 virtual void setParameters(const Vector<Double>& parms);
1313 virtual Bool checkParameters(const Vector<Double>& parms) const;
1314 // </group>
1315
1316 private:
1317 void setState();
1321};
1322
1323inline Double Weibull::alpha() const { return itsAlpha; }
1324
1325inline Double Weibull::beta() const { return itsBeta; }
1326
1327} // namespace casacore
1328
1329#endif
virtual ~ACG()
The destructor cleans up memory allocated by this class.
uInt lcgRecurr
Definition Random.h:248
Short itsStateSize
Definition Random.h:246
Short itsJ
Definition Random.h:249
virtual void reset()
Resets the random number generator.
uInt * itsAuxStatePtr
Definition Random.h:245
uInt * itsStatePtr
Definition Random.h:244
ACG(uInt seed=0, Int size=55)
The constructor allows you to specify seeds.
virtual uInt asuInt()
Return the 32-random bits as an unsigned integer.
Int itsInitTblEntry
Definition Random.h:242
Short itsAuxSize
Definition Random.h:247
uInt itsInitSeed
Definition Random.h:241
Short itsK
Definition Random.h:250
virtual Double operator()()
Returns a value from the Binomial distribution.
Binomial(RNG *gen, uInt n=1, Double p=0.5)
Construct a random number generator for a binomial distribution.
virtual Bool checkParameters(const Vector< Double > &parms) const
Double p() const
Definition Random.h:605
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (n & p) described above through the base class.
void n(Double newN)
void p(Double newP)
virtual ~Binomial()
The destructor is trivial.
uInt n() const
Functions that allow you to query and change the parameters of the binomial distribution.
Definition Random.h:603
virtual Vector< Double > parameters() const
void n(uInt newN)
virtual Vector< Double > parameters() const
virtual Bool checkParameters(const Vector< Double > &parms) const
Int low() const
Functions that allow you to query and change the parameters of the discrete uniform distribution.
Definition Random.h:683
virtual Double operator()()
Returns a value from the discrete uniform distribution.
void range(Int low, Int high)
DiscreteUniform(RNG *gen, Int low=-1, Int high=1)
Construct a random number generator for a discrete uniform distribution.
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (low & high) described above through the base c...
virtual ~DiscreteUniform()
The destructor is trivial.
static Double calcDelta(Int low, Int high)
virtual Double operator()()
Returns a value from the Erlang distribution.
Double variance() const
Definition Random.h:763
virtual Bool checkParameters(const Vector< Double > &parms) const
Double itsVariance
Definition Random.h:746
Erlang(RNG *gen, Double mean=1.0, Double variance=1.0)
Construct a random number generator for an Erlang distribution.
Definition Random.h:751
Double mean() const
Functions that allow you to query and change the parameters of the discrete uniform distribution.
Definition Random.h:756
Double itsMean
Definition Random.h:745
virtual ~Erlang()
The destructor is trivial.
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (mean & variance) described above through the b...
virtual Vector< Double > parameters() const
virtual Vector< Double > parameters() const
virtual Bool checkParameters(const Vector< Double > &parms) const
Geometric(RNG *gen, Double probability=0.5)
Construct a random number generator for a geometric uniform distribution.
void probability(Double x)
Double probability() const
Functions that allow you to query and change the parameters of the geometric uniform distribution.
Definition Random.h:838
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameter (probability) described above through the base c...
virtual ~Geometric()
The destructor is trivial.
Double itsProbability
Definition Random.h:835
virtual Double operator()()
Returns a value from the geometric uniform distribution.
Double mean() const
Functions that allow you to query and change the parameters of the hypergeometric distribution.
Definition Random.h:911
Double variance() const
Definition Random.h:918
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (mean & variance) described above through the b...
virtual Double operator()()
Returns a value from the hypergeometric distribution.
HyperGeometric(RNG *gen, Double mean=0.5, Double variance=1.0)
Construct a random number generator for an hypergeometric distribution.
Definition Random.h:906
virtual ~HyperGeometric()
The destructor is trivial.
virtual Bool checkParameters(const Vector< Double > &parms) const
virtual Vector< Double > parameters() const
virtual Bool checkParameters(const Vector< Double > &parms) const
virtual Double mean() const
Functions that allow you to query and change the parameters of the log-normal distribution.
Definition Random.h:1060
virtual void variance(Double x)
virtual Vector< Double > parameters() const
virtual Double variance() const
Definition Random.h:1062
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (mean & variance) described above through the b...
LogNormal(RNG *gen, Double mean=1.0, Double variance=1.0)
Construct a random number generator for a log-normal distribution.
virtual void mean(Double x)
virtual ~LogNormal()
The destructor is trivial.
virtual Double operator()()
Returns a value from the log-normal distribution.
void reseed(Int s1, Int s2)
Definition Random.h:352
Int seed1() const
Functions that allow the user to retrieve or change the seed integers.
Definition Random.h:338
Int itsInitSeedOne
Definition Random.h:332
virtual ~MLCG()
The destructor is trivial.
virtual void reset()
Resets the random number generator.
Int itsInitSeedTwo
Definition Random.h:333
Int seed2() const
Definition Random.h:345
MLCG(Int seed1=0, Int seed2=1)
The constructor allows you to specify seeds.
virtual uInt asuInt()
Return the 32-random bits as an unsigned integer.
Double mean() const
Functions that allow you to query and change the parameters of the negative exponential distribution.
Definition Random.h:1120
virtual Bool checkParameters(const Vector< Double > &parms) const
virtual Vector< Double > parameters() const
virtual ~NegativeExpntl()
The destructor is trivial.
NegativeExpntl(RNG *gen, Double mean=1.0)
Construct a random number generator for a negative exponential distribution.
virtual Double operator()()
Returns a value from the negative exponential distribution.
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (mean) described above through the base class.
virtual Double mean() const
Functions that allow you to query and change the parameters of the normal distribution.
Definition Random.h:992
virtual ~Normal()
The destructor is trivial.
virtual Double variance() const
Definition Random.h:994
Double itsStdDev
Definition Random.h:987
virtual Double operator()()
Returns a value from the normal distribution.
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (mean & variance) described above through the b...
Normal(RNG *gen, Double mean=0.0, Double variance=1.0)
Construct a random number generator for a normal distribution.
Double itsCachedValue
Definition Random.h:989
virtual void mean(Double x)
virtual Vector< Double > parameters() const
virtual Bool checkParameters(const Vector< Double > &parms) const
virtual void variance(Double x)
Double itsVariance
Definition Random.h:986
Double itsMean
Definition Random.h:985
virtual Bool checkParameters(const Vector< Double > &parms) const
virtual Vector< Double > parameters() const
void mean(Double x)
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (mean) described above through the base class.
Double mean() const
Functions that allow you to query and change the parameters of the Poisson distribution.
Definition Random.h:1185
virtual ~Poisson()
The destructor is trivial.
Poisson(RNG *gen, Double mean=0.0)
Construct a random number generator for a Poisson distribution.
virtual Double operator()()
Returns a value from the Poisson distribution.
Double asDouble()
virtual void reset()=0
Resets the random number generator.
Float asFloat()
Return random bits converted to either a Float or a Double.
virtual ~RNG()
A virtual destructor is needed to ensure that the destructor of derived classes gets used.
virtual uInt asuInt()=0
Return the 32-random bits as an unsigned integer.
Types
This enumerator lists all the predefined random number distributions.
Definition Random.h:417
@ POISSON
1 parameter, the mean.
Definition Random.h:454
@ NUMBER_TYPES
Number of distributions.
Definition Random.h:470
@ WEIBULL
2 parameters, alpha and beta.
Definition Random.h:464
@ UNKNOWN
An non-predefined random number distribution.
Definition Random.h:467
@ BINOMIAL
2 parameters.
Definition Random.h:422
@ NORMAL
2 parameters, the mean and variance.
Definition Random.h:444
@ UNIFORM
2 parameters, low and high.
Definition Random.h:460
@ GEOMETRIC
1 parameters, the mean.
Definition Random.h:435
@ ERLANG
2 parameters, mean and variance.
Definition Random.h:432
@ HYPERGEOMETRIC
2 parameters, mean and variance.
Definition Random.h:440
@ DISCRETEUNIFORM
2 parameters.
Definition Random.h:428
@ NEGATIVEEXPONENTIAL
1 parameter, the mean.
Definition Random.h:451
@ LOGNORMAL
2 parameters, mean and variance.
Definition Random.h:448
virtual Bool checkParameters(const Vector< Double > &parms) const =0
static String asString(Random::Types type)
Convert the enumerator to a lower-case string.
static Random::Types asType(const String &str)
Convert the string to enumerator.
static Random * construct(Random::Types type, RNG *gen)
Convert the Random::Type enumerator to a specific object (derived from Random but upcast to a Random ...
virtual Vector< Double > parameters() const =0
static Vector< Double > defaultParameters(Random::Types type)
returns the default parameters for the specified distribution.
virtual void setParameters(const Vector< Double > &parms)=0
These function allow you to manipulate the parameters (mean variance etc.) of random number distribut...
virtual Double operator()()=0
This function returns a random number from the appropriate distribution.
RNG * generator()
Functions that allow you to access and change the class that generates the random bits.
Definition Random.h:529
virtual ~Random()
A virtual destructor is needed to ensure that the destructor of derived classes gets used.
Random(RNG *generator)
Definition Random.h:527
String: the storage and methods of handling collections of characters.
Definition String.h:355
Double high() const
Definition Random.h:1257
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (low & high) described above through the base c...
void low(Double x)
void range(Double low, Double high)
virtual Vector< Double > parameters() const
Double low() const
Functions that allow you to query and change the parameters of the uniform distribution.
Definition Random.h:1255
virtual ~Uniform()
The destructor is trivial.
Uniform(RNG *gen, Double low=-1.0, Double high=1.0)
Construct a random number generator for a uniform distribution.
void high(Double x)
virtual Double operator()()
Returns a value from the uniform distribution.
virtual Bool checkParameters(const Vector< Double > &parms) const
static Double calcDelta(Double low, Double high)
virtual Vector< Double > parameters() const
virtual ~Weibull()
The destructor is trivial.
virtual Double operator()()
Returns a value from the Weiball distribution.
virtual void setParameters(const Vector< Double > &parms)
These function allow you to manipulate the parameters (alpha & beta) described above through the base...
virtual Bool checkParameters(const Vector< Double > &parms) const
Weibull(RNG *gen, Double alpha=1.0, Double beta=1.0)
Construct a random number generator for a uniform distribution.
Double itsInvAlpha
Definition Random.h:1320
void alpha(Double x)
Double alpha() const
Functions that allow you to query and change the parameters of the Weiball distribution.
Definition Random.h:1323
void beta(Double x)
Double beta() const
Definition Random.h:1325
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
short Short
Definition aipstype.h:46
unsigned int uInt
Definition aipstype.h:49
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
size_t size() const
Definition Block.h:566
double Double
Definition aipstype.h:53